lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@apache.org
Subject [lucy-commits] svn commit: r1179341 - in /incubator/lucy/branches/clownfish_lemon/clownfish: lib/Clownfish.xs lib/Clownfish/Parser.pm src/CFCParser.c src/CFCParser.h t/600-parser.t
Date Wed, 05 Oct 2011 17:32:31 GMT
Author: marvin
Date: Wed Oct  5 17:32:31 2011
New Revision: 1179341

URL: http://svn.apache.org/viewvc?rev=1179341&view=rev
Log:
Move storage of current parcel to C.

Modified:
    incubator/lucy/branches/clownfish_lemon/clownfish/lib/Clownfish.xs
    incubator/lucy/branches/clownfish_lemon/clownfish/lib/Clownfish/Parser.pm
    incubator/lucy/branches/clownfish_lemon/clownfish/src/CFCParser.c
    incubator/lucy/branches/clownfish_lemon/clownfish/src/CFCParser.h
    incubator/lucy/branches/clownfish_lemon/clownfish/t/600-parser.t

Modified: incubator/lucy/branches/clownfish_lemon/clownfish/lib/Clownfish.xs
URL: http://svn.apache.org/viewvc/incubator/lucy/branches/clownfish_lemon/clownfish/lib/Clownfish.xs?rev=1179341&r1=1179340&r2=1179341&view=diff
==============================================================================
--- incubator/lucy/branches/clownfish_lemon/clownfish/lib/Clownfish.xs (original)
+++ incubator/lucy/branches/clownfish_lemon/clownfish/lib/Clownfish.xs Wed Oct  5 17:32:31
2011
@@ -2068,3 +2068,18 @@ CODE:
     RETVAL = S_cfcbase_to_perlref(got);
 OUTPUT: RETVAL
 
+void
+set_parcel(unused, parcel)
+    SV *unused;
+    CFCParcel *parcel;
+PPCODE:
+    CFCParser_set_parcel(parcel);
+
+SV*
+get_parcel(...)
+CODE:
+    CFCParcel *parcel = CFCParser_get_parcel();
+    RETVAL = S_cfcbase_to_perlref((CFCBase*)parcel);
+OUTPUT: RETVAL
+
+

Modified: incubator/lucy/branches/clownfish_lemon/clownfish/lib/Clownfish/Parser.pm
URL: http://svn.apache.org/viewvc/incubator/lucy/branches/clownfish_lemon/clownfish/lib/Clownfish/Parser.pm?rev=1179341&r1=1179340&r2=1179341&view=diff
==============================================================================
--- incubator/lucy/branches/clownfish_lemon/clownfish/lib/Clownfish/Parser.pm (original)
+++ incubator/lucy/branches/clownfish_lemon/clownfish/lib/Clownfish/Parser.pm Wed Oct  5 17:32:31
2011
@@ -332,9 +332,6 @@ sub strip_plain_comments {
     return $text;
 }
 
