eolian: correctness fixes in tests and eo files
authorDaniel Kolesa <d.kolesa@osg.samsung.com>
Fri, 15 Sep 2017 15:48:28 +0000 (17:48 +0200)
committerDaniel Kolesa <d.kolesa@osg.samsung.com>
Fri, 15 Sep 2017 15:48:28 +0000 (17:48 +0200)
22 files changed:
src/lib/efl/interfaces/efl_types.eot
src/lib/elementary/efl_config_global.eo
src/lib/elementary/elm_web.eo
src/lib/eolian/database_type.c
src/lib/eolian/eo_lexer.c
src/tests/eolian/data/complex_type.eo
src/tests/eolian/data/decl.eo
src/tests/eolian/data/enum.eo
src/tests/eolian/data/extern.eo
src/tests/eolian/data/free_func.eo
src/tests/eolian/data/function_as_argument.eo
src/tests/eolian/data/function_as_argument_impl_ref.c
src/tests/eolian/data/function_as_argument_ref.c
src/tests/eolian/data/function_as_argument_ref.h
src/tests/eolian/data/function_types.eot
src/tests/eolian/data/function_types_ref.h
src/tests/eolian/data/object_impl.eo
src/tests/eolian/data/object_impl_add.eo
src/tests/eolian/data/struct.eo
src/tests/eolian/data/typedef.eo
src/tests/eolian/data/var.eo
src/tests/eolian/eolian_parsing.c

index 4d5535c..f515a92 100644 (file)
@@ -43,5 +43,5 @@ struct Efl.Observable.Tuple
 {
    [[This type describes an observable touple]]
    key: string; [[Touple key]]
-   data: free(own(iterator<Efl.Observer>), eina_iterator_free); [[Touple data]]
+   data: iterator<Efl.Observer> @owned; [[Touple data]]
 }
index a28f3fe..99ba68e 100644 (file)
@@ -66,7 +66,7 @@ class Efl.Config.Global (Efl.Object, Efl.Config)
             is_user: bool; [[$true to lookup for a user profile or $false for
                              a system one.]]
          }
-         return: string @owned; [[Directory of the profile, free after use.]]
+         return: stringshare @owned; [[Directory of the profile, free after use.]]
       }
       profile_derived_add @protected {
          [[Add a new profile of the given name to be derived from the current
index f00b64c..f1c8e98 100644 (file)
@@ -339,7 +339,8 @@ class Elm.Web (Elm.Widget)
               The string returned must be freed by the user when it's done
               with it.
             ]]
-            return: string @owned @warn_unused; [[A newly allocated string, or
+            /* FIXME: const doesn't belong here */
+            return: const(string) @owned @warn_unused; [[A newly allocated string, or
                                                       $null if nothing is selected
                                                       or an error occurred.]]
          }
index a05fa25..d9a8f17 100644 (file)
@@ -146,7 +146,12 @@ database_type_to_str(const Eolian_Type *tp, Eina_Strbuf *buf, const char *name,
           }
         int kw = eo_lexer_keyword_str_to_id(tp->name);
         if (kw && eo_lexer_is_type_keyword(kw))
-          eina_strbuf_append(buf, eo_lexer_get_c_type(kw));
+          {
+             /* FIXME: deal with aliased strings? */
+             if ((kw == KW_string) && !tp->owned)
+               eina_strbuf_append(buf, "const ");
+             eina_strbuf_append(buf, eo_lexer_get_c_type(kw));
+          }
         else
           eina_strbuf_append(buf, tp->name);
      }
index 044315c..caae8dd 100644 (file)
@@ -75,7 +75,7 @@ static const char * const ctypes[] =
 
    "Eina_Accessor", "Eina_Array", "Eina_Iterator", "Eina_Hash", "Eina_List",
    "Efl_Future",
-   "Eina_Value", "const char *", "Eina_Stringshare *",
+   "Eina_Value", "char *", "Eina_Stringshare *",
 
    "void *",
 
index 8aac116..2976125 100644 (file)
@@ -2,19 +2,19 @@ class Complex_Type {
    methods {
       @property a {
          set {
-            return: own(list<array<own(ptr(Eo))> >);
+            return: list<array<ptr(Eo) @owned> > @owned;
          }
          get {
          }
          values {
-            value: own(list<int>);
+            value: list<int> @owned;
          }
       }
       foo {
          params {
-            buf: own(ptr(char));
+            buf: string @owned;
          }
-         return: own(list<stringshare>); [[comment for method return]]
+         return: list<stringshare> @owned; [[comment for method return]]
       }
    }
 }
index 3492de0..de1ed88 100644 (file)
@@ -16,7 +16,7 @@ class Decl {
          params {
             idx: int;
          }
-         return: own(ptr(char));
+         return: string @owned;
       }
    }
 }
