Move parcel field from CFCSymbol to CFCClass
Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/ad6e0898 Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/ad6e0898 Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/ad6e0898 Branch: refs/heads/master Commit: ad6e08984c09aeb9664f44170135ea4fb5d9734a Parents: 3ef6577 Author: Nick Wellnhofer <[email protected]> Authored: Sun Jul 27 01:21:50 2014 +0200 Committer: Nick Wellnhofer <[email protected]> Committed: Thu May 7 21:19:37 2015 +0200 ---------------------------------------------------------------------- compiler/perl/lib/Clownfish/CFC.pm | 26 ++++---------- compiler/perl/lib/Clownfish/CFC.xs | 48 ++++++------------------- compiler/perl/t/051-symbol.t | 18 ++-------- compiler/perl/t/200-function.t | 1 - compiler/perl/t/201-method.t | 1 - compiler/perl/t/202-overridden_method.t | 1 - compiler/perl/t/203-final_method.t | 1 - compiler/perl/t/300-variable.t | 20 ++++------- compiler/perl/t/401-class.t | 3 -- compiler/perl/t/403-parcel.t | 11 +----- compiler/src/CFCCHtml.c | 7 ++-- compiler/src/CFCCallable.c | 5 ++- compiler/src/CFCCallable.h | 9 ++--- compiler/src/CFCClass.c | 14 +++++--- compiler/src/CFCClass.h | 2 +- compiler/src/CFCFunction.c | 16 ++++----- compiler/src/CFCFunction.h | 12 +++---- compiler/src/CFCGoClass.c | 2 +- compiler/src/CFCGoMethod.c | 8 ++--- compiler/src/CFCGoMethod.h | 2 +- compiler/src/CFCMethod.c | 54 ++++++++-------------------- compiler/src/CFCMethod.h | 23 +++--------- compiler/src/CFCParseHeader.y | 14 ++++---- compiler/src/CFCSymbol.c | 33 +++-------------- compiler/src/CFCSymbol.h | 27 ++------------ compiler/src/CFCTestClass.c | 7 ++-- compiler/src/CFCTestFunction.c | 5 ++- compiler/src/CFCTestMethod.c | 42 +++++++++++----------- compiler/src/CFCTestParcel.c | 11 +----- compiler/src/CFCTestSymbol.c | 53 +++++---------------------- compiler/src/CFCTestVariable.c | 11 +++--- compiler/src/CFCVariable.c | 16 ++++----- compiler/src/CFCVariable.h | 15 ++++---- 33 files changed, 146 insertions(+), 372 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/ad6e0898/compiler/perl/lib/Clownfish/CFC.pm ---------------------------------------------------------------------- diff --git a/compiler/perl/lib/Clownfish/CFC.pm b/compiler/perl/lib/Clownfish/CFC.pm index b714adb..21d41ed 100644 --- a/compiler/perl/lib/Clownfish/CFC.pm +++ b/compiler/perl/lib/Clownfish/CFC.pm @@ -219,7 +219,6 @@ BEGIN { XSLoader::load( 'Clownfish::CFC', '0.4.0' ) } param_list => undef, name => undef, docucomment => undef, - parcel => undef, inline => undef, exposure => undef, ); @@ -229,12 +228,10 @@ BEGIN { XSLoader::load( 'Clownfish::CFC', '0.4.0' ) } confess "no subclassing allowed" unless $either eq __PACKAGE__; verify_args( \%new_PARAMS, %args ) or confess $@; $args{inline} ||= 0; - $args{parcel} - = Clownfish::CFC::Model::Parcel->acquire( $args{parcel} ); return _new( @args{ - qw( parcel exposure class_name name return_type param_list - docucomment inline ) + qw( exposure class_name name return_type param_list docucomment + inline ) } ); } @@ -303,7 +300,6 @@ BEGIN { XSLoader::load( 'Clownfish::CFC', '0.4.0' ) } param_list => undef, name => undef, docucomment => undef, - parcel => undef, abstract => undef, final => undef, exposure => 'parcel', @@ -314,13 +310,11 @@ BEGIN { XSLoader::load( 'Clownfish::CFC', '0.4.0' ) } verify_args( \%new_PARAMS, %args ) or confess $@; confess "no subclassing allowed" unless $either eq __PACKAGE__; $args{abstract} ||= 0; - $args{parcel} - = Clownfish::CFC::Model::Parcel->acquire( $args{parcel} ); - $args{final} ||= 0; + $args{final} ||= 0; return _new( @args{ - qw( parcel exposure class_name name return_type param_list - docucomment final abstract ) + qw( exposure class_name name return_type param_list docucomment + final abstract ) } ); } @@ -452,7 +446,6 @@ BEGIN { XSLoader::load( 'Clownfish::CFC', '0.4.0' ) } use Carp; my %new_PARAMS = ( - parcel => undef, exposure => undef, class_name => undef, name => undef, @@ -462,10 +455,8 @@ BEGIN { XSLoader::load( 'Clownfish::CFC', '0.4.0' ) } my ( $either, %args ) = @_; verify_args( \%new_PARAMS, %args ) or confess $@; confess "no subclassing allowed" unless $either eq __PACKAGE__; - $args{parcel} - = Clownfish::CFC::Model::Parcel->acquire( $args{parcel} ); return _new( - @args{qw( parcel exposure class_name name )} ); + @args{qw( exposure class_name name )} ); } } @@ -635,7 +626,6 @@ BEGIN { XSLoader::load( 'Clownfish::CFC', '0.4.0' ) } our %new_PARAMS = ( type => undef, name => undef, - parcel => undef, exposure => 'local', class_name => undef, inert => undef, @@ -646,11 +636,9 @@ BEGIN { XSLoader::load( 'Clownfish::CFC', '0.4.0' ) } confess "no subclassing allowed" unless $either eq __PACKAGE__; verify_args( \%new_PARAMS, %args ) or confess $@; $args{exposure} ||= 'local'; - $args{parcel} - = Clownfish::CFC::Model::Parcel->acquire( $args{parcel} ); return _new( @args{ - qw( parcel exposure class_name name type inert ) + qw( exposure class_name name type inert ) } ); } http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/ad6e0898/compiler/perl/lib/Clownfish/CFC.xs ---------------------------------------------------------------------- diff --git a/compiler/perl/lib/Clownfish/CFC.xs b/compiler/perl/lib/Clownfish/CFC.xs index 524c5c9..0d0d83c 100644 --- a/compiler/perl/lib/Clownfish/CFC.xs +++ b/compiler/perl/lib/Clownfish/CFC.xs @@ -637,8 +637,7 @@ PPCODE: MODULE = Clownfish::CFC PACKAGE = Clownfish::CFC::Model::Function SV* -_new(parcel, exposure_sv, class_name_sv, name_sv, return_type, param_list, docucomment, is_inline) - CFCParcel *parcel; +_new(exposure_sv, class_name_sv, name_sv, return_type, param_list, docucomment, is_inline) SV *exposure_sv; SV *class_name_sv; SV *name_sv; @@ -654,8 +653,8 @@ CODE: const char *name = SvOK(name_sv) ? SvPV_nolen(name_sv) : NULL; CFCFunction *self - = CFCFunction_new(parcel, exposure, class_name, name, return_type, - param_list, docucomment, is_inline); + = CFCFunction_new(exposure, class_name, name, return_type, param_list, + docucomment, is_inline); RETVAL = S_cfcbase_to_perlref(self); CFCBase_decref((CFCBase*)self); OUTPUT: RETVAL @@ -819,8 +818,7 @@ PPCODE: MODULE = Clownfish::CFC PACKAGE = Clownfish::CFC::Model::Method SV* -_new(parcel, exposure_sv, class_name_sv, name, return_type, param_list, docucomment, is_final, is_abstract) - CFCParcel *parcel; +_new(exposure_sv, class_name_sv, name, return_type, param_list, docucomment, is_final, is_abstract) SV *exposure_sv; SV *class_name_sv; const char *name; @@ -835,8 +833,8 @@ CODE: const char *class_name = SvOK(class_name_sv) ? SvPV_nolen(class_name_sv) : NULL; CFCMethod *self - = CFCMethod_new(parcel, exposure, class_name, name, return_type, - param_list, docucomment, is_final, is_abstract); + = CFCMethod_new(exposure, class_name, name, return_type, param_list, + docucomment, is_final, is_abstract); RETVAL = S_cfcbase_to_perlref(self); CFCBase_decref((CFCBase*)self); OUTPUT: RETVAL @@ -1277,8 +1275,7 @@ PPCODE: MODULE = Clownfish::CFC PACKAGE = Clownfish::CFC::Model::Symbol SV* -_new(parcel, exposure, class_name_sv, name_sv) - CFCParcel *parcel; +_new(exposure, class_name_sv, name_sv) const char *exposure; SV *class_name_sv; SV *name_sv; @@ -1290,7 +1287,7 @@ CODE: ? SvPV_nolen(name_sv) : NULL; CFCSymbol *self - = CFCSymbol_new(parcel, exposure, class_name, name); + = CFCSymbol_new(exposure, class_name, name); RETVAL = S_cfcbase_to_perlref(self); CFCBase_decref((CFCBase*)self); OUTPUT: RETVAL @@ -1328,13 +1325,9 @@ void _set_or_get(self, ...) CFCSymbol *self; ALIAS: - get_parcel = 2 get_class_name = 4 get_exposure = 8 get_name = 10 - get_prefix = 12 - get_Prefix = 14 - get_PREFIX = 16 public = 18 private = 20 parcel = 22 @@ -1342,11 +1335,6 @@ ALIAS: PPCODE: { START_SET_OR_GET_SWITCH - case 2: { - struct CFCParcel *parcel = CFCSymbol_get_parcel(self); - retval = S_cfcbase_to_perlref(parcel); - } - break; case 4: { const char *class_name = CFCSymbol_get_class_name(self); retval = class_name @@ -1364,21 +1352,6 @@ PPCODE: retval = newSVpvn(name, strlen(name)); } break; - case 12: { - const char *value = CFCSymbol_get_prefix(self); - retval = newSVpvn(value, strlen(value)); - } - break; - case 14: { - const char *value = CFCSymbol_get_Prefix(self); - retval = newSVpvn(value, strlen(value)); - } - break; - case 16: { - const char *value = CFCSymbol_get_PREFIX(self); - retval = newSVpvn(value, strlen(value)); - } - break; case 18: retval = newSViv(CFCSymbol_public(self)); break; @@ -1770,8 +1743,7 @@ OUTPUT: RETVAL MODULE = Clownfish::CFC PACKAGE = Clownfish::CFC::Model::Variable SV* -_new(parcel, exposure, class_name_sv, name_sv, type_sv, inert_sv) - CFCParcel *parcel; +_new(exposure, class_name_sv, name_sv, type_sv, inert_sv) const char *exposure; SV *class_name_sv; SV *name_sv; @@ -1795,7 +1767,7 @@ CODE: croak("Param 'type' is not a Clownfish::CFC::Model::Type"); } CFCVariable *self - = CFCVariable_new(parcel, exposure, class_name, name, type, inert); + = CFCVariable_new(exposure, class_name, name, type, inert); RETVAL = S_cfcbase_to_perlref(self); CFCBase_decref((CFCBase*)self); OUTPUT: RETVAL http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/ad6e0898/compiler/perl/t/051-symbol.t ---------------------------------------------------------------------- diff --git a/compiler/perl/t/051-symbol.t b/compiler/perl/t/051-symbol.t index bd08450..b8dabad 100644 --- a/compiler/perl/t/051-symbol.t +++ b/compiler/perl/t/051-symbol.t @@ -16,7 +16,7 @@ use strict; use warnings; -use Test::More tests => 39; +use Test::More tests => 34; use Clownfish::CFC; my $parcel = Clownfish::CFC::Model::Parcel->new( name => 'Eep' ); @@ -48,16 +48,6 @@ ok( !$public_exposure->equals($parcel_exposure), "different exposure spoils equals" ); -my $lucifer_parcel = Clownfish::CFC::Model::Parcel->new( name => 'Lucifer' ); -$lucifer_parcel->register; -my $lucifer = new_symbol( parcel => 'Lucifer' ); -ok( $$lucifer_parcel == ${ $lucifer->get_parcel }, "derive parcel" ); -is( $lucifer->get_prefix, "lucifer_", "get_prefix" ); -is( $lucifer->get_Prefix, "Lucifer_", "get_Prefix" ); -is( $lucifer->get_PREFIX, "LUCIFER_", "get_PREFIX" ); -my $luser = new_symbol( parcel => 'Luser' ); -ok( !$lucifer->equals($luser), "different parcel spoils equals" ); - for ( qw( 1foo * 0 ), "\x{263a}" ) { eval { my $thing = new_symbol( name => $_ ); }; like( $@, qr/name/, "reject bad name" ); @@ -68,7 +58,6 @@ my $booga = new_symbol( name => 'booga' ); ok( !$ooga->equals($booga), "Different name spoils equals()" ); my $eep = new_symbol( - parcel => 'Eep', class_name => "Op::Ork", name => 'ah_ah', ); @@ -81,9 +70,8 @@ is( $eep->full_sym($ork), "eep_Ork_ah_ah", "full_sym" ); sub new_symbol { return Clownfish::CFC::Model::Symbol->new( - parcel => $parcel, - name => 'sym', - exposure => 'parcel', + name => 'sym', + exposure => 'parcel', @_ ); } http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/ad6e0898/compiler/perl/t/200-function.t ---------------------------------------------------------------------- diff --git a/compiler/perl/t/200-function.t b/compiler/perl/t/200-function.t index 1384a7d..5a04a30 100644 --- a/compiler/perl/t/200-function.t +++ b/compiler/perl/t/200-function.t @@ -27,7 +27,6 @@ $parser->parse('parcel Neato;') or die "failed to process parcel_definition"; my %args = ( - parcel => 'Neato', return_type => $parser->parse('Obj*'), class_name => 'Neato::Foo', param_list => $parser->parse('(int32_t some_num)'), http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/ad6e0898/compiler/perl/t/201-method.t ---------------------------------------------------------------------- diff --git a/compiler/perl/t/201-method.t b/compiler/perl/t/201-method.t index 8af24d7..66fbc3e 100644 --- a/compiler/perl/t/201-method.t +++ b/compiler/perl/t/201-method.t @@ -26,7 +26,6 @@ $parser->parse('parcel Neato;') or die "failed to process parcel_definition"; my %args = ( - parcel => 'Neato', return_type => $parser->parse('Obj*'), class_name => 'Neato::Foo', param_list => $parser->parse('(Foo *self, int32_t count = 0)'), http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/ad6e0898/compiler/perl/t/202-overridden_method.t ---------------------------------------------------------------------- diff --git a/compiler/perl/t/202-overridden_method.t b/compiler/perl/t/202-overridden_method.t index 792a08a..c33c928 100644 --- a/compiler/perl/t/202-overridden_method.t +++ b/compiler/perl/t/202-overridden_method.t @@ -30,7 +30,6 @@ my %args = ( class_name => 'Neato::Foo', param_list => $parser->parse('(Foo *self)'), name => 'Return_An_Obj', - parcel => 'Neato', ); my $orig = Clownfish::CFC::Model::Method->new(%args); http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/ad6e0898/compiler/perl/t/203-final_method.t ---------------------------------------------------------------------- diff --git a/compiler/perl/t/203-final_method.t b/compiler/perl/t/203-final_method.t index 5122ba5..ea98ca5 100644 --- a/compiler/perl/t/203-final_method.t +++ b/compiler/perl/t/203-final_method.t @@ -29,7 +29,6 @@ my %args = ( class_name => 'Neato::Foo', param_list => $parser->parse('(Foo* self)'), name => 'Return_An_Obj', - parcel => 'Neato', ); my $not_final_method = Clownfish::CFC::Model::Method->new(%args); http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/ad6e0898/compiler/perl/t/300-variable.t ---------------------------------------------------------------------- diff --git a/compiler/perl/t/300-variable.t b/compiler/perl/t/300-variable.t index 2ab2d62..86029b2 100644 --- a/compiler/perl/t/300-variable.t +++ b/compiler/perl/t/300-variable.t @@ -28,7 +28,6 @@ sub new_type { $parser->parse(shift) } eval { my $death = Clownfish::CFC::Model::Variable->new( - parcel => $parcel, name => 'foo', type => new_type('int'), extra_arg => undef, @@ -37,24 +36,19 @@ eval { like( $@, qr/extra_arg/, "Extra arg kills constructor" ); eval { - my $death = Clownfish::CFC::Model::Variable->new( - parcel => $parcel, - name => 'foo', - ); + my $death = Clownfish::CFC::Model::Variable->new( name => 'foo' ); }; like( $@, qr/type/, "type is required" ); eval { my $death = Clownfish::CFC::Model::Variable->new( - parcel => $parcel, - type => new_type('int32_t'), + type => new_type('int32_t'), ); }; like( $@, qr/name/, "name is required" ); my $var = Clownfish::CFC::Model::Variable->new( - parcel => $parcel, - name => 'foo', - type => new_type('float*') + name => 'foo', + type => new_type('float*'), ); $var->resolve_type; is( $var->local_c, 'float* foo', "local_c" ); @@ -62,9 +56,8 @@ is( $var->local_declaration, 'float* foo;', "declaration" ); ok( $var->local, "default to local access" ); $var = Clownfish::CFC::Model::Variable->new( - parcel => $parcel, - name => 'foo', - type => new_type('float[1]') + name => 'foo', + type => new_type('float[1]'), ); $var->resolve_type; is( $var->local_c, 'float foo[1]', @@ -75,7 +68,6 @@ my $lobclaw_class = $parser->parse( "class Crustacean::Lobster::LobsterClaw nickname LobClaw {}", ); $var = Clownfish::CFC::Model::Variable->new( - parcel => 'Neato', name => 'foo', type => new_type("Foo*"), class_name => 'Crustacean::Lobster::LobsterClaw', http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/ad6e0898/compiler/perl/t/401-class.t ---------------------------------------------------------------------- diff --git a/compiler/perl/t/401-class.t b/compiler/perl/t/401-class.t index 3560dae..5380f1a 100644 --- a/compiler/perl/t/401-class.t +++ b/compiler/perl/t/401-class.t @@ -24,19 +24,16 @@ my $parser = Clownfish::CFC::Parser->new; $parser->parse('parcel Neato;'); my $thing = Clownfish::CFC::Model::Variable->new( - parcel => 'Neato', class_name => 'Foo', type => $parser->parse('Thing*'), name => 'thing', ); my $widget = Clownfish::CFC::Model::Variable->new( - parcel => 'Neato', class_name => 'Widget', type => $parser->parse('Widget*'), name => 'widget', ); my $tread_water = Clownfish::CFC::Model::Function->new( - parcel => 'Neato', class_name => 'Foo', return_type => $parser->parse('void'), name => 'tread_water', http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/ad6e0898/compiler/perl/t/403-parcel.t ---------------------------------------------------------------------- diff --git a/compiler/perl/t/403-parcel.t b/compiler/perl/t/403-parcel.t index 1fd29a3..263e602 100644 --- a/compiler/perl/t/403-parcel.t +++ b/compiler/perl/t/403-parcel.t @@ -16,7 +16,7 @@ use strict; use warnings; -use Test::More tests => 38; +use Test::More tests => 35; use File::Spec::Functions qw( catfile ); BEGIN { use_ok('Clownfish::CFC::Model::Prereq') } @@ -101,15 +101,6 @@ my $parcel = Clownfish::CFC::Model::Parcel->new( $parcel->register; is( $parcel->get_version->get_vstring, 'v0', "get_version" ); -my $thing = Clownfish::CFC::Model::Symbol->new( - name => 'sym', - parcel => 'Crustacean', - exposure => 'parcel' -); -is( $thing->get_prefix, 'crust_', 'get_prefix with parcel' ); -is( $thing->get_Prefix, 'Crust_', 'get_Prefix with parcel' ); -is( $thing->get_PREFIX, 'CRUST_', 'get_PREFIx with parcel' ); - Clownfish::CFC::Model::Parcel->reap_singletons(); { http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/ad6e0898/compiler/src/CFCCHtml.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCCHtml.c b/compiler/src/CFCCHtml.c index 9cb680c..33ddd6e 100644 --- a/compiler/src/CFCCHtml.c +++ b/compiler/src/CFCCHtml.c @@ -489,6 +489,7 @@ S_html_create_description(CFCClass *klass) { static char* S_html_create_functions(CFCClass *klass) { CFCFunction **functions = CFCClass_functions(klass); + const char *prefix = CFCClass_get_prefix(klass); char *result = CFCUtil_strdup(""); for (int func_num = 0; functions[func_num] != NULL; func_num++) { @@ -503,9 +504,6 @@ S_html_create_functions(CFCClass *klass) { result = CFCUtil_cat(result, "<dt id=\"func_", name, "\">", name, "</dt>\n", NULL); - CFCParcel *parcel = CFCSymbol_get_parcel((CFCSymbol*)func); - const char *prefix = CFCParcel_get_prefix(parcel); - char *short_sym = CFCFunction_short_func_sym(func, klass); char *func_html = S_html_create_func(klass, func, prefix, short_sym); result = CFCUtil_cat(result, func_html, NULL); @@ -565,6 +563,7 @@ S_html_create_methods(CFCClass *klass) { static char* S_html_create_fresh_methods(CFCClass *klass, CFCClass *ancestor) { CFCMethod **fresh_methods = CFCClass_fresh_methods(klass); + const char *prefix = CFCClass_get_prefix(klass); const char *ancestor_name = CFCClass_get_class_name(ancestor); char *result = CFCUtil_strdup(""); @@ -594,8 +593,6 @@ S_html_create_fresh_methods(CFCClass *klass, CFCClass *ancestor) { } result = CFCUtil_cat(result, "</dt>\n", NULL); - CFCParcel *parcel = CFCSymbol_get_parcel((CFCSymbol*)method); - const char *prefix = CFCParcel_get_PREFIX(parcel); char *short_sym = CFCMethod_short_method_sym(method, klass); char *method_html = S_html_create_func(klass, (CFCFunction*)method, prefix, short_sym); http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/ad6e0898/compiler/src/CFCCallable.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCCallable.c b/compiler/src/CFCCallable.c index 4ab581e..a4f0e8d 100644 --- a/compiler/src/CFCCallable.c +++ b/compiler/src/CFCCallable.c @@ -25,7 +25,6 @@ #define CFC_NEED_CALLABLE_STRUCT_DEF #include "CFCCallable.h" #include "CFCClass.h" -#include "CFCParcel.h" #include "CFCType.h" #include "CFCParamList.h" #include "CFCVariable.h" @@ -39,7 +38,7 @@ static const CFCMeta CFCCALLABLE_META = { }; CFCCallable* -CFCCallable_init(CFCCallable *self, CFCParcel *parcel, const char *exposure, +CFCCallable_init(CFCCallable *self, const char *exposure, const char *class_name, const char *name, CFCType *return_type, CFCParamList *param_list, CFCDocuComment *docucomment) { @@ -48,7 +47,7 @@ CFCCallable_init(CFCCallable *self, CFCParcel *parcel, const char *exposure, CFCUTIL_NULL_CHECK(class_name); CFCUTIL_NULL_CHECK(return_type); CFCUTIL_NULL_CHECK(param_list); - CFCSymbol_init((CFCSymbol*)self, parcel, exposure, class_name, name); + CFCSymbol_init((CFCSymbol*)self, exposure, class_name, name); self->return_type = (CFCType*)CFCBase_incref((CFCBase*)return_type); self->param_list = (CFCParamList*)CFCBase_incref((CFCBase*)param_list); self->docucomment = (CFCDocuComment*)CFCBase_incref((CFCBase*)docucomment); http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/ad6e0898/compiler/src/CFCCallable.h ---------------------------------------------------------------------- diff --git a/compiler/src/CFCCallable.h b/compiler/src/CFCCallable.h index 0a68e82..9bab598 100644 --- a/compiler/src/CFCCallable.h +++ b/compiler/src/CFCCallable.h @@ -25,7 +25,6 @@ extern "C" { #endif typedef struct CFCCallable CFCCallable; -struct CFCParcel; struct CFCType; struct CFCDocuComment; struct CFCParamList; @@ -43,7 +42,6 @@ struct CFCCallable { #endif /** - * @param parcel A Clownfish::CFC::Model::Parcel. * @param exposure The callable's exposure (see * L<Clownfish::CFC::Model::Symbol>). * @param class_name The full name of the class in whose namespace the @@ -57,10 +55,9 @@ struct CFCCallable { * callable. */ CFCCallable* -CFCCallable_init(CFCCallable *self, struct CFCParcel *parcel, - const char *exposure, const char *class_name, - const char *name, struct CFCType *return_type, - struct CFCParamList *param_list, +CFCCallable_init(CFCCallable *self, const char *exposure, + const char *class_name, const char *name, + struct CFCType *return_type, struct CFCParamList *param_list, struct CFCDocuComment *docucomment); void http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/ad6e0898/compiler/src/CFCClass.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCClass.c b/compiler/src/CFCClass.c index 192723f..eb2ba7c 100644 --- a/compiler/src/CFCClass.c +++ b/compiler/src/CFCClass.c @@ -49,6 +49,7 @@ S_register(CFCClass *self); struct CFCClass { CFCSymbol symbol; + struct CFCParcel *parcel; char *nickname; int tree_grown; CFCDocuComment *docucomment; @@ -138,6 +139,7 @@ CFCClass_do_create(CFCClass *self, struct CFCParcel *parcel, CFCDocuComment *docucomment, CFCFileSpec *file_spec, const char *parent_class_name, int is_final, int is_inert, int is_abstract) { + CFCUTIL_NULL_CHECK(parcel); CFCUTIL_NULL_CHECK(class_name); exposure = exposure ? exposure : "parcel"; name = name ? name : "class"; @@ -166,13 +168,14 @@ CFCClass_do_create(CFCClass *self, struct CFCParcel *parcel, CFCUtil_die("Invalid nickname: '%s'", real_nickname); } - CFCSymbol_init((CFCSymbol*)self, parcel, exposure, class_name, name); + CFCSymbol_init((CFCSymbol*)self, exposure, class_name, name); if (!is_inert && !parent_class_name && strcmp(class_name, "Clownfish::Obj") != 0 ) { parent_class_name = "Clownfish::Obj"; } + self->parcel = (CFCParcel*)CFCBase_incref((CFCBase*)parcel); self->nickname = CFCUtil_strdup(real_nickname); self->tree_grown = false; self->parent = NULL; @@ -273,6 +276,7 @@ S_free_cfcbase_array(CFCBase **array) { void CFCClass_destroy(CFCClass *self) { + CFCBase_decref((CFCBase*)self->parcel); FREEMEM(self->nickname); CFCBase_decref((CFCBase*)self->docucomment); CFCBase_decref((CFCBase*)self->parent); @@ -875,17 +879,17 @@ CFCClass_get_docucomment(CFCClass *self) { const char* CFCClass_get_prefix(CFCClass *self) { - return CFCSymbol_get_prefix((CFCSymbol*)self); + return CFCParcel_get_prefix(self->parcel); } const char* CFCClass_get_Prefix(CFCClass *self) { - return CFCSymbol_get_Prefix((CFCSymbol*)self); + return CFCParcel_get_Prefix(self->parcel); } const char* CFCClass_get_PREFIX(CFCClass *self) { - return CFCSymbol_get_PREFIX((CFCSymbol*)self); + return CFCParcel_get_PREFIX(self->parcel); } const char* @@ -895,6 +899,6 @@ CFCClass_get_class_name(CFCClass *self) { CFCParcel* CFCClass_get_parcel(CFCClass *self) { - return CFCSymbol_get_parcel((CFCSymbol*)self); + return self->parcel; } http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/ad6e0898/compiler/src/CFCClass.h ---------------------------------------------------------------------- diff --git a/compiler/src/CFCClass.h b/compiler/src/CFCClass.h index a027242..a002663 100644 --- a/compiler/src/CFCClass.h +++ b/compiler/src/CFCClass.h @@ -41,7 +41,7 @@ struct CFCFileSpec; /** Create and register a quasi-singleton. May only be called once for each * unique parcel/class_name combination. * - * @param parcel See Clownfish::CFC::Model::Symbol. + * @param parcel A Clownfish::CFC::Model::Parcel. * @param exposure See Clownfish::CFC::Model::Symbol. * @param class_name See Clownfish::CFC::Model::Symbol. * @param class_nickname The C nickname associated with the supplied class http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/ad6e0898/compiler/src/CFCFunction.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCFunction.c b/compiler/src/CFCFunction.c index 791e882..d712403 100644 --- a/compiler/src/CFCFunction.c +++ b/compiler/src/CFCFunction.c @@ -26,7 +26,6 @@ #include "CFCCallable.h" #include "CFCFunction.h" #include "CFCClass.h" -#include "CFCParcel.h" #include "CFCType.h" #include "CFCParamList.h" #include "CFCVariable.h" @@ -45,13 +44,12 @@ static const CFCMeta CFCFUNCTION_META = { }; CFCFunction* -CFCFunction_new(CFCParcel *parcel, const char *exposure, - const char *class_name, const char *name, CFCType *return_type, - CFCParamList *param_list, CFCDocuComment *docucomment, - int is_inline) { +CFCFunction_new(const char *exposure, const char *class_name, const char *name, + CFCType *return_type, CFCParamList *param_list, + CFCDocuComment *docucomment, int is_inline) { CFCFunction *self = (CFCFunction*)CFCBase_allocate(&CFCFUNCTION_META); - return CFCFunction_init(self, parcel, exposure, class_name, name, - return_type, param_list, docucomment, is_inline); + return CFCFunction_init(self, exposure, class_name, name, return_type, + param_list, docucomment, is_inline); } static int @@ -66,7 +64,7 @@ S_validate_function_name(const char *name) { } CFCFunction* -CFCFunction_init(CFCFunction *self, CFCParcel *parcel, const char *exposure, +CFCFunction_init(CFCFunction *self, const char *exposure, const char *class_name, const char *name, CFCType *return_type, CFCParamList *param_list, CFCDocuComment *docucomment, int is_inline) { @@ -75,7 +73,7 @@ CFCFunction_init(CFCFunction *self, CFCParcel *parcel, const char *exposure, CFCBase_decref((CFCBase*)self); CFCUtil_die("Invalid function name: '%s'", name); } - CFCCallable_init((CFCCallable*)self, parcel, exposure, class_name, name, + CFCCallable_init((CFCCallable*)self, exposure, class_name, name, return_type, param_list, docucomment); self->is_inline = is_inline; return self; http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/ad6e0898/compiler/src/CFCFunction.h ---------------------------------------------------------------------- diff --git a/compiler/src/CFCFunction.h b/compiler/src/CFCFunction.h index 0f3bd21..0793ab3 100644 --- a/compiler/src/CFCFunction.h +++ b/compiler/src/CFCFunction.h @@ -25,14 +25,12 @@ extern "C" { #endif typedef struct CFCFunction CFCFunction; -struct CFCParcel; struct CFCType; struct CFCDocuComment; struct CFCParamList; struct CFCClass; /** - * @param parcel A Clownfish::CFC::Model::Parcel. * @param exposure The function's exposure (see * L<Clownfish::CFC::Model::Symbol>). * @param class_name The full name of the class in whose namespace the @@ -48,16 +46,14 @@ struct CFCClass; * compiler. */ CFCFunction* -CFCFunction_new(struct CFCParcel *parcel, const char *exposure, - const char *class_name, const char *name, +CFCFunction_new(const char *exposure, const char *class_name, const char *name, struct CFCType *return_type, struct CFCParamList *param_list, struct CFCDocuComment *docucomment, int is_inline); CFCFunction* -CFCFunction_init(CFCFunction *self, struct CFCParcel *parcel, - const char *exposure, const char *class_name, - const char *name, struct CFCType *return_type, - struct CFCParamList *param_list, +CFCFunction_init(CFCFunction *self, const char *exposure, + const char *class_name, const char *name, + struct CFCType *return_type, struct CFCParamList *param_list, struct CFCDocuComment *docucomment, int is_inline); void http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/ad6e0898/compiler/src/CFCGoClass.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCGoClass.c b/compiler/src/CFCGoClass.c index 3c8afb7..cffa762 100644 --- a/compiler/src/CFCGoClass.c +++ b/compiler/src/CFCGoClass.c @@ -213,7 +213,7 @@ CFCGoClass_go_typing(CFCGoClass *self) { } } - const char *sig = CFCGoMethod_get_sig(meth_binding); + const char *sig = CFCGoMethod_get_sig(meth_binding, self->client); novel_iface = CFCUtil_cat(novel_iface, "\t", sig, "\n", NULL); } http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/ad6e0898/compiler/src/CFCGoMethod.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCGoMethod.c b/compiler/src/CFCGoMethod.c index 87f062e..02d3779 100644 --- a/compiler/src/CFCGoMethod.c +++ b/compiler/src/CFCGoMethod.c @@ -85,13 +85,13 @@ CFCGoMethod_customize(CFCGoMethod *self, const char *sig) { } static void -S_lazy_init_sig(CFCGoMethod *self) { +S_lazy_init_sig(CFCGoMethod *self, CFCClass *invoker) { if (self->sig || !self->method) { return; } CFCMethod *method = self->method; - CFCParcel *parcel = CFCMethod_get_parcel(method); + CFCParcel *parcel = CFCClass_get_parcel(invoker); CFCType *return_type = CFCMethod_get_return_type(method); char *name = CFCGoFunc_go_meth_name(CFCMethod_get_name(method)); char *go_ret_type = CFCType_is_void(return_type) @@ -120,7 +120,7 @@ S_lazy_init_sig(CFCGoMethod *self) { } const char* -CFCGoMethod_get_sig(CFCGoMethod *self) { +CFCGoMethod_get_sig(CFCGoMethod *self, CFCClass *invoker) { if (self->sig) { return self->sig; } @@ -128,7 +128,7 @@ CFCGoMethod_get_sig(CFCGoMethod *self) { return ""; } else { - S_lazy_init_sig(self); + S_lazy_init_sig(self, invoker); return self->sig; } } http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/ad6e0898/compiler/src/CFCGoMethod.h ---------------------------------------------------------------------- diff --git a/compiler/src/CFCGoMethod.h b/compiler/src/CFCGoMethod.h index 2d956e9..f2ca8da 100644 --- a/compiler/src/CFCGoMethod.h +++ b/compiler/src/CFCGoMethod.h @@ -44,7 +44,7 @@ CFCGoMethod_customize(CFCGoMethod *self, const char *sig); /** Retrieve the Go interface method signature. */ const char* -CFCGoMethod_get_sig(CFCGoMethod *self); +CFCGoMethod_get_sig(CFCGoMethod *self, struct CFCClass *invoker); char* CFCGoMethod_func_def(CFCGoMethod *self, struct CFCClass *invoker); http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/ad6e0898/compiler/src/CFCMethod.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCMethod.c b/compiler/src/CFCMethod.c index 32b97fb..78180b4 100644 --- a/compiler/src/CFCMethod.c +++ b/compiler/src/CFCMethod.c @@ -25,7 +25,6 @@ #include "CFCClass.h" #include "CFCUtil.h" #include "CFCParamList.h" -#include "CFCParcel.h" #include "CFCDocuComment.h" #include "CFCVariable.h" @@ -51,13 +50,12 @@ static const CFCMeta CFCMETHOD_META = { }; CFCMethod* -CFCMethod_new(CFCParcel *parcel, const char *exposure, const char *class_name, - const char *name, CFCType *return_type, CFCParamList *param_list, +CFCMethod_new(const char *exposure, const char *class_name, const char *name, + CFCType *return_type, CFCParamList *param_list, CFCDocuComment *docucomment, int is_final, int is_abstract) { CFCMethod *self = (CFCMethod*)CFCBase_allocate(&CFCMETHOD_META); - return CFCMethod_init(self, parcel, exposure, class_name, name, - return_type, param_list, docucomment, is_final, - is_abstract); + return CFCMethod_init(self, exposure, class_name, name, return_type, + param_list, docucomment, is_final, is_abstract); } static int @@ -83,8 +81,8 @@ S_validate_meth_name(const char *meth_name) { } CFCMethod* -CFCMethod_init(CFCMethod *self, CFCParcel *parcel, const char *exposure, - const char *class_name, const char *name, CFCType *return_type, +CFCMethod_init(CFCMethod *self, const char *exposure, const char *class_name, + const char *name, CFCType *return_type, CFCParamList *param_list, CFCDocuComment *docucomment, int is_final, int is_abstract) { // Validate name. @@ -95,21 +93,20 @@ CFCMethod_init(CFCMethod *self, CFCParcel *parcel, const char *exposure, } // Super-init. - CFCCallable_init((CFCCallable*)self, parcel, exposure, class_name, name, + CFCCallable_init((CFCCallable*)self, exposure, class_name, name, return_type, param_list, docucomment); // Verify that the first element in the arg list is a self. CFCVariable **args = CFCParamList_get_variables(param_list); if (!args[0]) { CFCUtil_die("Missing 'self' argument"); } CFCType *type = CFCVariable_get_type(args[0]); - const char *specifier = CFCType_get_specifier(type); - const char *prefix = CFCMethod_get_prefix(self); + const char *specifier = CFCType_get_specifier(type); const char *last_colon = strrchr(class_name, ':'); const char *struct_sym = last_colon ? last_colon + 1 : class_name; if (strcmp(specifier, struct_sym) != 0) { - char *wanted = CFCUtil_sprintf("%s%s", prefix, struct_sym); - int mismatch = strcmp(wanted, specifier); - FREEMEM(wanted); + const char *first_underscore = strchr(specifier, '_'); + int mismatch = !first_underscore + || strcmp(first_underscore + 1, struct_sym) != 0; if (mismatch) { CFCUtil_die("First arg type doesn't match class: '%s' '%s'", class_name, specifier); @@ -225,12 +222,11 @@ CFCMethod_override(CFCMethod *self, CFCMethod *orig) { CFCMethod* CFCMethod_finalize(CFCMethod *self) { - CFCParcel *parcel = CFCMethod_get_parcel(self); - const char *exposure = CFCMethod_get_exposure(self); - const char *class_name = CFCMethod_get_class_name(self); - const char *name = CFCMethod_get_name(self); + const char *exposure = CFCMethod_get_exposure(self); + const char *class_name = CFCMethod_get_class_name(self); + const char *name = CFCMethod_get_name(self); CFCMethod *finalized - = CFCMethod_new(parcel, exposure, class_name, name, + = CFCMethod_new(exposure, class_name, name, self->callable.return_type, self->callable.param_list, self->callable.docucomment, true, @@ -378,26 +374,6 @@ CFCMethod_self_type(CFCMethod *self) { return CFCVariable_get_type(vars[0]); } -CFCParcel* -CFCMethod_get_parcel(CFCMethod *self) { - return CFCSymbol_get_parcel((CFCSymbol*)self); -} - -const char* -CFCMethod_get_prefix(CFCMethod *self) { - return CFCSymbol_get_prefix((CFCSymbol*)self); -} - -const char* -CFCMethod_get_Prefix(CFCMethod *self) { - return CFCSymbol_get_Prefix((CFCSymbol*)self); -} - -const char* -CFCMethod_get_PREFIX(CFCMethod *self) { - return CFCSymbol_get_PREFIX((CFCSymbol*)self); -} - const char* CFCMethod_get_exposure(CFCMethod *self) { return CFCSymbol_get_exposure((CFCSymbol*)self); http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/ad6e0898/compiler/src/CFCMethod.h ---------------------------------------------------------------------- diff --git a/compiler/src/CFCMethod.h b/compiler/src/CFCMethod.h index d8fb6b7..3f64c12 100644 --- a/compiler/src/CFCMethod.h +++ b/compiler/src/CFCMethod.h @@ -33,14 +33,12 @@ extern "C" { #endif typedef struct CFCMethod CFCMethod; -struct CFCParcel; struct CFCType; struct CFCClass; struct CFCParamList; struct CFCDocuComment; /** - * @param parcel See Clownfish::CFC::Model::Function. * @param exposure See Clownfish::CFC::Model::Symbol. Defaults to "parcel" * if not supplied. * @param class_name See Clownfish::CFC::Model::Function. @@ -54,16 +52,15 @@ struct CFCDocuComment; * @param is_abstract - Indicate whether the method is abstract. */ CFCMethod* -CFCMethod_new(struct CFCParcel *parcel, const char *exposure, - const char *class_name, const char *name, +CFCMethod_new(const char *exposure, const char *class_name, const char *name, struct CFCType *return_type, struct CFCParamList *param_list, struct CFCDocuComment *docucomment, int is_final, int is_abstract); CFCMethod* -CFCMethod_init(CFCMethod *self, struct CFCParcel *parcel, - const char *exposure, const char *class_name, const char *name, - struct CFCType *return_type, struct CFCParamList *param_list, +CFCMethod_init(CFCMethod *self, const char *exposure, const char *class_name, + const char *name, struct CFCType *return_type, + struct CFCParamList *param_list, struct CFCDocuComment *docucomment, int is_final, int is_abstract); @@ -205,18 +202,6 @@ CFCMethod_exclude_from_host(CFCMethod *self); int CFCMethod_excluded_from_host(CFCMethod *self); -struct CFCParcel* -CFCMethod_get_parcel(CFCMethod *self); - -const char* -CFCMethod_get_prefix(CFCMethod *self); - -const char* -CFCMethod_get_Prefix(CFCMethod *self); - -const char* -CFCMethod_get_PREFIX(CFCMethod *self); - const char* CFCMethod_get_exposure(CFCMethod *self); http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/ad6e0898/compiler/src/CFCParseHeader.y ---------------------------------------------------------------------- diff --git a/compiler/src/CFCParseHeader.y b/compiler/src/CFCParseHeader.y index 75c6515..7fa5304 100644 --- a/compiler/src/CFCParseHeader.y +++ b/compiler/src/CFCParseHeader.y @@ -70,13 +70,12 @@ S_new_var(CFCParser *state, char *exposure, char *modifiers, CFCType *type, inert = true; } - CFCParcel *parcel = CFCParser_get_parcel(state); - const char *class_name = NULL; + const char *class_name = NULL; if (exposure && strcmp(exposure, "local") != 0) { class_name = CFCParser_get_class_name(state); } - CFCVariable *var = CFCVariable_new(parcel, exposure, class_name, name, - type, inert); + CFCVariable *var = CFCVariable_new(exposure, class_name, name, type, + inert); /* Consume tokens. */ CFCBase_decref((CFCBase*)type); @@ -88,7 +87,6 @@ static CFCBase* S_new_sub(CFCParser *state, CFCDocuComment *docucomment, char *exposure, char *modifiers, CFCType *type, char *name, CFCParamList *param_list) { - CFCParcel *parcel = CFCParser_get_parcel(state); const char *class_name = CFCParser_get_class_name(state); /* Find modifiers by scanning the list. */ @@ -115,15 +113,15 @@ S_new_sub(CFCParser *state, CFCDocuComment *docucomment, if (is_final) { CFCUtil_die("Inert functions must not be final"); } - sub = (CFCBase*)CFCFunction_new(parcel, exposure, class_name, name, - type, param_list, docucomment, + sub = (CFCBase*)CFCFunction_new(exposure, class_name, name, type, + param_list, docucomment, is_inline); } else { if (is_inline) { CFCUtil_die("Methods must not be inline"); } - sub = (CFCBase*)CFCMethod_new(parcel, exposure, class_name, name, type, + sub = (CFCBase*)CFCMethod_new(exposure, class_name, name, type, param_list, docucomment, is_final, is_abstract); } http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/ad6e0898/compiler/src/CFCSymbol.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCSymbol.c b/compiler/src/CFCSymbol.c index bfa985d..20f06a7 100644 --- a/compiler/src/CFCSymbol.c +++ b/compiler/src/CFCSymbol.c @@ -35,10 +35,9 @@ static const CFCMeta CFCSYMBOL_META = { }; CFCSymbol* -CFCSymbol_new(struct CFCParcel *parcel, const char *exposure, - const char *class_name, const char *name) { +CFCSymbol_new(const char *exposure, const char *class_name, const char *name) { CFCSymbol *self = (CFCSymbol*)CFCBase_allocate(&CFCSYMBOL_META); - return CFCSymbol_init(self, parcel, exposure, class_name, name); + return CFCSymbol_init(self, exposure, class_name, name); } static int @@ -103,10 +102,9 @@ S_validate_identifier(const char *identifier) { } CFCSymbol* -CFCSymbol_init(CFCSymbol *self, struct CFCParcel *parcel, const char *exposure, - const char *class_name, const char *name) { +CFCSymbol_init(CFCSymbol *self, const char *exposure, const char *class_name, + const char *name) { // Validate. - CFCUTIL_NULL_CHECK(parcel); if (!S_validate_exposure(exposure)) { CFCBase_decref((CFCBase*)self); CFCUtil_die("Invalid exposure: '%s'", exposure ? exposure : "[NULL]"); @@ -121,7 +119,6 @@ CFCSymbol_init(CFCSymbol *self, struct CFCParcel *parcel, const char *exposure, } // Assign. - self->parcel = (CFCParcel*)CFCBase_incref((CFCBase*)parcel); self->exposure = CFCUtil_strdup(exposure); self->class_name = CFCUtil_strdup(class_name); self->name = CFCUtil_strdup(name); @@ -131,7 +128,6 @@ CFCSymbol_init(CFCSymbol *self, struct CFCParcel *parcel, const char *exposure, void CFCSymbol_destroy(CFCSymbol *self) { - CFCBase_decref((CFCBase*)self->parcel); FREEMEM(self->exposure); FREEMEM(self->class_name); FREEMEM(self->name); @@ -141,7 +137,6 @@ CFCSymbol_destroy(CFCSymbol *self) { int CFCSymbol_equals(CFCSymbol *self, CFCSymbol *other) { if (strcmp(self->name, other->name) != 0) { return false; } - if (!CFCParcel_equals(self->parcel, other->parcel)) { return false; } if (strcmp(self->exposure, other->exposure) != 0) { return false; } if (self->class_name) { if (!other->class_name) { return false; } @@ -190,11 +185,6 @@ CFCSymbol_short_sym(CFCSymbol *self, CFCClass *klass) { return short_sym; } -struct CFCParcel* -CFCSymbol_get_parcel(CFCSymbol *self) { - return self->parcel; -} - const char* CFCSymbol_get_class_name(CFCSymbol *self) { return self->class_name; @@ -210,18 +200,3 @@ CFCSymbol_get_name(CFCSymbol *self) { return self->name; } -const char* -CFCSymbol_get_prefix(CFCSymbol *self) { - return CFCParcel_get_prefix(self->parcel); -} - -const char* -CFCSymbol_get_Prefix(CFCSymbol *self) { - return CFCParcel_get_Prefix(self->parcel); -} - -const char* -CFCSymbol_get_PREFIX(CFCSymbol *self) { - return CFCParcel_get_PREFIX(self->parcel); -} - http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/ad6e0898/compiler/src/CFCSymbol.h ---------------------------------------------------------------------- diff --git a/compiler/src/CFCSymbol.h b/compiler/src/CFCSymbol.h index 2e365af..599138c 100644 --- a/compiler/src/CFCSymbol.h +++ b/compiler/src/CFCSymbol.h @@ -37,7 +37,6 @@ struct CFCParcel; #include "CFCBase.h" struct CFCSymbol { CFCBase base; - struct CFCParcel *parcel; char *exposure; char *class_name; char *name; @@ -52,7 +51,6 @@ int CFCSymbol_validate_class_name_component(const char *name); /** - * @param parcel A Clownfish::CFC::Model::Parcel. * @param exposure The scope in which the symbol is exposed. Must be * 'public', 'parcel', 'private', or 'local'. * @param class_name A optional class name, consisting of one or more @@ -62,12 +60,11 @@ CFCSymbol_validate_class_name_component(const char *name); * @param name The local identifier for the symbol. */ CFCSymbol* -CFCSymbol_new(struct CFCParcel *parcel, const char *exposure, - const char *class_name, const char *name); +CFCSymbol_new(const char *exposure, const char *class_name, const char *name); CFCSymbol* -CFCSymbol_init(CFCSymbol *self, struct CFCParcel *parcel, const char *exposure, - const char *class_name, const char *name); +CFCSymbol_init(CFCSymbol *self, const char *exposure, const char *class_name, + const char *name); void CFCSymbol_destroy(CFCSymbol *self); @@ -77,9 +74,6 @@ CFCSymbol_destroy(CFCSymbol *self); int CFCSymbol_equals(CFCSymbol *self, CFCSymbol *other); -struct CFCParcel* -CFCSymbol_get_parcel(CFCSymbol *self); - // May be NULL. const char* CFCSymbol_get_class_name(CFCSymbol *self); @@ -124,21 +118,6 @@ CFCSymbol_short_sym(CFCSymbol *self, struct CFCClass *klass); char* CFCSymbol_full_sym(CFCSymbol *self, struct CFCClass *klass); -/** Get the Symbol's all-lowercase prefix, delegating to `parcel`. - */ -const char* -CFCSymbol_get_prefix(CFCSymbol *self); - -/** Get the Symbol's Titlecase prefix, delegating to `parcel`. - */ -const char* -CFCSymbol_get_Prefix(CFCSymbol *self); - -/** Get the Symbol's all-uppercase prefix, delegating to `parcel`. - */ -const char* -CFCSymbol_get_PREFIX(CFCSymbol *self); - #ifdef __cplusplus } #endif http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/ad6e0898/compiler/src/CFCTestClass.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCTestClass.c b/compiler/src/CFCTestClass.c index 7f0e871..66d1cbc 100644 --- a/compiler/src/CFCTestClass.c +++ b/compiler/src/CFCTestClass.c @@ -65,17 +65,16 @@ S_run_tests(CFCTest *test) { { CFCType *thing_type = CFCTest_parse_type(test, parser, "Thing*"); - thing = CFCVariable_new(neato, NULL, "Foo", "thing", thing_type, 0); + thing = CFCVariable_new(NULL, "Foo", "thing", thing_type, 0); CFCType *widget_type = CFCTest_parse_type(test, parser, "Widget*"); - widget = CFCVariable_new(neato, NULL, "Widget", "widget", widget_type, - 0); + widget = CFCVariable_new(NULL, "Widget", "widget", widget_type, 0); CFCType *return_type = CFCTest_parse_type(test, parser, "void"); CFCParamList *param_list = CFCTest_parse_param_list(test, parser, "()"); tread_water - = CFCFunction_new(neato, NULL, "Foo", "tread_water", return_type, + = CFCFunction_new(NULL, "Foo", "tread_water", return_type, param_list, NULL, 0); CFCBase_decref((CFCBase*)thing_type); http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/ad6e0898/compiler/src/CFCTestFunction.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCTestFunction.c b/compiler/src/CFCTestFunction.c index 9ad7e4d..1d54537 100644 --- a/compiler/src/CFCTestFunction.c +++ b/compiler/src/CFCTestFunction.c @@ -43,9 +43,8 @@ S_run_tests(CFCTest *test) { CFCParamList *param_list = CFCTest_parse_param_list(test, parser, "(int32_t some_num)"); CFCFunction *func - = CFCFunction_new(neato_parcel, NULL, "Neato::Foo", - "return_an_obj", return_type, param_list, NULL, - 0); + = CFCFunction_new(NULL, "Neato::Foo", "return_an_obj", return_type, + param_list, NULL, 0); OK(test, func != NULL, "new"); CFCBase_decref((CFCBase*)return_type); http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/ad6e0898/compiler/src/CFCTestMethod.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCTestMethod.c b/compiler/src/CFCTestMethod.c index d0dc193..6e20069 100644 --- a/compiler/src/CFCTestMethod.c +++ b/compiler/src/CFCTestMethod.c @@ -65,24 +65,24 @@ S_run_basic_tests(CFCTest *test) { = CFCTest_parse_param_list(test, parser, "(Foo *self, int32_t count = 0)"); CFCMethod *method - = CFCMethod_new(neato_parcel, NULL, "Neato::Foo", "Return_An_Obj", - return_type, param_list, NULL, 0, 0); + = CFCMethod_new(NULL, "Neato::Foo", "Return_An_Obj", return_type, + param_list, NULL, 0, 0); OK(test, method != NULL, "new"); OK(test, CFCSymbol_parcel((CFCSymbol*)method), "parcel exposure by default"); { CFCMethod *dupe - = CFCMethod_new(neato_parcel, NULL, "Neato::Foo", "Return_An_Obj", - return_type, param_list, NULL, 0, 0); + = CFCMethod_new(NULL, "Neato::Foo", "Return_An_Obj", return_type, + param_list, NULL, 0, 0); OK(test, CFCMethod_compatible(method, dupe), "compatible"); CFCBase_decref((CFCBase*)dupe); } { CFCMethod *name_differs - = CFCMethod_new(neato_parcel, NULL, "Neato::Foo", "Eat", - return_type, param_list, NULL, 0, 0); + = CFCMethod_new(NULL, "Neato::Foo", "Eat", return_type, param_list, + NULL, 0, 0); OK(test, !CFCMethod_compatible(method, name_differs), "different name spoils compatible"); OK(test, !CFCMethod_compatible(name_differs, method), @@ -109,9 +109,8 @@ S_run_basic_tests(CFCTest *test) { CFCParamList *other_param_list = CFCTest_parse_param_list(test, parser, param_strings[i]); CFCMethod *other - = CFCMethod_new(neato_parcel, NULL, "Neato::Foo", - "Return_An_Obj", return_type, other_param_list, - NULL, 0, 0); + = CFCMethod_new(NULL, "Neato::Foo", "Return_An_Obj", + return_type, other_param_list, NULL, 0, 0); OK(test, !CFCMethod_compatible(method, other), "%s spoils compatible", test_names[i]); OK(test, !CFCMethod_compatible(other, method), @@ -126,8 +125,8 @@ S_run_basic_tests(CFCTest *test) { = CFCTest_parse_param_list(test, parser, "(Bar *self, int32_t count = 0)"); CFCMethod *self_differs - = CFCMethod_new(neato_parcel, NULL, "Neato::Bar", "Return_An_Obj", - return_type, self_differs_list, NULL, 0, 0); + = CFCMethod_new(NULL, "Neato::Bar", "Return_An_Obj", return_type, + self_differs_list, NULL, 0, 0); OK(test, CFCMethod_compatible(method, self_differs), "different self type still compatible()," " since can't test inheritance"); @@ -139,8 +138,8 @@ S_run_basic_tests(CFCTest *test) { { CFCMethod *aliased - = CFCMethod_new(neato_parcel, NULL, "Neato::Foo", "Aliased", - return_type, param_list, NULL, 0, 0); + = CFCMethod_new(NULL, "Neato::Foo", "Aliased", return_type, + param_list, NULL, 0, 0); OK(test, !CFCMethod_get_host_alias(aliased), "no host alias by default"); CFCMethod_set_host_alias(aliased, "Host_Alias"); @@ -151,8 +150,8 @@ S_run_basic_tests(CFCTest *test) { { CFCMethod *excluded - = CFCMethod_new(neato_parcel, NULL, "Neato::Foo", "Excluded", - return_type, param_list, NULL, 0, 0); + = CFCMethod_new(NULL, "Neato::Foo", "Excluded", return_type, + param_list, NULL, 0, 0); OK(test, !CFCMethod_excluded_from_host(excluded), "not excluded by default"); CFCMethod_exclude_from_host(excluded); @@ -214,15 +213,14 @@ S_run_overridden_tests(CFCTest *test) { CFCParamList *param_list = CFCTest_parse_param_list(test, parser, "(Foo *self)"); CFCMethod *orig - = CFCMethod_new(neato_parcel, NULL, "Neato::Foo", "Return_An_Obj", - return_type, param_list, NULL, 0, 0); + = CFCMethod_new(NULL, "Neato::Foo", "Return_An_Obj", return_type, + param_list, NULL, 0, 0); CFCParamList *overrider_param_list = CFCTest_parse_param_list(test, parser, "(FooJr *self)"); CFCMethod *overrider - = CFCMethod_new(neato_parcel, NULL, "Neato::Foo::FooJr", - "Return_An_Obj", return_type, overrider_param_list, - NULL, 0, 0); + = CFCMethod_new(NULL, "Neato::Foo::FooJr", "Return_An_Obj", + return_type, overrider_param_list, NULL, 0, 0); CFCMethod_override(overrider, orig); OK(test, !CFCMethod_novel(overrider), @@ -253,8 +251,8 @@ S_run_final_tests(CFCTest *test) { = CFCTest_parse_param_list(test, parser, "(Foo *self)"); CFCMethod *not_final - = CFCMethod_new(neato_parcel, NULL, "Neato::Foo", "Return_An_Obj", - return_type, param_list, NULL, 0, 0); + = CFCMethod_new(NULL, "Neato::Foo", "Return_An_Obj", return_type, + param_list, NULL, 0, 0); CFCMethod_resolve_types(not_final); CFCMethod *final = CFCMethod_finalize(not_final); OK(test, CFCMethod_compatible(not_final, final), http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/ad6e0898/compiler/src/CFCTestParcel.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCTestParcel.c b/compiler/src/CFCTestParcel.c index 3003173..8d57b0c 100644 --- a/compiler/src/CFCTestParcel.c +++ b/compiler/src/CFCTestParcel.c @@ -41,7 +41,7 @@ S_run_parcel_tests(CFCTest *test); const CFCTestBatch CFCTEST_BATCH_PARCEL = { "Clownfish::CFC::Model::Parcel", - 32, + 29, S_run_tests }; @@ -118,15 +118,6 @@ S_run_parcel_tests(CFCTest *test) { STR_EQ(test, CFCVersion_get_vstring(CFCParcel_get_version(parcel)), "v0", "get_version"); - CFCSymbol *thing = CFCSymbol_new(parcel, "parcel", NULL, "sym"); - STR_EQ(test, CFCSymbol_get_prefix(thing), "crust_", - "get_prefix with parcel"); - STR_EQ(test, CFCSymbol_get_Prefix(thing), "Crust_", - "get_Prefix with parcel"); - STR_EQ(test, CFCSymbol_get_PREFIX(thing), "CRUST_", - "get_PREFIX with parcel"); - - CFCBase_decref((CFCBase*)thing); CFCBase_decref((CFCBase*)parcel); CFCParcel_reap_singletons(); } http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/ad6e0898/compiler/src/CFCTestSymbol.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCTestSymbol.c b/compiler/src/CFCTestSymbol.c index 11a2c03..bf267e4 100644 --- a/compiler/src/CFCTestSymbol.c +++ b/compiler/src/CFCTestSymbol.c @@ -32,7 +32,7 @@ S_run_tests(CFCTest *test); const CFCTestBatch CFCTEST_BATCH_SYMBOL = { "Clownfish::CFC::Model::Symbol", - 27, + 22, S_run_tests }; @@ -51,8 +51,7 @@ S_run_tests(CFCTest *test) { CFCSymbol_local }; for (int i = 0; i < 4; ++i) { - CFCSymbol *symbol - = CFCSymbol_new(parcel, exposures[i], NULL, "sym"); + CFCSymbol *symbol = CFCSymbol_new(exposures[i], NULL, "sym"); for (int j = 0; j < 4; ++j) { int has_exposure = accessors[j](symbol); if (i == j) { @@ -68,9 +67,8 @@ S_run_tests(CFCTest *test) { } { - CFCSymbol *foo = CFCSymbol_new(parcel, "parcel", "Foo", "sym"); - CFCSymbol *foo_jr - = CFCSymbol_new(parcel, "parcel", "Foo::FooJr", "sym"); + CFCSymbol *foo = CFCSymbol_new("parcel", "Foo", "sym"); + CFCSymbol *foo_jr = CFCSymbol_new("parcel", "Foo::FooJr", "sym"); int equal = CFCSymbol_equals(foo, foo_jr); OK(test, !equal, "different class_name spoils equals"); @@ -82,10 +80,8 @@ S_run_tests(CFCTest *test) { } { - CFCSymbol *public_exposure - = CFCSymbol_new(parcel, "public", NULL, "sym"); - CFCSymbol *parcel_exposure - = CFCSymbol_new(parcel, "parcel", NULL, "sym"); + CFCSymbol *public_exposure = CFCSymbol_new("public", NULL, "sym"); + CFCSymbol *parcel_exposure = CFCSymbol_new("parcel", NULL, "sym"); int equal = CFCSymbol_equals(public_exposure, parcel_exposure); OK(test, !equal, "different exposure spoils equals"); CFCBase_decref((CFCBase*)public_exposure); @@ -93,38 +89,8 @@ S_run_tests(CFCTest *test) { } { - CFCParcel *lucifer_parcel - = CFCParcel_new("Lucifer", NULL, NULL, NULL); - CFCParcel_register(lucifer_parcel); - CFCSymbol *lucifer - = CFCSymbol_new(lucifer_parcel, "parcel", NULL, "sym"); - - CFCParcel *symbol_parcel = CFCSymbol_get_parcel(lucifer); - OK(test, symbol_parcel == lucifer_parcel, "derive parcel"); - const char *prefix = CFCSymbol_get_prefix(lucifer); - STR_EQ(test, prefix, "lucifer_", "get_prefix"); - const char *Prefix = CFCSymbol_get_Prefix(lucifer); - STR_EQ(test, Prefix, "Lucifer_", "get_Prefix"); - const char *PREFIX = CFCSymbol_get_PREFIX(lucifer); - STR_EQ(test, PREFIX, "LUCIFER_", "get_PREFIX"); - - CFCParcel *luser_parcel = CFCParcel_new("Luser", NULL, NULL, NULL); - CFCParcel_register(luser_parcel); - CFCSymbol *luser - = CFCSymbol_new(luser_parcel, "parcel", NULL, "sym"); - int equal = CFCSymbol_equals(lucifer, luser); - OK(test, !equal, "different exposure spoils equals"); - - CFCBase_decref((CFCBase*)lucifer_parcel); - CFCBase_decref((CFCBase*)lucifer); - CFCBase_decref((CFCBase*)luser_parcel); - CFCBase_decref((CFCBase*)luser); - } - - { - CFCSymbol *ooga = CFCSymbol_new(parcel, "parcel", NULL, "ooga"); - CFCSymbol *booga - = CFCSymbol_new(parcel, "parcel", NULL, "booga"); + CFCSymbol *ooga = CFCSymbol_new("parcel", NULL, "ooga"); + CFCSymbol *booga = CFCSymbol_new("parcel", NULL, "booga"); int equal = CFCSymbol_equals(ooga, booga); OK(test, !equal, "different name spoils equals"); CFCBase_decref((CFCBase*)ooga); @@ -137,8 +103,7 @@ S_run_tests(CFCTest *test) { CFCClass *ork = CFCClass_create(eep_parcel, NULL, "Op::Ork", NULL, NULL, NULL, NULL, NULL, false, false, false); - CFCSymbol *eep - = CFCSymbol_new(eep_parcel, "parcel", "Op::Ork", "ah_ah"); + CFCSymbol *eep = CFCSymbol_new("parcel", "Op::Ork", "ah_ah"); char *short_sym = CFCSymbol_short_sym(eep, ork); STR_EQ(test, short_sym, "Ork_ah_ah", "short_sym"); FREEMEM(short_sym); http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/ad6e0898/compiler/src/CFCTestVariable.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCTestVariable.c b/compiler/src/CFCTestVariable.c index 776efff..203ac90 100644 --- a/compiler/src/CFCTestVariable.c +++ b/compiler/src/CFCTestVariable.c @@ -48,8 +48,7 @@ S_run_tests(CFCTest *test) { { CFCType *type = CFCTest_parse_type(test, parser, "float*"); - CFCVariable *var - = CFCVariable_new(neato_parcel, NULL, NULL, "foo", type, 0); + CFCVariable *var = CFCVariable_new(NULL, NULL, "foo", type, 0); CFCVariable_resolve_type(var); STR_EQ(test, CFCVariable_local_c(var), "float* foo", "local_c"); STR_EQ(test, CFCVariable_local_declaration(var), "float* foo;", @@ -62,8 +61,7 @@ S_run_tests(CFCTest *test) { { CFCType *type = CFCTest_parse_type(test, parser, "float[1]"); - CFCVariable *var - = CFCVariable_new(neato_parcel, NULL, NULL, "foo", type, 0); + CFCVariable *var = CFCVariable_new(NULL, NULL, "foo", type, 0); CFCVariable_resolve_type(var); STR_EQ(test, CFCVariable_local_c(var), "float foo[1]", "to_c appends array to var name rather than type specifier"); @@ -75,9 +73,8 @@ S_run_tests(CFCTest *test) { { CFCType *type = CFCTest_parse_type(test, parser, "Foo*"); CFCVariable *var - = CFCVariable_new(neato_parcel, NULL, - "Crustacean::Lobster::LobsterClaw", "foo", type, - 0); + = CFCVariable_new(NULL, "Crustacean::Lobster::LobsterClaw", "foo", + type, 0); CFCVariable_resolve_type(var); CFCClass *ork = CFCClass_create(neato_parcel, NULL, http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/ad6e0898/compiler/src/CFCVariable.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCVariable.c b/compiler/src/CFCVariable.c index 507f65d..5b6804e 100644 --- a/compiler/src/CFCVariable.c +++ b/compiler/src/CFCVariable.c @@ -49,25 +49,23 @@ static void S_generate_c_strings(CFCVariable *self); CFCVariable* -CFCVariable_new(struct CFCParcel *parcel, const char *exposure, - const char *class_name, const char *name, struct CFCType *type, - int inert) { +CFCVariable_new(const char *exposure, const char *class_name, const char *name, + struct CFCType *type, int inert) { CFCVariable *self = (CFCVariable*)CFCBase_allocate(&CFCVARIABLE_META); - return CFCVariable_init(self, parcel, exposure, class_name, name, type, - inert); + return CFCVariable_init(self, exposure, class_name, name, type, inert); } CFCVariable* -CFCVariable_init(CFCVariable *self, struct CFCParcel *parcel, - const char *exposure, const char *class_name, - const char *name, struct CFCType *type, int inert) { +CFCVariable_init(CFCVariable *self, const char *exposure, + const char *class_name, const char *name, + struct CFCType *type, int inert) { // Validate params. CFCUTIL_NULL_CHECK(type); // Default exposure to "local". const char *real_exposure = exposure ? exposure : "local"; - CFCSymbol_init((CFCSymbol*)self, parcel, real_exposure, class_name, name); + CFCSymbol_init((CFCSymbol*)self, real_exposure, class_name, name); // Assign type, inert. self->type = (CFCType*)CFCBase_incref((CFCBase*)type); http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/ad6e0898/compiler/src/CFCVariable.h ---------------------------------------------------------------------- diff --git a/compiler/src/CFCVariable.h b/compiler/src/CFCVariable.h index ff5b6d2..a46eeaf 100644 --- a/compiler/src/CFCVariable.h +++ b/compiler/src/CFCVariable.h @@ -39,20 +39,19 @@ struct CFCParcel; struct CFCType; /** - * @param type A Clownfish::CFC::Model::Type. - * @param name The variable's name, without any namespacing prefixes. * @param exposure See Clownfish::CFC::Model::Symbol. * @param class_name See Clownfish::CFC::Model::Symbol. + * @param name The variable's name, without any namespacing prefixes. + * @param type A Clownfish::CFC::Model::Type. */ CFCVariable* -CFCVariable_new(struct CFCParcel *parcel, const char *exposure, - const char *class_name, const char *name, struct CFCType *type, - int inert); +CFCVariable_new(const char *exposure, const char *class_name, const char *name, + struct CFCType *type, int inert); CFCVariable* -CFCVariable_init(CFCVariable *self, struct CFCParcel *parcel, - const char *exposure, const char *class_name, - const char *name, struct CFCType *type, int inert); +CFCVariable_init(CFCVariable *self, const char *exposure, + const char *class_name, const char *name, + struct CFCType *type, int inert); void CFCVariable_resolve_type(CFCVariable *self);
