- Timestamp:
- 10/28/08 13:44:28 (2 months ago)
- Location:
- v6/smop/SMOP
- Files:
-
- 3 modified
Legend:
- Unmodified
- Added
- Removed
-
v6/smop/SMOP/SMOP.xs
r22796 r22797 8 8 #include <smop_native.h> 9 9 #include <smop_s1p.h> 10 #include <smop_identifiers.h> 10 11 11 12 MODULE = SMOP PACKAGE = SMOP … … 28 29 29 30 SV* 30 AUTOLOAD(SV* self, ...)31 __dispatch(char* name, SV* self, AV* positional, HV* named) 31 32 CODE: 32 33 printf("TODO!\n"); … … 79 80 OUTPUT: 80 81 RETVAL 82 83 MODULE = SMOP PACKAGE = SMOP::NATIVE::idconst 84 85 SV* 86 create(SV* p5class, char* val) 87 CODE: 88 SV* pointer = newSViv((int)SMOP__NATIVE__idconst_create(val)); 89 SV* object = newRV_noinc(pointer); 90 HV* class = gv_stashpv("SMOP::Object", 0); 91 RETVAL = sv_bless(object, class); 92 OUTPUT: 93 RETVAL 94 95 char* 96 fetch(SV* self) 97 CODE: 98 SV* value = SvRV(self); 99 SMOP__Object* object = (SMOP__Object*)SvIV(value); 100 if (SMOP_RI(object) == SMOP_RI(SMOP__ID__new)) { 101 int retsize; 102 RETVAL = SMOP__NATIVE__idconst_fetch(object, &retsize); 103 } else { 104 printf("Calling SMOP::NATIVE::int->fetch on a non-native int.\n"); 105 RETVAL = 0; 106 } 107 OUTPUT: 108 RETVAL -
v6/smop/SMOP/lib/SMOP.pm
r22796 r22797 10 10 require XSLoader; 11 11 XSLoader::load('SMOP', $VERSION); 12 13 package SMOP::Object; 14 15 our $AUTOLOAD; 16 17 sub AUTOLOAD { 18 my $self = shift; 19 my $name = $AUTOLOAD; 20 $name =~ s/.*://; 21 __dispatch($name, $self, [ @_ ], { @_ }); 22 } 12 23 13 24 1; -
v6/smop/SMOP/t/SMOP.t
r22795 r22797 1 1 2 use Test::More tests => 8;2 use Test::More tests => 11; 3 3 BEGIN { use_ok('SMOP') }; 4 4 … … 15 15 ok(!$@,'Can call SMOP::NATIVE::int->create'); 16 16 is(ref($r),'SMOP::Object','returns a SMOP::Object'); 17 is($r->SMOP::NATIVE::int::fetch, 4, 'fetches the int'); 17 18 18 is($r->SMOP::NATIVE::int::fetch, 4, 'fetches the int'); 19 eval '$r = SMOP::NATIVE::idconst->create("Hello World!")'; 20 ok(!$@,'Can call SMOP::NATIVE::idconst->create'); 21 is(ref($r),'SMOP::Object','returns a SMOP::Object'); 22 is($r->SMOP::NATIVE::idconst::fetch, 'Hello World!', 'fetches the idconst');