index 3b426e3..4275b24 100644 (file)
@@ -39,7 +39,7 @@ class Enum {
             params {
                 idx: int;
             }
-            return: own(ptr(char));
+            return: string @owned;
         }
     }
 }
index e8ee006..d59caa2 100644 (file)
@@ -22,7 +22,7 @@ class Extern {
          params {
             idx: int;
          }
-         return: own(ptr(char));
+         return: string @owned;
       }
    }
 }
index 5c10b24..5e77e5c 100644 (file)
@@ -24,7 +24,7 @@ class Free_Func {
          params {
             idx: int;
          }
-         return: own(ptr(char));
+         return: string @owned;
       }
    }
 }
index 2eb2cc2..4c27253 100644 (file)
@@ -19,7 +19,7 @@ class Function_As_Argument {
         a: int;
         b: double;
       }
-      return: own(string);
+      return: string @owned;
     }
   }
 }
index 7e8a89e..aef6721 100644 (file)
@@ -19,7 +19,7 @@ _function_as_argument_set_nonull_cb(Eo *obj, Function_As_Argument_Data *pd, void
 
 }
 
-EOLIAN static const char *
+EOLIAN static char *
 _function_as_argument_call_cb(Eo *obj, Function_As_Argument_Data *pd, int a, double b)
 {
 
index 742f8d8..f73c426 100644 (file)
@@ -7,9 +7,9 @@ void _function_as_argument_set_nonull_cb(Eo *obj, Function_As_Argument_Data *pd,
 
 EOAPI EFL_VOID_FUNC_BODYV(function_as_argument_set_nonull_cb, EFL_FUNC_CALL(cb_data, cb, cb_free_cb), void *cb_data, VoidFunc cb, Eina_Free_Cb cb_free_cb);
 
-const char *_function_as_argument_call_cb(Eo *obj, Function_As_Argument_Data *pd, int a, double b);
+char *_function_as_argument_call_cb(Eo *obj, Function_As_Argument_Data *pd, int a, double b);
 
-EOAPI EFL_FUNC_BODYV(function_as_argument_call_cb, const char *, NULL, EFL_FUNC_CALL(a, b), int a, double b);
+EOAPI EFL_FUNC_BODYV(function_as_argument_call_cb, char *, NULL, EFL_FUNC_CALL(a, b), int a, double b);
 
 static Eina_Bool
 _function_as_argument_class_initializer(Efl_Class *klass)
index 5eff241..16af428 100644 (file)
@@ -21,6 +21,6 @@ EOAPI void function_as_argument_set_cb(Eo *obj, void *cb_data, SimpleFunc cb, Ei
 
 EOAPI void function_as_argument_set_nonull_cb(Eo *obj, void *cb_data, VoidFunc cb, Eina_Free_Cb cb_free_cb) EINA_ARG_NONNULL(3);
 
-EOAPI const char *function_as_argument_call_cb(Eo *obj, int a, double b);
+EOAPI char *function_as_argument_call_cb(Eo *obj, int a, double b);
 
 #endif
index 5f06790..5eae0e2 100644 (file)
@@ -16,7 +16,7 @@ function SimpleFunc {
 function ComplexFunc {
   params {
     @in c: string;
-    @out d: own(string);
+    @out d: string @owned;
   }
   return: double;
 };
index fe7c57d..dcb8af2 100644 (file)
@@ -8,7 +8,7 @@ typedef void (*VoidFunc)(void *data);
 
 typedef const char * (*SimpleFunc)(void *data, int a, double b);
 
-typedef double (*ComplexFunc)(void *data, const char *c, const char **d);
+typedef double (*ComplexFunc)(void *data, const char *c, char **d);
 
 typedef void (*FuncAsArgFunc)(void *data, void *cb_data, VoidFunc cb, Eina_Free_Cb cb_free_cb, void *another_cb_data, SimpleFunc another_cb, Eina_Free_Cb another_cb_free_cb);
 
index 97906ab..7eb4f36 100644 (file)
@@ -13,7 +13,7 @@ class Object_Impl (Base) {
             part: string;
          }
          values {
-            value: own(list<int>);
+            value: list<int> @owned;
          }
       }
       @property b {
@@ -23,7 +23,7 @@ class Object_Impl (Base) {
             /* set as virtual pure - no implementation expected */
          }
          values {
-            value: own(list<int>);
+            value: list<int> @owned;
          }
       }
       constructor_1 {
index e0f24e4..3fa5892 100644 (file)
@@ -9,7 +9,7 @@ class Object_Impl_Add (Base) {
             /* set as virtual pure - no implementation expected */
          }
          values {
-            value: own(list<int>);
+            value: list<int> @owned;
          }
       }
    }
index 679ff5f..cb8981d 100644 (file)
@@ -23,7 +23,7 @@ class Struct {
          params {
             idx: int;
          }
-         return: own(ptr(char));
+         return: string @owned;
       }
       bar {
          return: ptr(Named);
index 3e60100..59a33cb 100644 (file)
@@ -1,5 +1,5 @@
 type Evas.Coord: int; /* Simple type definition */
-type List_Objects: own(list<ptr(Eo)>); /* A little more complex */
+type List_Objects: list<ptr(Eo)>; /* A little more complex */
 
 type Evas.Coord2: Evas.Coord;
 type Evas.Coord3: Evas.Coord2;
@@ -33,7 +33,7 @@ class Typedef {
          params {
             idx: int;
          }
-         return: own(ptr(char));
+         return: string @owned;
       }
    }
 }
index 93fcacc..6605d30 100644 (file)
@@ -16,7 +16,7 @@ class Var {
          params {
             idx: int;
          }
-         return: own(ptr(char));
+         return: string @owned;
       }
    }
 }
