Move class_name field from CFCSymbol to CFCMethod
Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/89bf831d Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/89bf831d Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/89bf831d Branch: refs/heads/master Commit: 89bf831d4649c97be4079787277d19baa300f066 Parents: 587d26b Author: Nick Wellnhofer <[email protected]> Authored: Tue Apr 21 11:09:23 2015 +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 | 60 +++++++++++---------------------- compiler/perl/t/051-symbol.t | 20 ++--------- compiler/perl/t/200-function.t | 1 - compiler/perl/t/201-method.t | 20 ++++++++++- compiler/perl/t/300-variable.t | 5 ++- compiler/perl/t/401-class.t | 11 +++--- compiler/src/CFCCallable.c | 6 ++-- compiler/src/CFCCallable.h | 5 +-- compiler/src/CFCFunction.c | 17 +++++----- compiler/src/CFCFunction.h | 7 ++-- compiler/src/CFCMethod.c | 57 +++++++++++++++---------------- compiler/src/CFCMethod.h | 21 +++++------- compiler/src/CFCParseHeader.y | 19 ++++------- compiler/src/CFCSymbol.c | 27 ++------------- compiler/src/CFCSymbol.h | 14 ++------ compiler/src/CFCTestClass.c | 9 +++-- compiler/src/CFCTestFunction.c | 5 ++- compiler/src/CFCTestMethod.c | 40 +++++++++++----------- compiler/src/CFCTestSymbol.c | 27 ++++----------- compiler/src/CFCTestVariable.c | 8 ++--- compiler/src/CFCVariable.c | 11 +++--- compiler/src/CFCVariable.h | 8 ++--- 23 files changed, 162 insertions(+), 262 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/89bf831d/compiler/perl/lib/Clownfish/CFC.pm ---------------------------------------------------------------------- diff --git a/compiler/perl/lib/Clownfish/CFC.pm b/compiler/perl/lib/Clownfish/CFC.pm index 6d9cd28..c71c63d 100644 --- a/compiler/perl/lib/Clownfish/CFC.pm +++ b/compiler/perl/lib/Clownfish/CFC.pm @@ -215,7 +215,6 @@ BEGIN { XSLoader::load( 'Clownfish::CFC', '0.4.0' ) } my %new_PARAMS = ( return_type => undef, - class_name => undef, param_list => undef, name => undef, docucomment => undef, @@ -230,8 +229,7 @@ BEGIN { XSLoader::load( 'Clownfish::CFC', '0.4.0' ) } $args{inline} ||= 0; return _new( @args{ - qw( exposure class_name name return_type param_list docucomment - inline ) + qw( exposure name return_type param_list docucomment inline ) } ); } @@ -296,10 +294,10 @@ BEGIN { XSLoader::load( 'Clownfish::CFC', '0.4.0' ) } my %new_PARAMS = ( return_type => undef, - class_name => undef, param_list => undef, name => undef, docucomment => undef, + class_name => undef, abstract => undef, final => undef, exposure => 'parcel', @@ -313,7 +311,7 @@ BEGIN { XSLoader::load( 'Clownfish::CFC', '0.4.0' ) } $args{final} ||= 0; return _new( @args{ - qw( exposure class_name name return_type param_list docucomment + qw( exposure name return_type param_list docucomment class_name final abstract ) } ); @@ -446,9 +444,8 @@ BEGIN { XSLoader::load( 'Clownfish::CFC', '0.4.0' ) } use Carp; my %new_PARAMS = ( - exposure => undef, - class_name => undef, - name => undef, + exposure => undef, + name => undef, ); sub new { @@ -456,7 +453,7 @@ BEGIN { XSLoader::load( 'Clownfish::CFC', '0.4.0' ) } verify_args( \%new_PARAMS, %args ) or confess $@; confess "no subclassing allowed" unless $either eq __PACKAGE__; return _new( - @args{qw( exposure class_name name )} ); + @args{qw( exposure name )} ); } } @@ -624,11 +621,10 @@ BEGIN { XSLoader::load( 'Clownfish::CFC', '0.4.0' ) } use Carp; our %new_PARAMS = ( - type => undef, - name => undef, - exposure => 'local', - class_name => undef, - inert => undef, + type => undef, + name => undef, + exposure => 'local', + inert => undef, ); sub new { @@ -638,7 +634,7 @@ BEGIN { XSLoader::load( 'Clownfish::CFC', '0.4.0' ) } $args{exposure} ||= 'local'; return _new( @args{ - qw( exposure class_name name type inert ) + qw( exposure name type inert ) } ); } http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/89bf831d/compiler/perl/lib/Clownfish/CFC.xs ---------------------------------------------------------------------- diff --git a/compiler/perl/lib/Clownfish/CFC.xs b/compiler/perl/lib/Clownfish/CFC.xs index a894710..090a63d 100644 --- a/compiler/perl/lib/Clownfish/CFC.xs +++ b/compiler/perl/lib/Clownfish/CFC.xs @@ -646,9 +646,8 @@ PPCODE: MODULE = Clownfish::CFC PACKAGE = Clownfish::CFC::Model::Function SV* -_new(exposure_sv, class_name_sv, name_sv, return_type, param_list, docucomment, is_inline) +_new(exposure_sv, name_sv, return_type, param_list, docucomment, is_inline) SV *exposure_sv; - SV *class_name_sv; SV *name_sv; CFCType *return_type; CFCParamList *param_list; @@ -657,13 +656,10 @@ _new(exposure_sv, class_name_sv, name_sv, return_type, param_list, docucomment, CODE: const char *exposure = SvOK(exposure_sv) ? SvPV_nolen(exposure_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; - CFCFunction *self - = CFCFunction_new(exposure, class_name, name, return_type, param_list, - docucomment, is_inline); + CFCFunction *self = CFCFunction_new(exposure, name, return_type, + param_list, docucomment, is_inline); RETVAL = S_cfcbase_to_perlref(self); CFCBase_decref((CFCBase*)self); OUTPUT: RETVAL @@ -827,13 +823,13 @@ PPCODE: MODULE = Clownfish::CFC PACKAGE = Clownfish::CFC::Model::Method SV* -_new(exposure_sv, class_name_sv, name, return_type, param_list, docucomment, is_final, is_abstract) +_new(exposure_sv, name, return_type, param_list, docucomment, class_name_sv, is_final, is_abstract) SV *exposure_sv; - SV *class_name_sv; const char *name; CFCType *return_type; CFCParamList *param_list; CFCDocuComment *docucomment; + SV *class_name_sv; int is_final; int is_abstract; CODE: @@ -842,8 +838,8 @@ CODE: const char *class_name = SvOK(class_name_sv) ? SvPV_nolen(class_name_sv) : NULL; CFCMethod *self - = CFCMethod_new(exposure, class_name, name, return_type, param_list, - docucomment, is_final, is_abstract); + = CFCMethod_new(exposure, name, return_type, param_list, docucomment, + class_name, is_final, is_abstract); RETVAL = S_cfcbase_to_perlref(self); CFCBase_decref((CFCBase*)self); OUTPUT: RETVAL @@ -1284,19 +1280,14 @@ PPCODE: MODULE = Clownfish::CFC PACKAGE = Clownfish::CFC::Model::Symbol SV* -_new(exposure, class_name_sv, name_sv) +_new(exposure, name_sv) const char *exposure; - SV *class_name_sv; SV *name_sv; CODE: - 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(exposure, class_name, name); + const char *name = SvOK(name_sv) + ? SvPV_nolen(name_sv) + : NULL; + CFCSymbol *self = CFCSymbol_new(exposure, name); RETVAL = S_cfcbase_to_perlref(self); CFCBase_decref((CFCBase*)self); OUTPUT: RETVAL @@ -1334,7 +1325,6 @@ void _set_or_get(self, ...) CFCSymbol *self; ALIAS: - get_class_name = 4 get_exposure = 8 get_name = 10 public = 18 @@ -1344,13 +1334,6 @@ ALIAS: PPCODE: { START_SET_OR_GET_SWITCH - case 4: { - const char *class_name = CFCSymbol_get_class_name(self); - retval = class_name - ? newSVpvn(class_name, strlen(class_name)) - : newSV(0); - } - break; case 8: { const char *exposure = CFCSymbol_get_exposure(self); retval = newSVpvn(exposure, strlen(exposure)); @@ -1752,21 +1735,17 @@ OUTPUT: RETVAL MODULE = Clownfish::CFC PACKAGE = Clownfish::CFC::Model::Variable SV* -_new(exposure, class_name_sv, name_sv, type_sv, inert_sv) +_new(exposure, name_sv, type_sv, inert_sv) const char *exposure; - SV *class_name_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 *name = SvOK(name_sv) - ? SvPV_nolen(name_sv) - : NULL; - int inert = SvOK(inert_sv) - ? !!SvTRUE(inert_sv) : 0; + 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)); @@ -1775,8 +1754,7 @@ CODE: else { croak("Param 'type' is not a Clownfish::CFC::Model::Type"); } - CFCVariable *self - = CFCVariable_new(exposure, class_name, name, type, inert); + CFCVariable *self = CFCVariable_new(exposure, 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/89bf831d/compiler/perl/t/051-symbol.t ---------------------------------------------------------------------- diff --git a/compiler/perl/t/051-symbol.t b/compiler/perl/t/051-symbol.t index b8dabad..9e463cd 100644 --- a/compiler/perl/t/051-symbol.t +++ b/compiler/perl/t/051-symbol.t @@ -16,19 +16,11 @@ use strict; use warnings; -use Test::More tests => 34; +use Test::More tests => 24; use Clownfish::CFC; my $parcel = Clownfish::CFC::Model::Parcel->new( name => 'Eep' ); -for (qw( foo 1Foo Foo_Bar 1FOOBAR )) { - eval { my $thing = new_symbol( class_name => $_ ) }; - like( $@, qr/class_name/, "Reject invalid class name $_" ); - my $bogus_middle = "Foo::" . $_ . "::Bar"; - eval { my $thing = new_symbol( class_name => $bogus_middle ) }; - like( $@, qr/class_name/, "Reject invalid class name $bogus_middle" ); -} - my @exposures = qw( public private parcel local ); for my $exposure (@exposures) { my $thing = new_symbol( exposure => $exposure ); @@ -37,11 +29,6 @@ for my $exposure (@exposures) { ok( !$thing->$_, "$exposure means not $_" ) for @not_exposures; } -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" ); - my $public_exposure = new_symbol( exposure => 'public' ); my $parcel_exposure = new_symbol( exposure => 'parcel' ); ok( !$public_exposure->equals($parcel_exposure), @@ -57,10 +44,7 @@ my $ooga = new_symbol( name => 'ooga' ); my $booga = new_symbol( name => 'booga' ); ok( !$ooga->equals($booga), "Different name spoils equals()" ); -my $eep = new_symbol( - class_name => "Op::Ork", - name => 'ah_ah', -); +my $eep = new_symbol( name => 'ah_ah' ); my $ork = Clownfish::CFC::Model::Class->create( parcel => $parcel, class_name => 'Op::Ork', http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/89bf831d/compiler/perl/t/200-function.t ---------------------------------------------------------------------- diff --git a/compiler/perl/t/200-function.t b/compiler/perl/t/200-function.t index 5a04a30..98455b8 100644 --- a/compiler/perl/t/200-function.t +++ b/compiler/perl/t/200-function.t @@ -28,7 +28,6 @@ $parser->parse('parcel Neato;') my %args = ( return_type => $parser->parse('Obj*'), - class_name => 'Neato::Foo', param_list => $parser->parse('(int32_t some_num)'), name => 'return_an_obj', ); http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/89bf831d/compiler/perl/t/201-method.t ---------------------------------------------------------------------- diff --git a/compiler/perl/t/201-method.t b/compiler/perl/t/201-method.t index 66fbc3e..f3467a7 100644 --- a/compiler/perl/t/201-method.t +++ b/compiler/perl/t/201-method.t @@ -16,7 +16,7 @@ use strict; use warnings; -use Test::More tests => 30; +use Test::More tests => 38; BEGIN { use_ok('Clownfish::CFC::Model::Method') } use Clownfish::CFC::Parser; @@ -48,6 +48,24 @@ eval { }; like( $@, qr/name/, "Invalid name kills constructor" ); +for (qw( foo 1Foo Foo_Bar 1FOOBAR )) { + eval { + Clownfish::CFC::Model::Method->new( + %args, + class_name => $_, + ); + }; + like( $@, qr/class_name/, "Reject invalid class name $_" ); + my $bogus_middle = "Foo::" . $_ . "::Bar"; + eval { + Clownfish::CFC::Model::Method->new( + %args, + class_name => $bogus_middle, + ); + }; + like( $@, qr/class_name/, "Reject invalid class name $bogus_middle" ); +} + my $dupe = Clownfish::CFC::Model::Method->new(%args); ok( $method->compatible($dupe), "compatible()" ); http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/89bf831d/compiler/perl/t/300-variable.t ---------------------------------------------------------------------- diff --git a/compiler/perl/t/300-variable.t b/compiler/perl/t/300-variable.t index 86029b2..278930f 100644 --- a/compiler/perl/t/300-variable.t +++ b/compiler/perl/t/300-variable.t @@ -68,9 +68,8 @@ my $lobclaw_class = $parser->parse( "class Crustacean::Lobster::LobsterClaw nickname LobClaw {}", ); $var = Clownfish::CFC::Model::Variable->new( - name => 'foo', - type => new_type("Foo*"), - class_name => 'Crustacean::Lobster::LobsterClaw', + name => 'foo', + type => new_type("Foo*"), ); $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/89bf831d/compiler/perl/t/401-class.t ---------------------------------------------------------------------- diff --git a/compiler/perl/t/401-class.t b/compiler/perl/t/401-class.t index 5380f1a..f456471 100644 --- a/compiler/perl/t/401-class.t +++ b/compiler/perl/t/401-class.t @@ -24,17 +24,14 @@ my $parser = Clownfish::CFC::Parser->new; $parser->parse('parcel Neato;'); my $thing = Clownfish::CFC::Model::Variable->new( - class_name => 'Foo', - type => $parser->parse('Thing*'), - name => 'thing', + type => $parser->parse('Thing*'), + name => 'thing', ); my $widget = Clownfish::CFC::Model::Variable->new( - class_name => 'Widget', - type => $parser->parse('Widget*'), - name => 'widget', + type => $parser->parse('Widget*'), + name => 'widget', ); my $tread_water = Clownfish::CFC::Model::Function->new( - class_name => 'Foo', return_type => $parser->parse('void'), name => 'tread_water', param_list => $parser->parse('()'), http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/89bf831d/compiler/src/CFCCallable.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCCallable.c b/compiler/src/CFCCallable.c index a4f0e8d..26f9c42 100644 --- a/compiler/src/CFCCallable.c +++ b/compiler/src/CFCCallable.c @@ -38,16 +38,14 @@ static const CFCMeta CFCCALLABLE_META = { }; CFCCallable* -CFCCallable_init(CFCCallable *self, const char *exposure, - const char *class_name, const char *name, +CFCCallable_init(CFCCallable *self, const char *exposure, 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, exposure, class_name, name); + CFCSymbol_init((CFCSymbol*)self, exposure, 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/89bf831d/compiler/src/CFCCallable.h ---------------------------------------------------------------------- diff --git a/compiler/src/CFCCallable.h b/compiler/src/CFCCallable.h index 9bab598..7ac737f 100644 --- a/compiler/src/CFCCallable.h +++ b/compiler/src/CFCCallable.h @@ -44,8 +44,6 @@ struct CFCCallable { /** * @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 - * function resides. * @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. @@ -55,8 +53,7 @@ struct CFCCallable { * callable. */ CFCCallable* -CFCCallable_init(CFCCallable *self, const char *exposure, - const char *class_name, const char *name, +CFCCallable_init(CFCCallable *self, const char *exposure, const char *name, struct CFCType *return_type, struct CFCParamList *param_list, struct CFCDocuComment *docucomment); http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/89bf831d/compiler/src/CFCFunction.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCFunction.c b/compiler/src/CFCFunction.c index d712403..bbfc88c 100644 --- a/compiler/src/CFCFunction.c +++ b/compiler/src/CFCFunction.c @@ -44,12 +44,12 @@ static const CFCMeta CFCFUNCTION_META = { }; CFCFunction* -CFCFunction_new(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 *name, CFCType *return_type, + CFCParamList *param_list, CFCDocuComment *docucomment, + int is_inline) { CFCFunction *self = (CFCFunction*)CFCBase_allocate(&CFCFUNCTION_META); - return CFCFunction_init(self, exposure, class_name, name, return_type, - param_list, docucomment, is_inline); + return CFCFunction_init(self, exposure, name, return_type, param_list, + docucomment, is_inline); } static int @@ -64,8 +64,7 @@ S_validate_function_name(const char *name) { } CFCFunction* -CFCFunction_init(CFCFunction *self, const char *exposure, - const char *class_name, const char *name, +CFCFunction_init(CFCFunction *self, const char *exposure, const char *name, CFCType *return_type, CFCParamList *param_list, CFCDocuComment *docucomment, int is_inline) { @@ -73,8 +72,8 @@ CFCFunction_init(CFCFunction *self, const char *exposure, CFCBase_decref((CFCBase*)self); CFCUtil_die("Invalid function name: '%s'", name); } - CFCCallable_init((CFCCallable*)self, exposure, class_name, name, - return_type, param_list, docucomment); + CFCCallable_init((CFCCallable*)self, exposure, name, return_type, + param_list, docucomment); self->is_inline = is_inline; return self; } http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/89bf831d/compiler/src/CFCFunction.h ---------------------------------------------------------------------- diff --git a/compiler/src/CFCFunction.h b/compiler/src/CFCFunction.h index 0793ab3..150b6b2 100644 --- a/compiler/src/CFCFunction.h +++ b/compiler/src/CFCFunction.h @@ -33,8 +33,6 @@ struct CFCClass; /** * @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 - * function resides. * @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. @@ -46,13 +44,12 @@ struct CFCClass; * compiler. */ CFCFunction* -CFCFunction_new(const char *exposure, const char *class_name, const char *name, +CFCFunction_new(const char *exposure, const char *name, struct CFCType *return_type, struct CFCParamList *param_list, struct CFCDocuComment *docucomment, int is_inline); CFCFunction* -CFCFunction_init(CFCFunction *self, const char *exposure, - const char *class_name, const char *name, +CFCFunction_init(CFCFunction *self, const char *exposure, const char *name, struct CFCType *return_type, struct CFCParamList *param_list, struct CFCDocuComment *docucomment, int is_inline); http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/89bf831d/compiler/src/CFCMethod.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCMethod.c b/compiler/src/CFCMethod.c index be17981..406a4f5 100644 --- a/compiler/src/CFCMethod.c +++ b/compiler/src/CFCMethod.c @@ -36,6 +36,7 @@ struct CFCMethod { CFCCallable callable; CFCMethod *novel_method; + char *fresh_class_name; char *host_alias; int is_final; int is_abstract; @@ -50,12 +51,12 @@ static const CFCMeta CFCMETHOD_META = { }; CFCMethod* -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_new(const char *exposure, const char *name, CFCType *return_type, + CFCParamList *param_list, CFCDocuComment *docucomment, + const char *class_name, int is_final, int is_abstract) { CFCMethod *self = (CFCMethod*)CFCBase_allocate(&CFCMETHOD_META); - return CFCMethod_init(self, exposure, class_name, name, return_type, - param_list, docucomment, is_final, is_abstract); + return CFCMethod_init(self, exposure, name, return_type, param_list, + docucomment, class_name, is_final, is_abstract); } static int @@ -81,10 +82,16 @@ S_validate_meth_name(const char *meth_name) { } CFCMethod* -CFCMethod_init(CFCMethod *self, const char *exposure, const char *class_name, - const char *name, CFCType *return_type, - CFCParamList *param_list, CFCDocuComment *docucomment, +CFCMethod_init(CFCMethod *self, const char *exposure, const char *name, + CFCType *return_type, CFCParamList *param_list, + CFCDocuComment *docucomment, const char *class_name, int is_final, int is_abstract) { + // Validate class_name. + CFCUTIL_NULL_CHECK(class_name); + if (!CFCClass_validate_class_name(class_name)) { + CFCBase_decref((CFCBase*)self); + CFCUtil_die("Invalid class_name: '%s'", class_name); + } // Validate name. if (!S_validate_meth_name(name)) { CFCBase_decref((CFCBase*)self); @@ -93,8 +100,8 @@ CFCMethod_init(CFCMethod *self, const char *exposure, const char *class_name, } // Super-init. - CFCCallable_init((CFCCallable*)self, exposure, class_name, name, - return_type, param_list, docucomment); + CFCCallable_init((CFCCallable*)self, exposure, 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); @@ -114,6 +121,7 @@ CFCMethod_init(CFCMethod *self, const char *exposure, const char *class_name, } self->novel_method = NULL; + self->fresh_class_name = CFCUtil_strdup(class_name); self->host_alias = NULL; self->is_final = is_final; self->is_abstract = is_abstract; @@ -134,6 +142,7 @@ CFCMethod_resolve_types(CFCMethod *self) { void CFCMethod_destroy(CFCMethod *self) { CFCBase_decref((CFCBase*)self->novel_method); + FREEMEM(self->fresh_class_name); FREEMEM(self->host_alias); CFCCallable_destroy((CFCCallable*)self); } @@ -199,17 +208,13 @@ CFCMethod_override(CFCMethod *self, CFCMethod *orig) { // Check that the override attempt is legal. if (CFCMethod_final(orig)) { const char *orig_name = CFCMethod_get_name(orig); - const char *orig_class = CFCMethod_get_class_name(orig); - const char *my_class = CFCMethod_get_class_name(self); CFCUtil_die("Attempt to override final method '%s' from '%s' by '%s'", - orig_name, orig_class, my_class); + orig_name, orig->fresh_class_name, self->fresh_class_name); } if (!CFCMethod_compatible(self, orig)) { const char *orig_name = CFCMethod_get_name(orig); - const char *orig_class = CFCMethod_get_class_name(orig); - const char *my_class = CFCMethod_get_class_name(self); CFCUtil_die("Non-matching signatures for method '%s' in '%s' and '%s'", - orig_name, orig_class, my_class); + orig_name, orig->fresh_class_name, self->fresh_class_name); } // Mark the Method as no longer novel. @@ -223,14 +228,13 @@ CFCMethod_override(CFCMethod *self, CFCMethod *orig) { CFCMethod* CFCMethod_finalize(CFCMethod *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(exposure, class_name, name, + = CFCMethod_new(exposure, name, self->callable.return_type, self->callable.param_list, - self->callable.docucomment, true, - self->is_abstract); + self->callable.docucomment, + self->fresh_class_name, true, self->is_abstract); finalized->novel_method = (CFCMethod*)CFCBase_incref((CFCBase*)self->novel_method); finalized->is_novel = self->is_novel; @@ -256,14 +260,14 @@ CFCMethod_set_host_alias(CFCMethod *self, const char *alias) { if (!self->is_novel) { const char *name = CFCMethod_get_name(self); CFCUtil_die("Can't set_host_alias %s -- method %s not novel in %s", - alias, name, CFCMethod_get_class_name(self)); + alias, name, self->fresh_class_name); } if (self->host_alias) { const char *name = CFCMethod_get_name(self); if (strcmp(self->host_alias, alias) == 0) { return; } CFCUtil_die("Can't set_host_alias %s -- already set to %s for method" " %s in %s", alias, self->host_alias, name, - CFCMethod_get_class_name(self)); + self->fresh_class_name); } self->host_alias = CFCUtil_strdup(alias); } @@ -279,7 +283,7 @@ CFCMethod_exclude_from_host(CFCMethod *self) { if (!self->is_novel) { const char *name = CFCMethod_get_name(self); CFCUtil_die("Can't exclude_from_host -- method %s not novel in %s", - name, CFCMethod_get_class_name(self)); + name, self->fresh_class_name); } self->is_excluded = true; } @@ -379,15 +383,10 @@ CFCMethod_get_exposure(CFCMethod *self) { return CFCSymbol_get_exposure((CFCSymbol*)self); } -const char* -CFCMethod_get_class_name(CFCMethod *self) { - return CFCSymbol_get_class_name((CFCSymbol*)self); -} - int CFCMethod_is_fresh(CFCMethod *self, CFCClass *klass) { const char *class_name = CFCClass_get_name(klass); - return strcmp(CFCMethod_get_class_name(self), class_name) == 0; + return strcmp(self->fresh_class_name, class_name) == 0; } int http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/89bf831d/compiler/src/CFCMethod.h ---------------------------------------------------------------------- diff --git a/compiler/src/CFCMethod.h b/compiler/src/CFCMethod.h index fa4df9e..643a10d 100644 --- a/compiler/src/CFCMethod.h +++ b/compiler/src/CFCMethod.h @@ -41,28 +41,28 @@ struct CFCDocuComment; /** * @param exposure See Clownfish::CFC::Model::Symbol. Defaults to "parcel" * if not supplied. - * @param class_name 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. * @param param_list - A Clownfish::CFC::Model::ParamList. The first element * must be an object of the class identified by C<class_name>. * @param docucomment see Clownfish::CFC::Model::Function. May be NULL. + * @param class_name The full name of the class in whose namespace the + * method is fresh. * @param is_final - Indicate whether the method is final. * @param is_abstract - Indicate whether the method is abstract. */ CFCMethod* -CFCMethod_new(const char *exposure, const char *class_name, const char *name, +CFCMethod_new(const char *exposure, const char *name, struct CFCType *return_type, struct CFCParamList *param_list, - struct CFCDocuComment *docucomment, int is_final, - int is_abstract); + struct CFCDocuComment *docucomment, const char *class_name, + int is_final, int is_abstract); CFCMethod* -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); +CFCMethod_init(CFCMethod *self, const char *exposure, const char *name, + struct CFCType *return_type, struct CFCParamList *param_list, + struct CFCDocuComment *docucomment, const char *class_name, + int is_final, int is_abstract); void CFCMethod_resolve_types(CFCMethod *self); @@ -205,9 +205,6 @@ CFCMethod_excluded_from_host(CFCMethod *self); const char* CFCMethod_get_exposure(CFCMethod *self); -const char* -CFCMethod_get_class_name(CFCMethod *self); - /** Return true if the method is fresh in `klass`. */ int http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/89bf831d/compiler/src/CFCParseHeader.y ---------------------------------------------------------------------- diff --git a/compiler/src/CFCParseHeader.y b/compiler/src/CFCParseHeader.y index 064199b..61d7ae1 100644 --- a/compiler/src/CFCParseHeader.y +++ b/compiler/src/CFCParseHeader.y @@ -70,12 +70,7 @@ S_new_var(CFCParser *state, char *exposure, char *modifiers, CFCType *type, inert = true; } - const char *class_name = NULL; - if (exposure && strcmp(exposure, "local") != 0) { - class_name = CFCParser_get_class_name(state); - } - CFCVariable *var = CFCVariable_new(exposure, class_name, name, type, - inert); + CFCVariable *var = CFCVariable_new(exposure, name, type, inert); /* Consume tokens. */ CFCBase_decref((CFCBase*)type); @@ -87,8 +82,6 @@ static CFCBase* S_new_sub(CFCParser *state, CFCDocuComment *docucomment, char *exposure, char *modifiers, CFCType *type, char *name, CFCParamList *param_list) { - const char *class_name = CFCParser_get_class_name(state); - /* Find modifiers by scanning the list. */ int is_abstract = false; int is_final = false; @@ -113,16 +106,16 @@ S_new_sub(CFCParser *state, CFCDocuComment *docucomment, if (is_final) { CFCUtil_die("Inert functions must not be final"); } - sub = (CFCBase*)CFCFunction_new(exposure, class_name, name, type, - param_list, docucomment, - is_inline); + sub = (CFCBase*)CFCFunction_new(exposure, name, type, param_list, + docucomment, is_inline); } else { if (is_inline) { CFCUtil_die("Methods must not be inline"); } - sub = (CFCBase*)CFCMethod_new(exposure, class_name, name, type, - param_list, docucomment, is_final, + const char *class_name = CFCParser_get_class_name(state); + sub = (CFCBase*)CFCMethod_new(exposure, name, type, param_list, + docucomment, class_name, is_final, is_abstract); } http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/89bf831d/compiler/src/CFCSymbol.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCSymbol.c b/compiler/src/CFCSymbol.c index 6189c3b..2dd7ddc 100644 --- a/compiler/src/CFCSymbol.c +++ b/compiler/src/CFCSymbol.c @@ -35,9 +35,9 @@ static const CFCMeta CFCSYMBOL_META = { }; CFCSymbol* -CFCSymbol_new(const char *exposure, const char *class_name, const char *name) { +CFCSymbol_new(const char *exposure, const char *name) { CFCSymbol *self = (CFCSymbol*)CFCBase_allocate(&CFCSYMBOL_META); - return CFCSymbol_init(self, exposure, class_name, name); + return CFCSymbol_init(self, exposure, name); } static int @@ -64,17 +64,12 @@ S_validate_identifier(const char *identifier) { } CFCSymbol* -CFCSymbol_init(CFCSymbol *self, const char *exposure, const char *class_name, - const char *name) { +CFCSymbol_init(CFCSymbol *self, const char *exposure, const char *name) { // Validate. if (!S_validate_exposure(exposure)) { CFCBase_decref((CFCBase*)self); CFCUtil_die("Invalid exposure: '%s'", exposure ? exposure : "[NULL]"); } - if (class_name && !CFCClass_validate_class_name(class_name)) { - CFCBase_decref((CFCBase*)self); - CFCUtil_die("Invalid class_name: '%s'", class_name); - } if (!name || !S_validate_identifier(name)) { CFCBase_decref((CFCBase*)self); CFCUtil_die("Invalid name: '%s'", name ? name : "[NULL]"); @@ -82,7 +77,6 @@ CFCSymbol_init(CFCSymbol *self, const char *exposure, const char *class_name, // Assign. self->exposure = CFCUtil_strdup(exposure); - self->class_name = CFCUtil_strdup(class_name); self->name = CFCUtil_strdup(name); return self; @@ -91,7 +85,6 @@ CFCSymbol_init(CFCSymbol *self, const char *exposure, const char *class_name, void CFCSymbol_destroy(CFCSymbol *self) { FREEMEM(self->exposure); - FREEMEM(self->class_name); FREEMEM(self->name); CFCBase_destroy((CFCBase*)self); } @@ -100,15 +93,6 @@ int CFCSymbol_equals(CFCSymbol *self, CFCSymbol *other) { if (strcmp(self->name, other->name) != 0) { return false; } if (strcmp(self->exposure, other->exposure) != 0) { return false; } - if (self->class_name) { - if (!other->class_name) { return false; } - if (strcmp(self->class_name, other->class_name) != 0) { - return false; - } - } - else if (other->class_name) { - return false; - } return true; } @@ -148,11 +132,6 @@ CFCSymbol_short_sym(CFCSymbol *self, CFCClass *klass) { } const char* -CFCSymbol_get_class_name(CFCSymbol *self) { - return self->class_name; -} - -const char* CFCSymbol_get_exposure(CFCSymbol *self) { return self->exposure; } http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/89bf831d/compiler/src/CFCSymbol.h ---------------------------------------------------------------------- diff --git a/compiler/src/CFCSymbol.h b/compiler/src/CFCSymbol.h index 397e016..d5226a3 100644 --- a/compiler/src/CFCSymbol.h +++ b/compiler/src/CFCSymbol.h @@ -38,7 +38,6 @@ struct CFCParcel; struct CFCSymbol { CFCBase base; char *exposure; - char *class_name; char *name; }; #endif @@ -46,18 +45,13 @@ struct CFCSymbol { /** * @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 - * 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 name The local identifier for the symbol. */ CFCSymbol* -CFCSymbol_new(const char *exposure, const char *class_name, const char *name); +CFCSymbol_new(const char *exposure, const char *name); CFCSymbol* -CFCSymbol_init(CFCSymbol *self, const char *exposure, const char *class_name, - const char *name); +CFCSymbol_init(CFCSymbol *self, const char *exposure, const char *name); void CFCSymbol_destroy(CFCSymbol *self); @@ -67,10 +61,6 @@ CFCSymbol_destroy(CFCSymbol *self); int CFCSymbol_equals(CFCSymbol *self, CFCSymbol *other); -// May be NULL. -const char* -CFCSymbol_get_class_name(CFCSymbol *self); - const char* CFCSymbol_get_exposure(CFCSymbol *self); http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/89bf831d/compiler/src/CFCTestClass.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCTestClass.c b/compiler/src/CFCTestClass.c index 9c41d66..a91e3b9 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(NULL, "Foo", "thing", thing_type, 0); + thing = CFCVariable_new(NULL, "thing", thing_type, 0); CFCType *widget_type = CFCTest_parse_type(test, parser, "Widget*"); - widget = CFCVariable_new(NULL, "Widget", "widget", widget_type, 0); + widget = CFCVariable_new(NULL, "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(NULL, "Foo", "tread_water", return_type, - param_list, NULL, 0); + tread_water = CFCFunction_new(NULL, "tread_water", return_type, + param_list, NULL, 0); CFCBase_decref((CFCBase*)thing_type); CFCBase_decref((CFCBase*)widget_type); http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/89bf831d/compiler/src/CFCTestFunction.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCTestFunction.c b/compiler/src/CFCTestFunction.c index 1d54537..22dd487 100644 --- a/compiler/src/CFCTestFunction.c +++ b/compiler/src/CFCTestFunction.c @@ -42,9 +42,8 @@ S_run_tests(CFCTest *test) { CFCType *return_type = CFCTest_parse_type(test, parser, "Obj*"); CFCParamList *param_list = CFCTest_parse_param_list(test, parser, "(int32_t some_num)"); - CFCFunction *func - = CFCFunction_new(NULL, "Neato::Foo", "return_an_obj", return_type, - param_list, NULL, 0); + CFCFunction *func = CFCFunction_new(NULL, "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/89bf831d/compiler/src/CFCTestMethod.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCTestMethod.c b/compiler/src/CFCTestMethod.c index 6e20069..3fc5d57 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(NULL, "Neato::Foo", "Return_An_Obj", return_type, - param_list, NULL, 0, 0); + = CFCMethod_new(NULL, "Return_An_Obj", return_type, param_list, NULL, + "Neato::Foo", 0, 0); OK(test, method != NULL, "new"); OK(test, CFCSymbol_parcel((CFCSymbol*)method), "parcel exposure by default"); { CFCMethod *dupe - = CFCMethod_new(NULL, "Neato::Foo", "Return_An_Obj", return_type, - param_list, NULL, 0, 0); + = CFCMethod_new(NULL, "Return_An_Obj", return_type, param_list, + NULL, "Neato::Foo", 0, 0); OK(test, CFCMethod_compatible(method, dupe), "compatible"); CFCBase_decref((CFCBase*)dupe); } { CFCMethod *name_differs - = CFCMethod_new(NULL, "Neato::Foo", "Eat", return_type, param_list, - NULL, 0, 0); + = CFCMethod_new(NULL, "Eat", return_type, param_list, NULL, + "Neato::Foo", 0, 0); OK(test, !CFCMethod_compatible(method, name_differs), "different name spoils compatible"); OK(test, !CFCMethod_compatible(name_differs, method), @@ -109,8 +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(NULL, "Neato::Foo", "Return_An_Obj", - return_type, other_param_list, NULL, 0, 0); + = CFCMethod_new(NULL, "Return_An_Obj", return_type, + other_param_list, NULL, "Neato::Foo", 0, 0); OK(test, !CFCMethod_compatible(method, other), "%s spoils compatible", test_names[i]); OK(test, !CFCMethod_compatible(other, method), @@ -125,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(NULL, "Neato::Bar", "Return_An_Obj", return_type, - self_differs_list, NULL, 0, 0); + = CFCMethod_new(NULL, "Return_An_Obj", return_type, + self_differs_list, NULL, "Neato::Bar", 0, 0); OK(test, CFCMethod_compatible(method, self_differs), "different self type still compatible()," " since can't test inheritance"); @@ -138,8 +138,8 @@ S_run_basic_tests(CFCTest *test) { { CFCMethod *aliased - = CFCMethod_new(NULL, "Neato::Foo", "Aliased", return_type, - param_list, NULL, 0, 0); + = CFCMethod_new(NULL, "Aliased", return_type, param_list, NULL, + "Neato::Foo", 0, 0); OK(test, !CFCMethod_get_host_alias(aliased), "no host alias by default"); CFCMethod_set_host_alias(aliased, "Host_Alias"); @@ -150,8 +150,8 @@ S_run_basic_tests(CFCTest *test) { { CFCMethod *excluded - = CFCMethod_new(NULL, "Neato::Foo", "Excluded", return_type, - param_list, NULL, 0, 0); + = CFCMethod_new(NULL, "Excluded", return_type, param_list, NULL, + "Neato::Foo", 0, 0); OK(test, !CFCMethod_excluded_from_host(excluded), "not excluded by default"); CFCMethod_exclude_from_host(excluded); @@ -213,14 +213,14 @@ S_run_overridden_tests(CFCTest *test) { CFCParamList *param_list = CFCTest_parse_param_list(test, parser, "(Foo *self)"); CFCMethod *orig - = CFCMethod_new(NULL, "Neato::Foo", "Return_An_Obj", return_type, - param_list, NULL, 0, 0); + = CFCMethod_new(NULL, "Return_An_Obj", return_type, param_list, NULL, + "Neato::Foo", 0, 0); CFCParamList *overrider_param_list = CFCTest_parse_param_list(test, parser, "(FooJr *self)"); CFCMethod *overrider - = CFCMethod_new(NULL, "Neato::Foo::FooJr", "Return_An_Obj", - return_type, overrider_param_list, NULL, 0, 0); + = CFCMethod_new(NULL, "Return_An_Obj", return_type, + overrider_param_list, NULL, "Neato::Foo::FooJr", 0, 0); CFCMethod_override(overrider, orig); OK(test, !CFCMethod_novel(overrider), @@ -251,8 +251,8 @@ S_run_final_tests(CFCTest *test) { = CFCTest_parse_param_list(test, parser, "(Foo *self)"); CFCMethod *not_final - = CFCMethod_new(NULL, "Neato::Foo", "Return_An_Obj", return_type, - param_list, NULL, 0, 0); + = CFCMethod_new(NULL, "Return_An_Obj", return_type, param_list, NULL, + "Neato::Foo", 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/89bf831d/compiler/src/CFCTestSymbol.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCTestSymbol.c b/compiler/src/CFCTestSymbol.c index 12cf7f5..690e55c 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", - 22, + 20, S_run_tests }; @@ -51,7 +51,7 @@ S_run_tests(CFCTest *test) { CFCSymbol_local }; for (int i = 0; i < 4; ++i) { - CFCSymbol *symbol = CFCSymbol_new(exposures[i], NULL, "sym"); + CFCSymbol *symbol = CFCSymbol_new(exposures[i], "sym"); for (int j = 0; j < 4; ++j) { int has_exposure = accessors[j](symbol); if (i == j) { @@ -67,21 +67,8 @@ S_run_tests(CFCTest *test) { } { - 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"); - const char *foo_jr_name = CFCSymbol_get_class_name(foo_jr); - STR_EQ(test, foo_jr_name, "Foo::FooJr", "get_class_name"); - - CFCBase_decref((CFCBase*)foo); - CFCBase_decref((CFCBase*)foo_jr); - } - - { - CFCSymbol *public_exposure = CFCSymbol_new("public", NULL, "sym"); - CFCSymbol *parcel_exposure = CFCSymbol_new("parcel", NULL, "sym"); + CFCSymbol *public_exposure = CFCSymbol_new("public", "sym"); + CFCSymbol *parcel_exposure = CFCSymbol_new("parcel", "sym"); int equal = CFCSymbol_equals(public_exposure, parcel_exposure); OK(test, !equal, "different exposure spoils equals"); CFCBase_decref((CFCBase*)public_exposure); @@ -89,8 +76,8 @@ S_run_tests(CFCTest *test) { } { - CFCSymbol *ooga = CFCSymbol_new("parcel", NULL, "ooga"); - CFCSymbol *booga = CFCSymbol_new("parcel", NULL, "booga"); + CFCSymbol *ooga = CFCSymbol_new("parcel", "ooga"); + CFCSymbol *booga = CFCSymbol_new("parcel", "booga"); int equal = CFCSymbol_equals(ooga, booga); OK(test, !equal, "different name spoils equals"); CFCBase_decref((CFCBase*)ooga); @@ -103,7 +90,7 @@ S_run_tests(CFCTest *test) { CFCClass *ork = CFCClass_create(eep_parcel, NULL, "Op::Ork", NULL, NULL, NULL, NULL, false, false, false); - CFCSymbol *eep = CFCSymbol_new("parcel", "Op::Ork", "ah_ah"); + CFCSymbol *eep = CFCSymbol_new("parcel", "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/89bf831d/compiler/src/CFCTestVariable.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCTestVariable.c b/compiler/src/CFCTestVariable.c index a8eec5a..d256c01 100644 --- a/compiler/src/CFCTestVariable.c +++ b/compiler/src/CFCTestVariable.c @@ -48,7 +48,7 @@ S_run_tests(CFCTest *test) { { CFCType *type = CFCTest_parse_type(test, parser, "float*"); - CFCVariable *var = CFCVariable_new(NULL, NULL, "foo", type, 0); + CFCVariable *var = CFCVariable_new(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;", @@ -61,7 +61,7 @@ S_run_tests(CFCTest *test) { { CFCType *type = CFCTest_parse_type(test, parser, "float[1]"); - CFCVariable *var = CFCVariable_new(NULL, NULL, "foo", type, 0); + CFCVariable *var = CFCVariable_new(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"); @@ -72,9 +72,7 @@ S_run_tests(CFCTest *test) { { CFCType *type = CFCTest_parse_type(test, parser, "Foo*"); - CFCVariable *var - = CFCVariable_new(NULL, "Crustacean::Lobster::LobsterClaw", "foo", - type, 0); + CFCVariable *var = CFCVariable_new(NULL, "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/89bf831d/compiler/src/CFCVariable.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCVariable.c b/compiler/src/CFCVariable.c index 5b6804e..c2802fc 100644 --- a/compiler/src/CFCVariable.c +++ b/compiler/src/CFCVariable.c @@ -49,15 +49,14 @@ static void S_generate_c_strings(CFCVariable *self); CFCVariable* -CFCVariable_new(const char *exposure, const char *class_name, const char *name, - struct CFCType *type, int inert) { +CFCVariable_new(const char *exposure, const char *name, struct CFCType *type, + int inert) { CFCVariable *self = (CFCVariable*)CFCBase_allocate(&CFCVARIABLE_META); - return CFCVariable_init(self, exposure, class_name, name, type, inert); + return CFCVariable_init(self, exposure, name, type, inert); } CFCVariable* -CFCVariable_init(CFCVariable *self, const char *exposure, - const char *class_name, const char *name, +CFCVariable_init(CFCVariable *self, const char *exposure, const char *name, struct CFCType *type, int inert) { // Validate params. CFCUTIL_NULL_CHECK(type); @@ -65,7 +64,7 @@ CFCVariable_init(CFCVariable *self, const char *exposure, // Default exposure to "local". const char *real_exposure = exposure ? exposure : "local"; - CFCSymbol_init((CFCSymbol*)self, real_exposure, class_name, name); + CFCSymbol_init((CFCSymbol*)self, real_exposure, name); // Assign type, inert. self->type = (CFCType*)CFCBase_incref((CFCBase*)type); http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/89bf831d/compiler/src/CFCVariable.h ---------------------------------------------------------------------- diff --git a/compiler/src/CFCVariable.h b/compiler/src/CFCVariable.h index a46eeaf..b42f16d 100644 --- a/compiler/src/CFCVariable.h +++ b/compiler/src/CFCVariable.h @@ -40,17 +40,15 @@ struct CFCType; /** * @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(const char *exposure, const char *class_name, const char *name, - struct CFCType *type, int inert); +CFCVariable_new(const char *exposure, const char *name, struct CFCType *type, + int inert); CFCVariable* -CFCVariable_init(CFCVariable *self, const char *exposure, - const char *class_name, const char *name, +CFCVariable_init(CFCVariable *self, const char *exposure, const char *name, struct CFCType *type, int inert); void
