Repository: lucy-clownfish Updated Branches: refs/heads/master 505750771 -> ec7d6e57c
Move class_nickname 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/3ef65778 Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/3ef65778 Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/3ef65778 Branch: refs/heads/master Commit: 3ef65778bddca48f545ce7a21d666214a947246c Parents: bfa43f3 Author: Nick Wellnhofer <[email protected]> Authored: Sun Jul 27 00:21:31 2014 +0200 Committer: Nick Wellnhofer <[email protected]> Committed: Thu May 7 21:13:59 2015 +0200 ---------------------------------------------------------------------- compiler/perl/lib/Clownfish/CFC.pm | 71 +++++++++++------------- compiler/perl/lib/Clownfish/CFC.xs | 82 ++++++++-------------------- compiler/perl/t/051-symbol.t | 4 +- compiler/perl/t/200-function.t | 12 ++-- compiler/perl/t/201-method.t | 17 +++--- compiler/perl/t/202-overridden_method.t | 16 +++--- compiler/perl/t/203-final_method.t | 11 ++-- compiler/perl/t/300-variable.t | 9 ++- compiler/perl/t/401-class.t | 4 +- compiler/perl/t/600-parser.t | 1 - compiler/src/CFCCallable.c | 9 ++- compiler/src/CFCCallable.h | 5 +- compiler/src/CFCClass.c | 53 ++++++++++++++++-- compiler/src/CFCClass.h | 4 +- compiler/src/CFCFunction.c | 20 +++---- compiler/src/CFCFunction.h | 10 ++-- compiler/src/CFCMethod.c | 27 +++------ compiler/src/CFCMethod.h | 12 +--- compiler/src/CFCParseHeader.y | 25 ++++----- compiler/src/CFCParser.c | 19 ------- compiler/src/CFCParser.h | 6 -- compiler/src/CFCSymbol.c | 58 ++------------------ compiler/src/CFCSymbol.h | 14 +---- compiler/src/CFCTestClass.c | 15 ++--- compiler/src/CFCTestFunction.c | 7 +-- compiler/src/CFCTestMethod.c | 42 ++++++-------- compiler/src/CFCTestParcel.c | 2 +- compiler/src/CFCTestParser.c | 1 - compiler/src/CFCTestSymbol.c | 25 ++++----- compiler/src/CFCTestVariable.c | 8 +-- compiler/src/CFCVariable.c | 14 ++--- compiler/src/CFCVariable.h | 8 +-- 32 files changed, 239 insertions(+), 372 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/3ef65778/compiler/perl/lib/Clownfish/CFC.pm ---------------------------------------------------------------------- diff --git a/compiler/perl/lib/Clownfish/CFC.pm b/compiler/perl/lib/Clownfish/CFC.pm index 358e8b1..b714adb 100644 --- a/compiler/perl/lib/Clownfish/CFC.pm +++ b/compiler/perl/lib/Clownfish/CFC.pm @@ -214,15 +214,14 @@ BEGIN { XSLoader::load( 'Clownfish::CFC', '0.4.0' ) } use Clownfish::CFC::Util qw( verify_args a_isa_b ); my %new_PARAMS = ( - return_type => undef, - class_name => undef, - class_nickname => undef, - param_list => undef, - name => undef, - docucomment => undef, - parcel => undef, - inline => undef, - exposure => undef, + return_type => undef, + class_name => undef, + param_list => undef, + name => undef, + docucomment => undef, + parcel => undef, + inline => undef, + exposure => undef, ); sub new { @@ -234,8 +233,8 @@ BEGIN { XSLoader::load( 'Clownfish::CFC', '0.4.0' ) } = Clownfish::CFC::Model::Parcel->acquire( $args{parcel} ); return _new( @args{ - qw( parcel exposure class_name class_nickname name - return_type param_list docucomment inline ) + qw( parcel exposure class_name name return_type param_list + docucomment inline ) } ); } @@ -299,16 +298,15 @@ BEGIN { XSLoader::load( 'Clownfish::CFC', '0.4.0' ) } use Carp; my %new_PARAMS = ( - return_type => undef, - class_name => undef, - class_nickname => undef, - param_list => undef, - name => undef, - docucomment => undef, - parcel => undef, - abstract => undef, - final => undef, - exposure => 'parcel', + return_type => undef, + class_name => undef, + param_list => undef, + name => undef, + docucomment => undef, + parcel => undef, + abstract => undef, + final => undef, + exposure => 'parcel', ); sub new { @@ -321,8 +319,8 @@ BEGIN { XSLoader::load( 'Clownfish::CFC', '0.4.0' ) } $args{final} ||= 0; return _new( @args{ - qw( parcel exposure class_name class_nickname name - return_type param_list docucomment final abstract ) + qw( parcel exposure class_name name return_type param_list + docucomment final abstract ) } ); } @@ -454,11 +452,10 @@ BEGIN { XSLoader::load( 'Clownfish::CFC', '0.4.0' ) } use Carp; my %new_PARAMS = ( - parcel => undef, - exposure => undef, - class_name => undef, - class_nickname => undef, - name => undef, + parcel => undef, + exposure => undef, + class_name => undef, + name => undef, ); sub new { @@ -468,7 +465,7 @@ BEGIN { XSLoader::load( 'Clownfish::CFC', '0.4.0' ) } $args{parcel} = Clownfish::CFC::Model::Parcel->acquire( $args{parcel} ); return _new( - @args{qw( parcel exposure class_name class_nickname name )} ); + @args{qw( parcel exposure class_name name )} ); } } @@ -636,13 +633,12 @@ BEGIN { XSLoader::load( 'Clownfish::CFC', '0.4.0' ) } use Carp; our %new_PARAMS = ( - type => undef, - name => undef, - parcel => undef, - exposure => 'local', - class_name => undef, - class_nickname => undef, - inert => undef, + type => undef, + name => undef, + parcel => undef, + exposure => 'local', + class_name => undef, + inert => undef, ); sub new { @@ -654,8 +650,7 @@ BEGIN { XSLoader::load( 'Clownfish::CFC', '0.4.0' ) } = Clownfish::CFC::Model::Parcel->acquire( $args{parcel} ); return _new( @args{ - qw( parcel exposure class_name class_nickname name type - inert ) + qw( parcel exposure class_name name type inert ) } ); } http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/3ef65778/compiler/perl/lib/Clownfish/CFC.xs ---------------------------------------------------------------------- diff --git a/compiler/perl/lib/Clownfish/CFC.xs b/compiler/perl/lib/Clownfish/CFC.xs index 10b2a22..524c5c9 100644 --- a/compiler/perl/lib/Clownfish/CFC.xs +++ b/compiler/perl/lib/Clownfish/CFC.xs @@ -637,11 +637,10 @@ PPCODE: MODULE = Clownfish::CFC PACKAGE = Clownfish::CFC::Model::Function SV* -_new(parcel, exposure_sv, class_name_sv, class_nickname_sv, name_sv, return_type, param_list, docucomment, is_inline) +_new(parcel, exposure_sv, class_name_sv, name_sv, return_type, param_list, docucomment, is_inline) CFCParcel *parcel; SV *exposure_sv; SV *class_name_sv; - SV *class_nickname_sv; SV *name_sv; CFCType *return_type; CFCParamList *param_list; @@ -652,14 +651,11 @@ CODE: SvOK(exposure_sv) ? SvPV_nolen(exposure_sv) : NULL; const char *class_name = SvOK(class_name_sv) ? SvPV_nolen(class_name_sv) : NULL; - const char *class_nickname = - SvOK(class_nickname_sv) ? SvPV_nolen(class_nickname_sv) : NULL; const char *name = SvOK(name_sv) ? SvPV_nolen(name_sv) : NULL; CFCFunction *self - = CFCFunction_new(parcel, exposure, class_name, class_nickname, - name, return_type, param_list, docucomment, - is_inline); + = CFCFunction_new(parcel, exposure, class_name, name, return_type, + param_list, docucomment, is_inline); RETVAL = S_cfcbase_to_perlref(self); CFCBase_decref((CFCBase*)self); OUTPUT: RETVAL @@ -823,11 +819,10 @@ PPCODE: MODULE = Clownfish::CFC PACKAGE = Clownfish::CFC::Model::Method SV* -_new(parcel, exposure_sv, class_name_sv, class_nickname_sv, name, return_type, param_list, docucomment, is_final, is_abstract) +_new(parcel, exposure_sv, class_name_sv, name, return_type, param_list, docucomment, is_final, is_abstract) CFCParcel *parcel; SV *exposure_sv; SV *class_name_sv; - SV *class_nickname_sv; const char *name; CFCType *return_type; CFCParamList *param_list; @@ -839,12 +834,9 @@ CODE: SvOK(exposure_sv) ? SvPV_nolen(exposure_sv) : NULL; const char *class_name = SvOK(class_name_sv) ? SvPV_nolen(class_name_sv) : NULL; - const char *class_nickname = - SvOK(class_nickname_sv) ? SvPV_nolen(class_nickname_sv) : NULL; CFCMethod *self - = CFCMethod_new(parcel, exposure, class_name, class_nickname, - name, return_type, param_list, docucomment, - is_final, is_abstract); + = CFCMethod_new(parcel, 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 @@ -1285,25 +1277,20 @@ PPCODE: MODULE = Clownfish::CFC PACKAGE = Clownfish::CFC::Model::Symbol SV* -_new(parcel, exposure, class_name_sv, class_nickname_sv, name_sv) +_new(parcel, exposure, class_name_sv, name_sv) CFCParcel *parcel; const char *exposure; SV *class_name_sv; - SV *class_nickname_sv; SV *name_sv; CODE: - const char *class_name = SvOK(class_name_sv) - ? SvPV_nolen(class_name_sv) - : NULL; - const char *class_nickname = SvOK(class_nickname_sv) - ? SvPV_nolen(class_nickname_sv) - : NULL; - const char *name = SvOK(name_sv) - ? SvPV_nolen(name_sv) - : NULL; + const char *class_name = SvOK(class_name_sv) + ? SvPV_nolen(class_name_sv) + : NULL; + const char *name = SvOK(name_sv) + ? SvPV_nolen(name_sv) + : NULL; CFCSymbol *self - = CFCSymbol_new(parcel, exposure, class_name, class_nickname, - name); + = CFCSymbol_new(parcel, exposure, class_name, name); RETVAL = S_cfcbase_to_perlref(self); CFCBase_decref((CFCBase*)self); OUTPUT: RETVAL @@ -1343,7 +1330,6 @@ _set_or_get(self, ...) ALIAS: get_parcel = 2 get_class_name = 4 - get_class_nickname = 6 get_exposure = 8 get_name = 10 get_prefix = 12 @@ -1368,14 +1354,6 @@ PPCODE: : newSV(0); } break; - case 6: { - const char *class_nickname - = CFCSymbol_get_class_nickname(self); - retval = class_nickname - ? newSVpvn(class_nickname, strlen(class_nickname)) - : newSV(0); - } - break; case 8: { const char *exposure = CFCSymbol_get_exposure(self); retval = newSVpvn(exposure, strlen(exposure)); @@ -1792,26 +1770,22 @@ OUTPUT: RETVAL MODULE = Clownfish::CFC PACKAGE = Clownfish::CFC::Model::Variable SV* -_new(parcel, exposure, class_name_sv, class_nickname_sv, name_sv, type_sv, inert_sv) +_new(parcel, exposure, class_name_sv, name_sv, type_sv, inert_sv) CFCParcel *parcel; const char *exposure; SV *class_name_sv; - SV *class_nickname_sv; SV *name_sv; SV *type_sv; SV *inert_sv; CODE: - const char *class_name = SvOK(class_name_sv) - ? SvPV_nolen(class_name_sv) - : NULL; - const char *class_nickname = SvOK(class_nickname_sv) - ? SvPV_nolen(class_nickname_sv) - : NULL; - const char *name = SvOK(name_sv) - ? SvPV_nolen(name_sv) - : NULL; - int inert = SvOK(inert_sv) - ? !!SvTRUE(inert_sv) : 0; + const char *class_name = SvOK(class_name_sv) + ? SvPV_nolen(class_name_sv) + : NULL; + const char *name = SvOK(name_sv) + ? SvPV_nolen(name_sv) + : NULL; + int inert = SvOK(inert_sv) + ? !!SvTRUE(inert_sv) : 0; CFCType *type = NULL; if (SvOK(type_sv) && sv_derived_from(type_sv, "Clownfish::CFC::Model::Type")) { IV objint = SvIV((SV*)SvRV(type_sv)); @@ -1821,8 +1795,7 @@ CODE: croak("Param 'type' is not a Clownfish::CFC::Model::Type"); } CFCVariable *self - = CFCVariable_new(parcel, exposure, class_name, class_nickname, - name, type, inert); + = CFCVariable_new(parcel, exposure, class_name, name, type, inert); RETVAL = S_cfcbase_to_perlref(self); CFCBase_decref((CFCBase*)self); OUTPUT: RETVAL @@ -2579,13 +2552,6 @@ set_class_name(self, class_name) PPCODE: CFCParser_set_class_name(self, class_name); -void -set_class_nickname(self, class_nickname) - CFCParser *self; - const char *class_nickname; -PPCODE: - CFCParser_set_class_nickname(self, class_nickname); - SV* get_parcel(self) CFCParser *self; http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/3ef65778/compiler/perl/t/051-symbol.t ---------------------------------------------------------------------- diff --git a/compiler/perl/t/051-symbol.t b/compiler/perl/t/051-symbol.t index 14c5262..bd08450 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 => 40; +use Test::More tests => 39; use Clownfish::CFC; my $parcel = Clownfish::CFC::Model::Parcel->new( name => 'Eep' ); @@ -41,8 +41,6 @@ my $foo = new_symbol( class_name => 'Foo' ); my $foo_jr = new_symbol( class_name => 'Foo::FooJr' ); ok( !$foo->equals($foo_jr), "different class_name spoils equals" ); is( $foo_jr->get_class_name, "Foo::FooJr", "get_class_name" ); -is( $foo_jr->get_class_nickname, "FooJr", - "derive class_nickname from class_name" ); my $public_exposure = new_symbol( exposure => 'public' ); my $parcel_exposure = new_symbol( exposure => 'parcel' ); http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/3ef65778/compiler/perl/t/200-function.t ---------------------------------------------------------------------- diff --git a/compiler/perl/t/200-function.t b/compiler/perl/t/200-function.t index 859907b..1384a7d 100644 --- a/compiler/perl/t/200-function.t +++ b/compiler/perl/t/200-function.t @@ -27,12 +27,11 @@ $parser->parse('parcel Neato;') or die "failed to process parcel_definition"; my %args = ( - parcel => 'Neato', - return_type => $parser->parse('Obj*'), - class_name => 'Neato::Foo', - class_nickname => 'Foo', - param_list => $parser->parse('(int32_t some_num)'), - name => 'return_an_obj', + parcel => 'Neato', + return_type => $parser->parse('Obj*'), + class_name => 'Neato::Foo', + param_list => $parser->parse('(int32_t some_num)'), + name => 'return_an_obj', ); my $func = Clownfish::CFC::Model::Function->new(%args); @@ -48,7 +47,6 @@ eval { Clownfish::CFC::Model::Function->new( %args, name => 'Uh_Oh' ); }; like( $@, qr/Uh_Oh/, "invalid name kills constructor" ); $parser->set_class_name("Neato::Obj"); -$parser->set_class_nickname("Obj"); isa_ok( $parser->parse($_), "Clownfish::CFC::Model::Function", http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/3ef65778/compiler/perl/t/201-method.t ---------------------------------------------------------------------- diff --git a/compiler/perl/t/201-method.t b/compiler/perl/t/201-method.t index 268a7e5..8af24d7 100644 --- a/compiler/perl/t/201-method.t +++ b/compiler/perl/t/201-method.t @@ -26,12 +26,11 @@ $parser->parse('parcel Neato;') or die "failed to process parcel_definition"; my %args = ( - parcel => 'Neato', - return_type => $parser->parse('Obj*'), - class_name => 'Neato::Foo', - class_nickname => 'Foo', - param_list => $parser->parse('(Foo *self, int32_t count = 0)'), - name => 'Return_An_Obj', + parcel => 'Neato', + return_type => $parser->parse('Obj*'), + class_name => 'Neato::Foo', + param_list => $parser->parse('(Foo *self, int32_t count = 0)'), + name => 'Return_An_Obj', ); my $method = Clownfish::CFC::Model::Method->new(%args); @@ -97,9 +96,8 @@ ok( !$param_type_differs->compatible($method), "... reversed" ); my $self_type_differs = Clownfish::CFC::Model::Method->new( %args, - class_name => 'Neato::Bar', - class_nickname => 'Bar', - param_list => $parser->parse('(Bar *self, int32_t count = 0)'), + class_name => 'Neato::Bar', + param_list => $parser->parse('(Bar *self, int32_t count = 0)'), ); ok( $method->compatible($self_type_differs), "different self type still compatible(), since can't test inheritance" ); @@ -119,7 +117,6 @@ for my $meth_meth (qw( short_method_sym full_method_sym full_offset_sym)) { } $parser->set_class_name("Neato::Obj"); -$parser->set_class_nickname("Obj"); isa_ok( $parser->parse($_), "Clownfish::CFC::Model::Method", http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/3ef65778/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 ebda8b6..792a08a 100644 --- a/compiler/perl/t/202-overridden_method.t +++ b/compiler/perl/t/202-overridden_method.t @@ -26,20 +26,18 @@ $parser->parse('parcel Neato;') or die "failed to process parcel_definition"; my %args = ( - return_type => $parser->parse('Obj*'), - class_name => 'Neato::Foo', - class_nickname => 'Foo', - param_list => $parser->parse('(Foo *self)'), - name => 'Return_An_Obj', - parcel => 'Neato', + return_type => $parser->parse('Obj*'), + class_name => 'Neato::Foo', + param_list => $parser->parse('(Foo *self)'), + name => 'Return_An_Obj', + parcel => 'Neato', ); my $orig = Clownfish::CFC::Model::Method->new(%args); my $overrider = Clownfish::CFC::Model::Method->new( %args, - param_list => $parser->parse('(FooJr *self)'), - class_name => 'Neato::Foo::FooJr', - class_nickname => 'FooJr' + param_list => $parser->parse('(FooJr *self)'), + class_name => 'Neato::Foo::FooJr', ); $overrider->override($orig); ok( !$overrider->novel, "A Method which overrides another is not 'novel'" ); http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/3ef65778/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 f2c2ca8..5122ba5 100644 --- a/compiler/perl/t/203-final_method.t +++ b/compiler/perl/t/203-final_method.t @@ -25,12 +25,11 @@ $parser->parse('parcel Neato;') or die "failed to process parcel_definition"; my %args = ( - return_type => $parser->parse('Obj*'), - class_name => 'Neato::Foo', - class_nickname => 'Foo', - param_list => $parser->parse('(Foo* self)'), - name => 'Return_An_Obj', - parcel => 'Neato', + return_type => $parser->parse('Obj*'), + 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/3ef65778/compiler/perl/t/300-variable.t ---------------------------------------------------------------------- diff --git a/compiler/perl/t/300-variable.t b/compiler/perl/t/300-variable.t index 83c9273..2ab2d62 100644 --- a/compiler/perl/t/300-variable.t +++ b/compiler/perl/t/300-variable.t @@ -75,11 +75,10 @@ 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', - class_nickname => 'LobClaw', + parcel => 'Neato', + name => 'foo', + type => new_type("Foo*"), + class_name => 'Crustacean::Lobster::LobsterClaw', ); $var->resolve_type; is( $var->global_c($lobclaw_class), 'neato_Foo* neato_LobClaw_foo', http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/3ef65778/compiler/perl/t/401-class.t ---------------------------------------------------------------------- diff --git a/compiler/perl/t/401-class.t b/compiler/perl/t/401-class.t index a392370..3560dae 100644 --- a/compiler/perl/t/401-class.t +++ b/compiler/perl/t/401-class.t @@ -16,7 +16,7 @@ use strict; use warnings; -use Test::More tests => 53; +use Test::More tests => 54; use Clownfish::CFC::Model::Class; use Clownfish::CFC::Parser; @@ -92,6 +92,8 @@ my $foo_jr = Clownfish::CFC::Model::Class->create( is( $foo_jr->get_struct_sym, 'FooJr', "struct_sym" ); is( $foo_jr->full_struct_sym, 'neato_FooJr', "full_struct_sym" ); +is( $foo_jr->get_nickname, "FooJr", + "derive class_nickname from class_name" ); my $file_spec = Clownfish::CFC::Model::FileSpec->new( source_dir => '.', http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/3ef65778/compiler/perl/t/600-parser.t ---------------------------------------------------------------------- diff --git a/compiler/perl/t/600-parser.t b/compiler/perl/t/600-parser.t index f8063ae..468c116 100644 --- a/compiler/perl/t/600-parser.t +++ b/compiler/perl/t/600-parser.t @@ -122,7 +122,6 @@ is_deeply( ); $parser->set_class_name('Stuff::Obj'); -$parser->set_class_nickname('Obj'); ok( $parser->parse($_), "declaration statement: $_" ) for ( 'public Foo* Spew_Foo(Obj *self, uint32_t *how_many);', http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/3ef65778/compiler/src/CFCCallable.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCCallable.c b/compiler/src/CFCCallable.c index 05aa572..4ab581e 100644 --- a/compiler/src/CFCCallable.c +++ b/compiler/src/CFCCallable.c @@ -40,16 +40,15 @@ static const CFCMeta CFCCALLABLE_META = { CFCCallable* CFCCallable_init(CFCCallable *self, CFCParcel *parcel, const char *exposure, - const char *class_name, const char *class_nickname, - const char *name, CFCType *return_type, - CFCParamList *param_list, CFCDocuComment *docucomment) { + const char *class_name, const char *name, + CFCType *return_type, CFCParamList *param_list, + CFCDocuComment *docucomment) { exposure = exposure ? exposure : "parcel"; CFCUTIL_NULL_CHECK(class_name); CFCUTIL_NULL_CHECK(return_type); CFCUTIL_NULL_CHECK(param_list); - CFCSymbol_init((CFCSymbol*)self, parcel, exposure, class_name, - class_nickname, name); + CFCSymbol_init((CFCSymbol*)self, parcel, 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/3ef65778/compiler/src/CFCCallable.h ---------------------------------------------------------------------- diff --git a/compiler/src/CFCCallable.h b/compiler/src/CFCCallable.h index 3c85c57..0a68e82 100644 --- a/compiler/src/CFCCallable.h +++ b/compiler/src/CFCCallable.h @@ -48,7 +48,6 @@ struct CFCCallable { * L<Clownfish::CFC::Model::Symbol>). * @param class_name The full name of the class in whose namespace the * function resides. - * @param class_nickname The C nickname for the class. * @param name The name of the callable, without any namespacing prefixes. * @param return_type A Clownfish::CFC::Model::Type representing the * callable's return type. @@ -60,8 +59,8 @@ struct CFCCallable { CFCCallable* CFCCallable_init(CFCCallable *self, struct CFCParcel *parcel, const char *exposure, const char *class_name, - const char *class_nickname, const char *name, - struct CFCType *return_type, struct CFCParamList *param_list, + 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/3ef65778/compiler/src/CFCClass.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCClass.c b/compiler/src/CFCClass.c index 053a4c3..192723f 100644 --- a/compiler/src/CFCClass.c +++ b/compiler/src/CFCClass.c @@ -49,6 +49,7 @@ S_register(CFCClass *self); struct CFCClass { CFCSymbol symbol; + char *nickname; int tree_grown; CFCDocuComment *docucomment; struct CFCClass *parent; @@ -114,6 +115,22 @@ CFCClass_create(struct CFCParcel *parcel, const char *exposure, is_final, is_inert, is_abstract); } +static int +S_validate_nickname(const char *nickname) { + // Allow all caps. + const char *ptr; + for (ptr = nickname; ; ptr++) { + if (*ptr == 0) { + if (strlen(nickname)) { return true; } + else { break; } + } + else if (!isupper(*ptr)) { break; } + } + + // Same as one component of a class name. + return CFCSymbol_validate_class_name_component(nickname); +} + CFCClass* CFCClass_do_create(CFCClass *self, struct CFCParcel *parcel, const char *exposure, const char *class_name, @@ -124,16 +141,41 @@ CFCClass_do_create(CFCClass *self, struct CFCParcel *parcel, CFCUTIL_NULL_CHECK(class_name); exposure = exposure ? exposure : "parcel"; name = name ? name : "class"; - CFCSymbol_init((CFCSymbol*)self, parcel, exposure, class_name, nickname, - name); + + // Derive nickname if necessary, then validate. + const char *real_nickname = NULL; + if (class_name) { + if (nickname) { + real_nickname = nickname; + } + else { + const char *last_colon = strrchr(class_name, ':'); + real_nickname = last_colon ? last_colon + 1 : class_name; + } + } + else if (nickname) { + // Sanity check nickname without class_name. + CFCBase_decref((CFCBase*)self); + CFCUtil_die("Can't supply nickname without class_name"); + } + else { + real_nickname = NULL; + } + if (real_nickname && !S_validate_nickname(real_nickname)) { + CFCBase_decref((CFCBase*)self); + CFCUtil_die("Invalid nickname: '%s'", real_nickname); + } + + CFCSymbol_init((CFCSymbol*)self, parcel, exposure, class_name, name); if (!is_inert && !parent_class_name && strcmp(class_name, "Clownfish::Obj") != 0 ) { parent_class_name = "Clownfish::Obj"; } - self->parent = NULL; - self->tree_grown = false; + self->nickname = CFCUtil_strdup(real_nickname); + self->tree_grown = false; + self->parent = NULL; self->children = (CFCClass**)CALLOCATE(1, sizeof(CFCClass*)); self->num_kids = 0; self->functions = (CFCFunction**)CALLOCATE(1, sizeof(CFCFunction*)); @@ -231,6 +273,7 @@ S_free_cfcbase_array(CFCBase **array) { void CFCClass_destroy(CFCClass *self) { + FREEMEM(self->nickname); CFCBase_decref((CFCBase*)self->docucomment); CFCBase_decref((CFCBase*)self->parent); CFCBase_decref((CFCBase*)self->file_spec); @@ -718,7 +761,7 @@ CFCClass_inert_vars(CFCClass *self) { const char* CFCClass_get_nickname(CFCClass *self) { - return CFCSymbol_get_class_nickname((CFCSymbol*)self); + return self->nickname; } void http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/3ef65778/compiler/src/CFCClass.h ---------------------------------------------------------------------- diff --git a/compiler/src/CFCClass.h b/compiler/src/CFCClass.h index bdba617..a027242 100644 --- a/compiler/src/CFCClass.h +++ b/compiler/src/CFCClass.h @@ -44,7 +44,9 @@ struct CFCFileSpec; * @param parcel See Clownfish::CFC::Model::Symbol. * @param exposure See Clownfish::CFC::Model::Symbol. * @param class_name See Clownfish::CFC::Model::Symbol. - * @param nickname See Clownfish::CFC::Model::Symbol. + * @param class_nickname The C nickname associated with the supplied class + * name. If not supplied, will be derived if possible from C<class_name> by + * extracting the last class name component. * @param name Defaults to "class". * @param docucomment An optional Clownfish::CFC::Model::DocuComment attached * to this class. http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/3ef65778/compiler/src/CFCFunction.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCFunction.c b/compiler/src/CFCFunction.c index d83115c..791e882 100644 --- a/compiler/src/CFCFunction.c +++ b/compiler/src/CFCFunction.c @@ -46,14 +46,12 @@ static const CFCMeta CFCFUNCTION_META = { CFCFunction* CFCFunction_new(CFCParcel *parcel, const char *exposure, - const char *class_name, const char *class_nickname, - const char *name, CFCType *return_type, + 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, class_nickname, - name, return_type, param_list, docucomment, - is_inline); + return CFCFunction_init(self, parcel, exposure, class_name, name, + return_type, param_list, docucomment, is_inline); } static int @@ -69,18 +67,16 @@ S_validate_function_name(const char *name) { CFCFunction* CFCFunction_init(CFCFunction *self, CFCParcel *parcel, const char *exposure, - const char *class_name, const char *class_nickname, - const char *name, CFCType *return_type, - CFCParamList *param_list, CFCDocuComment *docucomment, - int is_inline) { + const char *class_name, const char *name, + CFCType *return_type, CFCParamList *param_list, + CFCDocuComment *docucomment, int is_inline) { if (!S_validate_function_name(name)) { CFCBase_decref((CFCBase*)self); CFCUtil_die("Invalid function name: '%s'", name); } - CFCCallable_init((CFCCallable*)self, parcel, exposure, class_name, - class_nickname, name, return_type, param_list, - docucomment); + CFCCallable_init((CFCCallable*)self, parcel, 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/3ef65778/compiler/src/CFCFunction.h ---------------------------------------------------------------------- diff --git a/compiler/src/CFCFunction.h b/compiler/src/CFCFunction.h index 4ac17c5..0f3bd21 100644 --- a/compiler/src/CFCFunction.h +++ b/compiler/src/CFCFunction.h @@ -37,7 +37,6 @@ struct CFCClass; * L<Clownfish::CFC::Model::Symbol>). * @param class_name The full name of the class in whose namespace the * function resides. - * @param class_nickname The C nickname for the class. * @param name The name of the function, without any namespacing prefixes. * @param return_type A Clownfish::CFC::Model::Type representing the * function's return type. @@ -50,16 +49,15 @@ struct CFCClass; */ CFCFunction* CFCFunction_new(struct CFCParcel *parcel, const char *exposure, - const char *class_name, const char *class_nickname, - const char *name, struct CFCType *return_type, - struct CFCParamList *param_list, + 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 *class_nickname, const char *name, - struct CFCType *return_type, struct CFCParamList *param_list, + 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/3ef65778/compiler/src/CFCMethod.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCMethod.c b/compiler/src/CFCMethod.c index f8d1e76..32b97fb 100644 --- a/compiler/src/CFCMethod.c +++ b/compiler/src/CFCMethod.c @@ -52,13 +52,12 @@ static const CFCMeta CFCMETHOD_META = { CFCMethod* CFCMethod_new(CFCParcel *parcel, const char *exposure, const char *class_name, - const char *class_nickname, const char *name, - CFCType *return_type, CFCParamList *param_list, + 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, class_nickname, - name, return_type, param_list, docucomment, - is_final, is_abstract); + return CFCMethod_init(self, parcel, exposure, class_name, name, + return_type, param_list, docucomment, is_final, + is_abstract); } static int @@ -85,8 +84,7 @@ S_validate_meth_name(const char *meth_name) { CFCMethod* CFCMethod_init(CFCMethod *self, CFCParcel *parcel, const char *exposure, - const char *class_name, const char *class_nickname, - const char *name, CFCType *return_type, + const char *class_name, const char *name, CFCType *return_type, CFCParamList *param_list, CFCDocuComment *docucomment, int is_final, int is_abstract) { // Validate name. @@ -97,9 +95,8 @@ CFCMethod_init(CFCMethod *self, CFCParcel *parcel, const char *exposure, } // Super-init. - CFCCallable_init((CFCCallable*)self, parcel, exposure, class_name, - class_nickname, name, return_type, param_list, - docucomment); + CFCCallable_init((CFCCallable*)self, parcel, 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); @@ -231,11 +228,10 @@ 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 *class_nickname = CFCMethod_get_class_nickname(self); const char *name = CFCMethod_get_name(self); CFCMethod *finalized - = CFCMethod_new(parcel, exposure, class_name, class_nickname, - name, self->callable.return_type, + = CFCMethod_new(parcel, exposure, class_name, name, + self->callable.return_type, self->callable.param_list, self->callable.docucomment, true, self->is_abstract); @@ -412,11 +408,6 @@ CFCMethod_get_class_name(CFCMethod *self) { return CFCSymbol_get_class_name((CFCSymbol*)self); } -const char* -CFCMethod_get_class_nickname(CFCMethod *self) { - return CFCSymbol_get_class_nickname((CFCSymbol*)self);; -} - int CFCMethod_public(CFCMethod *self) { return CFCSymbol_public((CFCSymbol*)self); http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/3ef65778/compiler/src/CFCMethod.h ---------------------------------------------------------------------- diff --git a/compiler/src/CFCMethod.h b/compiler/src/CFCMethod.h index 8ac6395..d8fb6b7 100644 --- a/compiler/src/CFCMethod.h +++ b/compiler/src/CFCMethod.h @@ -44,7 +44,6 @@ struct CFCDocuComment; * @param exposure See Clownfish::CFC::Model::Symbol. Defaults to "parcel" * if not supplied. * @param class_name See Clownfish::CFC::Model::Function. - * @param class_nickname See Clownfish::CFC::Model::Function. * @param name - The mixed case name which will be used when invoking the * method. * @param return_type See Clownfish::CFC::Model::Function. @@ -56,16 +55,14 @@ struct CFCDocuComment; */ CFCMethod* CFCMethod_new(struct CFCParcel *parcel, const char *exposure, - const char *class_name, const char *class_nickname, - const char *name, struct CFCType *return_type, - struct CFCParamList *param_list, + 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 *class_nickname, const char *name, + 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); @@ -226,9 +223,6 @@ CFCMethod_get_exposure(CFCMethod *self); const char* CFCMethod_get_class_name(CFCMethod *self); -const char* -CFCMethod_get_class_nickname(CFCMethod *self); - int CFCMethod_public(CFCMethod *self); http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/3ef65778/compiler/src/CFCParseHeader.y ---------------------------------------------------------------------- diff --git a/compiler/src/CFCParseHeader.y b/compiler/src/CFCParseHeader.y index bff080e..75c6515 100644 --- a/compiler/src/CFCParseHeader.y +++ b/compiler/src/CFCParseHeader.y @@ -50,7 +50,6 @@ S_start_class(CFCParser *state, CFCDocuComment *docucomment, char *exposure, is_abstract = !!strstr(modifiers, "abstract"); } CFCParser_set_class_name(state, class_name); - CFCParser_set_class_nickname(state, class_nickname); CFCParser_set_class_final(state, is_final); CFCClass *klass = CFCClass_create(CFCParser_get_parcel(state), exposure, class_name, class_nickname, NULL, @@ -73,13 +72,11 @@ S_new_var(CFCParser *state, char *exposure, char *modifiers, CFCType *type, CFCParcel *parcel = CFCParser_get_parcel(state); const char *class_name = NULL; - const char *class_nickname = NULL; if (exposure && strcmp(exposure, "local") != 0) { class_name = CFCParser_get_class_name(state); - class_nickname = CFCParser_get_class_nickname(state); } - CFCVariable *var = CFCVariable_new(parcel, exposure, class_name, - class_nickname, name, type, inert); + CFCVariable *var = CFCVariable_new(parcel, exposure, class_name, name, + type, inert); /* Consume tokens. */ CFCBase_decref((CFCBase*)type); @@ -91,9 +88,8 @@ 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); - const char *class_nickname = CFCParser_get_class_nickname(state); + CFCParcel *parcel = CFCParser_get_parcel(state); + const char *class_name = CFCParser_get_class_name(state); /* Find modifiers by scanning the list. */ int is_abstract = false; @@ -119,17 +115,17 @@ 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, - class_nickname, name, type, - param_list, docucomment, is_inline); + sub = (CFCBase*)CFCFunction_new(parcel, 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, - class_nickname, name, type, param_list, - docucomment, is_final, is_abstract); + sub = (CFCBase*)CFCMethod_new(parcel, exposure, class_name, name, type, + param_list, docucomment, is_final, + is_abstract); } /* Consume tokens. */ @@ -349,7 +345,6 @@ class_declaration(A) ::= class_defs(B) RIGHT_CURLY_BRACE. { A = B; CFCParser_set_class_name(state, NULL); - CFCParser_set_class_nickname(state, NULL); } class_head(A) ::= docucomment(B) exposure_specifier(C) declaration_modifier_list(D) CLASS qualified_id(E) nickname(F) class_inheritance(G). { A = S_start_class(state, B, C, D, E, F, G ); } http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/3ef65778/compiler/src/CFCParser.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCParser.c b/compiler/src/CFCParser.c index 01bf47b..a49a6c4 100644 --- a/compiler/src/CFCParser.c +++ b/compiler/src/CFCParser.c @@ -40,7 +40,6 @@ struct CFCParser { int errors; int lineno; char *class_name; - char *class_nickname; int class_is_final; CFCFileSpec *file_spec; CFCMemPool *pool; @@ -69,7 +68,6 @@ CFCParser_init(CFCParser *self) { self->errors = false; self->lineno = 0; self->class_name = NULL; - self->class_nickname = NULL; self->file_spec = NULL; self->pool = NULL; self->parcel = NULL; @@ -80,7 +78,6 @@ void CFCParser_destroy(CFCParser *self) { CFCParseHeaderFree(self->header_parser, free); FREEMEM(self->class_name); - FREEMEM(self->class_nickname); CFCBase_decref((CFCBase*)self->file_spec); CFCBase_decref((CFCBase*)self->pool); CFCBase_decref(self->result); @@ -195,22 +192,6 @@ CFCParser_get_class_name(CFCParser *self) { } void -CFCParser_set_class_nickname(CFCParser *self, const char *class_nickname) { - FREEMEM(self->class_nickname); - if (class_nickname) { - self->class_nickname = CFCUtil_strdup(class_nickname); - } - else { - self->class_nickname = NULL; - } -} - -const char* -CFCParser_get_class_nickname(CFCParser *self) { - return self->class_nickname; -} - -void CFCParser_set_class_final(CFCParser *self, int is_final) { self->class_is_final = is_final; } http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/3ef65778/compiler/src/CFCParser.h ---------------------------------------------------------------------- diff --git a/compiler/src/CFCParser.h b/compiler/src/CFCParser.h index cf23153..cd862c0 100644 --- a/compiler/src/CFCParser.h +++ b/compiler/src/CFCParser.h @@ -89,12 +89,6 @@ const char* CFCParser_get_class_name(CFCParser *self); void -CFCParser_set_class_nickname(CFCParser *self, const char *class_nickname); - -const char* -CFCParser_get_class_nickname(CFCParser *self); - -void CFCParser_set_class_final(CFCParser *self, int is_final); int http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/3ef65778/compiler/src/CFCSymbol.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCSymbol.c b/compiler/src/CFCSymbol.c index dfb1150..bfa985d 100644 --- a/compiler/src/CFCSymbol.c +++ b/compiler/src/CFCSymbol.c @@ -36,11 +36,9 @@ static const CFCMeta CFCSYMBOL_META = { CFCSymbol* CFCSymbol_new(struct CFCParcel *parcel, const char *exposure, - const char *class_name, const char *class_nickname, - const char *name) { + const char *class_name, const char *name) { CFCSymbol *self = (CFCSymbol*)CFCBase_allocate(&CFCSYMBOL_META); - return CFCSymbol_init(self, parcel, exposure, class_name, class_nickname, - name); + return CFCSymbol_init(self, parcel, exposure, class_name, name); } static int @@ -95,22 +93,6 @@ CFCSymbol_validate_class_name_component(const char *name) { } static int -S_validate_class_nickname(const char *class_nickname) { - // Allow all caps. - const char *ptr; - for (ptr = class_nickname; ; ptr++) { - if (*ptr == 0) { - if (strlen(class_nickname)) { return true; } - else { break; } - } - else if (!isupper(*ptr)) { break; } - } - - // Same as one component of a class name. - return CFCSymbol_validate_class_name_component(class_nickname); -} - -static int S_validate_identifier(const char *identifier) { const char *ptr = identifier; if (!isalpha(*ptr) && *ptr != '_') { return false; } @@ -121,9 +103,8 @@ S_validate_identifier(const char *identifier) { } CFCSymbol* -CFCSymbol_init(CFCSymbol *self, struct CFCParcel *parcel, - const char *exposure, const char *class_name, - const char *class_nickname, const char *name) { +CFCSymbol_init(CFCSymbol *self, struct CFCParcel *parcel, const char *exposure, + const char *class_name, const char *name) { // Validate. CFCUTIL_NULL_CHECK(parcel); if (!S_validate_exposure(exposure)) { @@ -139,35 +120,10 @@ CFCSymbol_init(CFCSymbol *self, struct CFCParcel *parcel, CFCUtil_die("Invalid name: '%s'", name ? name : "[NULL]"); } - // Derive class_nickname if necessary, then validate. - const char *real_nickname = NULL; - if (class_name) { - if (class_nickname) { - real_nickname = class_nickname; - } - else { - const char *last_colon = strrchr(class_name, ':'); - real_nickname = last_colon ? last_colon + 1 : class_name; - } - } - else if (class_nickname) { - // Sanity check class_nickname without class_name. - CFCBase_decref((CFCBase*)self); - CFCUtil_die("Can't supply class_nickname without class_name"); - } - else { - real_nickname = NULL; - } - if (real_nickname && !S_validate_class_nickname(real_nickname)) { - CFCBase_decref((CFCBase*)self); - CFCUtil_die("Invalid class_nickname: '%s'", real_nickname); - } - // Assign. self->parcel = (CFCParcel*)CFCBase_incref((CFCBase*)parcel); self->exposure = CFCUtil_strdup(exposure); self->class_name = CFCUtil_strdup(class_name); - self->class_nickname = CFCUtil_strdup(real_nickname); self->name = CFCUtil_strdup(name); return self; @@ -178,7 +134,6 @@ CFCSymbol_destroy(CFCSymbol *self) { CFCBase_decref((CFCBase*)self->parcel); FREEMEM(self->exposure); FREEMEM(self->class_name); - FREEMEM(self->class_nickname); FREEMEM(self->name); CFCBase_destroy((CFCBase*)self); } @@ -246,11 +201,6 @@ CFCSymbol_get_class_name(CFCSymbol *self) { } const char* -CFCSymbol_get_class_nickname(CFCSymbol *self) { - return self->class_nickname; -} - -const char* CFCSymbol_get_exposure(CFCSymbol *self) { return self->exposure; } http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/3ef65778/compiler/src/CFCSymbol.h ---------------------------------------------------------------------- diff --git a/compiler/src/CFCSymbol.h b/compiler/src/CFCSymbol.h index 7f57d52..2e365af 100644 --- a/compiler/src/CFCSymbol.h +++ b/compiler/src/CFCSymbol.h @@ -40,7 +40,6 @@ struct CFCSymbol { struct CFCParcel *parcel; char *exposure; char *class_name; - char *class_nickname; char *name; }; #endif @@ -60,20 +59,15 @@ CFCSymbol_validate_class_name_component(const char *name); * components separated by "::". Each component must start with a capital * letter, contain at least one lower-case letter, and consist entirely of the * characters [A-Za-z0-9]. - * @param class_nickname The C nickname associated with the supplied class - * name. If not supplied, will be derived if possible from C<class_name> by - * extracting the last class name component. * @param name The local identifier for the symbol. */ CFCSymbol* CFCSymbol_new(struct CFCParcel *parcel, const char *exposure, - const char *class_name, const char *class_nickname, - const char *name); + const char *class_name, const char *name); CFCSymbol* CFCSymbol_init(CFCSymbol *self, struct CFCParcel *parcel, const char *exposure, - const char *class_name, const char *class_nickname, - const char *name); + const char *class_name, const char *name); void CFCSymbol_destroy(CFCSymbol *self); @@ -90,10 +84,6 @@ CFCSymbol_get_parcel(CFCSymbol *self); const char* CFCSymbol_get_class_name(CFCSymbol *self); -// May be NULL. -const char* -CFCSymbol_get_class_nickname(CFCSymbol *self); - const char* CFCSymbol_get_exposure(CFCSymbol *self); http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/3ef65778/compiler/src/CFCTestClass.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCTestClass.c b/compiler/src/CFCTestClass.c index a35399e..7f0e871 100644 --- a/compiler/src/CFCTestClass.c +++ b/compiler/src/CFCTestClass.c @@ -44,7 +44,7 @@ S_has_symbol(CFCSymbol **symbols, const char *name); const CFCTestBatch CFCTEST_BATCH_CLASS = { "Clownfish::CFC::Model::Class", - 85, + 86, S_run_tests }; @@ -65,19 +65,18 @@ S_run_tests(CFCTest *test) { { CFCType *thing_type = CFCTest_parse_type(test, parser, "Thing*"); - thing = CFCVariable_new(neato, NULL, "Foo", NULL, "thing", - thing_type, 0); + thing = CFCVariable_new(neato, NULL, "Foo", "thing", thing_type, 0); CFCType *widget_type = CFCTest_parse_type(test, parser, "Widget*"); - widget = CFCVariable_new(neato, NULL, "Widget", NULL, "widget", - widget_type, 0); + widget = CFCVariable_new(neato, 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", NULL, "tread_water", - return_type, param_list, NULL, 0); + = CFCFunction_new(neato, NULL, "Foo", "tread_water", return_type, + param_list, NULL, 0); CFCBase_decref((CFCBase*)thing_type); CFCBase_decref((CFCBase*)widget_type); @@ -104,6 +103,8 @@ S_run_tests(CFCTest *test) { "get_struct_sym"); STR_EQ(test, CFCClass_full_struct_sym(foo_jr), "neato_FooJr", "full_struct_sym"); + STR_EQ(test, CFCClass_get_nickname(foo_jr), "FooJr", + "derive class nickname from class name"); CFCClass *final_foo = CFCClass_create(neato, NULL, "Foo::FooJr::FinalFoo", NULL, NULL, NULL, http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/3ef65778/compiler/src/CFCTestFunction.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCTestFunction.c b/compiler/src/CFCTestFunction.c index a2b4d6d..9ad7e4d 100644 --- a/compiler/src/CFCTestFunction.c +++ b/compiler/src/CFCTestFunction.c @@ -43,9 +43,9 @@ 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", "Foo", - "return_an_obj", return_type, param_list, - NULL, 0); + = CFCFunction_new(neato_parcel, NULL, "Neato::Foo", + "return_an_obj", return_type, param_list, NULL, + 0); OK(test, func != NULL, "new"); CFCBase_decref((CFCBase*)return_type); @@ -55,7 +55,6 @@ S_run_tests(CFCTest *test) { { CFCParser_set_class_name(parser, "Neato::Obj"); - CFCParser_set_class_nickname(parser, "Obj"); static const char *func_strings[2] = { "inert int running_count(int biscuit);", "public inert Hash* init_fave_hash(int32_t num_buckets," http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/3ef65778/compiler/src/CFCTestMethod.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCTestMethod.c b/compiler/src/CFCTestMethod.c index 43be233..d0dc193 100644 --- a/compiler/src/CFCTestMethod.c +++ b/compiler/src/CFCTestMethod.c @@ -65,25 +65,23 @@ 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", "Foo", - "Return_An_Obj", return_type, param_list, - NULL, 0, 0); + = CFCMethod_new(neato_parcel, 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", "Foo", - "Return_An_Obj", return_type, param_list, - NULL, 0, 0); + = CFCMethod_new(neato_parcel, 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", "Foo", "Eat", + = CFCMethod_new(neato_parcel, NULL, "Neato::Foo", "Eat", return_type, param_list, NULL, 0, 0); OK(test, !CFCMethod_compatible(method, name_differs), "different name spoils compatible"); @@ -111,7 +109,7 @@ 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", "Foo", + = CFCMethod_new(neato_parcel, NULL, "Neato::Foo", "Return_An_Obj", return_type, other_param_list, NULL, 0, 0); OK(test, !CFCMethod_compatible(method, other), @@ -128,9 +126,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", "Bar", - "Return_An_Obj", return_type, self_differs_list, - NULL, 0, 0); + = CFCMethod_new(neato_parcel, 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"); @@ -142,9 +139,8 @@ S_run_basic_tests(CFCTest *test) { { CFCMethod *aliased - = CFCMethod_new(neato_parcel, NULL, "Neato::Foo", "Foo", - "Aliased", return_type, param_list, - NULL, 0, 0); + = CFCMethod_new(neato_parcel, 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"); @@ -155,9 +151,8 @@ S_run_basic_tests(CFCTest *test) { { CFCMethod *excluded - = CFCMethod_new(neato_parcel, NULL, "Neato::Foo", "Foo", - "Excluded", return_type, param_list, - NULL, 0, 0); + = CFCMethod_new(neato_parcel, 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); @@ -180,7 +175,6 @@ S_run_parser_tests(CFCTest *test) { CFCParcel *neato_parcel = CFCTest_parse_parcel(test, parser, "parcel Neato;"); CFCParser_set_class_name(parser, "Neato::Obj"); - CFCParser_set_class_nickname(parser, "Obj"); { static const char *method_strings[4] = { @@ -220,14 +214,13 @@ 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", "Foo", - "Return_An_Obj", return_type, param_list, - NULL, 0, 0); + = CFCMethod_new(neato_parcel, 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", "FooJr", + = CFCMethod_new(neato_parcel, NULL, "Neato::Foo::FooJr", "Return_An_Obj", return_type, overrider_param_list, NULL, 0, 0); @@ -260,9 +253,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", "Foo", - "Return_An_Obj", return_type, param_list, - NULL, 0, 0); + = CFCMethod_new(neato_parcel, 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/3ef65778/compiler/src/CFCTestParcel.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCTestParcel.c b/compiler/src/CFCTestParcel.c index 0c171e2..3003173 100644 --- a/compiler/src/CFCTestParcel.c +++ b/compiler/src/CFCTestParcel.c @@ -118,7 +118,7 @@ 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, NULL, "sym"); + 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_", http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/3ef65778/compiler/src/CFCTestParser.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCTestParser.c b/compiler/src/CFCTestParser.c index 097b1e5..879cff6 100644 --- a/compiler/src/CFCTestParser.c +++ b/compiler/src/CFCTestParser.c @@ -262,7 +262,6 @@ S_run_tests(CFCTest *test) { { CFCParser_set_class_name(parser, "Stuff::Obj"); - CFCParser_set_class_nickname(parser, "Obj"); const char *method_string = "public Foo* Spew_Foo(Obj *self, uint32_t *how_many);"; http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/3ef65778/compiler/src/CFCTestSymbol.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCTestSymbol.c b/compiler/src/CFCTestSymbol.c index cfb1d67..11a2c03 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", - 28, + 27, S_run_tests }; @@ -52,7 +52,7 @@ S_run_tests(CFCTest *test) { }; for (int i = 0; i < 4; ++i) { CFCSymbol *symbol - = CFCSymbol_new(parcel, exposures[i], NULL, NULL, "sym"); + = CFCSymbol_new(parcel, exposures[i], NULL, "sym"); for (int j = 0; j < 4; ++j) { int has_exposure = accessors[j](symbol); if (i == j) { @@ -68,17 +68,14 @@ S_run_tests(CFCTest *test) { } { - CFCSymbol *foo = CFCSymbol_new(parcel, "parcel", "Foo", NULL, "sym"); + CFCSymbol *foo = CFCSymbol_new(parcel, "parcel", "Foo", "sym"); CFCSymbol *foo_jr - = CFCSymbol_new(parcel, "parcel", "Foo::FooJr", NULL, "sym"); + = CFCSymbol_new(parcel, "parcel", "Foo::FooJr", "sym"); int equal = CFCSymbol_equals(foo, foo_jr); OK(test, !equal, "different class_name spoils equals"); const char *foo_jr_name = CFCSymbol_get_class_name(foo_jr); STR_EQ(test, foo_jr_name, "Foo::FooJr", "get_class_name"); - const char *foo_jr_nickname = CFCSymbol_get_class_nickname(foo_jr); - STR_EQ(test, foo_jr_nickname, "FooJr", - "derive class_nickname from class_name"); CFCBase_decref((CFCBase*)foo); CFCBase_decref((CFCBase*)foo_jr); @@ -86,9 +83,9 @@ S_run_tests(CFCTest *test) { { CFCSymbol *public_exposure - = CFCSymbol_new(parcel, "public", NULL, NULL, "sym"); + = CFCSymbol_new(parcel, "public", NULL, "sym"); CFCSymbol *parcel_exposure - = CFCSymbol_new(parcel, "parcel", NULL, NULL, "sym"); + = CFCSymbol_new(parcel, "parcel", NULL, "sym"); int equal = CFCSymbol_equals(public_exposure, parcel_exposure); OK(test, !equal, "different exposure spoils equals"); CFCBase_decref((CFCBase*)public_exposure); @@ -100,7 +97,7 @@ S_run_tests(CFCTest *test) { = CFCParcel_new("Lucifer", NULL, NULL, NULL); CFCParcel_register(lucifer_parcel); CFCSymbol *lucifer - = CFCSymbol_new(lucifer_parcel, "parcel", NULL, NULL, "sym"); + = CFCSymbol_new(lucifer_parcel, "parcel", NULL, "sym"); CFCParcel *symbol_parcel = CFCSymbol_get_parcel(lucifer); OK(test, symbol_parcel == lucifer_parcel, "derive parcel"); @@ -114,7 +111,7 @@ S_run_tests(CFCTest *test) { CFCParcel *luser_parcel = CFCParcel_new("Luser", NULL, NULL, NULL); CFCParcel_register(luser_parcel); CFCSymbol *luser - = CFCSymbol_new(luser_parcel, "parcel", NULL, NULL, "sym"); + = CFCSymbol_new(luser_parcel, "parcel", NULL, "sym"); int equal = CFCSymbol_equals(lucifer, luser); OK(test, !equal, "different exposure spoils equals"); @@ -125,9 +122,9 @@ S_run_tests(CFCTest *test) { } { - CFCSymbol *ooga = CFCSymbol_new(parcel, "parcel", NULL, NULL, "ooga"); + CFCSymbol *ooga = CFCSymbol_new(parcel, "parcel", NULL, "ooga"); CFCSymbol *booga - = CFCSymbol_new(parcel, "parcel", NULL, NULL, "booga"); + = CFCSymbol_new(parcel, "parcel", NULL, "booga"); int equal = CFCSymbol_equals(ooga, booga); OK(test, !equal, "different name spoils equals"); CFCBase_decref((CFCBase*)ooga); @@ -141,7 +138,7 @@ S_run_tests(CFCTest *test) { = CFCClass_create(eep_parcel, NULL, "Op::Ork", NULL, NULL, NULL, NULL, NULL, false, false, false); CFCSymbol *eep - = CFCSymbol_new(eep_parcel, "parcel", "Op::Ork", NULL, "ah_ah"); + = CFCSymbol_new(eep_parcel, "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/3ef65778/compiler/src/CFCTestVariable.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCTestVariable.c b/compiler/src/CFCTestVariable.c index 91d75b5..776efff 100644 --- a/compiler/src/CFCTestVariable.c +++ b/compiler/src/CFCTestVariable.c @@ -49,7 +49,7 @@ S_run_tests(CFCTest *test) { { CFCType *type = CFCTest_parse_type(test, parser, "float*"); CFCVariable *var - = CFCVariable_new(neato_parcel, NULL, NULL, NULL, "foo", type, 0); + = CFCVariable_new(neato_parcel, 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;", @@ -63,7 +63,7 @@ S_run_tests(CFCTest *test) { { CFCType *type = CFCTest_parse_type(test, parser, "float[1]"); CFCVariable *var - = CFCVariable_new(neato_parcel, NULL, NULL, NULL, "foo", type, 0); + = CFCVariable_new(neato_parcel, 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"); @@ -76,8 +76,8 @@ S_run_tests(CFCTest *test) { CFCType *type = CFCTest_parse_type(test, parser, "Foo*"); CFCVariable *var = CFCVariable_new(neato_parcel, NULL, - "Crustacean::Lobster::LobsterClaw", "LobClaw", - "foo", type, 0); + "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/3ef65778/compiler/src/CFCVariable.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCVariable.c b/compiler/src/CFCVariable.c index 69feba4..507f65d 100644 --- a/compiler/src/CFCVariable.c +++ b/compiler/src/CFCVariable.c @@ -50,26 +50,24 @@ S_generate_c_strings(CFCVariable *self); CFCVariable* CFCVariable_new(struct CFCParcel *parcel, const char *exposure, - const char *class_name, const char *class_nickname, - const char *name, struct CFCType *type, int inert) { + 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, class_nickname, - name, type, inert); + return CFCVariable_init(self, parcel, exposure, class_name, name, type, + inert); } CFCVariable* CFCVariable_init(CFCVariable *self, struct CFCParcel *parcel, const char *exposure, const char *class_name, - const char *class_nickname, const char *name, - struct CFCType *type, int inert) { + 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, - class_nickname, name); + CFCSymbol_init((CFCSymbol*)self, parcel, 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/3ef65778/compiler/src/CFCVariable.h ---------------------------------------------------------------------- diff --git a/compiler/src/CFCVariable.h b/compiler/src/CFCVariable.h index 9ecff5e..ff5b6d2 100644 --- a/compiler/src/CFCVariable.h +++ b/compiler/src/CFCVariable.h @@ -43,18 +43,16 @@ struct CFCType; * @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 class_nickname See Clownfish::CFC::Model::Symbol. */ CFCVariable* CFCVariable_new(struct CFCParcel *parcel, const char *exposure, - const char *class_name, const char *class_nickname, - const char *name, struct CFCType *type, int inert); + 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 *class_nickname, const char *name, - struct CFCType *type, int inert); + const char *name, struct CFCType *type, int inert); void CFCVariable_resolve_type(CFCVariable *self);