index 0b55cf1..79fdb64 100644 (file)
@@ -338,7 +338,7 @@ START_TEST(eolian_typedef)
    eina_stringshare_del(type_name);
    fail_if(!(type = eolian_typedecl_base_type_get(tdl)));
    fail_if(!(type_name = eolian_type_name_get(type)));
-   fail_if(eolian_type_is_own(type));
+   fail_if(eolian_type_is_owned(type));
    fail_if(eolian_type_is_const(type));
    fail_if(eolian_type_base_type_get(type));
    fail_if(strcmp(type_name, "int"));
@@ -358,14 +358,14 @@ START_TEST(eolian_typedef)
    fail_if(strcmp(type_name, "List_Objects"));
    fail_if(!(type = eolian_typedecl_base_type_get(tdl)));
    fail_if(!(type_name = eolian_type_c_type_get(type, EOLIAN_C_TYPE_DEFAULT)));
-   fail_if(!eolian_type_is_own(type));
+   fail_if(eolian_type_is_owned(type));
    fail_if(strcmp(type_name, "Eina_List *"));
    eina_stringshare_del(type_name);
    fail_if(!(type = eolian_type_base_type_get(type)));
    fail_if(!!eolian_type_next_type_get(type));
    fail_if(!(type_name = eolian_type_c_type_get(type, EOLIAN_C_TYPE_DEFAULT)));
    fail_if(strcmp(type_name, "Eo *"));
