lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nwelln...@apache.org
Subject [lucy-commits] [3/6] git commit: Don't allow default parcel in classes, vars, and types
Date Fri, 21 Mar 2014 20:16:01 GMT
Don't allow default parcel in classes, vars, and types

The 'parcel' member of CFCVariables is always set to the parcel where
the variable is declared. This requires a change of the method
compatibility test. Only the method parameter types are compared for
equality while the symbols may differ.


Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/11110170
Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/11110170
Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/11110170

Branch: refs/heads/master
Commit: 11110170069239d2c8f56aa810d9e59c716e1ecb
Parents: dadbb6b
Author: Nick Wellnhofer <wellnhofer@aevum.de>
Authored: Tue Mar 18 14:16:53 2014 +0100
Committer: Nick Wellnhofer <wellnhofer@aevum.de>
Committed: Fri Mar 21 21:12:56 2014 +0100

----------------------------------------------------------------------
 compiler/perl/t/201-method.t  |  4 ++--
 compiler/src/CFCClass.c       |  1 -
 compiler/src/CFCMethod.c      | 10 +++++++++-
 compiler/src/CFCParseHeader.y |  3 +--
 compiler/src/CFCSymbol.h      |  3 +--
 compiler/src/CFCTestMethod.c  |  2 +-
 compiler/src/CFCType.c        |  6 +-----
 compiler/src/CFCVariable.c    |  3 ---
 8 files changed, 15 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/11110170/compiler/perl/t/201-method.t
