From: Brian I. <in...@tt...> - 2003-09-29 20:33:05
|
My Norwegian friend Gisle Aas wrote really nice glue code to bind Perl and Python internals for Zope. He gave a talk about it entitled "Perl and Python is True". Well, as of this hour, Perl and Syck is True! I was able to (easily) bind libsyck to a Perl module. I've attached the simple files needed to make it work. Great job Why! I can't believe how simple it is. Of course I'll need to do all the object construction foo, but the basic binding was cake. And thanks go out to Clark, for helping me understand how Syck works. Cheers, Brian ---- 8< test.pl -------------------------------------------- use YAML::Parser::Syck; use Data::Dumper; local $/; print Data::Dumper::Dumper YAML::Parser::Syck::Parse(<DATA>); __DATA__ --- foo: &1 bar: xxx baz: 111 bar: *1 ---- 8< Syck.pm -------------------------------------------- package YAML::Parser::Syck; use strict; use vars qw($VERSION @ISA); use warnings; require DynaLoader; $VERSION = '0.01'; @ISA = qw(DynaLoader); YAML::Parser::Syck->bootstrap($VERSION); 1; ---- 8< Syck.xs -------------------------------------------- #include "EXTERN.h" #include "perl.h" #include "XSUB.h" #include "ppport.h" #include <syck.h> SYMID perl_syck_handler(SyckParser *p, SyckNode *n) { SYMID obj; SV *sv, *scalar, *entry, *key, *value; AV *seq; HV *map; long i; switch (n->kind) { case syck_str_kind: sv = newSVpv(n->data.str->ptr, n->data.str->len); break; case syck_seq_kind: seq = newAV(); for (i = 0; i < n->data.list->idx; i++) { obj = syck_seq_read(n, i); syck_lookup_sym(p, obj, (char**)&entry); av_push(seq, entry); } sv = newRV_inc((SV*)seq); break; case syck_map_kind: map = newHV(); for (i = 0; i < n->data.pairs->idx; i++) { obj = syck_map_read( n, map_key, i); syck_lookup_sym(p, obj, (char**)&key); obj = syck_map_read(n, map_value, i); syck_lookup_sym(p, obj, (char**)&value); hv_store_ent(map, key, value, 0); } sv = newRV_inc((SV*)map); break; } obj = syck_add_sym(p, (char *)sv); return obj; } static SV * Parse(char *s) { SV *obj; SYMID v; SyckParser *parser = syck_new_parser(); syck_parser_str_auto(parser, s, NULL); syck_parser_handler(parser, perl_syck_handler); syck_parser_error_handler(parser, NULL); syck_parser_implicit_typing(parser, 1); syck_parser_taguri_expansion(parser, 0); v = syck_parse(parser); syck_lookup_sym(parser, v, (char **)&obj); syck_free_parser(parser); return obj; } MODULE = YAML::Parser::Syck PACKAGE = YAML::Parser::Syck PROTOTYPES: DISABLE SV * Parse (s) char * s ---- 8< Makefile.PL -------------------------------------------- use ExtUtils::MakeMaker; WriteMakefile( NAME => 'YAML::Parser::Syck', VERSION_FROM => 'Syck.pm', LIBS => ['-lsyck'], DEFINE => '', INC => '-I.', ); ---- 8< ------------------------------------------------------- |
From: why t. l. s. <yam...@wh...> - 2003-09-29 04:52:51
|
Brilliant news! This sucks that I'm leaving town right now. I want to jump into this right away and yet my plane beckons in just 1 hour. On this day, I feel the love of a mother. More probably. When I get a chance, I'll get you cvs access and we'll check this in pronto. _why Brian Ingerson (in...@tt...) wrote: > My Norwegian friend Gisle Aas wrote really nice glue code to bind Perl > and Python internals for Zope. He gave a talk about it entitled "Perl > and Python is True". > > Well, as of this hour, Perl and Syck is True! > > I was able to (easily) bind libsyck to a Perl module. I've attached the > simple files needed to make it work. > > Great job Why! I can't believe how simple it is. Of course I'll need to > do all the object construction foo, but the basic binding was cake. And > thanks go out to Clark, for helping me understand how Syck works. > > Cheers, Brian > |
From: Rich M. <rd...@cf...> - 2003-09-29 21:08:54
|
At 3:16 AM -0700 9/28/03, Brian Ingerson wrote: >I can't believe how simple it is. It is, indeed, amazingly concise. A splendid example of multi-lingual code re-use, open source collaboration, etc. Kudos to all concerned. Now for a couple of small requests: * Could someone write up a skeletal man page that details the current state of the Perl interface to Syck? That is, something which (in addition to the Syck docs) lays out what we can currently do (and how to do it)? * If someone on the list knows how to build XS files under Mac OS X, could they do so and post a link to the result? If not, I'll ask for help on the macosx_perl (ma...@pe...) list. * This might make an interesting article for MacTech, if anyone wants to write it up (or answer my questions while I do so :-). -r -- email: rd...@cf...; phone: +1 650-873-7841 http://www.cfcl.com - Canta Forda Computer Laboratory http://www.cfcl.com/Meta - The FreeBSD Browser, Meta Project, etc. http://www.ptf.com/dossier - Prime Time Freeware's DOSSIER series |
From: Rich M. <rd...@cf...> - 2003-09-29 22:44:07
|
Here is a rundown on my installation progress for this code on Mac OS X 10.2.8. # Create some working directories. % mkdir ~/Work/YAML % cd ~/Work/YAML % mkdir syck # Dump Brian's code into files. % vi Makefile.PL ... # Download Syck from Sourceforge, via http://whytheluckystiff.net/syck. # Move downloaded tarfile and unpacked directory into ~/Work/YAML/Syck. # Build and install Syck, as described in the README: % cd syck % ./configure ... % make ... % make check ... % sudo make install ... % cd .. # Build and install the Perl XS module. % Makefile.PL ... % make mkdir blib ... cp Syck.pm blib/lib/YAML/Parser/Syck.pm /usr/bin/perl -I/System/Library/Perl/darwin -I/System/Library/Perl /System/Library/Perl/ExtUtils/xsubpp -typemap /System/Library/Perl/ExtUtils/typemap Syck.xs > Syck.xsc && mv Syck.xsc Syck.c cc -c -I. -g -pipe -pipe -fno-common -no-cpp-precomp -flat_namespace -DHAS_TELLDIR_PROTOTYPE -fno-strict-aliasing -Os -DVERSION=\"0.01\" -DXS_VERSION=\"0.01\" -I/System/Library/Perl/darwin/CORE Syck.c Syck.xs:6:20: ppport.h: No such file or directory make: *** [Syck.o] Error 1 Help? -- email: rd...@cf...; phone: +1 650-873-7841 http://www.cfcl.com - Canta Forda Computer Laboratory http://www.cfcl.com/Meta - The FreeBSD Browser, Meta Project, etc. http://www.ptf.com/dossier - Prime Time Freeware's DOSSIER series |
From: Brian I. <in...@tt...> - 2003-09-29 22:52:26
|
On 29/09/03 15:44 -0700, Rich Morin wrote: > Here is a rundown on my installation progress for this code on Mac OS X 10.2.8. > > # Create some working directories. > > % mkdir ~/Work/YAML > % cd ~/Work/YAML > % mkdir syck > > # Dump Brian's code into files. > > % vi Makefile.PL > ... > > # Download Syck from Sourceforge, via http://whytheluckystiff.net/syck. > # Move downloaded tarfile and unpacked directory into ~/Work/YAML/Syck. > > # Build and install Syck, as described in the README: > > % cd syck > % ./configure > ... > % make > ... > % make check > ... > % sudo make install > ... > % cd .. > > # Build and install the Perl XS module. > > % Makefile.PL > ... > % make > mkdir blib > ... > cp Syck.pm blib/lib/YAML/Parser/Syck.pm > /usr/bin/perl -I/System/Library/Perl/darwin -I/System/Library/Perl > /System/Library/Perl/ExtUtils/xsubpp -typemap > /System/Library/Perl/ExtUtils/typemap Syck.xs > Syck.xsc && mv > Syck.xsc Syck.c > cc -c -I. -g -pipe -pipe -fno-common -no-cpp-precomp -flat_namespace > -DHAS_TELLDIR_PROTOTYPE -fno-strict-aliasing -Os > -DVERSION=\"0.01\" -DXS_VERSION=\"0.01\" > -I/System/Library/Perl/darwin/CORE Syck.c > Syck.xs:6:20: ppport.h: No such file or directory > make: *** [Syck.o] Error 1 > > Help? Running h2xs -PAn foobar will generate one. You could probably comment it out too. Cheers, Brian > -- > email: rd...@cf...; phone: +1 650-873-7841 > http://www.cfcl.com - Canta Forda Computer Laboratory > http://www.cfcl.com/Meta - The FreeBSD Browser, Meta Project, etc. > http://www.ptf.com/dossier - Prime Time Freeware's DOSSIER series > > > ------------------------------------------------------- > This sf.net email is sponsored by:ThinkGeek > Welcome to geek heaven. > http://thinkgeek.com/sf > _______________________________________________ > Yaml-core mailing list > Yam...@li... > https://lists.sourceforge.net/lists/listinfo/yaml-core |