-   fail_if(eolian_type_is_own(type));
+   fail_if(eolian_type_is_owned(type));
    eina_stringshare_del(type_name);
 
    /* List */
@@ -411,19 +411,19 @@ START_TEST(eolian_complex_type)
    fail_if(!(fid = eolian_class_function_get_by_name(class, "a", EOLIAN_PROPERTY)));
    fail_if(!(type = eolian_function_return_type_get(fid, EOLIAN_PROP_SET)));
    fail_if(!(type_name = eolian_type_c_type_get(type, EOLIAN_C_TYPE_RETURN)));
-   fail_if(!eolian_type_is_own(type));
+   fail_if(!eolian_type_is_owned(type));
    fail_if(strcmp(type_name, "Eina_List *"));
    eina_stringshare_del(type_name);
    fail_if(!(type = eolian_type_base_type_get(type)));
    fail_if(!!eolian_type_next_type_get(type));
    fail_if(!(type_name = eolian_type_c_type_get(type, EOLIAN_C_TYPE_DEFAULT)));
-   fail_if(eolian_type_is_own(type));
+   fail_if(eolian_type_is_owned(type));
    fail_if(strcmp(type_name, "Eina_Array *"));
    eina_stringshare_del(type_name);
    fail_if(!(type = eolian_type_base_type_get(type)));
    fail_if(!!eolian_type_next_type_get(type));
    fail_if(!(type_name = eolian_type_c_type_get(type, EOLIAN_C_TYPE_DEFAULT)));
-   fail_if(!eolian_type_is_own(type));
+   fail_if(!eolian_type_is_owned(type));
    fail_if(strcmp(type_name, "Eo *"));
    eina_stringshare_del(type_name);
    /* Properties parameter type */
@@ -434,13 +434,13 @@ START_TEST(eolian_complex_type)
    fail_if(strcmp(eolian_parameter_name_get(param), "value"));
    fail_if(!(type = eolian_parameter_type_get(param)));
    fail_if(!(type_name = eolian_type_c_type_get(type, EOLIAN_C_TYPE_PARAM)));
-   fail_if(!eolian_type_is_own(type));
+   fail_if(!eolian_type_is_owned(type));
    fail_if(strcmp(type_name, "Eina_List *"));
    eina_stringshare_del(type_name);
    fail_if(!(type = eolian_type_base_type_get(type)));
    fail_if(!!eolian_type_next_type_get(type));
    fail_if(!(type_name = eolian_type_c_type_get(type, EOLIAN_C_TYPE_DEFAULT)));
-   fail_if(eolian_type_is_own(type));
+   fail_if(eolian_type_is_owned(type));
    fail_if(strcmp(type_name, "int"));
    eina_stringshare_del(type_name);
 
@@ -448,13 +448,13 @@ START_TEST(eolian_complex_type)
    fail_if(!(fid = eolian_class_function_get_by_name(class, "foo", EOLIAN_METHOD)));
    fail_if(!(type = eolian_function_return_type_get(fid, EOLIAN_METHOD)));
    fail_if(!(type_name = eolian_type_c_type_get(type, EOLIAN_C_TYPE_RETURN)));
-   fail_if(!eolian_type_is_own(type));
+   fail_if(!eolian_type_is_owned(type));
    fail_if(strcmp(type_name, "Eina_List *"));
    eina_stringshare_del(type_name);
    fail_if(!(type = eolian_type_base_type_get(type)));
    fail_if(!!eolian_type_next_type_get(type));
    fail_if(!(type_name = eolian_type_c_type_get(type, EOLIAN_C_TYPE_DEFAULT)));
-   fail_if(eolian_type_is_own(type));
+   fail_if(eolian_type_is_owned(type));
    fail_if(strcmp(type_name, "Eina_Stringshare *"));
    eina_stringshare_del(type_name);
    /* Methods parameter type */