----------------------------------------------------------------------
diff --git a/compiler/perl/t/201-method.t b/compiler/perl/t/201-method.t
index d1b232e..32b02b0 100644
--- a/compiler/perl/t/201-method.t
+++ b/compiler/perl/t/201-method.t
@@ -82,14 +82,14 @@ ok( !$method->compatible($missing_default),
 ok( !$missing_default->compatible($method), "... reversed" );
 
 my $param_name_differs = Clownfish::CFC::Model::Method->new( %args,
-    param_list => $parser->parse('(Foo *self, int32_t countess)'), );
+    param_list => $parser->parse('(Foo *self, int32_t countess = 0)'), );
 ok( !$method->compatible($param_name_differs),
     "different param name spoils compatible()"
 );
 ok( !$param_name_differs->compatible($method), "... reversed" );
 
 my $param_type_differs = Clownfish::CFC::Model::Method->new( %args,
-    param_list => $parser->parse('(Foo *self, uint32_t count)'), );
+    param_list => $parser->parse('(Foo *self, uint32_t count = 0)'), );
 ok( !$method->compatible($param_type_differs),
     "different param type spoils compatible()"
 );

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/11110170/compiler/src/CFCClass.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCClass.c b/compiler/src/CFCClass.c
index fccecf8..eb84dfb 100644
--- a/compiler/src/CFCClass.c
+++ b/compiler/src/CFCClass.c
@@ -118,7 +118,6 @@ CFCClass_do_create(CFCClass *self, struct CFCParcel *parcel,
     CFCUTIL_NULL_CHECK(class_name);
     exposure  = exposure  ? exposure  : "parcel";
     micro_sym = micro_sym ? micro_sym : "class";
-    parcel    = parcel    ? parcel    : CFCParcel_default_parcel();
     CFCSymbol_init((CFCSymbol*)self, parcel, exposure, class_name, cnick,
                    micro_sym);
     if (!is_inert

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/11110170/compiler/src/CFCMethod.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCMethod.c b/compiler/src/CFCMethod.c
index 97c68ae..090b35d 100644
--- a/compiler/src/CFCMethod.c
+++ b/compiler/src/CFCMethod.c
@@ -185,7 +185,15 @@ CFCMethod_compatible(CFCMethod *self, CFCMethod *other) {
             if (strcmp(my_vals[i], other_vals[i])) { return false; }
         }
         if (my_args[i]) {
-            if (!CFCVariable_equals(my_args[i], other_args[i])) {
+            CFCType *my_type    = CFCVariable_get_type(my_args[i]);
+            CFCType *other_type = CFCVariable_get_type(other_args[i]);
+            if (!CFCType_equals(my_type, other_type)) {
+                return false;
+            }
+
+            const char *my_sym    = CFCVariable_micro_sym(my_args[i]);
+            const char *other_sym = CFCVariable_micro_sym(other_args[i]);
+            if (strcmp(my_sym, other_sym) != 0) {
                 return false;
             }
         }

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/11110170/compiler/src/CFCParseHeader.y
----------------------------------------------------------------------
diff --git a/compiler/src/CFCParseHeader.y b/compiler/src/CFCParseHeader.y
index 7b83fa1..1cc84c2 100644
--- a/compiler/src/CFCParseHeader.y
+++ b/compiler/src/CFCParseHeader.y
@@ -68,11 +68,10 @@ S_new_var(CFCParser *state, char *exposure, char *modifiers, CFCType *type,
         inert = true;
     }
 
-    CFCParcel  *parcel      = NULL;
+    CFCParcel  *parcel      = CFCParser_get_parcel(state);
     const char *class_name  = NULL;
     const char *class_cnick = NULL;
     if (exposure && strcmp(exposure, "local") != 0) {
-        parcel      = CFCParser_get_parcel(state);
         class_name  = CFCParser_get_class_name(state);
         class_cnick = CFCParser_get_class_cnick(state);
     }

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/11110170/compiler/src/CFCSymbol.h
----------------------------------------------------------------------
diff --git a/compiler/src/CFCSymbol.h b/compiler/src/CFCSymbol.h
index 2777c2c..d91bb52 100644
--- a/compiler/src/CFCSymbol.h
+++ b/compiler/src/CFCSymbol.h
@@ -54,8 +54,7 @@ int
 CFCSymbol_validate_class_name_component(const char *name);
 
 /**
- * @param parcel A Clownfish::CFC::Model::Parcel.  If not supplied, will be
- * assigned to the default Parcel.
+ * @param parcel A Clownfish::CFC::Model::Parcel.
  * @param exposure The scope in which the symbol is exposed.  Must be
  * 'public', 'parcel', 'private', or 'local'.
  * @param class_name A optional class name, consisting of one or more

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/11110170/compiler/src/CFCTestMethod.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCTestMethod.c b/compiler/src/CFCTestMethod.c
index 39dd8d3..b2eca23 100644
--- a/compiler/src/CFCTestMethod.c
+++ b/compiler/src/CFCTestMethod.c
@@ -97,7 +97,7 @@ S_run_basic_tests(CFCTest *test) {
             "(Foo *self, int32_t count = 0, int b)",
             "(Foo *self, int32_t count = 1)",
             "(Foo *self, int32_t count)",
-            "(Foo *self, int32_t countess)",
+            "(Foo *self, int32_t countess = 0)",
             "(Foo *self, uint32_t count = 0)"
         };
         static const char *test_names[5] = {

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/11110170/compiler/src/CFCType.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCType.c b/compiler/src/CFCType.c
index 8a3d774..b3c13ce 100644
--- a/compiler/src/CFCType.c
+++ b/compiler/src/CFCType.c
@@ -167,6 +167,7 @@ CFCType*
 CFCType_new_object(int flags, CFCParcel *parcel, const char *specifier,
                    int indirection) {
     // Validate params.
+    CFCUTIL_NULL_CHECK(parcel);
     if (indirection != 1) {
         CFCUtil_die("Parameter 'indirection' can only be 1");
     }
@@ -177,11 +178,6 @@ CFCType_new_object(int flags, CFCParcel *parcel, const char *specifier,
         CFCUtil_die("Can't be both incremented and decremented");
     }
 
-    // Use default parcel if none supplied.
-    if (!parcel) {
-        parcel = CFCParcel_default_parcel();
-    }
-
     // Add flags.
     flags |= CFCTYPE_OBJECT;
     if (strstr(specifier, "String")) {

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/11110170/compiler/src/CFCVariable.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCVariable.c b/compiler/src/CFCVariable.c
index 71e3473..3443933 100644
--- a/compiler/src/CFCVariable.c
+++ b/compiler/src/CFCVariable.c
@@ -63,9 +63,6 @@ CFCVariable_init(CFCVariable *self, struct CFCParcel *parcel,
                  struct CFCType *type, int inert) {
     // Validate params.
     CFCUTIL_NULL_CHECK(type);
-    if (!parcel) {
-        parcel = CFCParcel_default_parcel();
-    }
 
     // Default exposure to "local".
     const char *real_exposure = exposure ? exposure : "local";


Mime
View raw message