diff --git a/src/bindings/eo_js/eo_js_constructor.hh b/src/bindings/eo_js/eo_js_constructor.hh index f0dddd9dbd..0b6502b2b3 100644 --- a/src/bindings/eo_js/eo_js_constructor.hh +++ b/src/bindings/eo_js/eo_js_constructor.hh @@ -40,8 +40,10 @@ struct constructor_caller template void operator()(T function) const { - aux(function, eina::make_index_sequence::type>::value>()); + std::size_t const parameters + = std::tuple_size::type>::value; + aux(function, eina::make_index_sequence()); + *current += parameters; } template @@ -57,7 +59,6 @@ struct constructor_caller void aux(T function, eina::index_sequence) const { function(get_value((*args)[I + *current])...); - std::cout << " should call " << typeid(function).name() << std::endl; } std::size_t* current; diff --git a/src/bindings/eo_js/eo_js_get_value.hh b/src/bindings/eo_js/eo_js_get_value.hh index 940e8ccb54..dca2756e54 100644 --- a/src/bindings/eo_js/eo_js_get_value.hh +++ b/src/bindings/eo_js/eo_js_get_value.hh @@ -1,6 +1,10 @@ #ifndef EFL_EO_JS_GET_VALUE_HH #define EFL_EO_JS_GET_VALUE_HH +#include + +#include + namespace efl { namespace eo { namespace js { template @@ -9,13 +13,28 @@ struct value_tag typedef T type; }; -inline int get_value_from_javascript(v8::Local v, value_tag) +template +inline int get_value_from_javascript + (v8::Local v, value_tag + , typename std::enable_if::value>::type* = 0) { + if(v->IsInt32()) + return v->Int32Value(); + else if(v->IsUint32()) + return v->Uint32Value(); + else + std::abort(); return 0; } -inline double get_value_from_javascript(v8::Local v, value_tag) +template +inline double get_value_from_javascript + (v8::Local v, value_tag + , typename std::enable_if::value>::type* = 0) { - return 0.0; + if(v->IsNumber()) + return v->NumberValue(); + else + std::abort(); } } } } diff --git a/src/tests/eolian_js/eolian_js_test_constructor_method_impl.c b/src/tests/eolian_js/eolian_js_test_constructor_method_impl.c index e92f7dcf3a..fe7fb4ce4d 100644 --- a/src/tests/eolian_js/eolian_js_test_constructor_method_impl.c +++ b/src/tests/eolian_js/eolian_js_test_constructor_method_impl.c @@ -9,6 +9,8 @@ #include "constructor_method_class.eo.h" +#include + struct _Constructor_Method_Class_Data { Eina_Bool one, two; @@ -24,11 +26,17 @@ static void _constructor_method_class_eo_base_constructor(Eo *obj, Constructor_M static void _constructor_method_class_constructor1(Eo *obj, Constructor_Method_Class_Data *pd, int one) { + fprintf(stderr, "one == %d\n", one); + fflush(stderr); + ck_assert(one == 5); pd->one = 1; } static void _constructor_method_class_constructor2(Eo *obj, Constructor_Method_Class_Data *pd, double two) { + fprintf(stderr, "two == %f\n", two); + fflush(stderr); + ck_assert(two == 10.0); pd->two = 1; } @@ -37,7 +45,6 @@ static Eo * _constructor_method_class_eo_base_finalize(Eo *obj, Constructor_Meth if(!pd->one || !pd->two) return NULL; - eo_do_super(obj, EO_BASE_CLASS, eo_finalize()); return obj; }