@@ -465,7 +465,7 @@ START_TEST(eolian_complex_type)
    fail_if(strcmp(eolian_parameter_name_get(param), "buf"));
    fail_if(!(type = eolian_parameter_type_get(param)));
    fail_if(!(type_name = eolian_type_c_type_get(type, EOLIAN_C_TYPE_PARAM)));
-   fail_if(!eolian_type_is_own(type));
+   fail_if(!eolian_type_is_owned(type));
    fail_if(strcmp(type_name, "char *"));
    eina_stringshare_del(type_name);
 
@@ -1458,7 +1458,7 @@ START_TEST(eolian_function_types)
    fail_if(strcmp(eolian_parameter_name_get(param), "c"));
    fail_if(!(type = eolian_parameter_type_get(param)));
    fail_if(eolian_parameter_direction_get(param) != EOLIAN_IN_PARAM);
-   fail_if(eolian_type_is_own(type));
+   fail_if(eolian_type_is_owned(type));
    fail_if(!(type_name = eolian_type_c_type_get(type, EOLIAN_C_TYPE_PARAM)));
    fail_if(strcmp(type_name, "const char *"));
 
@@ -1467,9 +1467,9 @@ START_TEST(eolian_function_types)
    fail_if(strcmp(eolian_parameter_name_get(param), "d"));
    fail_if(eolian_parameter_direction_get(param) != EOLIAN_OUT_PARAM);
    fail_if(!(type = eolian_parameter_type_get(param)));
-   fail_if(!eolian_type_is_own(type));
+   fail_if(!eolian_type_is_owned(type));
    fail_if(!(type_name = eolian_type_c_type_get(type, EOLIAN_C_TYPE_PARAM)));
-   fail_if(strcmp(type_name, "const char *"));
+   fail_if(strcmp(type_name, "char *"));
 
    fail_if(eina_iterator_next(iter, &dummy));
 
@@ -1488,7 +1488,7 @@ START_TEST(eolian_function_types)
    fail_if(strcmp(eolian_parameter_name_get(param), "cb"));
    fail_if(!(type = eolian_parameter_type_get(param)));
    fail_if(eolian_parameter_direction_get(param) != EOLIAN_IN_PARAM);
-   fail_if(eolian_type_is_own(type));
+   fail_if(eolian_type_is_owned(type));
    fail_if(!(type_name = eolian_type_name_get(type)));
    fail_if(strcmp(type_name, "VoidFunc"));
    fail_if(!(arg_decl = eolian_type_typedecl_get(type)));
@@ -1498,7 +1498,7 @@ START_TEST(eolian_function_types)
    fail_if(strcmp(eolian_parameter_name_get(param), "another_cb"));
    fail_if(eolian_parameter_direction_get(param) != EOLIAN_IN_PARAM);
    fail_if(!(type = eolian_parameter_type_get(param)));
-   fail_if(eolian_type_is_own(type));
+   fail_if(eolian_type_is_owned(type));
    fail_if(eolian_type_type_get(type) != EOLIAN_TYPE_REGULAR);
    fail_if(!(type_name = eolian_type_name_get(type)));
    fail_if(strcmp(type_name, "SimpleFunc"));
@@ -1539,7 +1539,7 @@ START_TEST(eolian_function_as_arguments)
    fail_if(strcmp(eolian_parameter_name_get(param), "cb"));
    fail_if(!(type = eolian_parameter_type_get(param)));
    fail_if(eolian_parameter_direction_get(param) != EOLIAN_IN_PARAM);
-   fail_if(eolian_type_is_own(type));
+   fail_if(eolian_type_is_owned(type));
    fail_if(!(type_name = eolian_type_name_get(type)));
    fail_if(strcmp(type_name, "SimpleFunc"));
    fail_if(!(arg_decl = eolian_type_typedecl_get(type)));