diff -Nru libextutils-xspp-perl-0.1602/Build.PL libextutils-xspp-perl-0.1800/Build.PL --- libextutils-xspp-perl-0.1602/Build.PL 2011-06-03 20:12:10.000000000 +0000 +++ libextutils-xspp-perl-0.1800/Build.PL 2013-09-18 08:17:53.000000000 +0000 @@ -11,7 +11,8 @@ license => 'perl', requires => { 'perl' => '5.6.1', - 'ExtUtils::ParseXS' => '2.2202', + 'ExtUtils::ParseXS' => '3.07', + 'ExtUtils::Typemaps' => '1', 'Digest::MD5' => '2.0', }, build_requires => diff -Nru libextutils-xspp-perl-0.1602/Changes libextutils-xspp-perl-0.1800/Changes --- libextutils-xspp-perl-0.1602/Changes 2011-06-03 20:12:10.000000000 +0000 +++ libextutils-xspp-perl-0.1800/Changes 2013-09-18 08:17:53.000000000 +0000 @@ -1,5 +1,28 @@ Revision history for Perl extension ExtUtils::XSpp. +0.18 Wed Sep 18 10:00:00 CEST 2013 + - Upgrade to stable release. + +0.17_02 Wed Aug 28 22:35:02 CEST 2013 + - Fixed getters for typemaps using %output_list annotation. + +0.17_01 Sat Aug 10 08:20:11 CEST 2013 + - Added standard XS typemap for objects (disabled by default for + backwards compatibility).x + - Allow specifying XS typemap code in the XS++ typemap declaration. + - Generate accessors for member variables. + - Handle multiple function/method annotations (used by plugins). + - Updated plugin interface (should be backwards-compatible). + +0.1700 Sun Feb 10 12:00:00 CET 2013 + - %alias feature for aliasing XS++ wrappers. + +0.1603 Fri Dec 28 12:03:09 CEST 2012 + - Fix blead-perl warning about unescaped { in regexps. + - Use ExtUtils::Typemaps instead of ExtUtils::Typemap (which + had to be renamed). + - Somewhat improved examples. + 0.1602 Fri Jun 3 22:08:53 CEST 2011 - Fixed code generation for package_static methods. diff -Nru libextutils-xspp-perl-0.1602/MANIFEST libextutils-xspp-perl-0.1800/MANIFEST --- libextutils-xspp-perl-0.1602/MANIFEST 2011-06-03 20:12:10.000000000 +0000 +++ libextutils-xspp-perl-0.1800/MANIFEST 2013-09-18 08:17:53.000000000 +0000 @@ -5,12 +5,9 @@ examples/Object-WithIntAndString/lib/Object/WithIntAndString.pm examples/Object-WithIntAndString/Makefile.PL examples/Object-WithIntAndString/Object-WithIntAndString.xsp -examples/Object-WithIntAndString/perlobject.map examples/Object-WithIntAndString/ppport.h examples/Object-WithIntAndString/t/01load.t examples/Object-WithIntAndString/t/02test.t -examples/Object-WithIntAndString/typemap -examples/Object-WithIntAndString/typemap.xsp examples/Object-WithIntAndString/WithIntAndString.xs examples/XSpp-Example/Build.PL examples/XSpp-Example/lib/XSpp/Example.pm @@ -52,6 +49,7 @@ lib/ExtUtils/XSpp/Node/EnumValue.pm lib/ExtUtils/XSpp/Node/File.pm lib/ExtUtils/XSpp/Node/Function.pm +lib/ExtUtils/XSpp/Node/Member.pm lib/ExtUtils/XSpp/Node/Method.pm lib/ExtUtils/XSpp/Node/Module.pm lib/ExtUtils/XSpp/Node/Package.pm @@ -61,10 +59,12 @@ lib/ExtUtils/XSpp/Node/Type.pm lib/ExtUtils/XSpp/Parser.pm lib/ExtUtils/XSpp/Plugin.pod +lib/ExtUtils/XSpp/Plugin/feature/default_xs_typemap.pm lib/ExtUtils/XSpp/Typemap.pm lib/ExtUtils/XSpp/Typemap/parsed.pm lib/ExtUtils/XSpp/Typemap/reference.pm lib/ExtUtils/XSpp/Typemap/simple.pm +lib/ExtUtils/XSpp/Typemap/wrapper.pm MANIFEST META.json META.yml @@ -75,12 +75,14 @@ t/010_base.t t/011_multiple_files.t t/012_preprocessor.t +t/013_typemap_output.t t/015_reference.t t/020_rename.t t/022_static.t t/022_virtual.t t/023_base_classes.t t/024_enum.t +t/025_member.t t/030_code_blocks.t t/031_verbatim_blocks.t t/035_include.t @@ -92,6 +94,8 @@ t/files/include.xsp t/files/test1.xsp t/files/typemap.xsp +t/lib/ExtUtils/XSpp/Plugin/TestArgumentPlugin.pm +t/lib/ExtUtils/XSpp/Plugin/TestNewNodesPlugin.pm t/lib/ExtUtils/XSpp/Plugin/TestParserPlugin.pm t/lib/ExtUtils/XSpp/Plugin/TestPlugin.pm t/lib/XSP/Plugin.pm diff -Nru libextutils-xspp-perl-0.1602/META.json libextutils-xspp-perl-0.1800/META.json --- libextutils-xspp-perl-0.1602/META.json 2011-06-03 20:12:10.000000000 +0000 +++ libextutils-xspp-perl-0.1800/META.json 2013-09-18 08:17:53.000000000 +0000 @@ -4,7 +4,7 @@ "Mattia Barbon " ], "dynamic_config" : 1, - "generated_by" : "Module::Build version 0.38, CPAN::Meta::Converter version 2.110930", + "generated_by" : "Module::Build version 0.4003, CPAN::Meta::Converter version 2.120921", "license" : [ "perl_5" ], @@ -16,19 +16,20 @@ "prereqs" : { "build" : { "requires" : { - "Test::Base" : 0, - "Test::Differences" : 0 + "Test::Base" : "0", + "Test::Differences" : "0" } }, "configure" : { "requires" : { - "Module::Build" : "0.38" + "Module::Build" : "0.40" } }, "runtime" : { "requires" : { "Digest::MD5" : "2.0", - "ExtUtils::ParseXS" : "2.2202", + "ExtUtils::ParseXS" : "3.07", + "ExtUtils::Typemaps" : "1", "perl" : "v5.6.1" } } @@ -36,7 +37,7 @@ "provides" : { "ExtUtils::XSpp" : { "file" : "lib/ExtUtils/XSpp.pm", - "version" : "0.1602" + "version" : "0.18" }, "ExtUtils::XSpp::Cmd" : { "file" : "lib/ExtUtils/XSpp/Cmd.pm", @@ -130,6 +131,10 @@ "file" : "lib/ExtUtils/XSpp/Node/Function.pm", "version" : 0 }, + "ExtUtils::XSpp::Node::Member" : { + "file" : "lib/ExtUtils/XSpp/Node/Member.pm", + "version" : 0 + }, "ExtUtils::XSpp::Node::Method" : { "file" : "lib/ExtUtils/XSpp/Node/Method.pm", "version" : 0 @@ -162,6 +167,10 @@ "file" : "lib/ExtUtils/XSpp/Parser.pm", "version" : 0 }, + "ExtUtils::XSpp::Plugin::feature::default_xs_typemap" : { + "file" : "lib/ExtUtils/XSpp/Plugin/feature/default_xs_typemap.pm", + "version" : 0 + }, "ExtUtils::XSpp::Typemap" : { "file" : "lib/ExtUtils/XSpp/Typemap.pm", "version" : 0 @@ -177,6 +186,10 @@ "ExtUtils::XSpp::Typemap::simple" : { "file" : "lib/ExtUtils/XSpp/Typemap/simple.pm", "version" : 0 + }, + "ExtUtils::XSpp::Typemap::wrapper" : { + "file" : "lib/ExtUtils/XSpp/Typemap/wrapper.pm", + "version" : 0 } }, "release_status" : "stable", @@ -185,5 +198,5 @@ "http://dev.perl.org/licenses/" ] }, - "version" : "0.1602" + "version" : "0.18" } diff -Nru libextutils-xspp-perl-0.1602/META.yml libextutils-xspp-perl-0.1800/META.yml --- libextutils-xspp-perl-0.1602/META.yml 2011-06-03 20:12:10.000000000 +0000 +++ libextutils-xspp-perl-0.1800/META.yml 2013-09-18 08:17:53.000000000 +0000 @@ -6,9 +6,9 @@ Test::Base: 0 Test::Differences: 0 configure_requires: - Module::Build: 0.38 + Module::Build: 0.40 dynamic_config: 1 -generated_by: 'Module::Build version 0.38, CPAN::Meta::Converter version 2.110930' +generated_by: 'Module::Build version 0.4003, CPAN::Meta::Converter version 2.120921' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html @@ -17,7 +17,7 @@ provides: ExtUtils::XSpp: file: lib/ExtUtils/XSpp.pm - version: 0.1602 + version: 0.18 ExtUtils::XSpp::Cmd: file: lib/ExtUtils/XSpp/Cmd.pm version: 0 @@ -87,6 +87,9 @@ ExtUtils::XSpp::Node::Function: file: lib/ExtUtils/XSpp/Node/Function.pm version: 0 + ExtUtils::XSpp::Node::Member: + file: lib/ExtUtils/XSpp/Node/Member.pm + version: 0 ExtUtils::XSpp::Node::Method: file: lib/ExtUtils/XSpp/Node/Method.pm version: 0 @@ -111,6 +114,9 @@ ExtUtils::XSpp::Parser: file: lib/ExtUtils/XSpp/Parser.pm version: 0 + ExtUtils::XSpp::Plugin::feature::default_xs_typemap: + file: lib/ExtUtils/XSpp/Plugin/feature/default_xs_typemap.pm + version: 0 ExtUtils::XSpp::Typemap: file: lib/ExtUtils/XSpp/Typemap.pm version: 0 @@ -123,10 +129,14 @@ ExtUtils::XSpp::Typemap::simple: file: lib/ExtUtils/XSpp/Typemap/simple.pm version: 0 + ExtUtils::XSpp::Typemap::wrapper: + file: lib/ExtUtils/XSpp/Typemap/wrapper.pm + version: 0 requires: Digest::MD5: 2.0 - ExtUtils::ParseXS: 2.2202 + ExtUtils::ParseXS: 3.07 + ExtUtils::Typemaps: 1 perl: v5.6.1 resources: license: http://dev.perl.org/licenses/ -version: 0.1602 +version: 0.18 diff -Nru libextutils-xspp-perl-0.1602/README libextutils-xspp-perl-0.1800/README --- libextutils-xspp-perl-0.1602/README 2011-06-03 20:12:10.000000000 +0000 +++ libextutils-xspp-perl-0.1800/README 2013-09-18 08:17:53.000000000 +0000 @@ -57,6 +57,19 @@ used in the return value, the function will create copy of the returned value using a copy constructor. + As a shortcut for the common case of declaring both of the above for a + given type, you may use + + %typemap{}; + + Which has the same effect as: + + %typemap{}{simple}; + %typemap{&}{reference}; + + For more control over the type mapping, you can use the "parsed" variant + as follows. + %typemap{}{parsed}{%%}; When "C++ type 1" is used, replace it with "C++ type 2" in the generated @@ -149,16 +162,19 @@ %file directive; use "-" for standard output. %module - %module{Module__Name}; + %module{Module::Name}; - Will be used to generate the "MODULE=Module__Name" XS directives. + Will be used to generate the "MODULE=Module::Name" XS directives. It + indirectly sets the name of the shared library that is generated as well + as the name of the module via which XSLoader will be able to find/load + it. %name %name{Perl::Class} class MyClass { ... }; %name{Perl::Func} int foo(); - Specifies the perl name under which the C++ class/function will be - accessible. + Specifies the Perl name under which the C++ class/function will be + accessible. By default, constructor names are mapped to "new" in Perl. %typemap See TYPEMAPS above. @@ -182,6 +198,26 @@ of the string (here: "line") *efficiently* as "length(line)" in the code. + %alias + Decorator for function/method declarations such as + + double add(double a, double b) + %alias{subtract = 1} %alias{multiply = 2}; + + Which will cause the generation of just a single XSUB using the XS + "ALIAS" feature (see perlxs). It will be installed as all of "add", + "subtract", and "multiply" on the Perl side and call either the C++ + "add", "subtract", or "multiply" functions depending on which way it was + called. + + Notes: If used in conjunction with %name{foo} to rename the function, + then the %name will only affect the main function name (in the above + example, "add" but not "subtract" or "multiply"). When used with the + %code feature, the custom code will have to use the "ix" integer + variable to decide which function to call. "ix" is set to 0 for the main + function. Make sure to read up on the ALIAS feature of plain XS. + Aliasing is not supported for constructors and destructors. + Classes %name{My::Class} class MyClass : public %name{My::Base} MyBase { @@ -189,19 +225,22 @@ MyClass( int arg ); // My::Class->newMyClass( ... ); %name{newMyClass} MyClass( const char* str, int arg ); - + // standard DESTROY method ~MyClass(); - + int GetInt(); void SetValue( int arg = -1 ); - + %name{SetString} void SetValue( const char* string = NULL ); - + // Supply a C or C block for the XS int MyMethod( int a, int b ) %code{% RETVAL = a + b; %} %cleanup{% /* do something */ %}; + + // Expose class method as My::ClassMethod::ClassMethod($foo) + static void ClassMethod( double foo ); }; Comments diff -Nru libextutils-xspp-perl-0.1602/XSP.yp libextutils-xspp-perl-0.1800/XSP.yp --- libextutils-xspp-perl-0.1602/XSP.yp 2011-06-03 20:12:10.000000000 +0000 +++ libextutils-xspp-perl-0.1800/XSP.yp 2013-09-18 08:17:53.000000000 +0000 @@ -18,12 +18,18 @@ %% top_list: - top { $_[1] ? [ $_[1] ] : [] } - | top_list top { push @{$_[1]}, $_[2] if $_[2]; $_[1] } + top + | top_list top { push @{$_[1]}, @{$_[2]}; $_[1] } + | p__type OPCURLY type CLCURLY + { $_[3] } ; -top: raw | class | directive | enum - | function { $_[1]->resolve_typemaps; $_[1]->resolve_exceptions; $_[1] }; +top: _top { !$_[1] ? [] : + ref $_[1] eq 'ARRAY' ? $_[1] : + [ $_[1] ] }; + +_top: raw | class | directive | enum + | function { process_function( $_[0], $_[1] ) }; directive: perc_module SEMICOLON { ExtUtils::XSpp::Node::Module->new( module => $_[1] ) } @@ -36,42 +42,33 @@ | perc_include SEMICOLON { $_[0]->YYData->{PARSER}->include_file( $_[1] ); undef } | perc_any SEMICOLON - { add_top_level_directive( $_[0], @{$_[1]} ); undef } + { add_top_level_directive( $_[0], %{$_[1][1]} ) } | typemap { } | exceptionmap { } ; typemap: p_typemap OPCURLY type CLCURLY OPCURLY ID CLCURLY special_blocks SEMICOLON - { my $package = "ExtUtils::XSpp::Typemap::" . $_[6]; - my $type = $_[3]; my $c = 0; + { my $c = 0; my %args = map { "arg" . ++$c => $_ } map { join( '', @$_ ) } @{$_[8] || []}; - my $tm = $package->new( type => $type, %args ); - ExtUtils::XSpp::Typemap::add_typemap_for_type( $type, $tm ); + add_typemap( $_[6], $_[3], %args ); undef } | p_typemap OPCURLY type CLCURLY OPCURLY ID CLCURLY OPCURLY perc_any_args CLCURLY SEMICOLON - { my $package = "ExtUtils::XSpp::Typemap::" . $_[6]; - my $type = $_[3]; - # this assumes that there will be at most one named + { # this assumes that there will be at most one named # block for each directive inside the typemap for( my $i = 1; $i <= $#{$_[9]}; $i += 2 ) { $_[9][$i] = join "\n", @{$_[9][$i][0]} if ref( $_[9][$i] ) eq 'ARRAY' && ref( $_[9][$i][0] ) eq 'ARRAY'; } - my $tm = $package->new( type => $type, @{$_[9]} ); - ExtUtils::XSpp::Typemap::add_typemap_for_type( $type, $tm ); + add_typemap( $_[6], $_[3], @{$_[9]} ); undef } | p_typemap OPCURLY type CLCURLY SEMICOLON - { my $type = $_[3]; # add simple and reference typemaps for this type - my $tm = ExtUtils::XSpp::Typemap::simple->new( type => $type ); - ExtUtils::XSpp::Typemap::add_typemap_for_type( $type, $tm ); - my $reftype = make_ref($type->clone); - $tm = ExtUtils::XSpp::Typemap::reference->new( type => $reftype ); - ExtUtils::XSpp::Typemap::add_typemap_for_type( $reftype, $tm ); + { add_typemap( 'simple', $_[3] ); + add_typemap( 'reference', make_ref($_[3]->clone) ); undef } ; @@ -144,11 +141,12 @@ class: class_decl SEMICOLON | decorate_class SEMICOLON; function: function_decl SEMICOLON; method: method_decl SEMICOLON; +member: member_decl SEMICOLON; decorate_class: perc_name class_decl { $_[2]->set_perl_name( $_[1] ); $_[2] }; -class_decl: 'class' ID base_classes class_metadata OPCURLY class_body_list CLCURLY +class_decl: 'class' class_name base_classes class_metadata OPCURLY class_body_list CLCURLY { create_class( $_[0], $_[2], $_[3], $_[4], $_[6], $_[0]->get_conditional ) }; @@ -183,9 +181,9 @@ ; class_body_element: - method | raw | typemap | exceptionmap | access_specifier + method | raw | typemap | exceptionmap | access_specifier | member | perc_any SEMICOLON - { ExtUtils::XSpp::Node::PercAny->new( @{$_[1]} ) } + { ExtUtils::XSpp::Node::PercAny->new( %{$_[1][1]} ) } ; access_specifier: @@ -194,6 +192,25 @@ | 'private' COLON { ExtUtils::XSpp::Node::Access->new( access => $_[1] ) } ; +member_metadata: member_metadata _member_metadata { [ @{$_[1]}, @{$_[2]} ] } + | { [] } + ; + +_member_metadata: perc_any; + +member_decl: + | looks_like_member + | perc_name looks_like_member + { $_[2]->set_perl_name( $_[1] ); $_[2] }; + +looks_like_member: + type ID member_metadata + { create_member( $_[0], + name => $_[2], + type => $_[1], + condition => $_[0]->get_conditional, + @{$_[3]} ) }; + method_decl: nmethod | vmethod | ctor | dtor; const: 'const' { 1 } @@ -308,30 +325,32 @@ | perc_cleanup | perc_postcall | perc_catch + | perc_alias | perc_any ; -perc_name: p_name OPCURLY class_name CLCURLY { $_[3] }; -perc_package: p_package OPCURLY class_name CLCURLY { $_[3] }; -perc_module: p_module OPCURLY class_name CLCURLY { $_[3] }; -perc_file: p_file OPCURLY file_name CLCURLY { $_[3] }; -perc_loadplugin: p_loadplugin OPCURLY class_name CLCURLY { $_[3] }; -perc_include: p_include OPCURLY file_name CLCURLY { $_[3] }; -perc_code: p_code special_block { [ code => $_[2] ] }; -perc_cleanup: p_cleanup special_block { [ cleanup => $_[2] ] }; -perc_postcall: p_postcall special_block { [ postcall => $_[2] ] }; -perc_catch: p_catch OPCURLY class_name_list CLCURLY { [ map {(catch => $_)} @{$_[3]} ] }; +perc_name: p_name OPCURLY class_name CLCURLY { $_[3] }; +perc_alias: p_alias OPCURLY ID EQUAL INTEGER CLCURLY { [ alias => [$_[3], $_[5]] ] }; +perc_package: p_package OPCURLY class_name CLCURLY { $_[3] }; +perc_module: p_module OPCURLY class_name CLCURLY { $_[3] }; +perc_file: p_file OPCURLY file_name CLCURLY { $_[3] }; +perc_loadplugin: p_loadplugin OPCURLY class_name CLCURLY { $_[3] }; +perc_include: p_include OPCURLY file_name CLCURLY { $_[3] }; +perc_code: p_code special_block { [ code => $_[2] ] }; +perc_cleanup: p_cleanup special_block { [ cleanup => $_[2] ] }; +perc_postcall: p_postcall special_block { [ postcall => $_[2] ] }; +perc_catch: p_catch OPCURLY class_name_list CLCURLY { [ map {(catch => $_)} @{$_[3]} ] }; # this expands mixed_blocks to avoid ambiguity in the OPCURLY case perc_any: p_any OPCURLY perc_any_args CLCURLY - { [ any => $_[1], any_named_arguments => $_[3] ] } + { [ tag => { any => $_[1], named => $_[3] } ] } | p_any OPCURLY ID CLCURLY mixed_blocks - { [ any => $_[1], any_positional_arguments => [ $_[3], @{$_[5]} ] ] } + { [ tag => { any => $_[1], positional => [ $_[3], @{$_[5]} ] } ] } | p_any special_block mixed_blocks - { [ any => $_[1], any_positional_arguments => [ $_[2], @{$_[3]} ] ] } + { [ tag => { any => $_[1], positional => [ $_[2], @{$_[3]} ] } ] } | p_any - { [ any => $_[1] ] } + { [ tag => { any => $_[1] } ] } ; perc_any_args: @@ -341,6 +360,7 @@ perc_any_arg: p_any mixed_blocks SEMICOLON { [ $_[1] => $_[2] ] } + | perc_name SEMICOLON { [ name => $_[1] ] } ; type: @@ -358,6 +378,7 @@ type_name: class_name | basic_type + | 'void' | 'unsigned' { 'unsigned int' } | 'unsigned' basic_type { 'unsigned' . ' ' . $_[2] } ; @@ -388,15 +409,26 @@ | ID DOT ID { $_[1] . '.' . $_[3] } | ID SLASH file_name { $_[1] . '/' . $_[3] }; -arg_list: argument { [ $_[1] ] } - | arg_list COMMA argument { push @{$_[1]}, $_[3]; $_[1] } - | ; +arg_list: nonvoid_arg_list + | 'void' { undef }; + +nonvoid_arg_list: + argument { [ $_[1] ] } + | nonvoid_arg_list COMMA argument { push @{$_[1]}, $_[3]; $_[1] } + | ; + +argument_metadata: argument_metadata _argument_metadata { [ @{$_[1]}, @{$_[2]} ] } + | { [] } + ; + +_argument_metadata: perc_any; argument: type p_length OPCURLY ID CLCURLY { make_argument( @_[0, 1], "length($_[4])" ) } - | type ID EQUAL expression - { make_argument( @_[0, 1, 2, 4] ) } - | type ID { make_argument( @_ ) }; + | type ID argument_metadata EQUAL expression + { make_argument( @_[0, 1, 2, 5], @{$_[3]} ) } + | type ID argument_metadata + { make_argument( @_[0, 1, 2], undef, @{$_[3]} ) }; value: INTEGER | DASH INTEGER { '-' . $_[2] } diff -Nru libextutils-xspp-perl-0.1602/debian/changelog libextutils-xspp-perl-0.1800/debian/changelog --- libextutils-xspp-perl-0.1602/debian/changelog 2011-12-20 15:50:52.000000000 +0000 +++ libextutils-xspp-perl-0.1800/debian/changelog 2013-09-20 22:40:10.000000000 +0000 @@ -1,3 +1,36 @@ +libextutils-xspp-perl (0.1800-1) unstable; urgency=low + + * Team upload + + * Import Upstream version 0.1800 + * Bump dependency on ExtUtils::ParseXS to 3.07 + + -- Florian Schlichting Sat, 21 Sep 2013 00:39:37 +0200 + +libextutils-xspp-perl (0.1700-1) unstable; urgency=low + + * Team upload + + [ gregor herrmann ] + * debian/control: update {versioned,alternative} (build) dependencies. + + [ Salvatore Bonaccorso ] + * Change Vcs-Git to canonical URI (git://anonscm.debian.org) + * Change search.cpan.org based URIs to metacpan.org based URIs + + [ Axel Beckert ] + * debian/copyright: migrate pre-1.0 format to 1.0 using "cme fix dpkg- + copyright" + + [ Florian Schlichting ] + * Import Upstream version 0.1700 + * Add build-dependency on Module::Build 0.40 + * Bump Standards-Version to 3.9.4 (no change) + * Add build-dependency on libparse-yapp-perl + * Remove comma in d/copyright Files field + + -- Florian Schlichting Mon, 16 Sep 2013 12:23:08 +0200 + libextutils-xspp-perl (0.1602-3) unstable; urgency=low * Remove debian/source/local-options; abort-on-upstream-changes and diff -Nru libextutils-xspp-perl-0.1602/debian/control libextutils-xspp-perl-0.1800/debian/control --- libextutils-xspp-perl-0.1602/debian/control 2011-12-20 15:50:52.000000000 +0000 +++ libextutils-xspp-perl-0.1800/debian/control 2013-09-20 22:37:46.000000000 +0000 @@ -1,25 +1,31 @@ Source: libextutils-xspp-perl +Maintainer: Debian Perl Group +Uploaders: Ryan Niebur , + Jonathan Yu , + gregor herrmann , + Ansgar Burchardt Section: perl Priority: optional -Build-Depends: debhelper (>= 8) +Build-Depends: debhelper (>= 8), + perl (>= 5.17.1) | libmodule-build-perl (>= 0.400000) Build-Depends-Indep: perl, - libtest-base-perl, - libtest-differences-perl, - perl (>= 5.14) | libextutils-parsexs-perl (>= 2.220200) -Maintainer: Debian Perl Group -Uploaders: Ryan Niebur , Jonathan Yu , - gregor herrmann , Ansgar Burchardt -Standards-Version: 3.9.2 -Homepage: http://search.cpan.org/dist/ExtUtils-XSpp/ -Vcs-Git: git://git.debian.org/pkg-perl/packages/libextutils-xspp-perl.git + libparse-yapp-perl, + libtest-base-perl, + libtest-differences-perl, + perl (>= 5.15.6) | libextutils-parsexs-perl (>= 3.070000) +Standards-Version: 3.9.4 Vcs-Browser: http://anonscm.debian.org/gitweb/?p=pkg-perl/packages/libextutils-xspp-perl.git +Vcs-Git: git://anonscm.debian.org/pkg-perl/packages/libextutils-xspp-perl.git +Homepage: https://metacpan.org/release/ExtUtils-XSpp/ Package: libextutils-xspp-perl Architecture: all -Depends: ${perl:Depends}, ${misc:Depends}, - perl (>= 5.14) | libextutils-parsexs-perl (>= 2.220200) +Depends: ${perl:Depends}, + ${misc:Depends}, + perl (>= 5.15.6) | libextutils-parsexs-perl (>= 3.070000), Description: module for using Perl XS with C++ code ExtUtils::XSpp is a Perl module that implements XS++, a thin layer on top of plain XS designed to support C++ code. It allows developers to easily write Perl bindings to C++ code by compiling code using the XS++ preprocessor `xspp' instead of the normal XS preprocessor `xsubpp'. + diff -Nru libextutils-xspp-perl-0.1602/debian/copyright libextutils-xspp-perl-0.1800/debian/copyright --- libextutils-xspp-perl-0.1602/debian/copyright 2011-12-20 15:50:52.000000000 +0000 +++ libextutils-xspp-perl-0.1800/debian/copyright 2013-09-16 10:23:46.000000000 +0000 @@ -1,7 +1,7 @@ -Format-Specification: http://anonscm.debian.org/viewvc/dep/web/deps/dep5.mdwn?view=markup&pathrev=135 -Maintainer: Mattia Barbon -Source: http://search.cpan.org/dist/ExtUtils-XSpp/ -Name: ExtUtils-XSpp +Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: ExtUtils-XSpp +Upstream-Contact: Mattia Barbon +Source: https://metacpan.org/release/ExtUtils-XSpp/ Files: * Copyright: 2003-2009, Mattia Barbon @@ -11,7 +11,7 @@ Copyright: 2009, Steffen Mueller License: Artistic or GPL-1+ -Files: examples/Object-WithIntAndString/ppport.h, +Files: examples/Object-WithIntAndString/ppport.h examples/XSpp-Example/src/ppport.h Copyright: 2004-2009, Marcus Holland-Moritz 2001, Paul Marquess (Version 2.x) diff -Nru libextutils-xspp-perl-0.1602/debian/watch libextutils-xspp-perl-0.1800/debian/watch --- libextutils-xspp-perl-0.1602/debian/watch 2011-12-20 15:50:52.000000000 +0000 +++ libextutils-xspp-perl-0.1800/debian/watch 2013-01-27 17:47:25.000000000 +0000 @@ -1,3 +1,3 @@ version=3 opts=uversionmangle=s/\.\d\d$/$&00/ \ - http://search.cpan.org/dist/ExtUtils-XSpp/ .*/ExtUtils-XSpp-v?(\d[\d.-]+)\.(?:tar(?:\.gz|\.bz2)?|tgz|zip)$ +https://metacpan.org/release/ExtUtils-XSpp/ .*/ExtUtils-XSpp-v?(\d[\d.-]+)\.(?:tar(?:\.gz|\.bz2)?|tgz|zip)$ diff -Nru libextutils-xspp-perl-0.1602/examples/Object-WithIntAndString/Makefile.PL libextutils-xspp-perl-0.1800/examples/Object-WithIntAndString/Makefile.PL --- libextutils-xspp-perl-0.1602/examples/Object-WithIntAndString/Makefile.PL 2011-06-03 20:12:10.000000000 +0000 +++ libextutils-xspp-perl-0.1800/examples/Object-WithIntAndString/Makefile.PL 2013-09-18 08:17:53.000000000 +0000 @@ -19,7 +19,7 @@ INC => '-I.', # e.g., '-I. -I/usr/include/other' OBJECT => '$(O_FILES)', # link all the C files too XSOPT => '-C++ -hiertype', - TYPEMAPS => ['perlobject.map'], + #TYPEMAPS => ['other_xs_typemap_files_here'], CC => $CC, LD => '$(CC)', ); diff -Nru libextutils-xspp-perl-0.1602/examples/Object-WithIntAndString/Object-WithIntAndString.xsp libextutils-xspp-perl-0.1800/examples/Object-WithIntAndString/Object-WithIntAndString.xsp --- libextutils-xspp-perl-0.1602/examples/Object-WithIntAndString/Object-WithIntAndString.xsp 2011-06-03 20:12:10.000000000 +0000 +++ libextutils-xspp-perl-0.1800/examples/Object-WithIntAndString/Object-WithIntAndString.xsp 2013-09-18 08:17:53.000000000 +0000 @@ -2,6 +2,9 @@ // This will be used to generate the XS MODULE line %module{Object::WithIntAndString}; +// Enable default XS typemaps +%loadplugin{feature::default_xs_typemap}; + // Associate a perl class with a C++ class %name{Object::WithIntAndString} class IntAndString { diff -Nru libextutils-xspp-perl-0.1602/examples/Object-WithIntAndString/WithIntAndString.xs libextutils-xspp-perl-0.1800/examples/Object-WithIntAndString/WithIntAndString.xs --- libextutils-xspp-perl-0.1602/examples/Object-WithIntAndString/WithIntAndString.xs 2011-06-03 20:12:10.000000000 +0000 +++ libextutils-xspp-perl-0.1800/examples/Object-WithIntAndString/WithIntAndString.xs 2013-09-18 08:17:53.000000000 +0000 @@ -18,6 +18,6 @@ ## xsp interface code for our class. ## It will include the output of the xsubplusplus run. -INCLUDE_COMMAND: $^X -MExtUtils::XSpp::Cmd -e xspp -- --typemap=typemap.xsp Object-WithIntAndString.xsp +INCLUDE_COMMAND: $^X -MExtUtils::XSpp::Cmd -e xspp -- Object-WithIntAndString.xsp diff -Nru libextutils-xspp-perl-0.1602/examples/Object-WithIntAndString/perlobject.map libextutils-xspp-perl-0.1800/examples/Object-WithIntAndString/perlobject.map --- libextutils-xspp-perl-0.1602/examples/Object-WithIntAndString/perlobject.map 2011-06-03 20:12:10.000000000 +0000 +++ libextutils-xspp-perl-0.1800/examples/Object-WithIntAndString/perlobject.map 1970-01-01 00:00:00.000000000 +0000 @@ -1,106 +0,0 @@ -# "perlobject.map" Dean Roehrich, version 19960302 -# -# TYPEMAPs -# -# HV * -> unblessed Perl HV object. -# AV * -> unblessed Perl AV object. -# -# INPUT/OUTPUT maps -# -# O_* -> opaque blessed objects -# T_* -> opaque blessed or unblessed objects -# -# O_OBJECT -> link an opaque C or C++ object to a blessed Perl object. -# T_OBJECT -> link an opaque C or C++ object to an unblessed Perl object. -# O_HvRV -> a blessed Perl HV object. -# T_HvRV -> an unblessed Perl HV object. -# O_AvRV -> a blessed Perl AV object. -# T_AvRV -> an unblessed Perl AV object. - -TYPEMAP - -HV * T_HvRV -AV * T_AvRV - - -###################################################################### -OUTPUT - -# The Perl object is blessed into 'CLASS', which should be a -# char* having the name of the package for the blessing. -O_OBJECT - sv_setref_pv( $arg, CLASS, (void*)$var ); - -T_OBJECT - sv_setref_pv( $arg, Nullch, (void*)$var ); - -# Cannot use sv_setref_pv() because that will destroy -# the HV-ness of the object. Remember that newRV() will increment -# the refcount. -O_HvRV - $arg = sv_bless( newRV((SV*)$var), gv_stashpv(CLASS,1) ); - -T_HvRV - $arg = newRV((SV*)$var); - -# Cannot use sv_setref_pv() because that will destroy -# the AV-ness of the object. Remember that newRV() will increment -# the refcount. -O_AvRV - $arg = sv_bless( newRV((SV*)$var), gv_stashpv(CLASS,1) ); - -T_AvRV - $arg = newRV((SV*)$var); - - -###################################################################### -INPUT - -O_OBJECT - if( sv_isobject($arg) && (SvTYPE(SvRV($arg)) == SVt_PVMG) ) - $var = ($type)SvIV((SV*)SvRV( $arg )); - else{ - warn( \"${Package}::$func_name() -- $var is not a blessed SV reference\" ); - XSRETURN_UNDEF; - } - -T_OBJECT - if( SvROK($arg) ) - $var = ($type)SvIV((SV*)SvRV( $arg )); - else{ - warn( \"${Package}::$func_name() -- $var is not an SV reference\" ); - XSRETURN_UNDEF; - } - -O_HvRV - if( sv_isobject($arg) && (SvTYPE(SvRV($arg)) == SVt_PVHV) ) - $var = (HV*)SvRV( $arg ); - else { - warn( \"${Package}::$func_name() -- $var is not a blessed HV reference\" ); - XSRETURN_UNDEF; - } - -T_HvRV - if( SvROK($arg) && (SvTYPE(SvRV($arg)) == SVt_PVHV) ) - $var = (HV*)SvRV( $arg ); - else { - warn( \"${Package}::$func_name() -- $var is not an HV reference\" ); - XSRETURN_UNDEF; - } - -O_AvRV - if( sv_isobject($arg) && (SvTYPE(SvRV($arg)) == SVt_PVAV) ) - $var = (AV*)SvRV( $arg ); - else { - warn( \"${Package}::$func_name() -- $var is not a blessed AV reference\" ); - XSRETURN_UNDEF; - } - -T_AvRV - if( SvROK($arg) && (SvTYPE(SvRV($arg)) == SVt_PVAV) ) - $var = (AV*)SvRV( $arg ); - else { - warn( \"${Package}::$func_name() -- $var is not an AV reference\" ); - XSRETURN_UNDEF; - } - diff -Nru libextutils-xspp-perl-0.1602/examples/Object-WithIntAndString/typemap libextutils-xspp-perl-0.1800/examples/Object-WithIntAndString/typemap --- libextutils-xspp-perl-0.1602/examples/Object-WithIntAndString/typemap 2011-06-03 20:12:10.000000000 +0000 +++ libextutils-xspp-perl-0.1800/examples/Object-WithIntAndString/typemap 1970-01-01 00:00:00.000000000 +0000 @@ -1,3 +0,0 @@ -TYPEMAP -IntAndString* O_OBJECT - diff -Nru libextutils-xspp-perl-0.1602/examples/Object-WithIntAndString/typemap.xsp libextutils-xspp-perl-0.1800/examples/Object-WithIntAndString/typemap.xsp --- libextutils-xspp-perl-0.1602/examples/Object-WithIntAndString/typemap.xsp 2011-06-03 20:12:10.000000000 +0000 +++ libextutils-xspp-perl-0.1800/examples/Object-WithIntAndString/typemap.xsp 1970-01-01 00:00:00.000000000 +0000 @@ -1,3 +0,0 @@ - -// Map the type of our custom class -%typemap{IntAndString*}{simple}; diff -Nru libextutils-xspp-perl-0.1602/examples/XSpp-Example/Build.PL libextutils-xspp-perl-0.1800/examples/XSpp-Example/Build.PL --- libextutils-xspp-perl-0.1602/examples/XSpp-Example/Build.PL 2011-06-03 20:12:10.000000000 +0000 +++ libextutils-xspp-perl-0.1800/examples/XSpp-Example/Build.PL 2013-09-18 08:17:53.000000000 +0000 @@ -6,9 +6,9 @@ module_name => 'XSpp::Example', license => 'perl', requires => {}, - # Provides extra C typemaps for opaque objects: + # Provides useful extra C typemaps for opaque objects: extra_typemap_modules => { - 'ExtUtils::Typemap::ObjectMap' => '0.01', + 'ExtUtils::Typemaps::ObjectMap' => '0.01', }, ); diff -Nru libextutils-xspp-perl-0.1602/examples/XSpp-Example/src/Dog.cc libextutils-xspp-perl-0.1800/examples/XSpp-Example/src/Dog.cc --- libextutils-xspp-perl-0.1602/examples/XSpp-Example/src/Dog.cc 2011-06-03 20:12:10.000000000 +0000 +++ libextutils-xspp-perl-0.1800/examples/XSpp-Example/src/Dog.cc 2013-09-18 08:17:53.000000000 +0000 @@ -22,3 +22,16 @@ Bark(); } +Dog* +Dog::Clone() + const +{ + return new Dog(GetName()); +} + +void +Dog::MakeDogBark(const Dog& d) +{ + d.Bark(); +} + diff -Nru libextutils-xspp-perl-0.1602/examples/XSpp-Example/src/Dog.h libextutils-xspp-perl-0.1800/examples/XSpp-Example/src/Dog.h --- libextutils-xspp-perl-0.1602/examples/XSpp-Example/src/Dog.h 2011-06-03 20:12:10.000000000 +0000 +++ libextutils-xspp-perl-0.1800/examples/XSpp-Example/src/Dog.h 2013-09-18 08:17:53.000000000 +0000 @@ -4,14 +4,16 @@ #include #include -// Note: The implementation is in the header for simplicity only... - class Dog : public Animal { public: Dog(const std::string& name); void Bark() const; void MakeSound() const; + + Dog* Clone() const; + + static void MakeDogBark(const Dog& d); }; diff -Nru libextutils-xspp-perl-0.1602/examples/XSpp-Example/t/01basic.t libextutils-xspp-perl-0.1800/examples/XSpp-Example/t/01basic.t --- libextutils-xspp-perl-0.1602/examples/XSpp-Example/t/01basic.t 2011-06-03 20:12:10.000000000 +0000 +++ libextutils-xspp-perl-0.1800/examples/XSpp-Example/t/01basic.t 2013-09-18 08:17:53.000000000 +0000 @@ -1,9 +1,17 @@ use strict; use warnings; -use Test::More tests => 15; +use Test::More tests => 24; use XSpp::Example; +{ + package Azawakh; + + our @ISA = qw(Dog); +} + +$| = 1; # autoflush + my $dog = Dog->new("Skip"); isa_ok($dog, 'Dog'); isa_ok($dog, 'Animal'); @@ -18,6 +26,11 @@ $dog->SetName("Brutus"); is($dog->GetName(), "Brutus"); +my $azawakh = Azawakh->new('Spot'); +isa_ok($azawakh, 'Azawakh'); +isa_ok($azawakh, 'Dog'); +isa_ok($azawakh, 'Animal'); + my $animal = Animal->new("Tweety"); isa_ok($animal, 'Animal'); ok(!$animal->isa('Dog'), "Animal isn't a dog"); @@ -31,3 +44,16 @@ my $exception = $@; ok($exception && $exception =~ /does not make sound/); +my $clone = $dog->Clone(); +isa_ok($clone, 'Dog'); +isa_ok($clone, 'Animal'); +is($clone->GetName(), $dog->GetName()); + +my $clone2 = $azawakh->Clone(); +isa_ok($clone2, 'Dog'); +isa_ok($clone2, 'Animal'); +is($clone2->GetName(), $azawakh->GetName()); + +print "# "; # comment the bark output +Dog::MakeDogBark($clone); + diff -Nru libextutils-xspp-perl-0.1602/examples/XSpp-Example/xsp/Dog.xsp libextutils-xspp-perl-0.1800/examples/XSpp-Example/xsp/Dog.xsp --- libextutils-xspp-perl-0.1602/examples/XSpp-Example/xsp/Dog.xsp 2011-06-03 20:12:10.000000000 +0000 +++ libextutils-xspp-perl-0.1800/examples/XSpp-Example/xsp/Dog.xsp 2013-09-18 08:17:53.000000000 +0000 @@ -9,6 +9,9 @@ void MakeSound(); void Bark(); + Dog* Clone(); + + static void MakeDogBark(Dog& d); }; diff -Nru libextutils-xspp-perl-0.1602/examples/XSpp-Example/xsp/mytype.map libextutils-xspp-perl-0.1800/examples/XSpp-Example/xsp/mytype.map --- libextutils-xspp-perl-0.1602/examples/XSpp-Example/xsp/mytype.map 2011-06-03 20:12:10.000000000 +0000 +++ libextutils-xspp-perl-0.1800/examples/XSpp-Example/xsp/mytype.map 2013-09-18 08:17:53.000000000 +0000 @@ -1,5 +1,3 @@ -Animal * O_OBJECT -Dog * O_OBJECT std::string* T_STRINGPTR std::string T_STRING @@ -12,7 +10,6 @@ T_STRINGPTR $var = new std::string(SvPV_nolen($arg)) - OUTPUT T_STRING @@ -20,3 +17,4 @@ T_STRINGPTR $arg = newSVpvn($var->c_str(), $var->length()); + diff -Nru libextutils-xspp-perl-0.1602/examples/XSpp-Example/xsp/typemap.xsp libextutils-xspp-perl-0.1800/examples/XSpp-Example/xsp/typemap.xsp --- libextutils-xspp-perl-0.1602/examples/XSpp-Example/xsp/typemap.xsp 2011-06-03 20:12:10.000000000 +0000 +++ libextutils-xspp-perl-0.1800/examples/XSpp-Example/xsp/typemap.xsp 2013-09-18 08:17:53.000000000 +0000 @@ -1,4 +1,8 @@ +// Enable default XS typemaps +%loadplugin{feature::default_xs_typemap}; + %typemap{std::string}{simple}; %typemap{std::string&}{reference}; +%typemap{Dog_Factory*}{simple}; %exception{noSoundException}{CannotMakeSoundException}{stdmessage}; diff -Nru libextutils-xspp-perl-0.1602/lib/ExtUtils/XSpp/Driver.pm libextutils-xspp-perl-0.1800/lib/ExtUtils/XSpp/Driver.pm --- libextutils-xspp-perl-0.1602/lib/ExtUtils/XSpp/Driver.pm 2011-06-03 20:12:10.000000000 +0000 +++ libextutils-xspp-perl-0.1800/lib/ExtUtils/XSpp/Driver.pm 2013-09-18 08:17:53.000000000 +0000 @@ -27,8 +27,22 @@ ); my $success = $parser->parse; return() if not $success; + my $generated = $self->_emit( $parser ); - return $self->_emit( $parser ); + my $typemap_code = ExtUtils::XSpp::Typemap::get_xs_typemap_code_for_all_typemaps(); + if (defined $typemap_code && $typemap_code =~ /\S/) { + if (exists $generated->{'-'} and $generated->{'-'} ne '') { + $generated->{'-'} = $typemap_code . $generated->{'-'}; + } + elsif (my @files = grep !/^-$/, keys %$generated) { + $generated->{$files[0]} = $typemap_code . ($generated->{$files[0]}||''); + } + else { + $generated->{'-'} = $typemap_code . ($generated->{'-'}||''); + } + } + + return $generated; } sub process { @@ -81,15 +95,19 @@ my %state = ( current_module => undef ); foreach my $plugin ( @{$parser->post_process_plugins} ) { - $plugin->post_process( $data ); + my $method = $plugin->{method}; + + $plugin->{plugin}->$method( $data ); } + $out{'-'} = preamble(); foreach my $e ( @$data ) { if( $e->isa( 'ExtUtils::XSpp::Node::Module' ) ) { $state{current_module} = $e; } if( $e->isa( 'ExtUtils::XSpp::Node::File' ) ) { $out_file = $e->file; + $out{$out_file} ||= preamble(); } $out{$out_file} .= $e->print( \%state ); } @@ -97,6 +115,16 @@ return \%out; } +sub preamble { + return < +#undef xsp_constructor_class +#define xsp_constructor_class(c) (c) + + +EOT +} + sub typemaps { @{$_[0]->{typemaps} || []} } sub file { $_[0]->{file} } sub string { $_[0]->{string} } diff -Nru libextutils-xspp-perl-0.1602/lib/ExtUtils/XSpp/Grammar.pm libextutils-xspp-perl-0.1800/lib/ExtUtils/XSpp/Grammar.pm --- libextutils-xspp-perl-0.1602/lib/ExtUtils/XSpp/Grammar.pm 2011-06-03 20:12:10.000000000 +0000 +++ libextutils-xspp-perl-0.1800/lib/ExtUtils/XSpp/Grammar.pm 2013-09-18 08:17:53.000000000 +0000 @@ -501,353 +501,357 @@ [ {#State 0 ACTIONS => { - 'ID' => 25, + 'ID' => 28, 'p_typemap' => 4, 'p_any' => 3, - 'OPSPECIAL' => 30, - 'COMMENT' => 6, - 'p_exceptionmap' => 33, - "class" => 8, - 'RAW_CODE' => 34, - "const" => 10, - "int" => 37, - 'p_module' => 15, - 'p_package' => 44, - "enum" => 43, - 'p_loadplugin' => 42, - 'PREPROCESSOR' => 16, - "short" => 17, - 'p_file' => 46, - "unsigned" => 47, - 'p_name' => 19, - 'p_include' => 20, - "long" => 21, - "char" => 24 + 'OPSPECIAL' => 33, + 'COMMENT' => 7, + 'p_exceptionmap' => 36, + "class" => 9, + 'RAW_CODE' => 37, + "const" => 11, + "int" => 40, + 'p_module' => 16, + "enum" => 47, + 'p_package' => 46, + 'p_loadplugin' => 45, + 'PREPROCESSOR' => 17, + "short" => 18, + 'p_file' => 49, + "void" => 19, + "unsigned" => 50, + 'p_name' => 21, + 'p_include' => 22, + "long" => 23, + 'p__type' => 26, + "char" => 27 }, GOTOS => { - 'perc_loadplugin' => 26, + 'perc_loadplugin' => 29, 'class_name' => 1, 'top_list' => 2, - 'perc_package' => 29, - 'function' => 28, - 'nconsttype' => 27, - 'looks_like_function' => 5, - 'exceptionmap' => 31, - 'special_block_start' => 32, - 'perc_name' => 7, - 'class_decl' => 35, - 'typemap' => 9, - 'enum' => 36, - 'decorate_class' => 11, - 'special_block' => 12, - 'perc_module' => 38, - 'type_name' => 13, - 'perc_file' => 41, - 'perc_any' => 40, - 'basic_type' => 39, - 'template' => 14, - 'looks_like_renamed_function' => 45, - 'top' => 18, - 'function_decl' => 48, - 'perc_include' => 49, - 'directive' => 50, - 'type' => 22, - 'class' => 23, - 'raw' => 51 + 'perc_package' => 32, + 'function' => 31, + 'nconsttype' => 30, + '_top' => 5, + 'looks_like_function' => 6, + 'exceptionmap' => 34, + 'special_block_start' => 35, + 'perc_name' => 8, + 'class_decl' => 38, + 'typemap' => 10, + 'enum' => 39, + 'decorate_class' => 12, + 'special_block' => 13, + 'perc_module' => 41, + 'type_name' => 14, + 'perc_file' => 44, + 'perc_any' => 43, + 'basic_type' => 42, + 'template' => 15, + 'looks_like_renamed_function' => 48, + 'top' => 20, + 'function_decl' => 51, + 'perc_include' => 52, + 'directive' => 53, + 'type' => 24, + 'class' => 25, + 'raw' => 54 } }, {#State 1 ACTIONS => { - 'OPANG' => 52 + 'OPANG' => 55 }, - DEFAULT => -119 + DEFAULT => -133 }, {#State 2 ACTIONS => { - 'ID' => 25, - '' => 53, + 'ID' => 28, + '' => 56, 'p_typemap' => 4, 'p_any' => 3, - 'OPSPECIAL' => 30, - 'COMMENT' => 6, - 'p_exceptionmap' => 33, - "class" => 8, - 'RAW_CODE' => 34, - "const" => 10, - "int" => 37, - 'p_module' => 15, - "enum" => 43, - 'p_package' => 44, - 'p_loadplugin' => 42, - 'PREPROCESSOR' => 16, - "short" => 17, - 'p_file' => 46, - "unsigned" => 47, - 'p_name' => 19, - 'p_include' => 20, - "long" => 21, - "char" => 24 + 'OPSPECIAL' => 33, + 'COMMENT' => 7, + 'p_exceptionmap' => 36, + "class" => 9, + 'RAW_CODE' => 37, + "const" => 11, + "int" => 40, + 'p_module' => 16, + "enum" => 47, + 'p_package' => 46, + 'p_loadplugin' => 45, + 'PREPROCESSOR' => 17, + "short" => 18, + 'p_file' => 49, + "void" => 19, + "unsigned" => 50, + 'p_name' => 21, + 'p_include' => 22, + "long" => 23, + "char" => 27 }, GOTOS => { - 'perc_loadplugin' => 26, + 'perc_loadplugin' => 29, 'class_name' => 1, - 'function' => 28, - 'perc_package' => 29, - 'nconsttype' => 27, - 'looks_like_function' => 5, - 'exceptionmap' => 31, - 'special_block_start' => 32, - 'perc_name' => 7, - 'class_decl' => 35, - 'typemap' => 9, - 'enum' => 36, - 'decorate_class' => 11, - 'special_block' => 12, - 'perc_module' => 38, - 'type_name' => 13, - 'perc_file' => 41, - 'perc_any' => 40, - 'basic_type' => 39, - 'template' => 14, - 'looks_like_renamed_function' => 45, - 'top' => 54, - 'function_decl' => 48, - 'perc_include' => 49, - 'directive' => 50, - 'type' => 22, - 'class' => 23, - 'raw' => 51 + 'function' => 31, + 'perc_package' => 32, + 'nconsttype' => 30, + '_top' => 5, + 'looks_like_function' => 6, + 'exceptionmap' => 34, + 'special_block_start' => 35, + 'perc_name' => 8, + 'class_decl' => 38, + 'typemap' => 10, + 'enum' => 39, + 'decorate_class' => 12, + 'special_block' => 13, + 'perc_module' => 41, + 'type_name' => 14, + 'perc_file' => 44, + 'perc_any' => 43, + 'basic_type' => 42, + 'template' => 15, + 'looks_like_renamed_function' => 48, + 'top' => 57, + 'function_decl' => 51, + 'perc_include' => 52, + 'directive' => 53, + 'type' => 24, + 'class' => 25, + 'raw' => 54 } }, {#State 3 ACTIONS => { - 'OPSPECIAL' => 30, - 'OPCURLY' => 55 + 'OPSPECIAL' => 33, + 'OPCURLY' => 58 }, - DEFAULT => -109, + DEFAULT => -122, GOTOS => { - 'special_block' => 56, - 'special_block_start' => 32 + 'special_block' => 59, + 'special_block_start' => 35 } }, {#State 4 ACTIONS => { - 'OPCURLY' => 57 + 'OPCURLY' => 60 } }, {#State 5 - DEFAULT => -75 + DEFAULT => -4 }, {#State 6 - DEFAULT => -25 + DEFAULT => -86 }, {#State 7 + DEFAULT => -27 + }, + {#State 8 ACTIONS => { - 'ID' => 25, - "class" => 8, - "short" => 17, - "const" => 10, - "unsigned" => 47, - "long" => 21, - "int" => 37, - "char" => 24 + 'ID' => 28, + "class" => 9, + "short" => 18, + "void" => 19, + "unsigned" => 50, + "const" => 11, + "long" => 23, + "int" => 40, + "char" => 27 }, GOTOS => { - 'type_name' => 13, + 'type_name' => 14, 'class_name' => 1, - 'basic_type' => 39, - 'nconsttype' => 27, - 'template' => 14, - 'looks_like_function' => 58, - 'class_decl' => 59, - 'type' => 22 + 'basic_type' => 42, + 'nconsttype' => 30, + 'template' => 15, + 'looks_like_function' => 61, + 'class_decl' => 62, + 'type' => 24 } }, - {#State 8 + {#State 9 ACTIONS => { - 'ID' => 60 + 'ID' => 28 + }, + GOTOS => { + 'class_name' => 63 } }, - {#State 9 - DEFAULT => -14 - }, {#State 10 + DEFAULT => -16 + }, + {#State 11 ACTIONS => { - 'ID' => 25, - "short" => 17, - "unsigned" => 47, - "long" => 21, - "int" => 37, - "char" => 24 + 'ID' => 28, + "short" => 18, + "void" => 19, + "unsigned" => 50, + "long" => 23, + "int" => 40, + "char" => 27 }, GOTOS => { - 'type_name' => 13, + 'type_name' => 14, 'class_name' => 1, - 'basic_type' => 39, - 'nconsttype' => 61, - 'template' => 14 + 'basic_type' => 42, + 'nconsttype' => 64, + 'template' => 15 } }, - {#State 11 + {#State 12 ACTIONS => { - 'SEMICOLON' => 62 + 'SEMICOLON' => 65 } }, - {#State 12 - DEFAULT => -27 - }, {#State 13 - DEFAULT => -117 + DEFAULT => -29 }, {#State 14 - DEFAULT => -118 + DEFAULT => -131 }, {#State 15 - ACTIONS => { - 'OPCURLY' => 63 - } + DEFAULT => -132 }, {#State 16 - DEFAULT => -26 + ACTIONS => { + 'OPCURLY' => 66 + } }, {#State 17 - ACTIONS => { - "int" => 64 - }, - DEFAULT => -126 + DEFAULT => -28 }, {#State 18 - DEFAULT => -1 + ACTIONS => { + "int" => 67 + }, + DEFAULT => -141 }, {#State 19 - ACTIONS => { - 'OPCURLY' => 65 - } + DEFAULT => -135 }, {#State 20 - ACTIONS => { - 'OPCURLY' => 66 - } + DEFAULT => -1 }, {#State 21 ACTIONS => { - "int" => 67 - }, - DEFAULT => -125 + 'OPCURLY' => 68 + } }, {#State 22 ACTIONS => { - 'ID' => 68 + 'OPCURLY' => 69 } }, {#State 23 - DEFAULT => -4 + ACTIONS => { + "int" => 70 + }, + DEFAULT => -140 }, {#State 24 - DEFAULT => -123 - }, - {#State 25 ACTIONS => { - 'DCOLON' => 70 - }, - DEFAULT => -132, - GOTOS => { - 'class_suffix' => 69 + 'ID' => 71 } }, + {#State 25 + DEFAULT => -6 + }, {#State 26 ACTIONS => { - 'SEMICOLON' => 71 + 'OPCURLY' => 72 } }, {#State 27 - ACTIONS => { - 'STAR' => 73, - 'AMP' => 72 - }, - DEFAULT => -114 + DEFAULT => -138 }, {#State 28 - DEFAULT => -7 + ACTIONS => { + 'DCOLON' => 74 + }, + DEFAULT => -147, + GOTOS => { + 'class_suffix' => 73 + } }, {#State 29 ACTIONS => { - 'SEMICOLON' => 74 + 'SEMICOLON' => 75 } }, {#State 30 - DEFAULT => -164 + ACTIONS => { + 'AMP' => 76, + 'STAR' => 77 + }, + DEFAULT => -128 }, {#State 31 - DEFAULT => -15 + DEFAULT => -9 }, {#State 32 ACTIONS => { - 'CLSPECIAL' => 75, - 'line' => 76 - }, - GOTOS => { - 'special_block_end' => 77, - 'lines' => 78 + 'SEMICOLON' => 78 } }, {#State 33 - ACTIONS => { - 'OPCURLY' => 79 - } + DEFAULT => -184 }, {#State 34 - DEFAULT => -24 + DEFAULT => -17 }, {#State 35 ACTIONS => { - 'SEMICOLON' => 80 + 'CLSPECIAL' => 79, + 'line' => 80 + }, + GOTOS => { + 'special_block_end' => 81, + 'lines' => 82 } }, {#State 36 - DEFAULT => -6 + ACTIONS => { + 'OPCURLY' => 83 + } }, {#State 37 - DEFAULT => -124 + DEFAULT => -26 }, {#State 38 ACTIONS => { - 'SEMICOLON' => 81 + 'SEMICOLON' => 84 } }, {#State 39 - DEFAULT => -120 + DEFAULT => -8 }, {#State 40 - ACTIONS => { - 'SEMICOLON' => 82 - } + DEFAULT => -139 }, {#State 41 ACTIONS => { - 'SEMICOLON' => 83 + 'SEMICOLON' => 85 } }, {#State 42 - ACTIONS => { - 'OPCURLY' => 84 - } + DEFAULT => -134 }, {#State 43 ACTIONS => { - 'ID' => 86, - 'OPCURLY' => 85 + 'SEMICOLON' => 86 } }, {#State 44 ACTIONS => { - 'OPCURLY' => 87 + 'SEMICOLON' => 87 } }, {#State 45 - DEFAULT => -84, - GOTOS => { - 'function_metadata' => 88 + ACTIONS => { + 'OPCURLY' => 88 } }, {#State 46 @@ -857,353 +861,369 @@ }, {#State 47 ACTIONS => { - "short" => 17, - "long" => 21, - "int" => 37, - "char" => 24 - }, - DEFAULT => -121, - GOTOS => { - 'basic_type' => 90 + 'ID' => 91, + 'OPCURLY' => 90 } }, {#State 48 - ACTIONS => { - 'SEMICOLON' => 91 + DEFAULT => -95, + GOTOS => { + 'function_metadata' => 92 } }, {#State 49 ACTIONS => { - 'SEMICOLON' => 92 + 'OPCURLY' => 93 } }, {#State 50 - DEFAULT => -5 + ACTIONS => { + "short" => 18, + "long" => 23, + "int" => 40, + "char" => 27 + }, + DEFAULT => -136, + GOTOS => { + 'basic_type' => 94 + } }, {#State 51 - DEFAULT => -3 + ACTIONS => { + 'SEMICOLON' => 95 + } }, {#State 52 ACTIONS => { - 'ID' => 25, - "short" => 17, - "unsigned" => 47, - "const" => 10, - "long" => 21, - "int" => 37, - "char" => 24 - }, - GOTOS => { - 'type_list' => 94, - 'type_name' => 13, - 'class_name' => 1, - 'basic_type' => 39, - 'nconsttype' => 27, - 'template' => 14, - 'type' => 93 + 'SEMICOLON' => 96 } }, {#State 53 - DEFAULT => 0 + DEFAULT => -7 }, {#State 54 - DEFAULT => -2 + DEFAULT => -5 }, {#State 55 ACTIONS => { - 'ID' => 97, - 'p_any' => 95 + 'ID' => 28, + "short" => 18, + "void" => 19, + "const" => 11, + "unsigned" => 50, + "long" => 23, + "int" => 40, + "char" => 27 }, GOTOS => { - 'perc_any_arg' => 96, - 'perc_any_args' => 98 + 'type_list' => 98, + 'type_name' => 14, + 'class_name' => 1, + 'basic_type' => 42, + 'nconsttype' => 30, + 'template' => 15, + 'type' => 97 } }, {#State 56 - DEFAULT => -22, - GOTOS => { - 'mixed_blocks' => 99 - } + DEFAULT => 0 }, {#State 57 + DEFAULT => -2 + }, + {#State 58 ACTIONS => { - 'ID' => 25, - "short" => 17, - "unsigned" => 47, - "const" => 10, - "long" => 21, - "int" => 37, - "char" => 24 + 'ID' => 102, + 'p_any' => 99, + 'p_name' => 21 }, GOTOS => { - 'type_name' => 13, - 'class_name' => 1, - 'basic_type' => 39, - 'nconsttype' => 27, - 'template' => 14, - 'type' => 100 + 'perc_name' => 101, + 'perc_any_arg' => 100, + 'perc_any_args' => 103 } }, - {#State 58 - DEFAULT => -76 - }, {#State 59 - DEFAULT => -40 + DEFAULT => -24, + GOTOS => { + 'mixed_blocks' => 104 + } }, {#State 60 ACTIONS => { - 'COLON' => 102 + 'ID' => 28, + "short" => 18, + "void" => 19, + "const" => 11, + "unsigned" => 50, + "long" => 23, + "int" => 40, + "char" => 27 }, - DEFAULT => -44, GOTOS => { - 'base_classes' => 101 + 'type_name' => 14, + 'class_name' => 1, + 'basic_type' => 42, + 'nconsttype' => 30, + 'template' => 15, + 'type' => 105 } }, {#State 61 - ACTIONS => { - 'STAR' => 73, - 'AMP' => 72 - }, - DEFAULT => -113 + DEFAULT => -87 }, {#State 62 - DEFAULT => -37 + DEFAULT => -43 }, {#State 63 ACTIONS => { - 'ID' => 25 + 'COLON' => 107 }, + DEFAULT => -47, GOTOS => { - 'class_name' => 103 + 'base_classes' => 106 } }, {#State 64 - DEFAULT => -128 - }, - {#State 65 ACTIONS => { - 'ID' => 25 + 'AMP' => 76, + 'STAR' => 77 }, - GOTOS => { - 'class_name' => 104 - } + DEFAULT => -127 + }, + {#State 65 + DEFAULT => -39 }, {#State 66 ACTIONS => { - 'ID' => 106, - 'DASH' => 107 + 'ID' => 28 }, GOTOS => { - 'file_name' => 105 + 'class_name' => 108 } }, {#State 67 - DEFAULT => -127 + DEFAULT => -143 }, {#State 68 ACTIONS => { - 'OPPAR' => 108 + 'ID' => 28 + }, + GOTOS => { + 'class_name' => 109 } }, {#State 69 ACTIONS => { - 'DCOLON' => 109 + 'ID' => 111, + 'DASH' => 112 }, - DEFAULT => -133 + GOTOS => { + 'file_name' => 110 + } }, {#State 70 - ACTIONS => { - 'ID' => 110 - } + DEFAULT => -142 }, {#State 71 - DEFAULT => -11 + ACTIONS => { + 'OPPAR' => 113 + } }, {#State 72 - DEFAULT => -116 + ACTIONS => { + 'ID' => 28, + "short" => 18, + "void" => 19, + "const" => 11, + "unsigned" => 50, + "long" => 23, + "int" => 40, + "char" => 27 + }, + GOTOS => { + 'type_name' => 14, + 'class_name' => 1, + 'basic_type' => 42, + 'nconsttype' => 30, + 'template' => 15, + 'type' => 114 + } }, {#State 73 - DEFAULT => -115 + ACTIONS => { + 'DCOLON' => 115 + }, + DEFAULT => -148 }, {#State 74 - DEFAULT => -9 + ACTIONS => { + 'ID' => 116 + } }, {#State 75 - DEFAULT => -165 + DEFAULT => -13 }, {#State 76 - DEFAULT => -166 + DEFAULT => -130 }, {#State 77 - DEFAULT => -163 + DEFAULT => -129 }, {#State 78 - ACTIONS => { - 'CLSPECIAL' => 75, - 'line' => 111 - }, - GOTOS => { - 'special_block_end' => 112 - } + DEFAULT => -11 }, {#State 79 - ACTIONS => { - 'ID' => 113 - } + DEFAULT => -185 }, {#State 80 - DEFAULT => -36 + DEFAULT => -186 }, {#State 81 - DEFAULT => -8 + DEFAULT => -183 }, {#State 82 - DEFAULT => -13 - }, - {#State 83 - DEFAULT => -10 - }, - {#State 84 ACTIONS => { - 'ID' => 25 + 'CLSPECIAL' => 79, + 'line' => 117 }, GOTOS => { - 'class_name' => 114 + 'special_block_end' => 118 } }, - {#State 85 - DEFAULT => -30, - GOTOS => { - 'enum_element_list' => 115 + {#State 83 + ACTIONS => { + 'ID' => 119 } }, + {#State 84 + DEFAULT => -38 + }, + {#State 85 + DEFAULT => -10 + }, {#State 86 - ACTIONS => { - 'OPCURLY' => 116 - } + DEFAULT => -15 }, {#State 87 - ACTIONS => { - 'ID' => 25 - }, - GOTOS => { - 'class_name' => 117 - } + DEFAULT => -12 }, {#State 88 ACTIONS => { - 'p_code' => 123, - 'p_cleanup' => 119, - 'p_any' => 3, - 'p_catch' => 127, - 'p_postcall' => 121 + 'ID' => 28 }, - DEFAULT => -77, GOTOS => { - 'perc_postcall' => 122, - 'perc_code' => 118, - 'perc_any' => 124, - 'perc_cleanup' => 125, - 'perc_catch' => 120, - '_function_metadata' => 126 + 'class_name' => 120 } }, {#State 89 ACTIONS => { - 'ID' => 106, - 'DASH' => 107 + 'ID' => 28 }, GOTOS => { - 'file_name' => 128 + 'class_name' => 121 } }, {#State 90 - DEFAULT => -122 + DEFAULT => -32, + GOTOS => { + 'enum_element_list' => 122 + } }, {#State 91 - DEFAULT => -38 + ACTIONS => { + 'OPCURLY' => 123 + } }, {#State 92 - DEFAULT => -12 + ACTIONS => { + 'p_any' => 3, + 'p_alias' => 128, + 'p_code' => 131, + 'p_cleanup' => 125, + 'p_postcall' => 127, + 'p_catch' => 135 + }, + DEFAULT => -88, + GOTOS => { + 'perc_postcall' => 130, + 'perc_code' => 124, + 'perc_any' => 132, + 'perc_cleanup' => 133, + 'perc_catch' => 126, + '_function_metadata' => 134, + 'perc_alias' => 129 + } }, {#State 93 - DEFAULT => -130 - }, - {#State 94 ACTIONS => { - 'CLANG' => 129, - 'COMMA' => 130 + 'ID' => 111, + 'DASH' => 112 + }, + GOTOS => { + 'file_name' => 136 } }, + {#State 94 + DEFAULT => -137 + }, {#State 95 - DEFAULT => -22, - GOTOS => { - 'mixed_blocks' => 131 - } + DEFAULT => -40 }, {#State 96 - DEFAULT => -110 + DEFAULT => -14 }, {#State 97 - ACTIONS => { - 'CLCURLY' => 132 - } + DEFAULT => -145 }, {#State 98 ACTIONS => { - 'p_any' => 95, - 'CLCURLY' => 134 - }, - GOTOS => { - 'perc_any_arg' => 133 + 'CLANG' => 137, + 'COMMA' => 138 } }, {#State 99 - ACTIONS => { - 'OPSPECIAL' => 30, - 'OPCURLY' => 135 - }, - DEFAULT => -108, + DEFAULT => -24, GOTOS => { - 'simple_block' => 137, - 'special_block' => 136, - 'special_block_start' => 32 + 'mixed_blocks' => 139 } }, {#State 100 - ACTIONS => { - 'CLCURLY' => 138 - } + DEFAULT => -123 }, {#State 101 ACTIONS => { - 'COMMA' => 140 - }, - DEFAULT => -52, - GOTOS => { - 'class_metadata' => 139 + 'SEMICOLON' => 140 } }, {#State 102 ACTIONS => { - "protected" => 144, - "private" => 143, - "public" => 141 - }, - GOTOS => { - 'base_class' => 142 + 'CLCURLY' => 141 } }, {#State 103 ACTIONS => { - 'CLCURLY' => 145 + 'p_any' => 99, + 'p_name' => 21, + 'CLCURLY' => 143 + }, + GOTOS => { + 'perc_name' => 101, + 'perc_any_arg' => 142 } }, {#State 104 ACTIONS => { - 'CLCURLY' => 146 - } - }, + 'OPSPECIAL' => 33, + 'OPCURLY' => 144 + }, + DEFAULT => -121, + GOTOS => { + 'simple_block' => 146, + 'special_block' => 145, + 'special_block_start' => 35 + } + }, {#State 105 ACTIONS => { 'CLCURLY' => 147 @@ -1211,1294 +1231,1475 @@ }, {#State 106 ACTIONS => { - 'DOT' => 149, - 'SLASH' => 148 + 'COMMA' => 149 + }, + DEFAULT => -55, + GOTOS => { + 'class_metadata' => 148 } }, {#State 107 - DEFAULT => -138 - }, - {#State 108 ACTIONS => { - 'ID' => 25, - "short" => 17, - "const" => 10, - "unsigned" => 47, - "long" => 21, - "int" => 37, - "char" => 24 + "protected" => 153, + "private" => 152, + "public" => 150 }, - DEFAULT => -143, GOTOS => { - 'type_name' => 13, - 'class_name' => 1, - 'basic_type' => 39, - 'nconsttype' => 27, - 'template' => 14, - 'arg_list' => 151, - 'argument' => 152, - 'type' => 150 + 'base_class' => 151 + } + }, + {#State 108 + ACTIONS => { + 'CLCURLY' => 154 } }, {#State 109 ACTIONS => { - 'ID' => 153 + 'CLCURLY' => 155 } }, {#State 110 - DEFAULT => -136 + ACTIONS => { + 'CLCURLY' => 156 + } }, {#State 111 - DEFAULT => -167 + ACTIONS => { + 'DOT' => 158, + 'SLASH' => 157 + } }, {#State 112 - DEFAULT => -162 + DEFAULT => -153 }, {#State 113 ACTIONS => { - 'CLCURLY' => 154 + 'ID' => 28, + "short" => 18, + "void" => 160, + "unsigned" => 50, + "const" => 11, + "long" => 23, + "int" => 40, + "char" => 27 + }, + DEFAULT => -160, + GOTOS => { + 'type_name' => 14, + 'class_name' => 1, + 'basic_type' => 42, + 'nconsttype' => 30, + 'template' => 15, + 'nonvoid_arg_list' => 159, + 'arg_list' => 162, + 'argument' => 163, + 'type' => 161 } }, {#State 114 ACTIONS => { - 'CLCURLY' => 155 + 'CLCURLY' => 164 } }, {#State 115 ACTIONS => { - 'ID' => 156, - 'PREPROCESSOR' => 16, - 'RAW_CODE' => 34, - 'OPSPECIAL' => 30, - 'COMMENT' => 6, - 'CLCURLY' => 158 - }, - GOTOS => { - 'enum_element' => 157, - 'special_block' => 12, - 'raw' => 159, - 'special_block_start' => 32 + 'ID' => 165 } }, {#State 116 - DEFAULT => -30, - GOTOS => { - 'enum_element_list' => 160 - } + DEFAULT => -151 }, {#State 117 - ACTIONS => { - 'CLCURLY' => 161 - } + DEFAULT => -187 }, {#State 118 - DEFAULT => -91 + DEFAULT => -182 }, {#State 119 ACTIONS => { - 'OPSPECIAL' => 30 - }, - GOTOS => { - 'special_block' => 162, - 'special_block_start' => 32 + 'CLCURLY' => 166 } }, {#State 120 - DEFAULT => -94 + ACTIONS => { + 'CLCURLY' => 167 + } }, {#State 121 ACTIONS => { - 'OPSPECIAL' => 30 - }, - GOTOS => { - 'special_block' => 163, - 'special_block_start' => 32 + 'CLCURLY' => 168 } }, {#State 122 - DEFAULT => -93 - }, - {#State 123 ACTIONS => { - 'OPSPECIAL' => 30 + 'ID' => 169, + 'PREPROCESSOR' => 17, + 'RAW_CODE' => 37, + 'OPSPECIAL' => 33, + 'COMMENT' => 7, + 'CLCURLY' => 171 }, GOTOS => { - 'special_block' => 164, - 'special_block_start' => 32 + 'enum_element' => 170, + 'special_block' => 13, + 'raw' => 172, + 'special_block_start' => 35 + } + }, + {#State 123 + DEFAULT => -32, + GOTOS => { + 'enum_element_list' => 173 } }, {#State 124 - DEFAULT => -95 + DEFAULT => -102 }, {#State 125 - DEFAULT => -92 + ACTIONS => { + 'OPSPECIAL' => 33 + }, + GOTOS => { + 'special_block' => 174, + 'special_block_start' => 35 + } }, {#State 126 - DEFAULT => -83 + DEFAULT => -105 }, {#State 127 ACTIONS => { - 'OPCURLY' => 165 + 'OPSPECIAL' => 33 + }, + GOTOS => { + 'special_block' => 175, + 'special_block_start' => 35 } }, {#State 128 ACTIONS => { - 'CLCURLY' => 166 + 'OPCURLY' => 176 } }, {#State 129 - DEFAULT => -129 + DEFAULT => -106 }, {#State 130 - ACTIONS => { - 'ID' => 25, - "short" => 17, - "unsigned" => 47, - "const" => 10, - "long" => 21, - "int" => 37, - "char" => 24 - }, - GOTOS => { - 'type_name' => 13, - 'class_name' => 1, - 'basic_type' => 39, - 'nconsttype' => 27, - 'template' => 14, - 'type' => 167 - } + DEFAULT => -104 }, {#State 131 ACTIONS => { - 'OPCURLY' => 135, - 'OPSPECIAL' => 30, - 'SEMICOLON' => 168 + 'OPSPECIAL' => 33 }, GOTOS => { - 'simple_block' => 137, - 'special_block' => 136, - 'special_block_start' => 32 + 'special_block' => 177, + 'special_block_start' => 35 } }, {#State 132 - DEFAULT => -22, - GOTOS => { - 'mixed_blocks' => 169 - } + DEFAULT => -107 }, {#State 133 - DEFAULT => -111 + DEFAULT => -103 }, {#State 134 - DEFAULT => -106 + DEFAULT => -94 }, {#State 135 ACTIONS => { - 'ID' => 170 + 'OPCURLY' => 178 } }, {#State 136 - DEFAULT => -20 + ACTIONS => { + 'CLCURLY' => 179 + } }, {#State 137 - DEFAULT => -21 + DEFAULT => -144 }, {#State 138 ACTIONS => { - 'OPCURLY' => 171, - 'SEMICOLON' => 172 + 'ID' => 28, + "short" => 18, + "void" => 19, + "const" => 11, + "unsigned" => 50, + "long" => 23, + "int" => 40, + "char" => 27 + }, + GOTOS => { + 'type_name' => 14, + 'class_name' => 1, + 'basic_type' => 42, + 'nconsttype' => 30, + 'template' => 15, + 'type' => 180 } }, {#State 139 ACTIONS => { - 'OPCURLY' => 173, - 'p_any' => 3, - 'p_catch' => 127 + 'OPCURLY' => 144, + 'OPSPECIAL' => 33, + 'SEMICOLON' => 181 }, GOTOS => { - 'perc_any' => 175, - 'perc_catch' => 174 + 'simple_block' => 146, + 'special_block' => 145, + 'special_block_start' => 35 } }, {#State 140 - ACTIONS => { - "protected" => 144, - "private" => 143, - "public" => 141 - }, - GOTOS => { - 'base_class' => 176 - } + DEFAULT => -126 }, {#State 141 - ACTIONS => { - 'ID' => 25, - 'p_name' => 19 - }, + DEFAULT => -24, GOTOS => { - 'perc_name' => 178, - 'class_name' => 177, - 'class_name_rename' => 179 + 'mixed_blocks' => 182 } }, {#State 142 - DEFAULT => -42 + DEFAULT => -124 }, {#State 143 - ACTIONS => { - 'ID' => 25, - 'p_name' => 19 - }, - GOTOS => { - 'perc_name' => 178, - 'class_name' => 177, - 'class_name_rename' => 180 - } + DEFAULT => -119 }, {#State 144 ACTIONS => { - 'ID' => 25, - 'p_name' => 19 - }, - GOTOS => { - 'perc_name' => 178, - 'class_name' => 177, - 'class_name_rename' => 181 + 'ID' => 183 } }, {#State 145 - DEFAULT => -98 + DEFAULT => -22 }, {#State 146 - DEFAULT => -96 + DEFAULT => -23 }, {#State 147 - DEFAULT => -101 + ACTIONS => { + 'OPCURLY' => 184, + 'SEMICOLON' => 185 + } }, {#State 148 ACTIONS => { - 'ID' => 106, - 'DASH' => 107 + 'OPCURLY' => 186, + 'p_any' => 3, + 'p_catch' => 135 }, GOTOS => { - 'file_name' => 182 + 'perc_any' => 188, + 'perc_catch' => 187 } }, {#State 149 ACTIONS => { - 'ID' => 183 + "protected" => 153, + "private" => 152, + "public" => 150 + }, + GOTOS => { + 'base_class' => 189 } }, {#State 150 ACTIONS => { - 'ID' => 185, - 'p_length' => 184 + 'ID' => 28, + 'p_name' => 21 + }, + GOTOS => { + 'perc_name' => 191, + 'class_name' => 190, + 'class_name_rename' => 192 } }, {#State 151 - ACTIONS => { - 'CLPAR' => 186, - 'COMMA' => 187 - } + DEFAULT => -45 }, {#State 152 - DEFAULT => -141 + ACTIONS => { + 'ID' => 28, + 'p_name' => 21 + }, + GOTOS => { + 'perc_name' => 191, + 'class_name' => 190, + 'class_name_rename' => 193 + } }, {#State 153 - DEFAULT => -137 - }, - {#State 154 ACTIONS => { - 'OPCURLY' => 188 + 'ID' => 28, + 'p_name' => 21 + }, + GOTOS => { + 'perc_name' => 191, + 'class_name' => 190, + 'class_name_rename' => 194 } }, + {#State 154 + DEFAULT => -111 + }, {#State 155 - DEFAULT => -100 + DEFAULT => -108 }, {#State 156 - ACTIONS => { - 'EQUAL' => 189 - }, - DEFAULT => -33 + DEFAULT => -114 }, {#State 157 ACTIONS => { - 'COMMA' => 190 + 'ID' => 111, + 'DASH' => 112 }, - DEFAULT => -31 + GOTOS => { + 'file_name' => 195 + } }, {#State 158 ACTIONS => { - 'SEMICOLON' => 191 + 'ID' => 196 } }, {#State 159 - DEFAULT => -35 + ACTIONS => { + 'COMMA' => 197 + }, + DEFAULT => -156 }, {#State 160 ACTIONS => { - 'ID' => 156, - 'PREPROCESSOR' => 16, - 'RAW_CODE' => 34, - 'OPSPECIAL' => 30, - 'COMMENT' => 6, - 'CLCURLY' => 192 + 'CLPAR' => -157 }, - GOTOS => { - 'enum_element' => 157, - 'special_block' => 12, - 'raw' => 159, - 'special_block_start' => 32 - } + DEFAULT => -135 }, {#State 161 - DEFAULT => -97 + ACTIONS => { + 'ID' => 199, + 'p_length' => 198 + } }, {#State 162 - DEFAULT => -103 + ACTIONS => { + 'CLPAR' => 200 + } }, {#State 163 - DEFAULT => -104 + DEFAULT => -158 }, {#State 164 - DEFAULT => -102 + DEFAULT => -3 }, {#State 165 - ACTIONS => { - 'ID' => 25 - }, - GOTOS => { - 'class_name' => 193, - 'class_name_list' => 194 - } + DEFAULT => -152 }, {#State 166 - DEFAULT => -99 + ACTIONS => { + 'OPCURLY' => 201 + } }, {#State 167 - DEFAULT => -131 + DEFAULT => -113 }, {#State 168 - DEFAULT => -112 + DEFAULT => -110 }, {#State 169 ACTIONS => { - 'OPSPECIAL' => 30, - 'OPCURLY' => 135 + 'EQUAL' => 202 }, - DEFAULT => -107, - GOTOS => { - 'simple_block' => 137, - 'special_block' => 136, - 'special_block_start' => 32 - } + DEFAULT => -35 }, {#State 170 ACTIONS => { - 'CLCURLY' => 195 - } + 'COMMA' => 203 + }, + DEFAULT => -33 }, {#State 171 ACTIONS => { - 'ID' => 196 + 'SEMICOLON' => 204 } }, {#State 172 - DEFAULT => -18 + DEFAULT => -37 }, {#State 173 - DEFAULT => -53, + ACTIONS => { + 'ID' => 169, + 'PREPROCESSOR' => 17, + 'RAW_CODE' => 37, + 'OPSPECIAL' => 33, + 'COMMENT' => 7, + 'CLCURLY' => 205 + }, GOTOS => { - 'class_body_list' => 197 + 'enum_element' => 170, + 'special_block' => 13, + 'raw' => 172, + 'special_block_start' => 35 } }, {#State 174 - DEFAULT => -50 + DEFAULT => -116 }, {#State 175 - DEFAULT => -51 + DEFAULT => -117 }, {#State 176 - DEFAULT => -43 + ACTIONS => { + 'ID' => 206 + } }, {#State 177 - DEFAULT => -48 + DEFAULT => -115 }, {#State 178 ACTIONS => { - 'ID' => 25 + 'ID' => 28 }, GOTOS => { - 'class_name' => 198 + 'class_name' => 207, + 'class_name_list' => 208 } }, {#State 179 - DEFAULT => -45 + DEFAULT => -112 }, {#State 180 - DEFAULT => -47 + DEFAULT => -146 }, {#State 181 - DEFAULT => -46 + DEFAULT => -125 }, {#State 182 - DEFAULT => -140 + ACTIONS => { + 'OPSPECIAL' => 33, + 'OPCURLY' => 144 + }, + DEFAULT => -120, + GOTOS => { + 'simple_block' => 146, + 'special_block' => 145, + 'special_block_start' => 35 + } }, {#State 183 - DEFAULT => -139 + ACTIONS => { + 'CLCURLY' => 209 + } }, {#State 184 ACTIONS => { - 'OPCURLY' => 199 + 'ID' => 210 } }, {#State 185 - ACTIONS => { - 'EQUAL' => 200 - }, - DEFAULT => -146 + DEFAULT => -20 }, {#State 186 - ACTIONS => { - "const" => 201 - }, - DEFAULT => -69, + DEFAULT => -56, GOTOS => { - 'const' => 202 + 'class_body_list' => 211 } }, {#State 187 - ACTIONS => { - 'ID' => 25, - "short" => 17, - "unsigned" => 47, - "const" => 10, - "long" => 21, - "int" => 37, - "char" => 24 - }, - GOTOS => { - 'argument' => 203, - 'type_name' => 13, - 'class_name' => 1, - 'basic_type' => 39, - 'nconsttype' => 27, - 'template' => 14, - 'type' => 150 - } + DEFAULT => -53 }, {#State 188 - ACTIONS => { - 'ID' => 25, - "short" => 17, - "unsigned" => 47, - "long" => 21, - "int" => 37, - "char" => 24 - }, - GOTOS => { - 'type_name' => 205, - 'class_name' => 204, - 'basic_type' => 39 - } + DEFAULT => -54 }, {#State 189 - ACTIONS => { - 'ID' => 25, - 'INTEGER' => 208, - 'QUOTED_STRING' => 210, - 'DASH' => 212, - 'FLOAT' => 211 - }, - GOTOS => { - 'class_name' => 206, - 'value' => 209, - 'expression' => 207 - } + DEFAULT => -46 }, {#State 190 - DEFAULT => -32 + DEFAULT => -51 }, {#State 191 - DEFAULT => -28 - }, - {#State 192 ACTIONS => { - 'SEMICOLON' => 213 + 'ID' => 28 + }, + GOTOS => { + 'class_name' => 212 } }, + {#State 192 + DEFAULT => -48 + }, {#State 193 - DEFAULT => -134 + DEFAULT => -50 }, {#State 194 - ACTIONS => { - 'COMMA' => 214, - 'CLCURLY' => 215 - } + DEFAULT => -49 }, {#State 195 - DEFAULT => -23 + DEFAULT => -155 }, {#State 196 - ACTIONS => { - 'CLCURLY' => 216 - } + DEFAULT => -154 }, {#State 197 ACTIONS => { - 'ID' => 231, - 'p_typemap' => 4, - 'p_any' => 3, - 'OPSPECIAL' => 30, - "virtual" => 232, - 'COMMENT' => 6, - "class_static" => 218, - "package_static" => 233, - "public" => 219, - 'p_exceptionmap' => 33, - 'RAW_CODE' => 34, - "const" => 10, - "static" => 237, - "int" => 37, - "private" => 224, - 'CLCURLY' => 240, - 'PREPROCESSOR' => 16, - "short" => 17, - "unsigned" => 47, - 'p_name' => 19, - 'TILDE' => 227, - "protected" => 228, - "long" => 21, - "char" => 24 + 'ID' => 28, + "short" => 18, + "void" => 19, + "const" => 11, + "unsigned" => 50, + "long" => 23, + "int" => 40, + "char" => 27 }, GOTOS => { + 'argument' => 213, + 'type_name' => 14, 'class_name' => 1, - 'nconsttype' => 27, - 'looks_like_function' => 5, - 'static' => 217, - 'exceptionmap' => 234, - 'special_block_start' => 32, - 'perc_name' => 220, - 'typemap' => 221, - 'class_body_element' => 235, - 'method' => 236, - 'vmethod' => 222, - 'nmethod' => 223, - 'special_block' => 12, - 'access_specifier' => 225, - 'type_name' => 13, - 'ctor' => 226, - 'perc_any' => 238, - 'basic_type' => 39, - 'template' => 14, - 'virtual' => 239, - 'looks_like_renamed_function' => 241, - '_vmethod' => 242, - 'type' => 22, - 'dtor' => 229, - 'raw' => 243, - 'method_decl' => 230 + 'basic_type' => 42, + 'nconsttype' => 30, + 'template' => 15, + 'type' => 161 } }, {#State 198 - DEFAULT => -49 + ACTIONS => { + 'OPCURLY' => 214 + } }, {#State 199 - ACTIONS => { - 'ID' => 244 + DEFAULT => -162, + GOTOS => { + 'argument_metadata' => 215 } }, {#State 200 ACTIONS => { - 'ID' => 25, - 'INTEGER' => 208, - 'QUOTED_STRING' => 210, - 'DASH' => 212, - 'FLOAT' => 211 + "const" => 216 }, + DEFAULT => -80, GOTOS => { - 'class_name' => 206, - 'value' => 209, - 'expression' => 245 + 'const' => 217 } }, {#State 201 - DEFAULT => -68 + ACTIONS => { + 'ID' => 28, + "short" => 18, + "void" => 19, + "unsigned" => 50, + "long" => 23, + "int" => 40, + "char" => 27 + }, + GOTOS => { + 'type_name' => 219, + 'class_name' => 218, + 'basic_type' => 42 + } }, {#State 202 - DEFAULT => -74 + ACTIONS => { + 'ID' => 28, + 'INTEGER' => 222, + 'QUOTED_STRING' => 224, + 'DASH' => 226, + 'FLOAT' => 225 + }, + GOTOS => { + 'class_name' => 220, + 'value' => 223, + 'expression' => 221 + } }, {#State 203 - DEFAULT => -142 + DEFAULT => -34 }, {#State 204 - DEFAULT => -119 + DEFAULT => -30 }, {#State 205 ACTIONS => { - 'CLCURLY' => 246 + 'SEMICOLON' => 227 } }, {#State 206 ACTIONS => { - 'OPPAR' => 247 - }, - DEFAULT => -151 + 'EQUAL' => 228 + } }, {#State 207 - DEFAULT => -34 + DEFAULT => -149 }, {#State 208 - DEFAULT => -147 + ACTIONS => { + 'COMMA' => 229, + 'CLCURLY' => 230 + } }, {#State 209 - ACTIONS => { - 'AMP' => 248, - 'PIPE' => 249 - }, - DEFAULT => -156 + DEFAULT => -25 }, {#State 210 - DEFAULT => -150 + ACTIONS => { + 'CLCURLY' => 231 + } }, {#State 211 - DEFAULT => -149 - }, - {#State 212 ACTIONS => { - 'INTEGER' => 250 + 'ID' => 250, + 'p_typemap' => 4, + 'p_any' => 3, + 'OPSPECIAL' => 33, + "virtual" => 251, + 'COMMENT' => 7, + "class_static" => 233, + "package_static" => 252, + "public" => 234, + 'p_exceptionmap' => 36, + 'RAW_CODE' => 37, + "const" => 11, + "static" => 256, + "int" => 40, + "private" => 240, + 'CLCURLY' => 259, + 'PREPROCESSOR' => 17, + "short" => 18, + "void" => 19, + "unsigned" => 50, + 'p_name' => 21, + 'TILDE' => 244, + "protected" => 245, + "long" => 23, + "char" => 27 + }, + DEFAULT => -71, + GOTOS => { + 'class_name' => 1, + 'nconsttype' => 30, + 'looks_like_function' => 6, + 'static' => 232, + 'exceptionmap' => 253, + 'special_block_start' => 35, + 'perc_name' => 235, + 'looks_like_member' => 236, + 'typemap' => 237, + 'class_body_element' => 254, + 'method' => 255, + 'special_block' => 13, + 'vmethod' => 238, + 'nmethod' => 239, + 'access_specifier' => 241, + 'type_name' => 14, + 'ctor' => 242, + 'perc_any' => 257, + 'basic_type' => 42, + 'template' => 15, + 'member' => 243, + 'virtual' => 258, + 'looks_like_renamed_function' => 260, + '_vmethod' => 261, + 'dtor' => 246, + 'type' => 247, + 'raw' => 262, + 'method_decl' => 249, + 'member_decl' => 248 } }, + {#State 212 + DEFAULT => -52 + }, {#State 213 - DEFAULT => -29 + DEFAULT => -159 }, {#State 214 ACTIONS => { - 'ID' => 25 - }, - GOTOS => { - 'class_name' => 251 + 'ID' => 263 } }, {#State 215 - DEFAULT => -105 - }, - {#State 216 ACTIONS => { - 'OPCURLY' => 252, - 'OPSPECIAL' => 30 + 'EQUAL' => 264, + 'p_any' => 3 }, - DEFAULT => -161, + DEFAULT => -166, GOTOS => { - 'special_blocks' => 254, - 'special_block' => 253, - 'special_block_start' => 32 + 'perc_any' => 266, + '_argument_metadata' => 265 } }, + {#State 216 + DEFAULT => -79 + }, {#State 217 - ACTIONS => { - 'ID' => 25, - "class_static" => 218, - "package_static" => 233, - "short" => 17, - "unsigned" => 47, - "const" => 10, - 'p_name' => 19, - "long" => 21, - "static" => 237, - "int" => 37, - "char" => 24 - }, - GOTOS => { - 'type_name' => 13, - 'class_name' => 1, - 'basic_type' => 39, - 'nconsttype' => 27, - 'template' => 14, - 'looks_like_function' => 5, - 'static' => 217, - 'perc_name' => 255, - 'looks_like_renamed_function' => 241, - 'nmethod' => 256, - 'type' => 22 - } + DEFAULT => -85 }, {#State 218 - DEFAULT => -72 + DEFAULT => -133 }, {#State 219 ACTIONS => { - 'COLON' => 257 + 'CLCURLY' => 267 } }, {#State 220 ACTIONS => { - 'ID' => 231, - "virtual" => 232, - "short" => 17, - "unsigned" => 47, - "const" => 10, - 'p_name' => 19, - 'TILDE' => 227, - "long" => 21, - "int" => 37, - "char" => 24 + 'OPPAR' => 268 }, - GOTOS => { - 'type_name' => 13, - 'class_name' => 1, - 'ctor' => 260, - 'basic_type' => 39, - 'nconsttype' => 27, - 'template' => 14, - 'looks_like_function' => 58, - 'virtual' => 239, - 'perc_name' => 258, - '_vmethod' => 242, - 'dtor' => 261, - 'vmethod' => 259, - 'type' => 22 - } + DEFAULT => -171 }, {#State 221 - DEFAULT => -57 + DEFAULT => -36 }, {#State 222 - DEFAULT => -65 + DEFAULT => -167 }, {#State 223 - DEFAULT => -64 + ACTIONS => { + 'AMP' => 269, + 'PIPE' => 270 + }, + DEFAULT => -176 }, {#State 224 - ACTIONS => { - 'COLON' => 262 - } + DEFAULT => -170 }, {#State 225 - DEFAULT => -59 + DEFAULT => -169 }, {#State 226 - DEFAULT => -66 - }, - {#State 227 ACTIONS => { - 'ID' => 263 + 'INTEGER' => 271 } }, + {#State 227 + DEFAULT => -31 + }, {#State 228 ACTIONS => { - 'COLON' => 264 + 'INTEGER' => 272 } }, {#State 229 - DEFAULT => -67 - }, - {#State 230 ACTIONS => { - 'SEMICOLON' => 265 + 'ID' => 28 + }, + GOTOS => { + 'class_name' => 273 } }, + {#State 230 + DEFAULT => -118 + }, {#State 231 ACTIONS => { - 'DCOLON' => 70, - 'OPPAR' => 266 + 'OPCURLY' => 274, + 'OPSPECIAL' => 33 }, - DEFAULT => -132, + DEFAULT => -181, GOTOS => { - 'class_suffix' => 69 + 'special_blocks' => 276, + 'special_block' => 275, + 'special_block_start' => 35 } }, {#State 232 - DEFAULT => -70 + ACTIONS => { + 'ID' => 28, + "class_static" => 233, + "package_static" => 252, + "short" => 18, + "void" => 19, + "unsigned" => 50, + "const" => 11, + 'p_name' => 21, + "long" => 23, + "static" => 256, + "int" => 40, + "char" => 27 + }, + GOTOS => { + 'type_name' => 14, + 'class_name' => 1, + 'basic_type' => 42, + 'nconsttype' => 30, + 'template' => 15, + 'looks_like_function' => 6, + 'static' => 232, + 'perc_name' => 277, + 'looks_like_renamed_function' => 260, + 'nmethod' => 278, + 'type' => 24 + } }, {#State 233 - DEFAULT => -71 + DEFAULT => -83 }, {#State 234 - DEFAULT => -58 + ACTIONS => { + 'COLON' => 279 + } }, {#State 235 - DEFAULT => -54 + ACTIONS => { + 'ID' => 250, + "virtual" => 251, + "short" => 18, + "void" => 19, + "unsigned" => 50, + "const" => 11, + 'p_name' => 21, + 'TILDE' => 244, + "long" => 23, + "int" => 40, + "char" => 27 + }, + GOTOS => { + 'type_name' => 14, + 'class_name' => 1, + 'ctor' => 283, + 'basic_type' => 42, + 'nconsttype' => 30, + 'template' => 15, + 'looks_like_function' => 61, + 'virtual' => 258, + 'perc_name' => 280, + 'looks_like_member' => 281, + '_vmethod' => 261, + 'dtor' => 284, + 'type' => 247, + 'vmethod' => 282 + } }, {#State 236 - DEFAULT => -55 + DEFAULT => -72 }, {#State 237 - DEFAULT => -73 + DEFAULT => -60 }, {#State 238 + DEFAULT => -76 + }, + {#State 239 + DEFAULT => -75 + }, + {#State 240 ACTIONS => { - 'SEMICOLON' => 267 + 'COLON' => 285 } }, - {#State 239 + {#State 241 + DEFAULT => -62 + }, + {#State 242 + DEFAULT => -77 + }, + {#State 243 + DEFAULT => -63 + }, + {#State 244 + ACTIONS => { + 'ID' => 286 + } + }, + {#State 245 ACTIONS => { - 'ID' => 25, - "virtual" => 232, - "short" => 17, - "unsigned" => 47, - "const" => 10, - 'p_name' => 19, - 'TILDE' => 227, - "long" => 21, - "int" => 37, - "char" => 24 + 'COLON' => 287 + } + }, + {#State 246 + DEFAULT => -78 + }, + {#State 247 + ACTIONS => { + 'ID' => 288 + } + }, + {#State 248 + ACTIONS => { + 'SEMICOLON' => 289 + } + }, + {#State 249 + ACTIONS => { + 'SEMICOLON' => 290 + } + }, + {#State 250 + ACTIONS => { + 'DCOLON' => 74, + 'OPPAR' => 291 + }, + DEFAULT => -147, + GOTOS => { + 'class_suffix' => 73 + } + }, + {#State 251 + DEFAULT => -81 + }, + {#State 252 + DEFAULT => -82 + }, + {#State 253 + DEFAULT => -61 + }, + {#State 254 + DEFAULT => -57 + }, + {#State 255 + DEFAULT => -58 + }, + {#State 256 + DEFAULT => -84 + }, + {#State 257 + ACTIONS => { + 'SEMICOLON' => 292 + } + }, + {#State 258 + ACTIONS => { + 'ID' => 28, + "virtual" => 251, + "short" => 18, + "void" => 19, + "unsigned" => 50, + "const" => 11, + 'p_name' => 21, + 'TILDE' => 244, + "long" => 23, + "int" => 40, + "char" => 27 }, GOTOS => { - 'type_name' => 13, + 'type_name' => 14, 'class_name' => 1, - 'basic_type' => 39, - 'nconsttype' => 27, - 'template' => 14, - 'looks_like_function' => 268, - 'virtual' => 271, - 'perc_name' => 269, - 'type' => 22, - 'dtor' => 270 + 'basic_type' => 42, + 'nconsttype' => 30, + 'template' => 15, + 'looks_like_function' => 293, + 'virtual' => 296, + 'perc_name' => 294, + 'type' => 24, + 'dtor' => 295 } }, - {#State 240 - DEFAULT => -41 + {#State 259 + DEFAULT => -44 }, - {#State 241 - DEFAULT => -84, + {#State 260 + DEFAULT => -95, GOTOS => { - 'function_metadata' => 272 + 'function_metadata' => 297 } }, - {#State 242 - DEFAULT => -87 + {#State 261 + DEFAULT => -98 }, - {#State 243 - DEFAULT => -56 + {#State 262 + DEFAULT => -59 }, - {#State 244 + {#State 263 ACTIONS => { - 'CLCURLY' => 273 + 'CLCURLY' => 298 } }, - {#State 245 - DEFAULT => -145 + {#State 264 + ACTIONS => { + 'ID' => 28, + 'INTEGER' => 222, + 'QUOTED_STRING' => 224, + 'DASH' => 226, + 'FLOAT' => 225 + }, + GOTOS => { + 'class_name' => 220, + 'value' => 223, + 'expression' => 299 + } }, - {#State 246 + {#State 265 + DEFAULT => -161 + }, + {#State 266 + DEFAULT => -163 + }, + {#State 267 ACTIONS => { - 'OPCURLY' => 274 + 'OPCURLY' => 300 } }, - {#State 247 + {#State 268 ACTIONS => { - 'ID' => 25, - 'INTEGER' => 208, - 'QUOTED_STRING' => 210, - 'DASH' => 212, - 'FLOAT' => 211 - }, - DEFAULT => -155, - GOTOS => { - 'class_name' => 206, - 'value_list' => 275, - 'value' => 276 + 'ID' => 28, + 'INTEGER' => 222, + 'QUOTED_STRING' => 224, + 'FLOAT' => 225, + 'DASH' => 226 + }, + DEFAULT => -175, + GOTOS => { + 'class_name' => 220, + 'value_list' => 301, + 'value' => 302 } }, - {#State 248 + {#State 269 ACTIONS => { - 'ID' => 25, - 'INTEGER' => 208, - 'QUOTED_STRING' => 210, - 'DASH' => 212, - 'FLOAT' => 211 + 'ID' => 28, + 'INTEGER' => 222, + 'QUOTED_STRING' => 224, + 'DASH' => 226, + 'FLOAT' => 225 }, GOTOS => { - 'class_name' => 206, - 'value' => 277 + 'class_name' => 220, + 'value' => 303 } }, - {#State 249 + {#State 270 ACTIONS => { - 'ID' => 25, - 'INTEGER' => 208, - 'QUOTED_STRING' => 210, - 'DASH' => 212, - 'FLOAT' => 211 + 'ID' => 28, + 'INTEGER' => 222, + 'QUOTED_STRING' => 224, + 'DASH' => 226, + 'FLOAT' => 225 }, GOTOS => { - 'class_name' => 206, - 'value' => 278 + 'class_name' => 220, + 'value' => 304 } }, - {#State 250 - DEFAULT => -148 + {#State 271 + DEFAULT => -168 }, - {#State 251 - DEFAULT => -135 + {#State 272 + ACTIONS => { + 'CLCURLY' => 305 + } }, - {#State 252 + {#State 273 + DEFAULT => -150 + }, + {#State 274 ACTIONS => { - 'p_any' => 95 + 'p_any' => 99, + 'p_name' => 21 }, GOTOS => { - 'perc_any_arg' => 96, - 'perc_any_args' => 279 + 'perc_name' => 101, + 'perc_any_arg' => 100, + 'perc_any_args' => 306 } }, - {#State 253 - DEFAULT => -159 + {#State 275 + DEFAULT => -179 }, - {#State 254 + {#State 276 ACTIONS => { - 'OPSPECIAL' => 30, - 'SEMICOLON' => 281 + 'OPSPECIAL' => 33, + 'SEMICOLON' => 308 }, GOTOS => { - 'special_block' => 280, - 'special_block_start' => 32 + 'special_block' => 307, + 'special_block_start' => 35 } }, - {#State 255 + {#State 277 ACTIONS => { - 'ID' => 25, - "short" => 17, - "unsigned" => 47, - "const" => 10, - "long" => 21, - "int" => 37, - "char" => 24 + 'ID' => 28, + "short" => 18, + "void" => 19, + "const" => 11, + "unsigned" => 50, + "long" => 23, + "int" => 40, + "char" => 27 }, GOTOS => { - 'type_name' => 13, + 'type_name' => 14, 'class_name' => 1, - 'basic_type' => 39, - 'nconsttype' => 27, - 'template' => 14, - 'looks_like_function' => 58, - 'type' => 22 + 'basic_type' => 42, + 'nconsttype' => 30, + 'template' => 15, + 'looks_like_function' => 61, + 'type' => 24 } }, - {#State 256 - DEFAULT => -86 + {#State 278 + DEFAULT => -97 }, - {#State 257 - DEFAULT => -61 + {#State 279 + DEFAULT => -65 }, - {#State 258 + {#State 280 ACTIONS => { - 'ID' => 282, - 'TILDE' => 227, - 'p_name' => 19, - "virtual" => 232 + 'ID' => 309, + 'TILDE' => 244, + 'p_name' => 21, + "virtual" => 251 }, GOTOS => { - 'perc_name' => 258, - 'ctor' => 260, - '_vmethod' => 242, - 'dtor' => 261, - 'vmethod' => 259, - 'virtual' => 239 + 'perc_name' => 280, + 'ctor' => 283, + '_vmethod' => 261, + 'dtor' => 284, + 'vmethod' => 282, + 'virtual' => 258 } }, - {#State 259 - DEFAULT => -88 + {#State 281 + DEFAULT => -73 }, - {#State 260 - DEFAULT => -79 + {#State 282 + DEFAULT => -99 }, - {#State 261 - DEFAULT => -81 + {#State 283 + DEFAULT => -90 }, - {#State 262 - DEFAULT => -63 + {#State 284 + DEFAULT => -92 }, - {#State 263 + {#State 285 + DEFAULT => -67 + }, + {#State 286 ACTIONS => { - 'OPPAR' => 283 + 'OPPAR' => 310 } }, - {#State 264 - DEFAULT => -62 + {#State 287 + DEFAULT => -66 + }, + {#State 288 + ACTIONS => { + 'OPPAR' => 113 + }, + DEFAULT => -69, + GOTOS => { + 'member_metadata' => 311 + } + }, + {#State 289 + DEFAULT => -42 }, - {#State 265 - DEFAULT => -39 + {#State 290 + DEFAULT => -41 }, - {#State 266 + {#State 291 ACTIONS => { - 'ID' => 25, - "short" => 17, - "const" => 10, - "unsigned" => 47, - "long" => 21, - "int" => 37, - "char" => 24 + 'ID' => 28, + "short" => 18, + "void" => 160, + "unsigned" => 50, + "const" => 11, + "long" => 23, + "int" => 40, + "char" => 27 }, - DEFAULT => -143, + DEFAULT => -160, GOTOS => { - 'type_name' => 13, + 'type_name' => 14, 'class_name' => 1, - 'basic_type' => 39, - 'nconsttype' => 27, - 'template' => 14, - 'arg_list' => 284, - 'argument' => 152, - 'type' => 150 + 'basic_type' => 42, + 'nconsttype' => 30, + 'template' => 15, + 'nonvoid_arg_list' => 159, + 'arg_list' => 312, + 'argument' => 163, + 'type' => 161 } }, - {#State 267 - DEFAULT => -60 + {#State 292 + DEFAULT => -64 }, - {#State 268 + {#State 293 ACTIONS => { - 'EQUAL' => 285 + 'EQUAL' => 313 }, - DEFAULT => -84, + DEFAULT => -95, GOTOS => { - 'function_metadata' => 286 + 'function_metadata' => 314 } }, - {#State 269 + {#State 294 ACTIONS => { - 'TILDE' => 227, - 'p_name' => 19, - "virtual" => 232 + 'TILDE' => 244, + 'p_name' => 21, + "virtual" => 251 }, GOTOS => { - 'perc_name' => 269, - 'dtor' => 261, - 'virtual' => 271 + 'perc_name' => 294, + 'dtor' => 284, + 'virtual' => 296 } }, - {#State 270 - DEFAULT => -82 + {#State 295 + DEFAULT => -93 }, - {#State 271 + {#State 296 ACTIONS => { - 'TILDE' => 227, - 'p_name' => 19, - "virtual" => 232 + 'TILDE' => 244, + 'p_name' => 21, + "virtual" => 251 }, GOTOS => { - 'perc_name' => 269, - 'dtor' => 270, - 'virtual' => 271 + 'perc_name' => 294, + 'dtor' => 295, + 'virtual' => 296 } }, - {#State 272 + {#State 297 ACTIONS => { - 'p_code' => 123, - 'p_cleanup' => 119, 'p_any' => 3, - 'p_catch' => 127, - 'p_postcall' => 121 - }, - DEFAULT => -85, - GOTOS => { - 'perc_postcall' => 122, - 'perc_code' => 118, - 'perc_any' => 124, - 'perc_cleanup' => 125, - 'perc_catch' => 120, - '_function_metadata' => 126 + 'p_alias' => 128, + 'p_code' => 131, + 'p_cleanup' => 125, + 'p_postcall' => 127, + 'p_catch' => 135 + }, + DEFAULT => -96, + GOTOS => { + 'perc_postcall' => 130, + 'perc_code' => 124, + 'perc_any' => 132, + 'perc_cleanup' => 133, + 'perc_catch' => 126, + '_function_metadata' => 134, + 'perc_alias' => 129 } }, - {#State 273 - DEFAULT => -144 + {#State 298 + DEFAULT => -164 }, - {#State 274 + {#State 299 + DEFAULT => -165 + }, + {#State 300 ACTIONS => { - 'ID' => 287 + 'ID' => 315 } }, - {#State 275 + {#State 301 ACTIONS => { - 'CLPAR' => 288, - 'COMMA' => 289 + 'CLPAR' => 316, + 'COMMA' => 317 } }, - {#State 276 - DEFAULT => -153 + {#State 302 + DEFAULT => -173 }, - {#State 277 - DEFAULT => -157 + {#State 303 + DEFAULT => -177 }, - {#State 278 - DEFAULT => -158 + {#State 304 + DEFAULT => -178 }, - {#State 279 + {#State 305 + DEFAULT => -109 + }, + {#State 306 ACTIONS => { - 'p_any' => 95, - 'CLCURLY' => 290 + 'p_any' => 99, + 'p_name' => 21, + 'CLCURLY' => 318 }, GOTOS => { - 'perc_any_arg' => 133 + 'perc_name' => 101, + 'perc_any_arg' => 142 } }, - {#State 280 - DEFAULT => -160 + {#State 307 + DEFAULT => -180 }, - {#State 281 - DEFAULT => -16 + {#State 308 + DEFAULT => -18 }, - {#State 282 + {#State 309 ACTIONS => { - 'OPPAR' => 266 + 'OPPAR' => 291 } }, - {#State 283 + {#State 310 ACTIONS => { - 'CLPAR' => 291 + 'CLPAR' => 319 } }, - {#State 284 + {#State 311 ACTIONS => { - 'CLPAR' => 292, - 'COMMA' => 187 + 'p_any' => 3 + }, + DEFAULT => -74, + GOTOS => { + 'perc_any' => 321, + '_member_metadata' => 320 } }, - {#State 285 + {#State 312 ACTIONS => { - 'INTEGER' => 293 + 'CLPAR' => 322 } }, - {#State 286 + {#State 313 + ACTIONS => { + 'INTEGER' => 323 + } + }, + {#State 314 ACTIONS => { - 'p_code' => 123, - 'p_cleanup' => 119, 'p_any' => 3, - 'p_catch' => 127, - 'p_postcall' => 121 + 'p_alias' => 128, + 'p_code' => 131, + 'p_cleanup' => 125, + 'p_postcall' => 127, + 'p_catch' => 135 }, - DEFAULT => -89, + DEFAULT => -100, GOTOS => { - 'perc_postcall' => 122, - 'perc_code' => 118, - 'perc_any' => 124, - 'perc_cleanup' => 125, - 'perc_catch' => 120, - '_function_metadata' => 126 + 'perc_postcall' => 130, + 'perc_code' => 124, + 'perc_any' => 132, + 'perc_cleanup' => 133, + 'perc_catch' => 126, + '_function_metadata' => 134, + 'perc_alias' => 129 } }, - {#State 287 + {#State 315 ACTIONS => { - 'CLCURLY' => 294 + 'CLCURLY' => 324 } }, - {#State 288 - DEFAULT => -152 + {#State 316 + DEFAULT => -172 }, - {#State 289 + {#State 317 ACTIONS => { - 'ID' => 25, - 'INTEGER' => 208, - 'QUOTED_STRING' => 210, - 'DASH' => 212, - 'FLOAT' => 211 + 'ID' => 28, + 'INTEGER' => 222, + 'QUOTED_STRING' => 224, + 'DASH' => 226, + 'FLOAT' => 225 }, GOTOS => { - 'class_name' => 206, - 'value' => 295 + 'class_name' => 220, + 'value' => 325 } }, - {#State 290 + {#State 318 ACTIONS => { - 'SEMICOLON' => 296 + 'SEMICOLON' => 326 } }, - {#State 291 - DEFAULT => -84, + {#State 319 + DEFAULT => -95, GOTOS => { - 'function_metadata' => 297 + 'function_metadata' => 327 } }, - {#State 292 - DEFAULT => -84, + {#State 320 + DEFAULT => -68 + }, + {#State 321 + DEFAULT => -70 + }, + {#State 322 + DEFAULT => -95, GOTOS => { - 'function_metadata' => 298 + 'function_metadata' => 328 } }, - {#State 293 - DEFAULT => -84, + {#State 323 + DEFAULT => -95, GOTOS => { - 'function_metadata' => 299 + 'function_metadata' => 329 } }, - {#State 294 - DEFAULT => -22, + {#State 324 + DEFAULT => -24, GOTOS => { - 'mixed_blocks' => 300 + 'mixed_blocks' => 330 } }, - {#State 295 - DEFAULT => -154 + {#State 325 + DEFAULT => -174 }, - {#State 296 - DEFAULT => -17 + {#State 326 + DEFAULT => -19 }, - {#State 297 + {#State 327 ACTIONS => { - 'p_code' => 123, - 'p_cleanup' => 119, 'p_any' => 3, - 'p_catch' => 127, - 'p_postcall' => 121 - }, - DEFAULT => -80, - GOTOS => { - 'perc_postcall' => 122, - 'perc_code' => 118, - 'perc_any' => 124, - 'perc_cleanup' => 125, - 'perc_catch' => 120, - '_function_metadata' => 126 + 'p_alias' => 128, + 'p_code' => 131, + 'p_cleanup' => 125, + 'p_postcall' => 127, + 'p_catch' => 135 + }, + DEFAULT => -91, + GOTOS => { + 'perc_postcall' => 130, + 'perc_code' => 124, + 'perc_any' => 132, + 'perc_cleanup' => 133, + 'perc_catch' => 126, + '_function_metadata' => 134, + 'perc_alias' => 129 } }, - {#State 298 + {#State 328 ACTIONS => { - 'p_code' => 123, - 'p_cleanup' => 119, 'p_any' => 3, - 'p_catch' => 127, - 'p_postcall' => 121 + 'p_alias' => 128, + 'p_code' => 131, + 'p_cleanup' => 125, + 'p_postcall' => 127, + 'p_catch' => 135 }, - DEFAULT => -78, + DEFAULT => -89, GOTOS => { - 'perc_postcall' => 122, - 'perc_code' => 118, - 'perc_any' => 124, - 'perc_cleanup' => 125, - 'perc_catch' => 120, - '_function_metadata' => 126 + 'perc_postcall' => 130, + 'perc_code' => 124, + 'perc_any' => 132, + 'perc_cleanup' => 133, + 'perc_catch' => 126, + '_function_metadata' => 134, + 'perc_alias' => 129 } }, - {#State 299 + {#State 329 ACTIONS => { - 'p_code' => 123, - 'p_cleanup' => 119, 'p_any' => 3, - 'p_catch' => 127, - 'p_postcall' => 121 + 'p_alias' => 128, + 'p_code' => 131, + 'p_cleanup' => 125, + 'p_postcall' => 127, + 'p_catch' => 135 }, - DEFAULT => -90, + DEFAULT => -101, GOTOS => { - 'perc_postcall' => 122, - 'perc_code' => 118, - 'perc_any' => 124, - 'perc_cleanup' => 125, - 'perc_catch' => 120, - '_function_metadata' => 126 + 'perc_postcall' => 130, + 'perc_code' => 124, + 'perc_any' => 132, + 'perc_cleanup' => 133, + 'perc_catch' => 126, + '_function_metadata' => 134, + 'perc_alias' => 129 } }, - {#State 300 + {#State 330 ACTIONS => { - 'OPCURLY' => 135, - 'OPSPECIAL' => 30, - 'SEMICOLON' => 301 + 'OPCURLY' => 144, + 'OPSPECIAL' => 33, + 'SEMICOLON' => 331 }, GOTOS => { - 'simple_block' => 137, - 'special_block' => 136, - 'special_block_start' => 32 + 'simple_block' => 146, + 'special_block' => 145, + 'special_block_start' => 35 } }, - {#State 301 - DEFAULT => -19 + {#State 331 + DEFAULT => -21 } ], yyrules => @@ -2507,129 +2708,131 @@ '$start', 2, undef ], [#Rule 1 - 'top_list', 1, -sub -#line 21 "XSP.yp" -{ $_[1] ? [ $_[1] ] : [] } + 'top_list', 1, undef ], [#Rule 2 'top_list', 2, sub #line 22 "XSP.yp" -{ push @{$_[1]}, $_[2] if $_[2]; $_[1] } +{ push @{$_[1]}, @{$_[2]}; $_[1] } ], [#Rule 3 - 'top', 1, undef + 'top_list', 4, +sub +#line 24 "XSP.yp" +{ $_[3] } ], [#Rule 4 - 'top', 1, undef + 'top', 1, +sub +#line 27 "XSP.yp" +{ !$_[1] ? [] : + ref $_[1] eq 'ARRAY' ? $_[1] : + [ $_[1] ] } ], [#Rule 5 - 'top', 1, undef + '_top', 1, undef ], [#Rule 6 - 'top', 1, undef + '_top', 1, undef ], [#Rule 7 - 'top', 1, -sub -#line 26 "XSP.yp" -{ $_[1]->resolve_typemaps; $_[1]->resolve_exceptions; $_[1] } + '_top', 1, undef ], [#Rule 8 + '_top', 1, undef + ], + [#Rule 9 + '_top', 1, +sub +#line 32 "XSP.yp" +{ process_function( $_[0], $_[1] ) } + ], + [#Rule 10 'directive', 2, sub -#line 29 "XSP.yp" +#line 35 "XSP.yp" { ExtUtils::XSpp::Node::Module->new( module => $_[1] ) } ], - [#Rule 9 + [#Rule 11 'directive', 2, sub -#line 31 "XSP.yp" +#line 37 "XSP.yp" { ExtUtils::XSpp::Node::Package->new( perl_name => $_[1] ) } ], - [#Rule 10 + [#Rule 12 'directive', 2, sub -#line 33 "XSP.yp" +#line 39 "XSP.yp" { ExtUtils::XSpp::Node::File->new( file => $_[1] ) } ], - [#Rule 11 + [#Rule 13 'directive', 2, sub -#line 35 "XSP.yp" +#line 41 "XSP.yp" { $_[0]->YYData->{PARSER}->load_plugin( $_[1] ); undef } ], - [#Rule 12 + [#Rule 14 'directive', 2, sub -#line 37 "XSP.yp" +#line 43 "XSP.yp" { $_[0]->YYData->{PARSER}->include_file( $_[1] ); undef } ], - [#Rule 13 + [#Rule 15 'directive', 2, sub -#line 39 "XSP.yp" -{ add_top_level_directive( $_[0], @{$_[1]} ); undef } +#line 45 "XSP.yp" +{ add_top_level_directive( $_[0], %{$_[1][1]} ) } ], - [#Rule 14 + [#Rule 16 'directive', 1, sub -#line 40 "XSP.yp" +#line 46 "XSP.yp" { } ], - [#Rule 15 + [#Rule 17 'directive', 1, sub -#line 41 "XSP.yp" +#line 47 "XSP.yp" { } ], - [#Rule 16 + [#Rule 18 'typemap', 9, sub -#line 46 "XSP.yp" -{ my $package = "ExtUtils::XSpp::Typemap::" . $_[6]; - my $type = $_[3]; my $c = 0; +#line 52 "XSP.yp" +{ my $c = 0; my %args = map { "arg" . ++$c => $_ } map { join( '', @$_ ) } @{$_[8] || []}; - my $tm = $package->new( type => $type, %args ); - ExtUtils::XSpp::Typemap::add_typemap_for_type( $type, $tm ); + add_typemap( $_[6], $_[3], %args ); undef } ], - [#Rule 17 + [#Rule 19 'typemap', 11, sub -#line 56 "XSP.yp" -{ my $package = "ExtUtils::XSpp::Typemap::" . $_[6]; - my $type = $_[3]; - # this assumes that there will be at most one named +#line 60 "XSP.yp" +{ # this assumes that there will be at most one named # block for each directive inside the typemap for( my $i = 1; $i <= $#{$_[9]}; $i += 2 ) { $_[9][$i] = join "\n", @{$_[9][$i][0]} if ref( $_[9][$i] ) eq 'ARRAY' && ref( $_[9][$i][0] ) eq 'ARRAY'; } - my $tm = $package->new( type => $type, @{$_[9]} ); - ExtUtils::XSpp::Typemap::add_typemap_for_type( $type, $tm ); + add_typemap( $_[6], $_[3], @{$_[9]} ); undef } ], - [#Rule 18 + [#Rule 20 'typemap', 5, sub -#line 69 "XSP.yp" -{ my $type = $_[3]; # add simple and reference typemaps for this type - my $tm = ExtUtils::XSpp::Typemap::simple->new( type => $type ); - ExtUtils::XSpp::Typemap::add_typemap_for_type( $type, $tm ); - my $reftype = make_ref($type->clone); - $tm = ExtUtils::XSpp::Typemap::reference->new( type => $reftype ); - ExtUtils::XSpp::Typemap::add_typemap_for_type( $reftype, $tm ); +#line 70 "XSP.yp" +{ add_typemap( 'simple', $_[3] ); + add_typemap( 'reference', make_ref($_[3]->clone) ); undef } ], - [#Rule 19 + [#Rule 21 'exceptionmap', 12, sub -#line 81 "XSP.yp" +#line 78 "XSP.yp" { my $package = "ExtUtils::XSpp::Exception::" . $_[9]; my $type = make_type($_[6]); my $c = 0; my %args = map { "arg" . ++$c => $_ } @@ -2639,301 +2842,344 @@ ExtUtils::XSpp::Exception->add_exception( $e ); undef } ], - [#Rule 20 + [#Rule 22 'mixed_blocks', 2, sub -#line 91 "XSP.yp" +#line 88 "XSP.yp" { [ @{$_[1]}, $_[2] ] } ], - [#Rule 21 + [#Rule 23 'mixed_blocks', 2, sub -#line 93 "XSP.yp" +#line 90 "XSP.yp" { [ @{$_[1]}, [ $_[2] ] ] } ], - [#Rule 22 + [#Rule 24 'mixed_blocks', 0, sub -#line 94 "XSP.yp" +#line 91 "XSP.yp" { [] } ], - [#Rule 23 + [#Rule 25 'simple_block', 3, sub -#line 97 "XSP.yp" +#line 94 "XSP.yp" { $_[2] } ], - [#Rule 24 + [#Rule 26 'raw', 1, sub -#line 99 "XSP.yp" +#line 96 "XSP.yp" { add_data_raw( $_[0], [ $_[1] ] ) } ], - [#Rule 25 + [#Rule 27 'raw', 1, sub -#line 100 "XSP.yp" +#line 97 "XSP.yp" { add_data_comment( $_[0], $_[1] ) } ], - [#Rule 26 + [#Rule 28 'raw', 1, sub -#line 101 "XSP.yp" +#line 98 "XSP.yp" { ExtUtils::XSpp::Node::Preprocessor->new ( rows => [ $_[1][0] ], symbol => $_[1][1], ) } ], - [#Rule 27 + [#Rule 29 'raw', 1, sub -#line 105 "XSP.yp" +#line 102 "XSP.yp" { add_data_raw( $_[0], [ @{$_[1]} ] ) } ], - [#Rule 28 + [#Rule 30 'enum', 5, sub -#line 109 "XSP.yp" +#line 106 "XSP.yp" { ExtUtils::XSpp::Node::Enum->new ( elements => $_[3], condition => $_[0]->get_conditional, ) } ], - [#Rule 29 + [#Rule 31 'enum', 6, sub -#line 114 "XSP.yp" +#line 111 "XSP.yp" { ExtUtils::XSpp::Node::Enum->new ( name => $_[2], elements => $_[4], condition => $_[0]->get_conditional, ) } ], - [#Rule 30 + [#Rule 32 'enum_element_list', 0, sub -#line 122 "XSP.yp" +#line 119 "XSP.yp" { [] } ], - [#Rule 31 + [#Rule 33 'enum_element_list', 2, sub -#line 124 "XSP.yp" +#line 121 "XSP.yp" { push @{$_[1]}, $_[2] if $_[2]; $_[1] } ], - [#Rule 32 + [#Rule 34 'enum_element_list', 3, sub -#line 126 "XSP.yp" +#line 123 "XSP.yp" { push @{$_[1]}, $_[2] if $_[2]; $_[1] } ], - [#Rule 33 + [#Rule 35 'enum_element', 1, sub -#line 131 "XSP.yp" +#line 128 "XSP.yp" { ExtUtils::XSpp::Node::EnumValue->new ( name => $_[1], condition => $_[0]->get_conditional, ) } ], - [#Rule 34 + [#Rule 36 'enum_element', 3, sub -#line 136 "XSP.yp" +#line 133 "XSP.yp" { ExtUtils::XSpp::Node::EnumValue->new ( name => $_[1], value => $_[3], condition => $_[0]->get_conditional, ) } ], - [#Rule 35 + [#Rule 37 'enum_element', 1, undef ], - [#Rule 36 + [#Rule 38 'class', 2, undef ], - [#Rule 37 + [#Rule 39 'class', 2, undef ], - [#Rule 38 + [#Rule 40 'function', 2, undef ], - [#Rule 39 + [#Rule 41 'method', 2, undef ], - [#Rule 40 + [#Rule 42 + 'member', 2, undef + ], + [#Rule 43 'decorate_class', 2, sub -#line 149 "XSP.yp" +#line 147 "XSP.yp" { $_[2]->set_perl_name( $_[1] ); $_[2] } ], - [#Rule 41 + [#Rule 44 'class_decl', 7, sub -#line 152 "XSP.yp" +#line 150 "XSP.yp" { create_class( $_[0], $_[2], $_[3], $_[4], $_[6], $_[0]->get_conditional ) } ], - [#Rule 42 + [#Rule 45 'base_classes', 2, sub -#line 156 "XSP.yp" +#line 154 "XSP.yp" { [ $_[2] ] } ], - [#Rule 43 + [#Rule 46 'base_classes', 3, sub -#line 157 "XSP.yp" +#line 155 "XSP.yp" { push @{$_[1]}, $_[3] if $_[3]; $_[1] } ], - [#Rule 44 + [#Rule 47 'base_classes', 0, undef ], - [#Rule 45 + [#Rule 48 'base_class', 2, sub -#line 161 "XSP.yp" +#line 159 "XSP.yp" { $_[2] } ], - [#Rule 46 + [#Rule 49 'base_class', 2, sub -#line 162 "XSP.yp" +#line 160 "XSP.yp" { $_[2] } ], - [#Rule 47 + [#Rule 50 'base_class', 2, sub -#line 163 "XSP.yp" +#line 161 "XSP.yp" { $_[2] } ], - [#Rule 48 + [#Rule 51 'class_name_rename', 1, sub -#line 167 "XSP.yp" +#line 165 "XSP.yp" { create_class( $_[0], $_[1], [], [] ) } ], - [#Rule 49 + [#Rule 52 'class_name_rename', 2, sub -#line 168 "XSP.yp" +#line 166 "XSP.yp" { my $klass = create_class( $_[0], $_[2], [], [] ); $klass->set_perl_name( $_[1] ); $klass } ], - [#Rule 50 + [#Rule 53 'class_metadata', 2, sub -#line 174 "XSP.yp" +#line 172 "XSP.yp" { [ @{$_[1]}, @{$_[2]} ] } ], - [#Rule 51 + [#Rule 54 'class_metadata', 2, sub -#line 175 "XSP.yp" +#line 173 "XSP.yp" { [ @{$_[1]}, @{$_[2]} ] } ], - [#Rule 52 + [#Rule 55 'class_metadata', 0, sub -#line 176 "XSP.yp" +#line 174 "XSP.yp" { [] } ], - [#Rule 53 + [#Rule 56 'class_body_list', 0, sub -#line 180 "XSP.yp" +#line 178 "XSP.yp" { [] } ], - [#Rule 54 + [#Rule 57 'class_body_list', 2, sub -#line 182 "XSP.yp" +#line 180 "XSP.yp" { push @{$_[1]}, $_[2] if $_[2]; $_[1] } ], - [#Rule 55 + [#Rule 58 'class_body_element', 1, undef ], - [#Rule 56 + [#Rule 59 'class_body_element', 1, undef ], - [#Rule 57 + [#Rule 60 'class_body_element', 1, undef ], - [#Rule 58 + [#Rule 61 'class_body_element', 1, undef ], - [#Rule 59 + [#Rule 62 'class_body_element', 1, undef ], - [#Rule 60 + [#Rule 63 + 'class_body_element', 1, undef + ], + [#Rule 64 'class_body_element', 2, sub -#line 188 "XSP.yp" -{ ExtUtils::XSpp::Node::PercAny->new( @{$_[1]} ) } +#line 186 "XSP.yp" +{ ExtUtils::XSpp::Node::PercAny->new( %{$_[1][1]} ) } ], - [#Rule 61 + [#Rule 65 + 'access_specifier', 2, +sub +#line 190 "XSP.yp" +{ ExtUtils::XSpp::Node::Access->new( access => $_[1] ) } + ], + [#Rule 66 + 'access_specifier', 2, +sub +#line 191 "XSP.yp" +{ ExtUtils::XSpp::Node::Access->new( access => $_[1] ) } + ], + [#Rule 67 'access_specifier', 2, sub #line 192 "XSP.yp" { ExtUtils::XSpp::Node::Access->new( access => $_[1] ) } ], - [#Rule 62 - 'access_specifier', 2, + [#Rule 68 + 'member_metadata', 2, +sub +#line 195 "XSP.yp" +{ [ @{$_[1]}, @{$_[2]} ] } + ], + [#Rule 69 + 'member_metadata', 0, +sub +#line 196 "XSP.yp" +{ [] } + ], + [#Rule 70 + '_member_metadata', 1, undef + ], + [#Rule 71 + 'member_decl', 0, undef + ], + [#Rule 72 + 'member_decl', 1, undef + ], + [#Rule 73 + 'member_decl', 2, sub -#line 193 "XSP.yp" -{ ExtUtils::XSpp::Node::Access->new( access => $_[1] ) } +#line 204 "XSP.yp" +{ $_[2]->set_perl_name( $_[1] ); $_[2] } ], - [#Rule 63 - 'access_specifier', 2, + [#Rule 74 + 'looks_like_member', 3, sub -#line 194 "XSP.yp" -{ ExtUtils::XSpp::Node::Access->new( access => $_[1] ) } +#line 208 "XSP.yp" +{ create_member( $_[0], + name => $_[2], + type => $_[1], + condition => $_[0]->get_conditional, + @{$_[3]} ) } ], - [#Rule 64 + [#Rule 75 'method_decl', 1, undef ], - [#Rule 65 + [#Rule 76 'method_decl', 1, undef ], - [#Rule 66 + [#Rule 77 'method_decl', 1, undef ], - [#Rule 67 + [#Rule 78 'method_decl', 1, undef ], - [#Rule 68 + [#Rule 79 'const', 1, sub -#line 199 "XSP.yp" +#line 216 "XSP.yp" { 1 } ], - [#Rule 69 + [#Rule 80 'const', 0, sub -#line 200 "XSP.yp" +#line 217 "XSP.yp" { 0 } ], - [#Rule 70 + [#Rule 81 'virtual', 1, undef ], - [#Rule 71 + [#Rule 82 'static', 1, undef ], - [#Rule 72 + [#Rule 83 'static', 1, undef ], - [#Rule 73 + [#Rule 84 'static', 1, sub -#line 206 "XSP.yp" +#line 223 "XSP.yp" { 'package_static' } ], - [#Rule 74 + [#Rule 85 'looks_like_function', 6, sub -#line 211 "XSP.yp" +#line 228 "XSP.yp" { return { ret_type => $_[1], name => $_[2], @@ -2942,19 +3188,19 @@ }; } ], - [#Rule 75 + [#Rule 86 'looks_like_renamed_function', 1, undef ], - [#Rule 76 + [#Rule 87 'looks_like_renamed_function', 2, sub -#line 222 "XSP.yp" +#line 239 "XSP.yp" { $_[2]->{perl_name} = $_[1]; $_[2] } ], - [#Rule 77 + [#Rule 88 'function_decl', 2, sub -#line 225 "XSP.yp" +#line 242 "XSP.yp" { add_data_function( $_[0], name => $_[1]->{name}, perl_name => $_[1]->{perl_name}, @@ -2963,58 +3209,58 @@ condition => $_[0]->get_conditional, @{$_[2]} ) } ], - [#Rule 78 + [#Rule 89 'ctor', 5, sub -#line 234 "XSP.yp" +#line 251 "XSP.yp" { add_data_ctor( $_[0], name => $_[1], arguments => $_[3], condition => $_[0]->get_conditional, @{ $_[5] } ) } ], - [#Rule 79 + [#Rule 90 'ctor', 2, sub -#line 238 "XSP.yp" +#line 255 "XSP.yp" { $_[2]->set_perl_name( $_[1] ); $_[2] } ], - [#Rule 80 + [#Rule 91 'dtor', 5, sub -#line 241 "XSP.yp" +#line 258 "XSP.yp" { add_data_dtor( $_[0], name => $_[2], condition => $_[0]->get_conditional, @{ $_[5] }, ) } ], - [#Rule 81 + [#Rule 92 'dtor', 2, sub -#line 245 "XSP.yp" +#line 262 "XSP.yp" { $_[2]->set_perl_name( $_[1] ); $_[2] } ], - [#Rule 82 + [#Rule 93 'dtor', 2, sub -#line 246 "XSP.yp" +#line 263 "XSP.yp" { $_[2]->set_virtual( 1 ); $_[2] } ], - [#Rule 83 + [#Rule 94 'function_metadata', 2, sub -#line 248 "XSP.yp" +#line 265 "XSP.yp" { [ @{$_[1]}, @{$_[2]} ] } ], - [#Rule 84 + [#Rule 95 'function_metadata', 0, sub -#line 249 "XSP.yp" +#line 266 "XSP.yp" { [] } ], - [#Rule 85 + [#Rule 96 'nmethod', 2, sub -#line 254 "XSP.yp" +#line 271 "XSP.yp" { my $m = add_data_method ( $_[0], name => $_[1]->{name}, @@ -3028,25 +3274,25 @@ $m } ], - [#Rule 86 + [#Rule 97 'nmethod', 2, sub -#line 267 "XSP.yp" +#line 284 "XSP.yp" { $_[2]->set_static( $_[1] ); $_[2] } ], - [#Rule 87 + [#Rule 98 'vmethod', 1, undef ], - [#Rule 88 + [#Rule 99 'vmethod', 2, sub -#line 272 "XSP.yp" +#line 289 "XSP.yp" { $_[2]->set_perl_name( $_[1] ); $_[2] } ], - [#Rule 89 + [#Rule 100 '_vmethod', 3, sub -#line 277 "XSP.yp" +#line 294 "XSP.yp" { my $m = add_data_method ( $_[0], name => $_[2]->{name}, @@ -3061,10 +3307,10 @@ $m } ], - [#Rule 90 + [#Rule 101 '_vmethod', 5, sub -#line 291 "XSP.yp" +#line 308 "XSP.yp" { my $m = add_data_method ( $_[0], name => $_[2]->{name}, @@ -3080,394 +3326,436 @@ $m } ], - [#Rule 91 + [#Rule 102 '_function_metadata', 1, undef ], - [#Rule 92 + [#Rule 103 '_function_metadata', 1, undef ], - [#Rule 93 + [#Rule 104 '_function_metadata', 1, undef ], - [#Rule 94 + [#Rule 105 '_function_metadata', 1, undef ], - [#Rule 95 + [#Rule 106 '_function_metadata', 1, undef ], - [#Rule 96 + [#Rule 107 + '_function_metadata', 1, undef + ], + [#Rule 108 'perc_name', 4, sub -#line 314 "XSP.yp" +#line 332 "XSP.yp" { $_[3] } ], - [#Rule 97 + [#Rule 109 + 'perc_alias', 6, +sub +#line 333 "XSP.yp" +{ [ alias => [$_[3], $_[5]] ] } + ], + [#Rule 110 'perc_package', 4, sub -#line 315 "XSP.yp" +#line 334 "XSP.yp" { $_[3] } ], - [#Rule 98 + [#Rule 111 'perc_module', 4, sub -#line 316 "XSP.yp" +#line 335 "XSP.yp" { $_[3] } ], - [#Rule 99 + [#Rule 112 'perc_file', 4, sub -#line 317 "XSP.yp" +#line 336 "XSP.yp" { $_[3] } ], - [#Rule 100 + [#Rule 113 'perc_loadplugin', 4, sub -#line 318 "XSP.yp" +#line 337 "XSP.yp" { $_[3] } ], - [#Rule 101 + [#Rule 114 'perc_include', 4, sub -#line 319 "XSP.yp" +#line 338 "XSP.yp" { $_[3] } ], - [#Rule 102 + [#Rule 115 'perc_code', 2, sub -#line 320 "XSP.yp" +#line 339 "XSP.yp" { [ code => $_[2] ] } ], - [#Rule 103 + [#Rule 116 'perc_cleanup', 2, sub -#line 321 "XSP.yp" +#line 340 "XSP.yp" { [ cleanup => $_[2] ] } ], - [#Rule 104 + [#Rule 117 'perc_postcall', 2, sub -#line 322 "XSP.yp" +#line 341 "XSP.yp" { [ postcall => $_[2] ] } ], - [#Rule 105 + [#Rule 118 'perc_catch', 4, sub -#line 323 "XSP.yp" +#line 342 "XSP.yp" { [ map {(catch => $_)} @{$_[3]} ] } ], - [#Rule 106 + [#Rule 119 'perc_any', 4, sub -#line 328 "XSP.yp" -{ [ any => $_[1], any_named_arguments => $_[3] ] } +#line 347 "XSP.yp" +{ [ tag => { any => $_[1], named => $_[3] } ] } ], - [#Rule 107 + [#Rule 120 'perc_any', 5, sub -#line 330 "XSP.yp" -{ [ any => $_[1], any_positional_arguments => [ $_[3], @{$_[5]} ] ] } +#line 349 "XSP.yp" +{ [ tag => { any => $_[1], positional => [ $_[3], @{$_[5]} ] } ] } ], - [#Rule 108 + [#Rule 121 'perc_any', 3, sub -#line 332 "XSP.yp" -{ [ any => $_[1], any_positional_arguments => [ $_[2], @{$_[3]} ] ] } +#line 351 "XSP.yp" +{ [ tag => { any => $_[1], positional => [ $_[2], @{$_[3]} ] } ] } ], - [#Rule 109 + [#Rule 122 'perc_any', 1, sub -#line 334 "XSP.yp" -{ [ any => $_[1] ] } +#line 353 "XSP.yp" +{ [ tag => { any => $_[1] } ] } ], - [#Rule 110 + [#Rule 123 'perc_any_args', 1, sub -#line 338 "XSP.yp" +#line 357 "XSP.yp" { $_[1] } ], - [#Rule 111 + [#Rule 124 'perc_any_args', 2, sub -#line 339 "XSP.yp" +#line 358 "XSP.yp" { [ @{$_[1]}, @{$_[2]} ] } ], - [#Rule 112 + [#Rule 125 'perc_any_arg', 3, sub -#line 343 "XSP.yp" +#line 362 "XSP.yp" { [ $_[1] => $_[2] ] } ], - [#Rule 113 + [#Rule 126 + 'perc_any_arg', 2, +sub +#line 363 "XSP.yp" +{ [ name => $_[1] ] } + ], + [#Rule 127 'type', 2, sub -#line 347 "XSP.yp" +#line 367 "XSP.yp" { make_const( $_[2] ) } ], - [#Rule 114 + [#Rule 128 'type', 1, undef ], - [#Rule 115 + [#Rule 129 'nconsttype', 2, sub -#line 352 "XSP.yp" +#line 372 "XSP.yp" { make_ptr( $_[1] ) } ], - [#Rule 116 + [#Rule 130 'nconsttype', 2, sub -#line 353 "XSP.yp" +#line 373 "XSP.yp" { make_ref( $_[1] ) } ], - [#Rule 117 + [#Rule 131 'nconsttype', 1, sub -#line 354 "XSP.yp" +#line 374 "XSP.yp" { make_type( $_[1] ) } ], - [#Rule 118 + [#Rule 132 'nconsttype', 1, undef ], - [#Rule 119 + [#Rule 133 'type_name', 1, undef ], - [#Rule 120 + [#Rule 134 'type_name', 1, undef ], - [#Rule 121 + [#Rule 135 + 'type_name', 1, undef + ], + [#Rule 136 'type_name', 1, sub -#line 361 "XSP.yp" +#line 382 "XSP.yp" { 'unsigned int' } ], - [#Rule 122 + [#Rule 137 'type_name', 2, sub -#line 362 "XSP.yp" +#line 383 "XSP.yp" { 'unsigned' . ' ' . $_[2] } ], - [#Rule 123 + [#Rule 138 'basic_type', 1, undef ], - [#Rule 124 + [#Rule 139 'basic_type', 1, undef ], - [#Rule 125 + [#Rule 140 'basic_type', 1, undef ], - [#Rule 126 + [#Rule 141 'basic_type', 1, undef ], - [#Rule 127 + [#Rule 142 'basic_type', 2, undef ], - [#Rule 128 + [#Rule 143 'basic_type', 2, undef ], - [#Rule 129 + [#Rule 144 'template', 4, sub -#line 368 "XSP.yp" +#line 389 "XSP.yp" { make_template( $_[1], $_[3] ) } ], - [#Rule 130 + [#Rule 145 'type_list', 1, sub -#line 372 "XSP.yp" +#line 393 "XSP.yp" { [ $_[1] ] } ], - [#Rule 131 + [#Rule 146 'type_list', 3, sub -#line 373 "XSP.yp" +#line 394 "XSP.yp" { push @{$_[1]}, $_[3]; $_[1] } ], - [#Rule 132 + [#Rule 147 'class_name', 1, undef ], - [#Rule 133 + [#Rule 148 'class_name', 2, sub -#line 377 "XSP.yp" +#line 398 "XSP.yp" { $_[1] . '::' . $_[2] } ], - [#Rule 134 + [#Rule 149 'class_name_list', 1, sub -#line 380 "XSP.yp" +#line 401 "XSP.yp" { [ $_[1] ] } ], - [#Rule 135 + [#Rule 150 'class_name_list', 3, sub -#line 381 "XSP.yp" +#line 402 "XSP.yp" { push @{$_[1]}, $_[3]; $_[1] } ], - [#Rule 136 + [#Rule 151 'class_suffix', 2, sub -#line 384 "XSP.yp" +#line 405 "XSP.yp" { $_[2] } ], - [#Rule 137 + [#Rule 152 'class_suffix', 3, sub -#line 385 "XSP.yp" +#line 406 "XSP.yp" { $_[1] . '::' . $_[3] } ], - [#Rule 138 + [#Rule 153 'file_name', 1, sub -#line 387 "XSP.yp" +#line 408 "XSP.yp" { '-' } ], - [#Rule 139 + [#Rule 154 'file_name', 3, sub -#line 388 "XSP.yp" +#line 409 "XSP.yp" { $_[1] . '.' . $_[3] } ], - [#Rule 140 + [#Rule 155 'file_name', 3, sub -#line 389 "XSP.yp" +#line 410 "XSP.yp" { $_[1] . '/' . $_[3] } ], - [#Rule 141 + [#Rule 156 + 'arg_list', 1, undef + ], + [#Rule 157 'arg_list', 1, sub -#line 391 "XSP.yp" +#line 413 "XSP.yp" +{ undef } + ], + [#Rule 158 + 'nonvoid_arg_list', 1, +sub +#line 416 "XSP.yp" { [ $_[1] ] } ], - [#Rule 142 - 'arg_list', 3, + [#Rule 159 + 'nonvoid_arg_list', 3, sub -#line 392 "XSP.yp" +#line 417 "XSP.yp" { push @{$_[1]}, $_[3]; $_[1] } ], - [#Rule 143 - 'arg_list', 0, undef + [#Rule 160 + 'nonvoid_arg_list', 0, undef ], - [#Rule 144 + [#Rule 161 + 'argument_metadata', 2, +sub +#line 420 "XSP.yp" +{ [ @{$_[1]}, @{$_[2]} ] } + ], + [#Rule 162 + 'argument_metadata', 0, +sub +#line 421 "XSP.yp" +{ [] } + ], + [#Rule 163 + '_argument_metadata', 1, undef + ], + [#Rule 164 'argument', 5, sub -#line 396 "XSP.yp" +#line 427 "XSP.yp" { make_argument( @_[0, 1], "length($_[4])" ) } ], - [#Rule 145 - 'argument', 4, + [#Rule 165 + 'argument', 5, sub -#line 398 "XSP.yp" -{ make_argument( @_[0, 1, 2, 4] ) } +#line 429 "XSP.yp" +{ make_argument( @_[0, 1, 2, 5], @{$_[3]} ) } ], - [#Rule 146 - 'argument', 2, + [#Rule 166 + 'argument', 3, sub -#line 399 "XSP.yp" -{ make_argument( @_ ) } +#line 431 "XSP.yp" +{ make_argument( @_[0, 1, 2], undef, @{$_[3]} ) } ], - [#Rule 147 + [#Rule 167 'value', 1, undef ], - [#Rule 148 + [#Rule 168 'value', 2, sub -#line 402 "XSP.yp" +#line 434 "XSP.yp" { '-' . $_[2] } ], - [#Rule 149 + [#Rule 169 'value', 1, undef ], - [#Rule 150 + [#Rule 170 'value', 1, undef ], - [#Rule 151 + [#Rule 171 'value', 1, undef ], - [#Rule 152 + [#Rule 172 'value', 4, sub -#line 406 "XSP.yp" +#line 438 "XSP.yp" { "$_[1]($_[3])" } ], - [#Rule 153 + [#Rule 173 'value_list', 1, undef ], - [#Rule 154 + [#Rule 174 'value_list', 3, sub -#line 411 "XSP.yp" +#line 443 "XSP.yp" { "$_[1], $_[2]" } ], - [#Rule 155 + [#Rule 175 'value_list', 0, sub -#line 412 "XSP.yp" +#line 444 "XSP.yp" { "" } ], - [#Rule 156 + [#Rule 176 'expression', 1, undef ], - [#Rule 157 + [#Rule 177 'expression', 3, sub -#line 418 "XSP.yp" +#line 450 "XSP.yp" { "$_[1] & $_[3]" } ], - [#Rule 158 + [#Rule 178 'expression', 3, sub -#line 420 "XSP.yp" +#line 452 "XSP.yp" { "$_[1] | $_[3]" } ], - [#Rule 159 + [#Rule 179 'special_blocks', 1, sub -#line 424 "XSP.yp" +#line 456 "XSP.yp" { [ $_[1] ] } ], - [#Rule 160 + [#Rule 180 'special_blocks', 2, sub -#line 426 "XSP.yp" +#line 458 "XSP.yp" { [ @{$_[1]}, $_[2] ] } ], - [#Rule 161 + [#Rule 181 'special_blocks', 0, undef ], - [#Rule 162 + [#Rule 182 'special_block', 3, sub -#line 430 "XSP.yp" +#line 462 "XSP.yp" { $_[2] } ], - [#Rule 163 + [#Rule 183 'special_block', 2, sub -#line 432 "XSP.yp" +#line 464 "XSP.yp" { [] } ], - [#Rule 164 + [#Rule 184 'special_block_start', 1, sub -#line 435 "XSP.yp" +#line 467 "XSP.yp" { push_lex_mode( $_[0], 'special' ) } ], - [#Rule 165 + [#Rule 185 'special_block_end', 1, sub -#line 437 "XSP.yp" +#line 469 "XSP.yp" { pop_lex_mode( $_[0], 'special' ) } ], - [#Rule 166 + [#Rule 186 'lines', 1, sub -#line 439 "XSP.yp" +#line 471 "XSP.yp" { [ $_[1] ] } ], - [#Rule 167 + [#Rule 187 'lines', 2, sub -#line 440 "XSP.yp" +#line 472 "XSP.yp" { push @{$_[1]}, $_[2]; $_[1] } ] ], @@ -3475,7 +3763,7 @@ bless($self,$class); } -#line 442 "XSP.yp" +#line 474 "XSP.yp" use ExtUtils::XSpp::Lexer; diff -Nru libextutils-xspp-perl-0.1602/lib/ExtUtils/XSpp/Lexer.pm libextutils-xspp-perl-0.1800/lib/ExtUtils/XSpp/Lexer.pm --- libextutils-xspp-perl-0.1602/lib/ExtUtils/XSpp/Lexer.pm 2011-06-03 20:12:10.000000000 +0000 +++ libextutils-xspp-perl-0.1800/lib/ExtUtils/XSpp/Lexer.pm 2013-09-18 08:17:53.000000000 +0000 @@ -16,6 +16,7 @@ use ExtUtils::XSpp::Node::Destructor; use ExtUtils::XSpp::Node::File; use ExtUtils::XSpp::Node::Function; +use ExtUtils::XSpp::Node::Member; use ExtUtils::XSpp::Node::Method; use ExtUtils::XSpp::Node::Module; use ExtUtils::XSpp::Node::Package; @@ -67,6 +68,8 @@ '%length' => 'p_length', '%loadplugin' => 'p_loadplugin', '%include' => 'p_include', + '%alias' => 'p_alias', + '%_type' => 'p__type', ); my %keywords = ( const => 1, @@ -76,6 +79,7 @@ long => 1, int => 1, char => 1, + void => 1, package_static => 1, class_static => 1, static => 1, @@ -198,7 +202,7 @@ return ( $tokens{$1}, $1 ) if exists $tokens{$1}; return ( 'p_any', substr $1, 1 ); } elsif( $$buf =~ s/^( \%} - | \%{ | {\% + | \%\{ | \{\% | [{}();%~*&,=\/\.\-<>|] | :: | : )//x ) { @@ -254,6 +258,13 @@ ) } +sub add_typemap { + my( $name, $type, @args ) = @_; + my $tm = ExtUtils::XSpp::Typemap::create( $name, type => $type, @args ); + + ExtUtils::XSpp::Typemap::add_typemap_for_type( $type, $tm ); +} + sub add_data_raw { my $p = shift; my $rows = shift; @@ -273,18 +284,26 @@ $parser->YYData->{PARSER}->handle_toplevel_tag_plugins ( $args{any}, - any_named_arguments => $args{any_named_arguments}, - any_positional_arguments => $args{any_positional_arguments}, + named => $args{named}, + positional => $args{positional}, + any_named_arguments => $args{named}, + any_positional_arguments => $args{positional}, condition => $parser->get_conditional, ); } sub make_argument { - my( $p, $type, $name, $default ) = @_; + my( $p, $type, $name, $default, @args ) = @_; + my %args = @args; + _merge_keys( 'tag', \%args, \@args ); - ExtUtils::XSpp::Node::Argument->new( type => $type, - name => $name, - default => $default ); + my $arg = ExtUtils::XSpp::Node::Argument->new + ( type => $type, + name => $name, + default => $default, + tags => $args{tag} ); + + return $arg; } sub create_class { @@ -304,16 +323,48 @@ my @any = grep $_->isa( 'ExtUtils::XSpp::Node::PercAny' ), @$methods; my @rest = grep !$_->isa( 'ExtUtils::XSpp::Node::PercAny' ), @$methods; + # finish creating the class + $class->add_methods( @rest ); + + foreach my $meth ( grep $_->isa( 'ExtUtils::XSpp::Node::Method' ), @rest ) { + call_argument_tags( $parser, $meth ); + + my $nodes = $parser->YYData->{PARSER}->handle_method_tags_plugins( $meth, $meth->tags ); + + $class->add_methods( @$nodes ); + } + foreach my $any ( @any ) { - $parser->YYData->{PARSER}->handle_class_tag_plugins + if( $any->{NAME} eq 'accessors' ) { + # TODO use plugin infrastructure, add decent validation + my %args = @{$any->{NAMED_ARGUMENTS}}; + if( $args{get_style} ) { + if( @{$args{get_style}} ) { + $class->set_getter_style( $args{get_style}[0][0] ); + } else { + die "Invalid accessor style declaration"; + } + } + if( $args{set_style} ) { + if( @{$args{set_style}} ) { + $class->set_setter_style( $args{set_style}[0][0] ); + } else { + die "Invalid accessor style declaration"; + } + } + next; + } + + my $nodes = $parser->YYData->{PARSER}->handle_class_tag_plugins ( $class, $any->{NAME}, + named => $any->{NAMED_ARGUMENTS}, + positional => $any->{POSITIONAL_ARGUMENTS}, any_named_arguments => $any->{NAMED_ARGUMENTS}, any_positional_arguments => $any->{POSITIONAL_ARGUMENTS}, ); - } - # finish creating the class - $class->add_methods( @rest ); + $class->add_methods( @$nodes ); + } return $class; } @@ -330,16 +381,35 @@ push @occurrances, $paramlist->[$i+1]; } } - @occurrances = map {ref($_) eq 'ARRAY' ? @$_ : $_} @occurrances; + @occurrances = map {ref($_) eq 'ARRAY' ? @$_ : $_} @occurrances; $argshash->{$key} = \@occurrances; } + +sub create_member { + my( $parser, @args ) = @_; + my %args = @args; + _merge_keys( 'tag', \%args, \@args ); + + return ExtUtils::XSpp::Node::Member->new + ( cpp_name => $args{name}, + perl_name => $args{perl_name}, + class => $args{class}, + type => $args{type}, + condition => $args{condition}, + tags => $args{tag}, + ); +} + sub add_data_function { my( $parser, @args ) = @_; my %args = @args; _merge_keys( 'catch', \%args, \@args ); + _merge_keys( 'alias', \%args, \@args ); + _merge_keys( 'tag', \%args, \@args ); + $args{alias} = +{@{$args{alias}}} if exists $args{alias}; - my $f = ExtUtils::XSpp::Node::Function->new + return ExtUtils::XSpp::Node::Function->new ( cpp_name => $args{name}, perl_name => $args{perl_name}, class => $args{class}, @@ -350,23 +420,18 @@ postcall => $args{postcall}, catch => $args{catch}, condition => $args{condition}, + alias => $args{alias}, + tags => $args{tag}, ); - - if( $args{any} ) { - $parser->YYData->{PARSER}->handle_function_tag_plugins - ( $f, $args{any}, - any_named_arguments => $args{any_named_arguments}, - any_positional_arguments => $args{any_positional_arguments}, - ); - } - - return $f; } sub add_data_method { my( $parser, @args ) = @_; my %args = @args; _merge_keys( 'catch', \%args, \@args ); + _merge_keys( 'alias', \%args, \@args ); + _merge_keys( 'tag', \%args, \@args ); + $args{alias} = +{@{$args{alias}}} if exists $args{alias}; my $m = ExtUtils::XSpp::Node::Method->new ( cpp_name => $args{name}, @@ -379,16 +444,10 @@ perl_name => $args{perl_name}, catch => $args{catch}, condition => $args{condition}, + alias => $args{alias}, + tags => $args{tag}, ); - if( $args{any} ) { - $parser->YYData->{PARSER}->handle_method_tag_plugins - ( $m, $args{any}, - any_named_arguments => $args{any_named_arguments}, - any_positional_arguments => $args{any_positional_arguments}, - ); - } - return $m; } @@ -396,6 +455,7 @@ my( $parser, @args ) = @_; my %args = @args; _merge_keys( 'catch', \%args, \@args ); + _merge_keys( 'tag', \%args, \@args ); my $m = ExtUtils::XSpp::Node::Constructor->new ( cpp_name => $args{name}, @@ -405,16 +465,9 @@ postcall => $args{postcall}, catch => $args{catch}, condition => $args{condition}, + tags => $args{tag}, ); - if( $args{any} ) { - $parser->YYData->{PARSER}->handle_method_tag_plugins - ( $m, $args{any}, - any_named_arguments => $args{any_named_arguments}, - any_positional_arguments => $args{any_positional_arguments}, - ); - } - return $m; } @@ -422,6 +475,7 @@ my( $parser, @args ) = @_; my %args = @args; _merge_keys( 'catch', \%args, \@args ); + _merge_keys( 'tag', \%args, \@args ); my $m = ExtUtils::XSpp::Node::Destructor->new ( cpp_name => $args{name}, @@ -430,31 +484,30 @@ postcall => $args{postcall}, catch => $args{catch}, condition => $args{condition}, + tags => $args{tag}, ); - if( $args{any} ) { - $parser->YYData->{PARSER}->handle_method_tag_plugins - ( $m, $args{any}, - any_named_arguments => $args{any_named_arguments}, - any_positional_arguments => $args{any_positional_arguments}, - ); - } - return $m; } -sub is_directive { - my( $p, $d, $name ) = @_; +sub process_function { + my( $parser, $function ) = @_; + + $function->resolve_typemaps; + $function->resolve_exceptions; + call_argument_tags( $parser, $function ); + + my $nodes = $parser->YYData->{PARSER}->handle_function_tags_plugins( $function, $function->tags ); - return $d->[0] eq $name; + return [ $function, @$nodes ]; } -#sub assert_directive { -# my( $p, $d, $name ) = @_; -# -# if( $d->[0] ne $name ) -# { $p->YYError } -# 1; -#} +sub call_argument_tags { + my( $parser, $function ) = @_; + + foreach my $arg ( @{$function->arguments} ) { + $parser->YYData->{PARSER}->handle_argument_tags_plugins( $arg, $arg->tags ); + } +} 1; diff -Nru libextutils-xspp-perl-0.1602/lib/ExtUtils/XSpp/Node/Argument.pm libextutils-xspp-perl-0.1800/lib/ExtUtils/XSpp/Node/Argument.pm --- libextutils-xspp-perl-0.1602/lib/ExtUtils/XSpp/Node/Argument.pm 2011-06-03 20:12:10.000000000 +0000 +++ libextutils-xspp-perl-0.1800/lib/ExtUtils/XSpp/Node/Argument.pm 2013-09-18 08:17:53.000000000 +0000 @@ -60,6 +60,7 @@ $this->{TYPE} = $args{type}; $this->{NAME} = $args{name}; $this->{DEFAULT} = $args{default}; + $this->{TAGS} = $args{tags}; } sub print { @@ -115,12 +116,24 @@ Returns whether there is a default for the function parameter. +=head2 function + +Returns a reference to the containing function/method. + +=head2 index + +Returns the 0-based index of the argument in the argument list. + =cut sub type { $_[0]->{TYPE} } sub name { $_[0]->{NAME} } +sub tags { $_[0]->{TAGS} } sub default { $_[0]->{DEFAULT} } sub has_default { defined $_[0]->{DEFAULT} } +sub function { $_[0]->{FUNCTION} } +sub index { $_[0]->{INDEX} } + 1; diff -Nru libextutils-xspp-perl-0.1602/lib/ExtUtils/XSpp/Node/Class.pm libextutils-xspp-perl-0.1800/lib/ExtUtils/XSpp/Node/Class.pm --- libextutils-xspp-perl-0.1602/lib/ExtUtils/XSpp/Node/Class.pm 2011-06-03 20:12:10.000000000 +0000 +++ libextutils-xspp-perl-0.1800/lib/ExtUtils/XSpp/Node/Class.pm 2013-09-18 08:17:53.000000000 +0000 @@ -51,6 +51,7 @@ $this->{CATCH} = $args{catch}; $this->{CONDITION} = $args{condition}; $this->{EMIT_CONDITION} = $args{emit_condition}; + $this->{GETTER_STYLE} = $this->{SETTER_STYLE} = 'underscore'; $all_classes{$this->cpp_name} = $this unless $this->empty; @@ -88,6 +89,10 @@ $meth->add_exception_handlers( @{$this->{CATCH} || []} ); $meth->resolve_typemaps; $meth->resolve_exceptions; + } elsif( $meth->isa( 'ExtUtils::XSpp::Node::Member' ) ) { + $meth->{CLASS} = $this; + $meth->{ACCESS} = $access; + $meth->resolve_typemaps; } elsif( $meth->isa( 'ExtUtils::XSpp::Node::Access' ) ) { $access = $meth->access; next; @@ -153,6 +158,46 @@ return $out; } +my %getter_maker = + ( no_prefix => sub { $_[0] }, + underscore => sub { 'get_' . $_[0] }, + camelcase => sub { 'get' . ucfirst $_[0] }, + uppercase => sub { 'Get' . ucfirst $_[0] }, + ); + +my %setter_maker = + ( no_prefix => sub { $_[0] }, + underscore => sub { 'set_' . $_[0] }, + camelcase => sub { 'set' . ucfirst $_[0] }, + uppercase => sub { 'Set' . ucfirst $_[0] }, + ); + +sub _getter_name { + my( $this, $base ) = @_; + + return $getter_maker{$this->{GETTER_STYLE}}->( $base ); +} + +sub _setter_name { + my( $this, $base ) = @_; + + return $setter_maker{$this->{SETTER_STYLE}}->( $base ); +} + +sub set_getter_style { + my( $this, $style ) = @_; + + die "Invalid accessor style '$style'" unless exists $getter_maker{$style}; + $this->{GETTER_STYLE} = $style; +} + +sub set_setter_style { + my( $this, $style ) = @_; + + die "Invalid accessor style '$style'" unless exists $setter_maker{$style}; + $this->{SETTER_STYLE} = $style; +} + =head1 ACCESSORS =head2 methods diff -Nru libextutils-xspp-perl-0.1602/lib/ExtUtils/XSpp/Node/Constructor.pm libextutils-xspp-perl-0.1800/lib/ExtUtils/XSpp/Node/Constructor.pm --- libextutils-xspp-perl-0.1602/lib/ExtUtils/XSpp/Node/Constructor.pm 2011-06-03 20:12:10.000000000 +0000 +++ libextutils-xspp-perl-0.1800/lib/ExtUtils/XSpp/Node/Constructor.pm 2013-09-18 08:17:53.000000000 +0000 @@ -38,6 +38,20 @@ die "Can't specify return value in constructor" if $this->{RET_TYPE}; } +sub print { + my $this = shift; + my $state = shift; + my $out = $this->SUPER::print( $state ); + + return sprintf <{FILE} } -sub print { - "\n#include \n\n\n" -} +sub print { return '' } 1; diff -Nru libextutils-xspp-perl-0.1602/lib/ExtUtils/XSpp/Node/Function.pm libextutils-xspp-perl-0.1800/lib/ExtUtils/XSpp/Node/Function.pm --- libextutils-xspp-perl-0.1602/lib/ExtUtils/XSpp/Node/Function.pm 2011-06-03 20:12:10.000000000 +0000 +++ libextutils-xspp-perl-0.1800/lib/ExtUtils/XSpp/Node/Function.pm 2013-09-18 08:17:53.000000000 +0000 @@ -47,15 +47,24 @@ $this->{ARGUMENTS} = $args{arguments} || []; $this->{RET_TYPE} = $args{ret_type}; $this->{CODE} = $args{code}; + $this->{CALL_CODE} = $args{call_code}; $this->{CLEANUP} = $args{cleanup}; $this->{POSTCALL} = $args{postcall}; $this->{CLASS} = $args{class}; $this->{CATCH} = $args{catch}; $this->{CONDITION} = $args{condition}; + $this->{ALIAS} = $args{alias}; + $this->{TAGS} = $args{tags}; $this->{EMIT_CONDITION} = $args{emit_condition}; - if (ref($this->{CATCH}) - and @{$this->{CATCH}} > 1 + my $index = 0; + foreach my $arg ( @{$this->{ARGUMENTS}} ) { + $arg->{FUNCTION} = $this; + $arg->{INDEX} = $index; + ++$index; + } + + if (@{$this->catch} > 1 and grep {$_ eq 'nothing'} @{$this->{CATCH}}) { Carp::croak( ref($this) . " '" . $this->{CPP_NAME} @@ -76,14 +85,15 @@ sub resolve_typemaps { my $this = shift; + my $index = 0; if( $this->ret_type ) { - $this->{TYPEMAPS}{RET_TYPE} = + $this->{TYPEMAPS}{RET_TYPE} ||= ExtUtils::XSpp::Typemap::get_typemap_for_type( $this->ret_type ); } foreach my $a ( @{$this->arguments} ) { - my $t = ExtUtils::XSpp::Typemap::get_typemap_for_type( $a->type ); - push @{$this->{TYPEMAPS}{ARGUMENTS}}, $t; + $this->{TYPEMAPS}{ARGUMENTS}[$index++] ||= + ExtUtils::XSpp::Typemap::get_typemap_for_type( $a->type ); } } @@ -98,7 +108,7 @@ sub resolve_exceptions { my $this = shift; - my @catch = @{$this->{CATCH} || []}; + my @catch = @{$this->catch}; my @exceptions; @@ -129,6 +139,12 @@ $this->{EXCEPTIONS} = \@exceptions; } +sub disable_exceptions { + my $this = shift; + + $this->{EXCEPTIONS} = []; +} + =head2 add_exception_handlers Adds a list of exception names to the list of exception handlers. @@ -143,13 +159,12 @@ my $this = shift; # ignore class %catch'es if overridden with "nothing" in the method - if ($this->{CATCH} and @{$this->{CATCH}} == 1 - and $this->{CATCH} eq 'nothing') { + if (@{$this->catch} == 1 and $this->{CATCH}[0] eq 'nothing') { return(); } # ignore class %catch{nothing} if overridden in the method - if (@_ == 1 and $_[0] eq 'nothing' and @{$this->{CATCH}}) { + if (@_ == 1 and $_[0] eq 'nothing' and @{$this->catch}) { return(); } @@ -159,7 +174,6 @@ return(); } - # Depending on argument style, this produces either: (style=kr) # # return_type @@ -168,6 +182,8 @@ # type arg # PREINIT: # aux vars +# [ALIAS: +# ID = INTEGER...] # [PP]CODE: # RETVAL = new Foo( THIS->method( arg1, *arg2 ) ); # POSTCALL: @@ -193,12 +209,14 @@ my $args = $this->arguments; my $ret_type = $this->ret_type; my $ret_typemap = $this->{TYPEMAPS}{RET_TYPE}; + my $aliases = $this->{ALIAS} || {}; + + my $has_aliases = scalar(keys %$aliases); $out .= '#if ' . $this->emit_condition . "\n" if $this->emit_condition; my( $init, $arg_list, $call_arg_list, $code, $output, $cleanup, - $postcall, $precall ) = - ( '', '', '', '', '', '', '', '' ); + $postcall, $precall, $alias ) = ( ('') x 9 ); # compute the precall code, XS argument list and C++ argument list using # the typemap information @@ -223,6 +241,15 @@ $call_arg_list = ' ' . join( ', ', @call_arg_list ) . ' '; } + # If there's %alias{foo = 123} definitions, generate ALIAS section + if ($has_aliases) { + # order by ordinal for consistent hash-order-independent output + my @alias_list = map " $_ = $aliases->{$_}\n", + sort {$aliases->{$a} <=> $aliases->{$b}} + keys %$aliases; + $alias = " ALIAS:\n" . join("", @alias_list); + } + my $retstr = $ret_typemap ? $ret_typemap->cpp_type : 'void'; # special case: constructors with name different from 'new' @@ -237,21 +264,30 @@ my $ppcode = $has_ret && $ret_typemap->output_list( '' ) ? 1 : 0; my $code_type = $ppcode ? "PPCODE" : "CODE"; my $ccode = $this->_call_code( $call_arg_list ); - if ($this->isa('ExtUtils::XSpp::Node::Destructor')) { + if ($this->{CALL_CODE}) { + $ccode = join( "\n", @{$this->{CALL_CODE}} ); + } elsif ($this->isa('ExtUtils::XSpp::Node::Destructor')) { $ccode = 'delete THIS'; $has_ret = 0; } elsif( $has_ret && defined $ret_typemap->call_function_code( '', '' ) ) { $ccode = $ret_typemap->call_function_code( $ccode, 'RETVAL' ); } elsif( $has_ret ) { - $ccode = "RETVAL = $ccode"; + if ($has_aliases) { + $ccode = $this->_generate_alias_conditionals($call_arg_list, 1); # 1 == use RETVAL + } else { + $ccode = "RETVAL = $ccode"; + } + } elsif( $has_aliases ) { # aliases but no RETVAL + $ccode = $this->_generate_alias_conditionals($call_arg_list, 0); # 0 == no RETVAL } + my @catchers = @{$this->{EXCEPTIONS}}; $code .= " $code_type:\n"; - $code .= " try {\n"; + $code .= " try {\n" if @catchers; if ($precall) { $code .= ' ' . $precall; } - $code .= ' ' . $ccode . ";\n"; + $code .= (@catchers ? ' ' : '') . ' ' . $ccode . ";\n"; if( $has_ret && defined $ret_typemap->output_code( '', '' ) ) { my $retcode = $ret_typemap->output_code( 'ST(0)', 'RETVAL' ); $code .= ' ' . $retcode . ";\n"; @@ -260,8 +296,7 @@ my $retcode = $ret_typemap->output_list( 'RETVAL' ); $code .= ' ' . $retcode . ";\n"; } - $code .= " }\n"; - my @catchers = @{$this->{EXCEPTIONS}}; + $code .= " }\n" if @catchers; foreach my $exception_handler (@catchers) { my $handler_code = $exception_handler->handler_code; $code .= $handler_code; @@ -277,8 +312,6 @@ if( $this->code ) { $code = " $code_type:\n " . join( "\n", @{$this->code} ) . "\n"; - # cleanup potential multiple newlines because they break XSUBs - $code =~ s/^\s*\z//m; $output = " OUTPUT: RETVAL\n" if $code =~ m/\bRETVAL\b/; } if( $this->postcall ) { @@ -306,7 +339,12 @@ my $head = "$retstr\n" . "$fname($arg_list)\n"; - my $body = $init . $code . $postcall . $output . $cleanup . "\n"; + my $body = $alias . $init . $code . $postcall . $output . $cleanup; + + # cleanup potential multiple newlines because they break XSUBs + $body =~ s/^\s*\n//mg; + $body .= "\n"; + $this->_munge_code(\$body) if $this->has_argument_with_length; $out .= $head . $body; @@ -380,7 +418,7 @@ =begin documentation -ExtUtils::XSpp::Node::_call_code( argument_string ) +ExtUtils::XSpp::Function::_call_code( argument_string ) Return something like "foo( $argument_string )". @@ -390,6 +428,56 @@ sub _call_code { return $_[0]->cpp_name . '(' . $_[1] . ')'; } +=begin documentation + +ExtUtils::XSpp::Function::_call_code_aliased( function_alias_name, argument_string ) + +Return something like "$function_alias_name( $argument_string )". + +=end documentation + +=cut + +sub _call_code_aliased { return $_[1] . '(' . $_[2] . ')'; } + +=begin documentation + +ExtUtils::XSpp::Function::_generate_alias_conditionals( argument_string, use_retval_bool ) + +Generates if()else if()else block for XS function name aliasing (cf. the XS manual and the ix +variable). If use_retval_bool is true, each included function call will contain an +assignment to RETVAL. + +Returns the generated code. + +=end documentation + +=cut +sub _generate_alias_conditionals { + my ($this, $call_arg_list, $use_retval) = @_; + my $aliases = $this->{ALIAS}; + + my $retval_code = $use_retval ? "RETVAL = " : ""; + my $buf = "if (ix == 0) {\n $retval_code" + . $this->_call_code($call_arg_list) + . ";\n}\n"; + # order by ordinal for consistent hash-order-independent output + foreach my $alias (sort {$aliases->{$a} <=> $aliases->{$b}} keys %$aliases) + { + $buf .= "else if (ix == $aliases->{$alias}) {\n " + . $retval_code . $this->_call_code_aliased($alias, $call_arg_list) + . ";\n}\n"; + } + $buf .= "else\n croak(\"Panic: Invalid invocation of function alias number %i!\", (int)ix))"; + + # indent + $buf =~ s/^/ /gm; + $buf =~ s/^\s+//; # first line will get special treatment... + + return $buf; +} + + =head1 ACCESSORS =head2 cpp_name @@ -435,6 +523,12 @@ Returns the set of exception types that were associated with the function via C<%catch>. (array reference) +=head2 aliases + +Returns a hashref of C position> +function name aliases (see %alias and L ALIAS keyword). +Does not include the main function name. + =cut sub cpp_name { $_[0]->{CPP_NAME} } @@ -448,6 +542,8 @@ sub cleanup { $_[0]->{CLEANUP} } sub postcall { $_[0]->{POSTCALL} } sub catch { $_[0]->{CATCH} ? $_[0]->{CATCH} : [] } +sub aliases { $_[0]->{ALIAS} ? $_[0]->{ALIAS} : {} } +sub tags { $_[0]->{TAGS} } =head2 set_static @@ -475,4 +571,50 @@ sub package_static { ( $_[0]->{STATIC} || '' ) eq 'package_static' } sub class_static { ( $_[0]->{STATIC} || '' ) eq 'class_static' } +=head2 ret_typemap + +Returns the typemap for the return value of the function. + +=head2 set_ret_typemap( typemap ) + +Sets the typemap for the return value of the function. + +=head2 arg_typemap( index ) + +Returns the typemap for one function arguments. + +=head2 set_arg_typemap( index, typemap ) + +Sets the typemap for one function argument. + +=cut + +sub ret_typemap { + my ($this) = @_; + + die "Typemap not available yet" unless $this->{TYPEMAPS}{RET_TYPE}; + return $this->{TYPEMAPS}{RET_TYPE}; +} + +sub set_ret_typemap { + my ($this, $typemap) = @_; + + $this->{TYPEMAPS}{RET_TYPE} = $typemap; +} + +sub arg_typemap { + my ($this, $index) = @_; + + die "Invalid index" unless $index < @{$this->{ARGUMENTS}}; + die "Typemap not available yet" unless $this->{TYPEMAPS}{ARGUMENTS}; + return $this->{TYPEMAPS}{ARGUMENTS}[$index]; +} + +sub set_arg_typemap { + my ($this, $index, $typemap) = @_; + + die "Invalid index" unless $index < @{$this->{ARGUMENTS}}; + $this->{TYPEMAPS}{ARGUMENTS}[$index] = $typemap; +} + 1; diff -Nru libextutils-xspp-perl-0.1602/lib/ExtUtils/XSpp/Node/Member.pm libextutils-xspp-perl-0.1800/lib/ExtUtils/XSpp/Node/Member.pm --- libextutils-xspp-perl-0.1602/lib/ExtUtils/XSpp/Node/Member.pm 1970-01-01 00:00:00.000000000 +0000 +++ libextutils-xspp-perl-0.1800/lib/ExtUtils/XSpp/Node/Member.pm 2013-09-18 08:17:53.000000000 +0000 @@ -0,0 +1,234 @@ +package ExtUtils::XSpp::Node::Member; +use strict; +use warnings; +use Carp (); +use base 'ExtUtils::XSpp::Node'; + +=head1 NAME + +ExtUtils::XSpp::Node::Member - Node representing a class member variable + +=head1 DESCRIPTION + +An L sub-class representing a single member +variable in a class such as + + class FooBar { + int foo; // <-- this one + } + +Member declarations do not produce any XS code unless they are +decorated by either C<%get> or C<%set>. + +=head1 METHODS + +=head2 new + +Creates a new C. + +Named parameters: C indicating the C++ name of the member, +C indicating the Perl name of the member (defaults to the +same as C), C indicates the (C++) type of the member +and finally C, which is an L. + +=cut + +sub init { + my $this = shift; + my %args = @_; + + $this->{CPP_NAME} = $args{cpp_name}; + $this->{PERL_NAME} = $args{perl_name} || $args{cpp_name}; + $this->{TYPE} = $args{type}; + $this->{CLASS} = $args{class}; + $this->{CONDITION} = $args{condition}; + $this->{TAGS} = $args{tags}; + $this->{EMIT_CONDITION} = $args{emit_condition}; +} + +sub print { + my( $this, $state ) = @_; + my $str = ''; + + $str .= $this->_getter->print( $state ) if $this->_getter; + $str .= $this->_setter->print( $state ) if $this->_setter; + + return $str; +} + +sub _getter { + my( $this ) = @_; + + die 'Tried to create getter before adding member to a class' + unless $this->class; + return $this->{_getter} if $this->{_getter}; + + # TODO use plugin infrastructure + my $getter; + for my $tag ( @{$this->tags} ) { + if( $tag->{any} eq 'get' ) { + $getter = $tag->{positional}[0] || ''; + last; + } + } + return unless defined $getter; + + my $f = $this->{_getter} = + ExtUtils::XSpp::Node::Method->new + ( class => $this->class, + cpp_name => $this->_getter_name( $getter ), + ret_type => $this->type, + call_code => $this->_getter_code, + condition => $this->condition, + emit_condition => $this->emit_condition, + const => 1, + ); + $f->set_ret_typemap( $this->typemap ); + $f->resolve_typemaps; + $f->disable_exceptions; + + return $this->{_getter}; +} + +sub _setter { + my( $this ) = @_; + + die 'Tried to create getter before adding member to a class' + unless $this->class; + return $this->{_setter} if $this->{_setter}; + + # TODO use plugin infrastructure + my $setter; + for my $tag ( @{$this->tags} ) { + if( $tag->{any} eq 'set' ) { + $setter = $tag->{positional}[0] || ''; + last; + } + } + return unless defined $setter; + + my $f = $this->{_setter} = + ExtUtils::XSpp::Node::Method->new + ( class => $this->class, + cpp_name => $this->_setter_name( $setter ), + arguments => [ ExtUtils::XSpp::Node::Argument->new + ( type => $this->type, + name => 'value' + ) + ], + ret_type => ExtUtils::XSpp::Node::Type->new( base => 'void' ), + call_code => $this->_setter_code, + condition => $this->condition, + emit_condition => $this->emit_condition, + ); + $f->set_arg_typemap( 0, $this->typemap ); + $f->resolve_typemaps; + $f->disable_exceptions; + + return $this->{_setter}; +} + +sub _getter_code { + my( $this ) = @_; + + return [ sprintf 'RETVAL = THIS->%s', $this->cpp_name ]; +} + +sub _getter_name { + my( $this, $name ) = @_; + + return $name if $name; + return $this->class->_getter_name( $this->perl_name ); +} + +sub _setter_code { + my( $this ) = @_; + + return [ sprintf 'THIS->%s = value', $this->cpp_name ]; +} + +sub _setter_name { + my( $this, $name ) = @_; + + return $name if $name; + return $this->class->_setter_name( $this->perl_name ); +} + +=head2 resolve_typemaps + +Fetches the L object for the type +from the typemap registry and stores a reference to the object. + +=cut + +sub resolve_typemaps { + my $this = shift; + + $this->{TYPEMAPS}{TYPE} ||= + ExtUtils::XSpp::Typemap::get_typemap_for_type( $this->type ); +} + +=head1 ACCESSORS + +=head2 cpp_name + +Returns the C++ name of the member. + +=head2 perl_name + +Returns the Perl name of the member (defaults to same as C++). + +=head2 set_perl_name + +Sets the Perl name of the member. + +=head2 type + +Returns the C++ type for the member. + +=head2 class + +Returns the class (L) that the +member belongs to. + +=head2 access + +Returns C<'public'>, C<'protected'> or C<'private'> depending on +member access declaration. + +=cut + +sub cpp_name { $_[0]->{CPP_NAME} } +sub set_cpp_name { $_[0]->{CPP_NAME} = $_[1] } +sub perl_name { $_[0]->{PERL_NAME} } +sub set_perl_name { $_[0]->{PERL_NAME} = $_[1] } +sub type { $_[0]->{TYPE} } +sub tags { $_[0]->{TAGS} } +sub class { $_[0]->{CLASS} } +sub access { $_[0]->{ACCESS} } +sub set_access { $_[0]->{ACCESS} = $_[1] } + +=head2 typemap + +Returns the typemap for member type. + +=head2 set_typemap( typemap ) + +Sets the typemap for member type. + +=cut + +sub typemap { + my ($this) = @_; + + die "Typemap not available yet" unless $this->{TYPEMAPS}{TYPE}; + return $this->{TYPEMAPS}{TYPE}; +} + +sub set_typemap { + my ($this, $typemap) = @_; + + $this->{TYPEMAPS}{TYPE} = $typemap; +} + +1; diff -Nru libextutils-xspp-perl-0.1602/lib/ExtUtils/XSpp/Node/Method.pm libextutils-xspp-perl-0.1800/lib/ExtUtils/XSpp/Node/Method.pm --- libextutils-xspp-perl-0.1602/lib/ExtUtils/XSpp/Node/Method.pm 2011-06-03 20:12:10.000000000 +0000 +++ libextutils-xspp-perl-0.1800/lib/ExtUtils/XSpp/Node/Method.pm 2013-09-18 08:17:53.000000000 +0000 @@ -63,14 +63,20 @@ } sub _call_code { - my( $self ) = @_; + my( $self, $arg_string ) = @_; + + return $self->_call_code_aliased($self->cpp_name, $arg_string); +} + +sub _call_code_aliased { + my( $self, $alias_name, $arg_string ) = @_; if( $self->package_static ) { - return $_[0]->class->cpp_name . '::' . - $_[0]->cpp_name . '(' . $_[1] . ')'; + return $self->class->cpp_name . '::' . + $alias_name . '(' . $arg_string . ')'; } else { return "THIS->" . - $_[0]->cpp_name . '(' . $_[1] . ')'; + $alias_name . '(' . $arg_string . ')'; } } diff -Nru libextutils-xspp-perl-0.1602/lib/ExtUtils/XSpp/Node/PercAny.pm libextutils-xspp-perl-0.1800/lib/ExtUtils/XSpp/Node/PercAny.pm --- libextutils-xspp-perl-0.1602/lib/ExtUtils/XSpp/Node/PercAny.pm 2011-06-03 20:12:10.000000000 +0000 +++ libextutils-xspp-perl-0.1800/lib/ExtUtils/XSpp/Node/PercAny.pm 2013-09-18 08:17:53.000000000 +0000 @@ -17,8 +17,8 @@ my( $this, %args ) = @_; $this->{NAME} = $args{any}; - $this->{NAMED_ARGUMENTS} = $args{any_named_arguments}; - $this->{POSITIONAL_ARGUMENTS} = $args{any_positional_arguments}; + $this->{NAMED_ARGUMENTS} = $args{named}; + $this->{POSITIONAL_ARGUMENTS} = $args{positional}; } 1; diff -Nru libextutils-xspp-perl-0.1602/lib/ExtUtils/XSpp/Parser.pm libextutils-xspp-perl-0.1800/lib/ExtUtils/XSpp/Parser.pm --- libextutils-xspp-perl-0.1602/lib/ExtUtils/XSpp/Parser.pm 2011-06-03 20:12:10.000000000 +0000 +++ libextutils-xspp-perl-0.1800/lib/ExtUtils/XSpp/Parser.pm 2013-09-18 08:17:53.000000000 +0000 @@ -68,10 +68,15 @@ yyerror => \&ExtUtils::XSpp::Grammar::yyerror, yydebug => 0x00, ); - if (ref($this->{DATA})) { - unshift @{$this->{DATA}}, - ExtUtils::XSpp::Node::Raw->new(rows =>['#include ']); - } +} + +sub parse_type { + my( $class, $type ) = @_; + my $this = $class->new( string => "%_type{$type}" ); + + $this->parse; + + return $this->{DATA}; } sub include_file { @@ -128,7 +133,7 @@ } elsif (!eval "require $package;") { die "Could not load XS++ plugin '$package' (neither via the namespace " - ."'ExtUtils::XS++::Plugin::$package' nor via '$package'). Reason: $@"; + ."'ExtUtils::XSpp::Plugin::$package' nor via '$package'). Reason: $@"; } # only call register_plugin once @@ -152,7 +157,7 @@ sub add_post_process_plugin { my( $this, %args ) = @_; - push @{$this->{PLUGINS}{POST_PROCESS}}, $args{plugin}; + _add_plugin( $this, 'POST_PROCESS', \%args, 'post_process' ); } sub post_process_plugins { $_[0]->{PLUGINS}{POST_PROCESS} || [] } @@ -168,14 +173,14 @@ my( $this, %args ) = @_; my $tag = $args{tag} || '_any_'; - push @{$this->{PLUGINS}{CLASS_TAG}{$tag}}, $args{plugin}; + _add_plugin( $this, 'CLASS_TAG', \%args, 'handle_class_tag' ); } sub handle_class_tag_plugins { my( $this, $class, @args ) = @_; _handle_plugin( $this, $this->{PLUGINS}{CLASS_TAG}, 'class', - 'handle_class_tag', [ $class, @args ] ); + [ $class, @args ] ); } =head2 ExtUtils::XSpp::Parser::add_function_tag_plugin @@ -189,14 +194,14 @@ my( $this, %args ) = @_; my $tag = $args{tag} || '_any_'; - push @{$this->{PLUGINS}{FUNCTION_TAG}{$tag}}, $args{plugin}; + _add_plugin( $this, 'FUNCTION_TAG', \%args, 'handle_function_tag' ); } -sub handle_function_tag_plugins { - my( $this, $function, @args ) = @_; +sub handle_function_tags_plugins { + my( $this, $function, $tags ) = @_; - _handle_plugin( $this, $this->{PLUGINS}{FUNCTION_TAG}, 'function', - 'handle_function_tag', [ $function, @args ] ); + _handle_plugins( $this, $this->{PLUGINS}{FUNCTION_TAG}, 'function', + $tags, $function ) } =head2 ExtUtils::XSpp::Parser::add_method_tag_plugin @@ -210,14 +215,35 @@ my( $this, %args ) = @_; my $tag = $args{tag} || '_any_'; - push @{$this->{PLUGINS}{METHOD_TAG}{$tag}}, $args{plugin}; + _add_plugin( $this, 'METHOD_TAG', \%args, 'handle_method_tag' ); } -sub handle_method_tag_plugins { - my( $this, $method, @args ) = @_; +sub handle_method_tags_plugins { + my( $this, $method, $tags ) = @_; - _handle_plugin( $this, $this->{PLUGINS}{METHOD_TAG}, 'method', - 'handle_method_tag', [ $method, @args ] ); + _handle_plugins( $this, $this->{PLUGINS}{METHOD_TAG}, 'method', + $tags, $method ); +} + +=head2 ExtUtils::XSpp::Parser::add_argument_tag_plugin + +Adds the specified plugin to the list of plugins that can handle custom +%foo annotations for an arguments. + +=cut + +sub add_argument_tag_plugin { + my( $this, %args ) = @_; + my $tag = $args{tag} || '_any_'; + + _add_plugin( $this, 'ARGUMENT_TAG', \%args, 'handle_argument_tag' ); +} + +sub handle_argument_tags_plugins { + my( $this, $argument, $tags ) = @_; + + _handle_plugins( $this, $this->{PLUGINS}{ARGUMENT_TAG}, 'argument', + $tags, $argument ); } =head2 ExtUtils::XSpp::Parser::add_toplevel_tag_plugin @@ -231,27 +257,60 @@ my( $this, %args ) = @_; my $tag = $args{tag} || '_any_'; - push @{$this->{PLUGINS}{TOPLEVEL_TAG}{$tag}}, $args{plugin}; + _add_plugin( $this, 'TOPLEVEL_TAG', \%args, 'handle_toplevel_tag' ); } sub handle_toplevel_tag_plugins { my( $this, @args ) = @_; _handle_plugin( $this, $this->{PLUGINS}{TOPLEVEL_TAG}, 'top-level', - 'handle_toplevel_tag', [ undef, @args ] ); + [ undef, @args ] ); +} + +sub _add_plugin { + my( $this, $kind, $args, $default_method ) = @_; + my $entry = { plugin => $args->{plugin}, + method => $args->{method} || $default_method, + }; + + if( $kind eq 'POST_PROCESS' ) { + push @{$this->{PLUGINS}{$kind}}, $entry; + } else { + push @{$this->{PLUGINS}{$kind}{$args->{tag} || '_any_'}}, $entry; + } +} + +sub _handle_plugins { + my( $this, $plugins, $plugin_type, $tags, $arg ) = @_; + my @nodes; + + foreach my $tag ( @{$tags || []} ) { + my $nodes = _handle_plugin( $this, $plugins, $plugin_type, + [ $arg, $tag->{any}, + named => $tag->{named}, + positional => $tag->{positional}, + any_named_arguments => $tag->{named}, + any_positional_arguments => $tag->{positional}, + ] ); + + push @nodes, @$nodes; + } + + return \@nodes; } sub _handle_plugin { - my( $this, $plugins, $plugin_type, $plugin_method, $plugin_args ) = @_; + my( $this, $plugins, $plugin_type, $plugin_args ) = @_; my $tag = $plugin_args->[1]; - my $handled; foreach my $plugin ( @{$plugins->{$tag} || []}, @{$plugins->{_any_} || []} ) { - $handled ||= $plugin->$plugin_method( @$plugin_args ); - last if $handled; + my $method = $plugin->{method}; + + my( $handled, @nodes ) = $plugin->{plugin}->$method( @$plugin_args ); + return \@nodes if $handled; } - die "Unhandled $plugin_type annotation $tag" unless $handled; + die "Unhandled $plugin_type annotation '$tag'"; } sub current_file { $_[0]->{PARSER}->YYData->{LEX}{FILE} } diff -Nru libextutils-xspp-perl-0.1602/lib/ExtUtils/XSpp/Plugin/feature/default_xs_typemap.pm libextutils-xspp-perl-0.1800/lib/ExtUtils/XSpp/Plugin/feature/default_xs_typemap.pm --- libextutils-xspp-perl-0.1602/lib/ExtUtils/XSpp/Plugin/feature/default_xs_typemap.pm 1970-01-01 00:00:00.000000000 +0000 +++ libextutils-xspp-perl-0.1800/lib/ExtUtils/XSpp/Plugin/feature/default_xs_typemap.pm 2013-09-18 08:17:53.000000000 +0000 @@ -0,0 +1,13 @@ +package ExtUtils::XSpp::Plugin::feature::default_xs_typemap; + +use strict; +use warnings; + +sub register_plugin { + my( $class, $parser ) = @_; + + ExtUtils::XSpp::Typemap::_enable_default_xs_typemaps(); + +} + +1; diff -Nru libextutils-xspp-perl-0.1602/lib/ExtUtils/XSpp/Plugin.pod libextutils-xspp-perl-0.1800/lib/ExtUtils/XSpp/Plugin.pod --- libextutils-xspp-perl-0.1602/lib/ExtUtils/XSpp/Plugin.pod 2011-06-03 20:12:10.000000000 +0000 +++ libextutils-xspp-perl-0.1800/lib/ExtUtils/XSpp/Plugin.pod 2013-09-18 08:17:53.000000000 +0000 @@ -45,8 +45,8 @@ gives an error if the annotation is not handled by any plugin. Positional parameters are passed to tag handlers as an array reference -in the C parameter; named handlers are passed as -an hash reference in the C parameter. +in the C parameter; named handlers are passed as +an hash reference in the C parameter. The value of a special block parameter is an array reference with an element for each line in the special block. For consistency, the @@ -58,7 +58,9 @@ =head2 add_post_process_plugin - $parser->add_post_process_plugin( plugin => $instance ); + $parser->add_post_process_plugin( plugin => $instance, + method => 'post_process', + ); Registers a post-processing plugin to be called after the parsing finishes. @@ -68,6 +70,7 @@ $parser->add_function_tag_plugin( plugin => $instance, # optional tag => $tag, + method => 'handle_function_tag', ); Add a plugin to handle functions annotated with tags. @@ -77,6 +80,7 @@ $parser->add_class_tag_plugin( plugin => $instance, # optional tag => $tag, + method => 'handle_class_tag', ); Add a plugin to handle classes annotated with tags. @@ -86,6 +90,7 @@ $parser->add_method_tag_plugin( plugin => $instance, # optional tag => $tag, + method => 'handle_method_tag', ); Add a plugin to handle methods annotated with tags. @@ -95,6 +100,7 @@ $parser->add_toplevel_tag_plugin( plugin => $instance, # optional tag => $tag, + method => 'handle_toplevel_tag', ); Add a plugin to handle top-level directives. @@ -139,6 +145,12 @@ If the method handles the tag, it must return C<1> to the caller. +If the return value is a list, the first element is the +handled/not-handled flag, remaining elements are a list of nodes to +add to the node list returned by the parser. + +The method is called after parsing of the function completes. + =head2 handle_class_tag sub handle_class_tag { @@ -153,6 +165,13 @@ If the method handles the tag, it must return C<1> to the caller. +If the return value is a list, the first element is the +handled/not-handled flag, remaining elements are a list of nodes to +add to the node list in the class. + +The method is called after parsing of the class completes, and after the +handlers for methods contained in the class. + =head2 handle_method_tag sub handle_method_tag { @@ -166,6 +185,13 @@ If the method handles the tag, it must return C<1> to the caller. +If the return value is a list, the first element is the +handled/not-handled flag, remaining elements are a list of nodes to +add to the node list in the containing class. + +The method is called after the method has been added to the class and +before the handler for class tags. + =head2 handle_toplevel_tag sub handle_toplevel_tag { @@ -180,6 +206,12 @@ If the method handles the tag, it must return C<1> to the caller. +If the return value is a list, the first element is the +handled/not-handled flag, remaining elements are a list of nodes to +add to the node list returned by the parser. + +The method is called after the parsing of the tag completes. + =end internal =cut diff -Nru libextutils-xspp-perl-0.1602/lib/ExtUtils/XSpp/Typemap/parsed.pm libextutils-xspp-perl-0.1800/lib/ExtUtils/XSpp/Typemap/parsed.pm --- libextutils-xspp-perl-0.1602/lib/ExtUtils/XSpp/Typemap/parsed.pm 2011-06-03 20:12:10.000000000 +0000 +++ libextutils-xspp-perl-0.1800/lib/ExtUtils/XSpp/Typemap/parsed.pm 2013-09-18 08:17:53.000000000 +0000 @@ -8,13 +8,30 @@ my $this = shift; my %args = @_; + if( my $base = $args{base} ) { + %args = ( cpp_type => $base->{CPP_TYPE}, + call_function_code => $base->{CALL_FUNCTION_CODE}, + output_code => $base->{OUTPUT_CODE}, + cleanup_code => $base->{CLEANUP_CODE}, + precall_code => $base->{PRECALL_CODE}, + output_list => $base->{OUTPUT_LIST}, + xs_type => $base->{XS_TYPE}, + xs_input_code => $base->{XS_INPUT_CODE}, + xs_output_code => $base->{XS_OUTPUT_CODE}, + %args ); + } + $this->{TYPE} = $args{type}; + $this->{NAME} = $args{name}; $this->{CPP_TYPE} = $args{cpp_type} || $args{arg1}; $this->{CALL_FUNCTION_CODE} = _dl( $args{call_function_code} || $args{arg2} ); $this->{OUTPUT_CODE} = _dl( $args{output_code} || $args{arg3} ); $this->{CLEANUP_CODE} = _dl( $args{cleanup_code} || $args{arg4} ); $this->{PRECALL_CODE} = _dl( $args{precall_code} || $args{arg5} ); $this->{OUTPUT_LIST} = _dl( $args{output_list} ); + $this->{XS_TYPE} = $args{xs_type}; + $this->{XS_INPUT_CODE} = $args{xs_input_code}; + $this->{XS_OUTPUT_CODE} = $args{xs_output_code}; } sub cpp_type { $_[0]->{CPP_TYPE} || $_[0]->{TYPE}->print } diff -Nru libextutils-xspp-perl-0.1602/lib/ExtUtils/XSpp/Typemap/reference.pm libextutils-xspp-perl-0.1800/lib/ExtUtils/XSpp/Typemap/reference.pm --- libextutils-xspp-perl-0.1602/lib/ExtUtils/XSpp/Typemap/reference.pm 2011-06-03 20:12:10.000000000 +0000 +++ libextutils-xspp-perl-0.1800/lib/ExtUtils/XSpp/Typemap/reference.pm 2013-09-18 08:17:53.000000000 +0000 @@ -6,6 +6,15 @@ my $this = shift; my %args = @_; + if( my $base = $args{base} ) { + %args = ( xs_type => $base->{XS_TYPE}, + xs_input_code => $base->{XS_INPUT_CODE}, + xs_output_code => $base->{XS_OUTPUT_CODE}, + %args ); + } + + $this->{XS_TYPE} = $args{xs_type}; + $this->{NAME} = $args{name}; $this->{TYPE} = $args{type}; } diff -Nru libextutils-xspp-perl-0.1602/lib/ExtUtils/XSpp/Typemap/simple.pm libextutils-xspp-perl-0.1800/lib/ExtUtils/XSpp/Typemap/simple.pm --- libextutils-xspp-perl-0.1602/lib/ExtUtils/XSpp/Typemap/simple.pm 2011-06-03 20:12:10.000000000 +0000 +++ libextutils-xspp-perl-0.1800/lib/ExtUtils/XSpp/Typemap/simple.pm 2013-09-18 08:17:53.000000000 +0000 @@ -6,7 +6,18 @@ my $this = shift; my %args = @_; + if( my $base = $args{base} ) { + %args = ( xs_type => $base->{XS_TYPE}, + xs_input_code => $base->{XS_INPUT_CODE}, + xs_output_code => $base->{XS_OUTPUT_CODE}, + %args ); + } + $this->{TYPE} = $args{type}; + $this->{NAME} = $args{name}; + $this->{XS_TYPE} = $args{xs_type}; + $this->{XS_INPUT_CODE} = $args{xs_input_code}; + $this->{XS_OUTPUT_CODE} = $args{xs_output_code}; } sub cpp_type { $_[0]->{TYPE}->print } diff -Nru libextutils-xspp-perl-0.1602/lib/ExtUtils/XSpp/Typemap/wrapper.pm libextutils-xspp-perl-0.1800/lib/ExtUtils/XSpp/Typemap/wrapper.pm --- libextutils-xspp-perl-0.1602/lib/ExtUtils/XSpp/Typemap/wrapper.pm 1970-01-01 00:00:00.000000000 +0000 +++ libextutils-xspp-perl-0.1800/lib/ExtUtils/XSpp/Typemap/wrapper.pm 2013-09-18 08:17:53.000000000 +0000 @@ -0,0 +1,24 @@ +package ExtUtils::XSpp::Typemap::wrapper; + +use base 'ExtUtils::XSpp::Typemap'; + +sub init { + my $this = shift; + my %args = @_; + + $this->{TYPEMAP} = $args{typemap}; +} + +sub type { shift->{TYPEMAP}->type( @_ ) } +sub cpp_type { shift->{TYPEMAP}->cpp_type( @_ ) } +sub input_code { shift->{TYPEMAP}->input_code( @_ ) } +sub precall_code { shift->{TYPEMAP}->precall_code( @_ ) } +sub output_code { shift->{TYPEMAP}->output_code( @_ ) } +sub cleanup_code { shift->{TYPEMAP}->cleanup_code( @_ ) } +sub call_parameter_code { shift->{TYPEMAP}->call_parameter_code( @_ ) } +sub call_function_code { shift->{TYPEMAP}->call_function_code( @_ ) } +sub output_list { shift->{TYPEMAP}->output_list( @_ ) } + +sub typemap { $_[0]->{TYPEMAP} } + +1; diff -Nru libextutils-xspp-perl-0.1602/lib/ExtUtils/XSpp/Typemap.pm libextutils-xspp-perl-0.1800/lib/ExtUtils/XSpp/Typemap.pm --- libextutils-xspp-perl-0.1602/lib/ExtUtils/XSpp/Typemap.pm 2011-06-03 20:12:10.000000000 +0000 +++ libextutils-xspp-perl-0.1800/lib/ExtUtils/XSpp/Typemap.pm 2013-09-18 08:17:53.000000000 +0000 @@ -2,10 +2,15 @@ use strict; use warnings; +use ExtUtils::Typemaps; + +require ExtUtils::XSpp::Node::Type; require ExtUtils::XSpp::Typemap::parsed; require ExtUtils::XSpp::Typemap::simple; require ExtUtils::XSpp::Typemap::reference; +my %TypemapsByName; + =head1 NAME ExtUtils::XSpp::Typemap - map types @@ -21,6 +26,22 @@ return $this; } +sub create { + my( $name, @args ) = @_; + + if( my $template = $TypemapsByName{$name} ) { + my $package = ref $template; + + return $package->new( base => $template, @args ); + } else { + my $package = "ExtUtils::XSpp::Typemap::" . $name; + + return $package->new( @args ); + } +} + +=head1 METHODS + =head2 ExtUtils::XSpp::Typemap::type Returns the ExtUtils::XSpp::Node::Type that is used for this typemap. @@ -29,6 +50,18 @@ sub type { $_[0]->{TYPE} } +=head2 ExtUtils::XSpp::Typemap::xs_type() + +(Optional) XS typemap identifier (e.g. T_IV) for this C++ type. + +=head2 ExtUtils::XSpp::Typemap::xs_input_code() + +(Optional) XS input code for the associated XS typemap. + +=head2 ExtUtils::XSpp::Typemap::xs_output_code() + +(Optional) XS output code for the associated XS typemap. + =head2 ExtUtils::XSpp::Typemap::cpp_type() Returns the C++ type to be used for the local variable declaration. @@ -38,18 +71,26 @@ Code to put the contents of the perl_argument (typically ST(x)) into the C++ variable(s). -=head2 ExtUtils::XSpp::Typemap::output_code() +=head2 ExtUtils::XSpp::Typemap::output_code( perl_variable, c_variable ) -=head2 ExtUtils::XSpp::Typemap::cleanup_code() +=head2 ExtUtils::XSpp::Typemap::cleanup_code( perl_variable, c_variable ) =head2 ExtUtils::XSpp::Typemap::call_parameter_code( parameter_name ) =head2 ExtUtils::XSpp::Typemap::call_function_code( function_call_code, return_variable ) +Allows modifying the code used in the function/method call. The first +parameter has the form Cmethod( )>, the second +parameter is a variable to hold the return value. + =cut sub init { } +sub xs_type { $_[0]->{XS_TYPE} } +sub xs_input_code { $_[0]->{XS_INPUT_CODE} } +sub xs_output_code { $_[0]->{XS_OUTPUT_CODE} } +sub name { $_[0]->{NAME} } sub cpp_type { die; } sub input_code { die; } sub precall_code { undef } @@ -59,7 +100,17 @@ sub call_function_code { undef } sub output_list { undef } -my @typemaps; +my @Typemaps; +my $Default_output_code = 'sv_setref_pv( $arg, xsp_constructor_class("${my $ntt = $type; $ntt =~ s{^const\s+|[ \t*]+$}{}g; \\$ntt}"), (void*)$var );'; +my $Default_input_code = <<'INPUTCODE'; + if( sv_isobject($arg) && (SvTYPE(SvRV($arg)) == SVt_PVMG) ) + $var = ($type)SvIV((SV*)SvRV( $arg )); + else{ + warn( \"${Package}::$func_name() -- $var is not a blessed SV reference\" ); + XSRETURN_UNDEF; + } +INPUTCODE + # add typemaps for basic C types add_default_typemaps(); @@ -67,24 +118,27 @@ sub add_typemap_for_type { my( $type, $typemap ) = @_; - unshift @typemaps, [ $type, $typemap ]; + unshift @Typemaps, [ $type, $typemap ]; + $TypemapsByName{$typemap->name} = $typemap if $typemap->name; +} + +sub reset_typemaps { + @Typemaps = (); + add_default_typemaps(); } # a weak typemap does not override an already existing typemap for the # same type sub add_weak_typemap_for_type { my( $type, $typemap ) = @_; - - foreach my $t ( @typemaps ) { - return if $t->[0]->equals( $type ); - } - unshift @typemaps, [ $type, $typemap ]; + push @Typemaps, [ $type, $typemap ]; + $TypemapsByName{$typemap->name} ||= $typemap if $typemap->name; } sub get_typemap_for_type { my $type = shift; - foreach my $t ( @typemaps ) { + foreach my $t ( @Typemaps ) { return ${$t}[1] if $t->[0]->equals( $type ); } @@ -92,7 +146,7 @@ my $errmsg = "No typemap for type " . $type->print . "\nThere are typemaps for the following types:\n"; my @types; - foreach my $t (@typemaps) { + foreach my $t (@Typemaps) { push @types, " - " . $t->[0]->print . "\n"; } @@ -107,6 +161,52 @@ Carp::confess( $errmsg ); } +sub get_xs_typemap_code_for_all_typemaps { + my $typemaps = ExtUtils::Typemaps->new; + + # process typemaps in reverse order, so newer ones take precedence + my @xs_typemaps = grep $_->[1]->xs_type, reverse @Typemaps; + return unless @xs_typemaps; + + my %xs_types; + foreach my $typemap (grep $_->[1]->cpp_type && $_->[1]->cpp_type ne '_', @xs_typemaps) { + my $xstype = $typemap->[1]->xs_type; + + $xs_types{$typemap->[1]->cpp_type} = $xstype; + $typemaps->add_typemap( + ctype => $typemap->[1]->cpp_type, + xstype => $xstype, + replace => 1, + ); + } + + # avoid adding INPUT/OUTPUT sections for unused mappings + %xs_types = reverse %xs_types; + foreach my $typemap (grep $xs_types{$_->[1]->xs_type || ''}, @xs_typemaps) { + my $xstype = $typemap->[1]->xs_type; + + $typemaps->add_inputmap( + xstype => $xstype, + code => $typemap->[1]->xs_input_code, + replace => 1, + ) if $typemap->[1]->xs_input_code; + + $typemaps->add_outputmap( + xstype => $xstype, + code => $typemap->[1]->xs_output_code, + replace => 1, + ) if $typemap->[1]->xs_output_code; + } + + return '' if $typemaps->is_empty; + my $code = $typemaps->as_string; + my $end_marker = 'END'; + while ($code =~ /^\Q$end_marker\E\s*$/m) { + $end_marker .= '_'; + } + return "TYPEMAP: <<$end_marker\n$code\n$end_marker\n"; +} + # adds default typemaps for C* and C& sub add_class_default_typemaps { my( $name ) = @_; @@ -120,15 +220,17 @@ reference => 1, ); + my $xs_type = $TypemapsByName{object}->xs_type; + add_weak_typemap_for_type - ( $ptr, ExtUtils::XSpp::Typemap::simple->new( type => $ptr ) ); + ( $ptr, ExtUtils::XSpp::Typemap::simple->new( type => $ptr, xs_type => $xs_type ) ); add_weak_typemap_for_type - ( $ref, ExtUtils::XSpp::Typemap::reference->new( type => $ref ) ); + ( $ref, ExtUtils::XSpp::Typemap::reference->new( type => $ref, xs_type => $xs_type ) ); } sub add_default_typemaps { # void, integral and floating point types - foreach my $t ( 'char', 'short', 'int', 'long', + foreach my $t ( 'char', 'short', 'int', 'long', 'bool', 'unsigned char', 'unsigned short', 'unsigned int', 'unsigned long', 'void', 'float', 'double', 'long double' ) { @@ -155,6 +257,26 @@ ExtUtils::XSpp::Typemap::add_typemap_for_type ( $const_char_p, ExtUtils::XSpp::Typemap::simple->new( type => $const_char_p ) ); + + # objects + my $dummy_type = ExtUtils::XSpp::Node::Type->new( base => '' ); + my $obj_typemap = ExtUtils::XSpp::Typemap::parsed->new( + name => 'object', + type => $dummy_type, + xs_input_code => $Default_input_code, + xs_output_code => $Default_output_code, + ); + + ExtUtils::XSpp::Typemap::add_typemap_for_type( $dummy_type, $obj_typemap ) +} + +sub _enable_default_xs_typemaps { + foreach my $t ( reverse @Typemaps ) { + if( ($t->[1]->name || '') eq 'object' ) { + $t->[1]{XS_TYPE} ||= 'O_OBJECT'; + last; + } + } } 1; diff -Nru libextutils-xspp-perl-0.1602/lib/ExtUtils/XSpp.pm libextutils-xspp-perl-0.1800/lib/ExtUtils/XSpp.pm --- libextutils-xspp-perl-0.1602/lib/ExtUtils/XSpp.pm 2011-06-03 20:12:10.000000000 +0000 +++ libextutils-xspp-perl-0.1800/lib/ExtUtils/XSpp.pm 2013-09-18 08:17:53.000000000 +0000 @@ -5,6 +5,6 @@ use ExtUtils::XSpp::Driver; -our $VERSION = '0.1602'; +our $VERSION = '0.18'; 1; diff -Nru libextutils-xspp-perl-0.1602/lib/ExtUtils/XSpp.pod libextutils-xspp-perl-0.1800/lib/ExtUtils/XSpp.pod --- libextutils-xspp-perl-0.1602/lib/ExtUtils/XSpp.pod 2011-06-03 20:12:10.000000000 +0000 +++ libextutils-xspp-perl-0.1800/lib/ExtUtils/XSpp.pod 2013-09-18 08:17:53.000000000 +0000 @@ -25,8 +25,9 @@ XS++ is just a thin layer over plain XS, hence to use it you are supposed to know, at the very least, C++ and XS. -This means that you will need typemaps for B the normal XS -pre-processor I and the XS++ pre-processor I. +This means that you may need typemaps for B the normal XS +pre-processor I and the XS++ pre-processor I. More on +that in the I section below. =head1 COMMAND LINE @@ -48,9 +49,38 @@ =head1 TYPEMAPS -There is nothing special about typemap files (i.e. you can put typemaps -directly in your .xsp file), but it is handy to have common typemaps in a -separate file, to avoid duplication. +=head2 Ordinary XS typemaps + +To recap, I XS typemaps do the following three things: + +=over 2 + +=item * + +Associate a C type with an identifier such as T_FOO or O_FOO +(which we'll call I here). + +=item * + +Define an INPUT mapping for converting a Perl data structure to the +aforementioned C type. + +=item * + +Define an OUTPUT mapping for converting the C data structure back +into a Perl data structure. + +=back + +These are still required in the context of XS++. There are some helpers +to take away the tedium, but I'll get to that later. For XS++, there's +another layer of typemaps. The following section will discuss those. + +=head2 XS++ typemaps + +There is nothing special about XS++ typemap files (i.e. you can put typemaps +directly in your F<.xsp> file), but it is handy to have common typemaps in a +separate file, typically called F to avoid duplication. %typemap{}{simple}; @@ -154,6 +184,62 @@ =back +=head2 Putting all the typemaps together + +In summary, the XS++ typemaps (optionally) give you much more control +over the type conversion code that's generated for your XSUBs. But +you still need to let the XS compiler know how to map the C types +to Perl and back using the XS typemaps. + +Most of the time, you just need to convert basic C(++) types or the types +that you define with your C++ classes. For the former, XS++ comes with +a few default mappings for booleans, integers, floating point numbers, +and strings. +For classes, XS++ can automatically create a mapping of type C +which uses the de-facto standard way of storing a pointer to the C(++) +object in the IV slot of a referenced/blessed scalar. Due to backwards +compatibility, this must be explicitly enabled by adding + + %loadplugin{feature::default_xs_typemap}; + +in F (or near the top of every F<.xsp> file). + +If you deal with any +other types as arguments or return types, you still need to write both +XS and XS++ typemaps for these so that the systems know how to deal with them. + +See either L below for a way to specify XS typemaps from +XS++ or L for a discussion of inline XS typemaps that don't require +the traditional XS F file. + +=head2 Custom XS typemaps + +XS++ provides a default mapping for object types to an C typemap +with standard input and output glue code, which should be adequate for most +uses. + +There are multiple ways to override this default when needed. + + %typemap{Foo *}{simple}{ + %xs_type{O_MYMAP}; + %xs_input_code{% ... %}; // optional + %xs_output_code{% ... %}; // optional + }; + +can be used to define a new type -> XS typemap mapping, with optinal +input/output code. Since XS typemap definitions are global, XS +input/output code applies to all types with the same %xs_type, hence +there is no need to repeat it. + + %typemap{_}{simple}{ + %name{object}; + %xs_type{O_MYMAP}; + %xs_input_code{% ... %}; // optional + %xs_output_code{% ... %}; // optional + }; + +can be used to change the default typemap used for all classes. + =head1 DESCRIPTION Anything that does not look like a XS++ directive or a class @@ -201,7 +287,7 @@ =head2 %typemap -See B above. +See L above. =head2 %length @@ -223,6 +309,28 @@ then you can refer to the length of the string (here: C) I as C in the code. +=head2 %alias + +Decorator for function/method declarations such as + + double add(double a, double b) + %alias{subtract = 1} %alias{multiply = 2}; + +Which will cause the generation of just a single XSUB using the +XS "ALIAS" feature (see L). It will be installed as all of +C, C, and C on the Perl side and call either +the C++ C, C, or C functions depending on +which way it was called. + +Notes: If used in conjunction with C<%name{foo}> to rename the function, +then the C<%name> will only affect the main function name +(in the above example, C but not C or C). +When used with the C<%code> feature, the custom code will have to +use the C integer variable to decide which function to call. +C is set to 0 for the main function. Make sure to read up +on the ALIAS feature of plain XS. Aliasing is not supported for +constructors and destructors. + =head2 Classes %name{My::Class} class MyClass : public %name{My::Base} MyBase @@ -231,19 +339,25 @@ MyClass( int arg ); // My::Class->newMyClass( ... ); %name{newMyClass} MyClass( const char* str, int arg ); - + // standard DESTROY method ~MyClass(); - + int GetInt(); void SetValue( int arg = -1 ); - + %name{SetString} void SetValue( const char* string = NULL ); - + // Supply a C or C block for the XS int MyMethod( int a, int b ) %code{% RETVAL = a + b; %} %cleanup{% /* do something */ %}; + + // Expose class method as My::ClassMethod::ClassMethod($foo) + static void ClassMethod( double foo ); + + // Expose member variable as a pair of set_boolean/get_boolean accessors + bool boolean %get %set; }; =head2 Comments @@ -262,6 +376,39 @@ Note that if you supply a custom C<%code> block for a function or method, the automatic exception handling is turned off. +=head2 Member variables + +By default, member variable declarations are ignored; the C<%get> and +C<%set> decorators syntehsize a getter/setter named after the member +variable (can be renamed using C<%name>). + +XS++ defaults to get_/set_ prefix for getters/setters. This can be +overridden on an individual basis by using e.g. + + int foo %get{readFoo} %set{writeFoo}; + +As an alternative, the class-level C<%accessors> decorator sets the the +accessor style for the whole class: + + %accessors{ + %get_style{no_prefix}; + %set_style{camelcase}; + }; + +Available styles are + +=over 4 + +=item no_prefix => foo + +=item underscore => get_foo, set_foo + +=item camelcase => getFoo, setFoo + +=item uppercase => GetFoo, SetFoo + +=back + =head1 EXAMPLES The distribution contains an F directory. The diff -Nru libextutils-xspp-perl-0.1602/t/005_io.t libextutils-xspp-perl-0.1800/t/005_io.t --- libextutils-xspp-perl-0.1602/t/005_io.t 2011-06-03 20:12:10.000000000 +0000 +++ libextutils-xspp-perl-0.1800/t/005_io.t 2013-09-18 08:17:53.000000000 +0000 @@ -31,6 +31,8 @@ eq_or_diff( $out, < +#undef xsp_constructor_class +#define xsp_constructor_class(c) (c) MODULE=Foo::Bar::Baz @@ -40,10 +42,6 @@ MODULE=Foo::Bar::Baz PACKAGE=Foo::Bar::Baz::Buz - -#include - - int foo( int a, int b, int c ) CODE: @@ -61,8 +59,9 @@ EOT eq_or_diff( slurp 't/files/foo.h', < +#undef xsp_constructor_class +#define xsp_constructor_class(c) (c) diff -Nru libextutils-xspp-perl-0.1602/t/010_base.t libextutils-xspp-perl-0.1800/t/010_base.t --- libextutils-xspp-perl-0.1602/t/010_base.t 2011-06-03 20:12:10.000000000 +0000 +++ libextutils-xspp-perl-0.1800/t/010_base.t 2013-09-18 08:17:53.000000000 +0000 @@ -17,7 +17,7 @@ int foo( int a, int b, int c ); }; --- expected -#include +# XSP preamble MODULE=Foo @@ -46,7 +46,7 @@ { }; --- expected -#include +# XSP preamble MODULE=Foo @@ -60,7 +60,7 @@ int foo( int a ); --- expected -#include +# XSP preamble MODULE=Foo @@ -90,7 +90,7 @@ int foo( int a = 1, int b = 0x1, int c = 1|2 ); }; --- expected -#include +# XSP preamble MODULE=Foo @@ -120,13 +120,16 @@ Foo( int a = 1 ); }; --- expected -#include +# XSP preamble MODULE=Foo MODULE=Foo PACKAGE=Foo +#undef xsp_constructor_class +#define xsp_constructor_class(c) (CLASS) + Foo* Foo::new( int a = 1 ) CODE: @@ -141,6 +144,9 @@ } OUTPUT: RETVAL +#undef xsp_constructor_class +#define xsp_constructor_class(c) (c) + === Destructor --- xsp_stdout %module{Foo}; @@ -150,7 +156,7 @@ ~Foo(); }; --- expected -#include +# XSP preamble MODULE=Foo @@ -179,7 +185,7 @@ void foo( int a ); }; --- expected -#include +# XSP preamble MODULE=Foo @@ -206,9 +212,10 @@ class Foo { void foo(); + void bar(void); }; --- expected -#include +# XSP preamble MODULE=Foo @@ -228,6 +235,19 @@ croak("Caught C++ exception of unknown type"); } +void +Foo::bar() + CODE: + try { + THIS->bar(); + } + catch (std::exception& e) { + croak("Caught C++ exception of type or derived from 'std::exception': %s", e.what()); + } + catch (...) { + croak("Caught C++ exception of unknown type"); + } + === Comments and raw blocks --- xsp_stdout // comment before %module @@ -258,7 +278,7 @@ * class */ --- expected -#include +# XSP preamble @@ -312,7 +332,7 @@ unsigned int bar( char* line, unsigned long %length{line} ); --- expected -#include +# XSP preamble MODULE=Foo @@ -343,7 +363,7 @@ bar( char* line, unsigned long %length{line} ) %code{%RETVAL = bar(length(line)*2);%}; --- expected -#include +# XSP preamble MODULE=Foo @@ -367,7 +387,7 @@ %postcall{% cout << length(line) << endl;%} %cleanup{% cout << 2*length(line) << endl;%}; --- expected -#include +# XSP preamble MODULE=Foo @@ -401,7 +421,7 @@ short int bar( short a, unsigned short int b, unsigned c, unsigned int d, int e, unsigned short f, long int g, unsigned long int h ); --- expected -#include +# XSP preamble MODULE=Foo @@ -434,16 +454,22 @@ %}; }; --- expected -#include +# XSP preamble MODULE=Wx MODULE=Wx PACKAGE=Wx::RichTextCtrl +#undef xsp_constructor_class +#define xsp_constructor_class(c) (CLASS) + static wxRichTextCtrl* wxRichTextCtrl::newDefault() CODE: RETVAL = new wxRichTextCtrl(); wxPli_create_evthandler( aTHX_ RETVAL, CLASS ); OUTPUT: RETVAL + +#undef xsp_constructor_class +#define xsp_constructor_class(c) (c) diff -Nru libextutils-xspp-perl-0.1602/t/011_multiple_files.t libextutils-xspp-perl-0.1800/t/011_multiple_files.t --- libextutils-xspp-perl-0.1602/t/011_multiple_files.t 2011-06-03 20:12:10.000000000 +0000 +++ libextutils-xspp-perl-0.1800/t/011_multiple_files.t 2013-09-18 08:17:53.000000000 +0000 @@ -22,17 +22,13 @@ int foo( int a, int b, int c ); --- expected -#include +# XSP preamble MODULE=Foo MODULE=Foo PACKAGE=Foo - -#include - - int foo( int a, int b, int c ) CODE: @@ -61,7 +57,7 @@ int foo( int a, int b, int c ); --- expected -#include +# XSP preamble @@ -79,7 +75,7 @@ int foo( int a, int b, int c ); --- expected -#include +# XSP preamble int diff -Nru libextutils-xspp-perl-0.1602/t/012_preprocessor.t libextutils-xspp-perl-0.1800/t/012_preprocessor.t --- libextutils-xspp-perl-0.1602/t/012_preprocessor.t 2011-06-03 20:12:10.000000000 +0000 +++ libextutils-xspp-perl-0.1800/t/012_preprocessor.t 2013-09-18 08:17:53.000000000 +0000 @@ -43,7 +43,7 @@ #error 2 #endif --- expected -#include +# XSP preamble #include "foo.h" @@ -73,7 +73,7 @@ #error 2 #endif --- expected -#include +# XSP preamble #include "foo.h" @@ -105,7 +105,7 @@ #error 2 #endif --- expected -#include +# XSP preamble #include "foo.h" @@ -140,7 +140,7 @@ #endif --- expected -#include +# XSP preamble MODULE=Foo @@ -172,7 +172,7 @@ #endif --- expected -#include +# XSP preamble MODULE=Foo @@ -205,7 +205,7 @@ #endif --- expected -#include +# XSP preamble MODULE=Foo diff -Nru libextutils-xspp-perl-0.1602/t/013_typemap_output.t libextutils-xspp-perl-0.1800/t/013_typemap_output.t --- libextutils-xspp-perl-0.1602/t/013_typemap_output.t 1970-01-01 00:00:00.000000000 +0000 +++ libextutils-xspp-perl-0.1800/t/013_typemap_output.t 2013-09-18 08:17:53.000000000 +0000 @@ -0,0 +1,181 @@ +#!/usr/bin/perl -w + +use strict; +use warnings; +use t::lib::XSP::Test tests => 5; + +use ExtUtils::XSpp; +use ExtUtils::XSpp::Typemap::simple; +use Test::Differences; + +# First, add a manual typemap and see if that ends up in the generated +# typemap block. +is(ExtUtils::XSpp::Typemap::get_xs_typemap_code_for_all_typemaps(), undef); +my $type = ExtUtils::XSpp::Node::Type->new( + base => 'bar', + pointer => 1, +); +my $tm = ExtUtils::XSpp::Typemap::simple->new( + type => $type, + xs_type => 'T_BAR', + xs_input_code => 'MY_IN($arg, $var, $type, $Package, $func_name, Bar)', + xs_output_code => 'MY_OUT($arg, $var, Bar)', +); +ExtUtils::XSpp::Typemap::add_typemap_for_type($type => $tm); + +# Check whether writing basic typemaps works. +my $typemap_code = ExtUtils::XSpp::Typemap::get_xs_typemap_code_for_all_typemaps(); +eq_or_diff($typemap_code, <<'EXPECTED'); +TYPEMAP: <new( string => <<'HERE' ); +%module{Foo2}; + +class bar +{ + int foo2( int a, int b, int c ); +}; +HERE + +eq_or_diff($d->generate->{'-'}, <<'HERE'); +TYPEMAP: < +#undef xsp_constructor_class +#define xsp_constructor_class(c) (c) + + +MODULE=Foo2 + +MODULE=Foo2 PACKAGE=bar + +int +bar::foo2( int a, int b, int c ) + CODE: + try { + RETVAL = THIS->foo2( a, b, c ); + } + catch (std::exception& e) { + croak("Caught C++ exception of type or derived from 'std::exception': %s", e.what()); + } + catch (...) { + croak("Caught C++ exception of unknown type"); + } + OUTPUT: RETVAL + +HERE + +# Now parse a normal class, which will auto-add a typemap entry +run_diff xsp_stdout => 'expected'; + +__DATA__ + +=== Basic class +--- xsp_stdout +%module{Foo}; + +%loadplugin{feature::default_xs_typemap}; + +%typemap{bar *}{simple}{ + %xs_type{T_BAR}; +}; + +class Foo +{ + int foo( int a, int b, int c ); +}; +--- expected +TYPEMAP: <foo( a, b, c ); + } + catch (std::exception& e) { + croak("Caught C++ exception of type or derived from 'std::exception': %s", e.what()); + } + catch (...) { + croak("Caught C++ exception of unknown type"); + } + OUTPUT: RETVAL + +=== Override default +--- xsp_stdout +%module{Foo}; + +%typemap{_}{simple}{ + %name{object}; + %xs_type{T_BAR}; + %xs_input_code{% MY_IN($arg, $var, $type, $Package, $func_name, Bar) %}; + %xs_output_code{% MY_OUT($arg, $var, Bar) %}; +}; + +class Foo +{ + int foo( int a, int b, int c ); +}; +--- expected +TYPEMAP: <foo( a, b, c ); + } + catch (std::exception& e) { + croak("Caught C++ exception of type or derived from 'std::exception': %s", e.what()); + } + catch (...) { + croak("Caught C++ exception of unknown type"); + } + OUTPUT: RETVAL diff -Nru libextutils-xspp-perl-0.1602/t/015_reference.t libextutils-xspp-perl-0.1800/t/015_reference.t --- libextutils-xspp-perl-0.1602/t/015_reference.t 2011-06-03 20:12:10.000000000 +0000 +++ libextutils-xspp-perl-0.1800/t/015_reference.t 2013-09-18 08:17:53.000000000 +0000 @@ -17,7 +17,7 @@ void foo( Foo& a ); }; --- expected -#include +# XSP preamble MODULE=Foo @@ -46,7 +46,7 @@ Foo& foo(); }; --- expected -#include +# XSP preamble MODULE=Foo diff -Nru libextutils-xspp-perl-0.1602/t/020_rename.t libextutils-xspp-perl-0.1800/t/020_rename.t --- libextutils-xspp-perl-0.1602/t/020_rename.t 2011-06-03 20:12:10.000000000 +0000 +++ libextutils-xspp-perl-0.1800/t/020_rename.t 2013-09-18 08:17:53.000000000 +0000 @@ -2,10 +2,12 @@ use strict; use warnings; -use t::lib::XSP::Test tests => 5; +use t::lib::XSP::Test tests => 9; run_diff xsp_stdout => 'expected'; +# tests for %name{} and %alias{} + __DATA__ === Renamed function (also in different package) @@ -16,7 +18,7 @@ %name{boo} int foo(int a); %name{moo::boo} int foo(int a); --- expected -#include +# XSP preamble MODULE=Foo @@ -53,6 +55,106 @@ } OUTPUT: RETVAL +=== Function with alias +--- xsp_stdout +%module{Foo}; +%package{Foo::Bar}; + +%name{boo} int foo2(int a) %alias{baz2 = 3}; +--- expected +# XSP preamble + + +MODULE=Foo + +MODULE=Foo PACKAGE=Foo::Bar + +int +boo( int a ) + ALIAS: + baz2 = 3 + CODE: + try { + if (ix == 0) { + RETVAL = foo2( a ); + } + else if (ix == 3) { + RETVAL = baz2( a ); + } + else + croak("Panic: Invalid invocation of function alias number %i!", (int)ix)); + } + catch (std::exception& e) { + croak("Caught C++ exception of type or derived from 'std::exception': %s", e.what()); + } + catch (...) { + croak("Caught C++ exception of unknown type"); + } + OUTPUT: RETVAL + +=== Function with alias and code +--- xsp_stdout +%module{Foo}; +%package{Foo::Bar}; + +%name{boo} int foo2(int a) %alias{baz2 = 3} %code{%RETVAL = a;%}; +--- expected +# XSP preamble + + +MODULE=Foo + +MODULE=Foo PACKAGE=Foo::Bar + +int +boo( int a ) + ALIAS: + baz2 = 3 + CODE: + RETVAL = a; + OUTPUT: RETVAL + +=== Function with multiple aliases +--- xsp_stdout +%module{Foo}; +%package{Foo::Bar}; + +%name{boo} int foo2(int a) %alias{baz2 = 3} %alias{buz2 = 1}; +--- expected +# XSP preamble + + +MODULE=Foo + +MODULE=Foo PACKAGE=Foo::Bar + +int +boo( int a ) + ALIAS: + buz2 = 1 + baz2 = 3 + CODE: + try { + if (ix == 0) { + RETVAL = foo2( a ); + } + else if (ix == 1) { + RETVAL = buz2( a ); + } + else if (ix == 3) { + RETVAL = baz2( a ); + } + else + croak("Panic: Invalid invocation of function alias number %i!", (int)ix)); + } + catch (std::exception& e) { + croak("Caught C++ exception of type or derived from 'std::exception': %s", e.what()); + } + catch (...) { + croak("Caught C++ exception of unknown type"); + } + OUTPUT: RETVAL + === Renamed method --- xsp_stdout %module{Foo}; @@ -62,7 +164,7 @@ %name{bar} int foo( int a ); }; --- expected -#include +# XSP preamble MODULE=Foo @@ -83,6 +185,45 @@ } OUTPUT: RETVAL +=== Renamed method with alias +--- xsp_stdout +%module{Foo}; + +class Foo +{ + %name{bar} int foo( int a ) %alias{baz = 1}; +}; +--- expected +# XSP preamble + + +MODULE=Foo + +MODULE=Foo PACKAGE=Foo + +int +Foo::bar( int a ) + ALIAS: + baz = 1 + CODE: + try { + if (ix == 0) { + RETVAL = THIS->foo( a ); + } + else if (ix == 1) { + RETVAL = THIS->baz( a ); + } + else + croak("Panic: Invalid invocation of function alias number %i!", (int)ix)); + } + catch (std::exception& e) { + croak("Caught C++ exception of type or derived from 'std::exception': %s", e.what()); + } + catch (...) { + croak("Caught C++ exception of unknown type"); + } + OUTPUT: RETVAL + === Renamed constructor --- xsp_stdout %module{Foo}; @@ -92,13 +233,16 @@ %name{newFoo} Foo( int a ); }; --- expected -#include +# XSP preamble MODULE=Foo MODULE=Foo PACKAGE=Foo +#undef xsp_constructor_class +#define xsp_constructor_class(c) (CLASS) + static Foo* Foo::newFoo( int a ) CODE: @@ -113,6 +257,9 @@ } OUTPUT: RETVAL +#undef xsp_constructor_class +#define xsp_constructor_class(c) (c) + === Renamed destructor --- xsp_stdout %module{Foo}; @@ -122,7 +269,7 @@ %name{destroy} ~Foo(); }; --- expected -#include +# XSP preamble MODULE=Foo @@ -152,7 +299,7 @@ %name{foo_int} int foo( int a ); }; --- expected -#include +# XSP preamble MODULE=Foo diff -Nru libextutils-xspp-perl-0.1602/t/022_static.t libextutils-xspp-perl-0.1800/t/022_static.t --- libextutils-xspp-perl-0.1602/t/022_static.t 2011-06-03 20:12:10.000000000 +0000 +++ libextutils-xspp-perl-0.1800/t/022_static.t 2013-09-18 08:17:53.000000000 +0000 @@ -17,7 +17,7 @@ package_static int foo(int a); }; --- expected -#include +# XSP preamble MODULE=Foo diff -Nru libextutils-xspp-perl-0.1602/t/022_virtual.t libextutils-xspp-perl-0.1800/t/022_virtual.t --- libextutils-xspp-perl-0.1602/t/022_virtual.t 2011-06-03 20:12:10.000000000 +0000 +++ libextutils-xspp-perl-0.1800/t/022_virtual.t 2013-09-18 08:17:53.000000000 +0000 @@ -20,7 +20,7 @@ %code{%dummy%}; }; --- expected -#include +# XSP preamble MODULE=Foo @@ -49,7 +49,7 @@ %code{%dummy%}; }; --- expected -#include +# XSP preamble MODULE=Foo @@ -73,7 +73,7 @@ %code{%dummy%}; }; --- expected -#include +# XSP preamble MODULE=Foo diff -Nru libextutils-xspp-perl-0.1602/t/023_base_classes.t libextutils-xspp-perl-0.1800/t/023_base_classes.t --- libextutils-xspp-perl-0.1602/t/023_base_classes.t 2011-06-03 20:12:10.000000000 +0000 +++ libextutils-xspp-perl-0.1800/t/023_base_classes.t 2013-09-18 08:17:53.000000000 +0000 @@ -17,7 +17,7 @@ void foo(); }; --- expected -#include +# XSP preamble MODULE=Foo @@ -52,7 +52,7 @@ void foo(); }; --- expected -#include +# XSP preamble MODULE=Foo diff -Nru libextutils-xspp-perl-0.1602/t/024_enum.t libextutils-xspp-perl-0.1800/t/024_enum.t --- libextutils-xspp-perl-0.1602/t/024_enum.t 2011-06-03 20:12:10.000000000 +0000 +++ libextutils-xspp-perl-0.1800/t/024_enum.t 2013-09-18 08:17:53.000000000 +0000 @@ -31,7 +31,7 @@ THREE, }; --- expected -#include +# XSP preamble MODULE=Foo @@ -51,7 +51,7 @@ THREE }; --- expected -#include +# XSP preamble MODULE=Foo diff -Nru libextutils-xspp-perl-0.1602/t/025_member.t libextutils-xspp-perl-0.1800/t/025_member.t --- libextutils-xspp-perl-0.1602/t/025_member.t 1970-01-01 00:00:00.000000000 +0000 +++ libextutils-xspp-perl-0.1800/t/025_member.t 2013-09-18 08:17:53.000000000 +0000 @@ -0,0 +1,246 @@ +#!/usr/bin/perl -w + +use strict; +use warnings; +use t::lib::XSP::Test tests => 4; + +run_diff xsp_stdout => 'expected'; + +__DATA__ + +=== Basic accessors +--- xsp_stdout +%module{Foo}; + +class Foo +{ + int foo %get %set; +}; +--- expected +# XSP preamble + + +MODULE=Foo + +MODULE=Foo PACKAGE=Foo + +int +Foo::get_foo() + CODE: + RETVAL = THIS->foo; + OUTPUT: RETVAL + +void +Foo::set_foo( int value ) + CODE: + THIS->foo = value; + + +=== Only getter/setter +--- xsp_stdout +%module{Foo}; + +class Foo +{ + int foo %get; + int bar %set; +}; +--- expected +# XSP preamble + + +MODULE=Foo + +MODULE=Foo PACKAGE=Foo + +int +Foo::get_foo() + CODE: + RETVAL = THIS->foo; + OUTPUT: RETVAL + +void +Foo::set_bar( int value ) + CODE: + THIS->bar = value; + + +=== Getter/setter name +--- xsp_stdout +%module{Foo}; + +class Foo +{ + int foo %get{readFoo} %set{writeFoo}; +}; +--- expected +# XSP preamble + + +MODULE=Foo + +MODULE=Foo PACKAGE=Foo + +int +Foo::readFoo() + CODE: + RETVAL = THIS->foo; + OUTPUT: RETVAL + +void +Foo::writeFoo( int value ) + CODE: + THIS->foo = value; + + +=== Getter/setter style +--- xsp_stdout +%module{Foo}; + +class Foo1 +{ + %accessors{ + %get_style{underscore}; + %set_style{underscore}; + }; + + %name{bar} int foo %get %set; +}; + +class Foo2 +{ + %accessors{ + %get_style{no_prefix}; + %set_style{camelcase}; + }; + + %name{bar} int foo %get %set; +}; + +class Foo3 +{ + %accessors{ + %get_style{no_prefix}; + %set_style{underscore}; + }; + + %name{bar} int foo %get %set; +}; + +class Foo4 +{ + %accessors{ + %get_style{uppercase}; + %set_style{uppercase}; + }; + + %name{bar} int foo %get %set; +}; + +class Foo5 +{ + %accessors{ + %get_style{no_prefix}; + %set_style{uppercase}; + }; + + %name{bar} int foo %get %set; +}; + +class Foo6 +{ + %accessors{ + %get_style{camelcase}; + %set_style{camelcase}; + }; + + %name{bar} int foo %get %set; +}; +--- expected +# XSP preamble + + +MODULE=Foo + +MODULE=Foo PACKAGE=Foo1 + +int +Foo1::get_bar() + CODE: + RETVAL = THIS->foo; + OUTPUT: RETVAL + +void +Foo1::set_bar( int value ) + CODE: + THIS->foo = value; + + +MODULE=Foo PACKAGE=Foo2 + +int +Foo2::bar() + CODE: + RETVAL = THIS->foo; + OUTPUT: RETVAL + +void +Foo2::setBar( int value ) + CODE: + THIS->foo = value; + + +MODULE=Foo PACKAGE=Foo3 + +int +Foo3::bar() + CODE: + RETVAL = THIS->foo; + OUTPUT: RETVAL + +void +Foo3::set_bar( int value ) + CODE: + THIS->foo = value; + + +MODULE=Foo PACKAGE=Foo4 + +int +Foo4::GetBar() + CODE: + RETVAL = THIS->foo; + OUTPUT: RETVAL + +void +Foo4::SetBar( int value ) + CODE: + THIS->foo = value; + + +MODULE=Foo PACKAGE=Foo5 + +int +Foo5::bar() + CODE: + RETVAL = THIS->foo; + OUTPUT: RETVAL + +void +Foo5::SetBar( int value ) + CODE: + THIS->foo = value; + + +MODULE=Foo PACKAGE=Foo6 + +int +Foo6::getBar() + CODE: + RETVAL = THIS->foo; + OUTPUT: RETVAL + +void +Foo6::setBar( int value ) + CODE: + THIS->foo = value; diff -Nru libextutils-xspp-perl-0.1602/t/030_code_blocks.t libextutils-xspp-perl-0.1800/t/030_code_blocks.t --- libextutils-xspp-perl-0.1602/t/030_code_blocks.t 2011-06-03 20:12:10.000000000 +0000 +++ libextutils-xspp-perl-0.1800/t/030_code_blocks.t 2013-09-18 08:17:53.000000000 +0000 @@ -16,7 +16,7 @@ %name{boo} int foo(int a) %code{% RETVAL = a + 12; %}; --- expected -#include +# XSP preamble MODULE=Foo @@ -37,7 +37,7 @@ %name{boo} int foo(int a) %cleanup{% free( it ); %}; --- expected -#include +# XSP preamble MODULE=Foo @@ -68,7 +68,7 @@ int foo(int a) %postcall{% blub( a ); %}; --- expected -#include +# XSP preamble MODULE=Foo @@ -99,7 +99,7 @@ %name{boo} void foo(int a) %code{% blub( a ); %}; --- expected -#include +# XSP preamble MODULE=Foo @@ -120,7 +120,7 @@ %code{% blub( a ); %} %cleanup{% free( it ); %}; --- expected -#include +# XSP preamble MODULE=Foo @@ -142,7 +142,7 @@ void foo(int a) %postcall{% blub( a ); %}; --- expected -#include +# XSP preamble MODULE=Foo diff -Nru libextutils-xspp-perl-0.1602/t/031_verbatim_blocks.t libextutils-xspp-perl-0.1800/t/031_verbatim_blocks.t --- libextutils-xspp-perl-0.1602/t/031_verbatim_blocks.t 2011-06-03 20:12:10.000000000 +0000 +++ libextutils-xspp-perl-0.1800/t/031_verbatim_blocks.t 2013-09-18 08:17:53.000000000 +0000 @@ -17,7 +17,7 @@ Straight to XS, no checks... %} --- expected -#include +# XSP preamble MODULE=Foo @@ -39,7 +39,7 @@ int foo(int a); }; --- expected -#include +# XSP preamble MODULE=Foo diff -Nru libextutils-xspp-perl-0.1602/t/035_include.t libextutils-xspp-perl-0.1800/t/035_include.t --- libextutils-xspp-perl-0.1602/t/035_include.t 2011-06-03 20:12:10.000000000 +0000 +++ libextutils-xspp-perl-0.1800/t/035_include.t 2013-09-18 08:17:53.000000000 +0000 @@ -17,7 +17,7 @@ %include{t/files/include.xsp}; int bar(int y); --- expected -#include +# XSP preamble MODULE=Foo diff -Nru libextutils-xspp-perl-0.1602/t/040_plugin.t libextutils-xspp-perl-0.1800/t/040_plugin.t --- libextutils-xspp-perl-0.1602/t/040_plugin.t 2011-06-03 20:12:10.000000000 +0000 +++ libextutils-xspp-perl-0.1800/t/040_plugin.t 2013-09-18 08:17:53.000000000 +0000 @@ -22,7 +22,7 @@ void bar(); }; --- expected -#include +# XSP preamble MODULE=Foo @@ -72,7 +72,7 @@ void bar(); }; --- expected -#include +# XSP preamble MODULE=Foo diff -Nru libextutils-xspp-perl-0.1602/t/043_parser_plugins.t libextutils-xspp-perl-0.1800/t/043_parser_plugins.t --- libextutils-xspp-perl-0.1602/t/043_parser_plugins.t 2011-06-03 20:12:10.000000000 +0000 +++ libextutils-xspp-perl-0.1800/t/043_parser_plugins.t 2013-09-18 08:17:53.000000000 +0000 @@ -2,7 +2,7 @@ use strict; use warnings; -use t::lib::XSP::Test tests => 2; +use t::lib::XSP::Test tests => 4; run_diff xsp_stdout => 'expected'; @@ -13,19 +13,21 @@ %module{Foo}; %package{Foo}; %loadplugin{TestParserPlugin}; +%loadplugin{TestNewNodesPlugin}; -int foo(int y) %MyFuncRename{Foo}; +int foo(int y) %MyFuncRename{Foo} %MyComment; class klass { %MyClassRename{Klass}; + %MyComment; - klass() %MyMethodRename{newKlass}; + klass() %MyMethodRename{newKlass} %MyComment; - void bar() %MyMethodRename{Bar}; + void bar() %MyMethodRename{Bar} %MyComment; }; --- expected -#include +# XSP preamble MODULE=Foo @@ -46,9 +48,15 @@ } OUTPUT: RETVAL +// function foo + + MODULE=Foo PACKAGE=Klass +#undef xsp_constructor_class +#define xsp_constructor_class(c) (CLASS) + static klass* klass::newKlass() CODE: @@ -63,6 +71,9 @@ } OUTPUT: RETVAL +#undef xsp_constructor_class +#define xsp_constructor_class(c) (c) + void klass::Bar() CODE: @@ -76,20 +87,85 @@ croak("Caught C++ exception of unknown type"); } +// method klass::klass + + +// method klass::bar + + +// class klass + === Handle top level directives --- xsp_stdout %module{Foo}; %package{Foo}; %loadplugin{TestParserPlugin}; +%loadplugin{TestNewNodesPlugin}; %MyDirective{Foo}; +%MyComment; --- expected -#include +# XSP preamble MODULE=Foo MODULE=Foo PACKAGE=Foo +// directive MyComment + + // Foo + +=== Handle argument annotations +--- xsp_stdout +%module{Foo}; + +%loadplugin{TestArgumentPlugin}; + +class klass +{ + int bar(int bar, int foo %MyWrap) %MyWrap; +}; +--- expected +# XSP preamble + + +MODULE=Foo + +MODULE=Foo PACKAGE=klass + +int +klass::bar( int bar, int foo ) + CODE: + try { + // wrapped typemap 1; + RETVAL = THIS->bar( bar, foo ); + } + catch (std::exception& e) { + croak("Caught C++ exception of type or derived from 'std::exception': %s", e.what()); + } + catch (...) { + croak("Caught C++ exception of unknown type"); + } + OUTPUT: RETVAL + CLEANUP: + // wrapped typemap ret; + +=== Handle member annotations +--- xsp_stdout +%module{Foo}; + +class klass +{ + int foo; + %name{baz} int bar; +}; +--- expected +# XSP preamble + + +MODULE=Foo + +MODULE=Foo PACKAGE=klass diff -Nru libextutils-xspp-perl-0.1602/t/075_types.t libextutils-xspp-perl-0.1800/t/075_types.t --- libextutils-xspp-perl-0.1602/t/075_types.t 2011-06-03 20:12:10.000000000 +0000 +++ libextutils-xspp-perl-0.1800/t/075_types.t 2013-09-18 08:17:53.000000000 +0000 @@ -19,7 +19,7 @@ int* foo(); int* boo(const int* a); --- expected -#include +# XSP preamble MODULE=Foo @@ -65,7 +65,7 @@ void foo(const std::string a); void boo(const std::string& a); --- expected -#include +# XSP preamble MODULE=Foo @@ -110,7 +110,7 @@ void boo(const std::string& a); void foo2(std::vector a, std::vector& b); --- expected -#include +# XSP preamble MODULE=Foo @@ -169,7 +169,7 @@ void foo(const std::vector& a); void boo(const std::map a); --- expected -#include +# XSP preamble MODULE=Foo @@ -211,7 +211,7 @@ void foo(const std::vector& a); --- expected -#include +# XSP preamble MODULE=Foo diff -Nru libextutils-xspp-perl-0.1602/t/080_complex_typemap.t libextutils-xspp-perl-0.1800/t/080_complex_typemap.t --- libextutils-xspp-perl-0.1602/t/080_complex_typemap.t 2011-06-03 20:12:10.000000000 +0000 +++ libextutils-xspp-perl-0.1800/t/080_complex_typemap.t 2013-09-18 08:17:53.000000000 +0000 @@ -25,7 +25,7 @@ int foo( int a, funnyvoid b ); }; --- expected -#include +# XSP preamble MODULE=Foo @@ -59,7 +59,7 @@ int foo( int a, int b ); }; --- expected -#include +# XSP preamble MODULE=Foo @@ -93,7 +93,7 @@ int foo( int a, int b ); }; --- expected -#include +# XSP preamble MODULE=Foo @@ -128,7 +128,7 @@ int foo( int a, int b ); }; --- expected -#include +# XSP preamble MODULE=Foo @@ -164,7 +164,7 @@ int foo( int a, int b ); }; --- expected -#include +# XSP preamble MODULE=Foo @@ -200,7 +200,7 @@ int foo( int a, int b ); }; --- expected -#include +# XSP preamble MODULE=Foo diff -Nru libextutils-xspp-perl-0.1602/t/090_exceptions.t libextutils-xspp-perl-0.1800/t/090_exceptions.t --- libextutils-xspp-perl-0.1602/t/090_exceptions.t 2011-06-03 20:12:10.000000000 +0000 +++ libextutils-xspp-perl-0.1800/t/090_exceptions.t 2013-09-18 08:17:53.000000000 +0000 @@ -17,7 +17,7 @@ int foo(int a); --- expected -#include +# XSP preamble MODULE=Foo @@ -44,7 +44,7 @@ %catch{myException}; --- expected -#include +# XSP preamble MODULE=Foo @@ -87,7 +87,7 @@ }; --- expected -#include +# XSP preamble MODULE=Foo @@ -169,7 +169,7 @@ %catch{myException}; --- expected -#include +# XSP preamble MODULE=Foo @@ -197,7 +197,7 @@ %catch{myException}; --- expected -#include +# XSP preamble MODULE=Foo @@ -232,7 +232,7 @@ %catch{myException}; --- expected -#include +# XSP preamble MODULE=Foo @@ -274,7 +274,7 @@ }; --- expected -#include +# XSP preamble MODULE=Foo @@ -315,7 +315,7 @@ }; --- expected -#include +# XSP preamble MODULE=Foo @@ -365,7 +365,7 @@ }; --- expected -#include +# XSP preamble MODULE=Foo diff -Nru libextutils-xspp-perl-0.1602/t/lib/ExtUtils/XSpp/Plugin/TestArgumentPlugin.pm libextutils-xspp-perl-0.1800/t/lib/ExtUtils/XSpp/Plugin/TestArgumentPlugin.pm --- libextutils-xspp-perl-0.1602/t/lib/ExtUtils/XSpp/Plugin/TestArgumentPlugin.pm 1970-01-01 00:00:00.000000000 +0000 +++ libextutils-xspp-perl-0.1800/t/lib/ExtUtils/XSpp/Plugin/TestArgumentPlugin.pm 2013-09-18 08:17:53.000000000 +0000 @@ -0,0 +1,70 @@ +package ExtUtils::XSpp::Plugin::TestArgumentPlugin; + +use strict; +use warnings; + +sub new { return bless { directives => [] }, $_[0] } + +sub register_plugin { + my( $class, $parser ) = @_; + my $inst = $class->new; + + $parser->add_method_tag_plugin( plugin => $inst, tag => 'MyWrap' ); + $parser->add_argument_tag_plugin( plugin => $inst, tag => 'MyWrap' ); +} + +sub handle_method_tag { + my( $self, $method, $any_tag, %args ) = @_; + + $method->set_ret_typemap( _wrap_typemap( $method->ret_typemap, 'ret' ) ); + + return 1; +} + +sub handle_argument_tag { + my( $self, $argument, $any_tag, %args ) = @_; + my $function = $argument->function; + + $function->set_arg_typemap + ( $argument->index, _wrap_typemap( $function->arg_typemap( $argument->index ), $argument->index ) ); + + return 1; +} + +sub _wrap_typemap { + my( $typemap, $description ) = @_; + + return ExtUtils::XSpp::Plugin::TestArgumentPlugin::Wrapper->new + ( typemap => $typemap, description => $description ); +} + +package ExtUtils::XSpp::Plugin::TestArgumentPlugin::Wrapper; + +use strict; +use warnings; +use base 'ExtUtils::XSpp::Typemap::wrapper'; + +sub init { + my( $self, %args ) = @_; + $self->SUPER::init( %args ); + + $self->{DESCRIPTION} = $args{description}; +} + +sub precall_code { + my( $self, $pvar, $cvar ) = @_; + my $code = $self->typemap->precall_code( $pvar, $cvar ); + my $add = '// wrapped typemap ' . $self->{DESCRIPTION}; + + return $code ? "$code\n$add" : $add; +} + +sub cleanup_code { + my( $self, $pvar, $cvar ) = @_; + my $code = $self->typemap->cleanup_code( $pvar, $cvar ); + my $add = '// wrapped typemap ' . $self->{DESCRIPTION}; + + return $code ? "$code\n$add" : $add; +} + +1; diff -Nru libextutils-xspp-perl-0.1602/t/lib/ExtUtils/XSpp/Plugin/TestNewNodesPlugin.pm libextutils-xspp-perl-0.1800/t/lib/ExtUtils/XSpp/Plugin/TestNewNodesPlugin.pm --- libextutils-xspp-perl-0.1602/t/lib/ExtUtils/XSpp/Plugin/TestNewNodesPlugin.pm 1970-01-01 00:00:00.000000000 +0000 +++ libextutils-xspp-perl-0.1800/t/lib/ExtUtils/XSpp/Plugin/TestNewNodesPlugin.pm 2013-09-18 08:17:53.000000000 +0000 @@ -0,0 +1,47 @@ +package ExtUtils::XSpp::Plugin::TestNewNodesPlugin; + +use strict; +use warnings; + +sub new { return bless { directives => [] }, $_[0] } + +sub register_plugin { + my( $class, $parser ) = @_; + my $inst = $class->new; + + $parser->add_function_tag_plugin( plugin => $inst, tag => 'MyComment' ); + $parser->add_class_tag_plugin( plugin => $inst, tag => 'MyComment' ); + $parser->add_method_tag_plugin( plugin => $inst, tag => 'MyComment' ); + $parser->add_toplevel_tag_plugin( plugin => $inst, tag => 'MyComment' ); +} + +sub handle_method_tag { + my( $self, $method, $any_tag, %args ) = @_; + + ( 1, ExtUtils::XSpp::Node::Raw->new + ( rows => [ '// method ' . $method->class->cpp_name . + '::' . $method->cpp_name ] ) ); +} + +sub handle_function_tag { + my( $self, $function, $any_tag, %args ) = @_; + + ( 1, ExtUtils::XSpp::Node::Raw->new + ( rows => [ '// function ' . $function->cpp_name ] ) ); +} + +sub handle_class_tag { + my( $self, $class, $any_tag, %args ) = @_; + + ( 1, ExtUtils::XSpp::Node::Raw->new + ( rows => [ '// class ' . $class->cpp_name ] ) ); +} + +sub handle_toplevel_tag { + my( $self, undef, $any_tag, %args ) = @_; + + ( 1, ExtUtils::XSpp::Node::Raw->new + ( rows => [ '// directive ' . $any_tag ] ) ); +} + +1; diff -Nru libextutils-xspp-perl-0.1602/t/lib/ExtUtils/XSpp/Plugin/TestParserPlugin.pm libextutils-xspp-perl-0.1800/t/lib/ExtUtils/XSpp/Plugin/TestParserPlugin.pm --- libextutils-xspp-perl-0.1602/t/lib/ExtUtils/XSpp/Plugin/TestParserPlugin.pm 2011-06-03 20:12:10.000000000 +0000 +++ libextutils-xspp-perl-0.1800/t/lib/ExtUtils/XSpp/Plugin/TestParserPlugin.pm 2013-09-18 08:17:53.000000000 +0000 @@ -19,7 +19,7 @@ sub handle_method_tag { my( $self, $method, $any_tag, %args ) = @_; - my $name = $args{any_positional_arguments}[0]; + my $name = $args{positional}[0]; $method->set_perl_name( $name ); @@ -28,7 +28,7 @@ sub handle_function_tag { my( $self, $function, $any_tag, %args ) = @_; - my $name = $args{any_positional_arguments}[0]; + my $name = $args{positional}[0]; $function->set_perl_name( $name ); @@ -37,7 +37,7 @@ sub handle_class_tag { my( $self, $class, $any_tag, %args ) = @_; - my $name = $args{any_positional_arguments}[0]; + my $name = $args{positional}[0]; $class->set_perl_name( $name ); @@ -46,7 +46,7 @@ sub handle_toplevel_tag { my( $self, undef, $any_tag, %args ) = @_; - my $name = $args{any_positional_arguments}[0]; + my $name = $args{positional}[0]; push @{$self->{directives}}, $name; diff -Nru libextutils-xspp-perl-0.1602/t/lib/XSP/Test.pm libextutils-xspp-perl-0.1800/t/lib/XSP/Test.pm --- libextutils-xspp-perl-0.1602/t/lib/XSP/Test.pm 2011-06-03 20:12:10.000000000 +0000 +++ libextutils-xspp-perl-0.1800/t/lib/XSP/Test.pm 2013-09-18 08:17:53.000000000 +0000 @@ -6,6 +6,7 @@ use Test::Base -Base; use Test::Differences; +use ExtUtils::XSpp::Typemap; our @EXPORT = qw(run_diff); @@ -31,6 +32,7 @@ my $block = shift; my( $b_got, $b_expected ) = map { s/^\n+//s; s/\n+$//s; $_ } $block->$got, $block->$expected; + eq_or_diff( $b_got, $b_expected, $block->name); }; } @@ -51,21 +53,39 @@ return shift @random_digits; } +sub _munge_output($) { + my $b_got = $_[0]; + + # This removes the default typemap entry that is added for O_OBJECT + # I admit that it doesn't make me feel all warm and fuzzy inside, but + # the alternative of having even more code duplicated a lot of times in + # all test files isn't any better. + $b_got =~ s/^INPUT\s*\n.*^OUTPUT\s*\n.*^END\s*\n/END\n/sm; + # remove some more repetitive preamble code + $b_got =~ s|^#include \n.*?^#define xsp_constructor_class.*?\n|# XSP preamble\n|sm; + + return $b_got; +} + sub xsp_stdout { + ExtUtils::XSpp::Typemap::reset_typemaps(); @random_digits = @random_list; my $d = ExtUtils::XSpp::Driver->new( string => shift ); my $out = $d->generate; + ExtUtils::XSpp::Typemap::reset_typemaps(); - return $out->{'-'}; + return _munge_output( $out->{'-'} ); } sub xsp_file { + ExtUtils::XSpp::Typemap::reset_typemaps(); @random_digits = @random_list; my $name = Test::Base::filter_arguments(); my $d = ExtUtils::XSpp::Driver->new( string => shift ); my $out = $d->generate; + ExtUtils::XSpp::Typemap::reset_typemaps(); - return $out->{$name}; + return _munge_output( $out->{$name} ); } 1;