summaryrefslogtreecommitdiff
path: root/src/bindings/eo_js/eo_js_construct_from_eo.hh
diff options
context:
space:
mode:
Diffstat (limited to 'src/bindings/eo_js/eo_js_construct_from_eo.hh')
-rw-r--r--src/bindings/eo_js/eo_js_construct_from_eo.hh39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/bindings/eo_js/eo_js_construct_from_eo.hh b/src/bindings/eo_js/eo_js_construct_from_eo.hh
new file mode 100644
index 0000000000..287aaa748c
--- /dev/null
+++ b/src/bindings/eo_js/eo_js_construct_from_eo.hh
@@ -0,0 +1,39 @@
+#ifndef EFL_EO_JS_CONSTRUCT_FROM_EO_HH
+#define EFL_EO_JS_CONSTRUCT_FROM_EO_HH
+
+#include <eina_tuple.hh>
+#include <eina_tuple_c.hh>
+#include <eina_function.hh>
+#include <Eo.h>
+
+#include <cstdlib>
+#include <functional>
+#include <iostream>
+#include <cassert>
+#include <vector>
+
+namespace efl { namespace eo { namespace js {
+
+inline eina::js::compatibility_return_type construct_from_eo(eina::js::compatibility_callback_info_type args)
+{
+ if(args.IsConstructCall())
+ {
+ Eo* eo = static_cast<Eo*>(v8::External::Cast(*args[0])->Value());
+ args.This()->SetInternalField(0, args[0]);
+ efl::eina::js::make_weak(args.GetIsolate(), args.This(), [eo] { eo_unref(eo); });
+ return eina::js::compatibility_return();
+ }
+ else
+ {
+ std::size_t argc = args.Length();
+ std::vector<v8::Local<v8::Value> > argv (argc ? argc : 1 );
+ for(int i = 0; i != args.Length(); ++i)
+ argv[i] = args[i];
+ args.Callee()->NewInstance(argc, &argv[0]);
+ return eina::js::compatibility_return();
+ }
+}
+
+} } }
+
+#endif