-our $parcel = undef;
-sub set_parcel { $parcel = $_[1] }
-
 sub new_integer_type {
     my ( undef, $item ) = @_;
     my $specifier = $item->{c_integer_specifier}
@@ -362,7 +359,7 @@ sub new_arbitrary_type {
     my ( undef, $item ) = @_;
     return Clownfish::Type->new_arbitrary(
         specifier => $item->{arbitrary_type_specifier},
-        parcel    => $parcel,
+        parcel    => get_parcel(),
     );
 }
 
@@ -370,7 +367,7 @@ sub new_object_type {
     my ( undef, $item ) = @_;
     my %args = (
         specifier => $item->{object_type_specifier},
-        parcel    => $parcel,
+        parcel    => get_parcel(),
     );
     $args{$_} = 1 for @{ $item->{'type_qualifier(s?)'} };
     return Clownfish::Type->new_object(%args);
@@ -420,7 +417,7 @@ sub new_var {
         $args{class_cnick} = $arg->{cnick} if $arg->{cnick};
     }
     return Clownfish::Variable->new(
-        parcel    => $parcel,
+        parcel    => get_parcel(),
         type      => $item->{type},
         micro_sym => $item->{declarator},
         %args,
@@ -458,7 +455,7 @@ sub new_sub {
     }
 
     return $class->new(
-        parcel      => $parcel,
+        parcel      => get_parcel(),
         docucomment => $docucom,
         class_name  => $arg->{class},
         class_cnick => $arg->{cnick},
@@ -494,7 +491,7 @@ sub new_class {
     }
 
     my $class = Clownfish::Class->create(
-        parcel            => $parcel,
+        parcel            => get_parcel(),
         class_name        => $item->{class_name},
         cnick             => $item->{'cnick(?)'}[0],
         parent_class_name => $item->{'class_inheritance(?)'}[0],

Modified: incubator/lucy/branches/clownfish_lemon/clownfish/src/CFCParser.c
URL: http://svn.apache.org/viewvc/incubator/lucy/branches/clownfish_lemon/clownfish/src/CFCParser.c?rev=1179341&r1=1179340&r2=1179341&view=diff
==============================================================================
--- incubator/lucy/branches/clownfish_lemon/clownfish/src/CFCParser.c (original)
+++ incubator/lucy/branches/clownfish_lemon/clownfish/src/CFCParser.c Wed Oct  5 17:32:31
2011
@@ -20,6 +20,7 @@
 #define CFC_NEED_BASE_STRUCT_DEF
 #include "CFCBase.h"
 #include "CFCParser.h"
+#include "CFCParcel.h"
 #include "CFCUtil.h"
 #include "CFCLexHeader.h"
 #include "CFCParseHeader.h"
@@ -70,6 +71,7 @@ CFCParser_destroy(CFCParser *self) {
 static CFCParserState state;
 CFCParserState *CFCParser_current_state  = &state;
 void           *CFCParser_current_parser = NULL;
+CFCParcel      *CFCParser_current_parcel = NULL;
 
 CFCBase*
 CFCParser_parse(CFCParser *self, const char *string) {
@@ -91,3 +93,15 @@ CFCParser_parse(CFCParser *self, const c
     return state.result;
 }
 
+void
+CFCParser_set_parcel(CFCParcel *parcel) {
+    CFCBase_incref((CFCBase*)parcel);
+    CFCBase_decref((CFCBase*)CFCParser_current_parcel);
+    CFCParser_current_parcel = parcel;
+}
+
+CFCParcel*
+CFCParser_get_parcel(void) {
+    return CFCParser_current_parcel;
+}
+

Modified: incubator/lucy/branches/clownfish_lemon/clownfish/src/CFCParser.h
URL: http://svn.apache.org/viewvc/incubator/lucy/branches/clownfish_lemon/clownfish/src/CFCParser.h?rev=1179341&r1=1179340&r2=1179341&view=diff
==============================================================================
--- incubator/lucy/branches/clownfish_lemon/clownfish/src/CFCParser.h (original)
+++ incubator/lucy/branches/clownfish_lemon/clownfish/src/CFCParser.h Wed Oct  5 17:32:31
2011
@@ -23,6 +23,7 @@ extern "C" {
 
 typedef struct CFCParser CFCParser;
 struct CFCBase;
+struct CFCParcel;
 
 struct CFCParserState 
 {
@@ -48,6 +49,13 @@ CFCParser_destroy(CFCParser *self);
 struct CFCBase*
 CFCParser_parse(CFCParser *self, const char *string);
 
+
+void
+CFCParser_set_parcel(struct CFCParcel *parcel);
+
+struct CFCParcel*
+CFCParser_get_parcel(void);
+
 #ifdef __cplusplus
 }
 #endif

Modified: incubator/lucy/branches/clownfish_lemon/clownfish/t/600-parser.t
URL: http://svn.apache.org/viewvc/incubator/lucy/branches/clownfish_lemon/clownfish/t/600-parser.t?rev=1179341&r1=1179340&r2=1179341&view=diff
==============================================================================
--- incubator/lucy/branches/clownfish_lemon/clownfish/t/600-parser.t (original)
+++ incubator/lucy/branches/clownfish_lemon/clownfish/t/600-parser.t Wed Oct  5 17:32:31 2011
@@ -31,7 +31,7 @@ isa_ok( $parser->parcel_definition("parc
 # Set and leave parcel.
 my $parcel = $parser->parcel_definition('parcel Crustacean cnick Crust;')
     or die "failed to process parcel_definition";
-is( $Clownfish::Parser::parcel, $parcel,
+is( Clownfish::Parser->get_parcel, $parcel,
     "parcel_definition sets internal \$parcel var" );
 
 is( $parser->strip_plain_comments("/*x*/"),



Mime
View raw message