forked from enlightenment/efl
Added Indexed Property Handler for list
This commit is contained in:
parent
1ac7705e55
commit
9af366b1df
|
@ -22,9 +22,15 @@ struct eina_list
|
||||||
void push_back(eina_list& list, v8::Persistent<v8::Value, v8::CopyablePersistentTraits<v8::Value> > object)
|
void push_back(eina_list& list, v8::Persistent<v8::Value, v8::CopyablePersistentTraits<v8::Value> > object)
|
||||||
{
|
{
|
||||||
std::cout << "eina_list push_back" << std::endl;
|
std::cout << "eina_list push_back" << std::endl;
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
void index_get(uint32_t index, v8::PropertyCallbackInfo<v8::Value>const& info)
|
||||||
|
{
|
||||||
|
std::cout << "index_get " << index << std::endl;
|
||||||
|
if(
|
||||||
|
info.GetReturnValue().Set(5);
|
||||||
|
}
|
||||||
|
|
||||||
void new_eina_list(v8::FunctionCallbackInfo<v8::Value> const& args)
|
void new_eina_list(v8::FunctionCallbackInfo<v8::Value> const& args)
|
||||||
{
|
{
|
||||||
void* p = new eina_list;
|
void* p = new eina_list;
|
||||||
|
@ -73,6 +79,7 @@ R call_impl(v8::Isolate* isolate
|
||||||
, eina::index_sequence<N...>)
|
, eina::index_sequence<N...>)
|
||||||
|
|
||||||
{
|
{
|
||||||
|
std::cout << "self " << self << std::endl;
|
||||||
(*f)(*self, js::get_element<N, Sig>(isolate, args)...);
|
(*f)(*self, js::get_element<N, Sig>(isolate, args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,11 +129,14 @@ void register_(v8::Isolate* isolate, const char* name, F&& f, v8::Handle<v8::Obj
|
||||||
|
|
||||||
EAPI void eina_list_register(v8::Handle<v8::ObjectTemplate> global, v8::Isolate* isolate)
|
EAPI void eina_list_register(v8::Handle<v8::ObjectTemplate> global, v8::Isolate* isolate)
|
||||||
{
|
{
|
||||||
v8::Local<v8::FunctionTemplate> constructor = v8::FunctionTemplate::New(isolate, &efl::js::new_eina_list );
|
v8::Handle<v8::FunctionTemplate> constructor = v8::FunctionTemplate::New(isolate, &efl::js::new_eina_list );
|
||||||
v8::Local<v8::ObjectTemplate> instance_t = constructor->InstanceTemplate();
|
v8::Local<v8::ObjectTemplate> instance_t = constructor->InstanceTemplate();
|
||||||
instance_t->SetInternalFieldCount(1);
|
instance_t->SetInternalFieldCount(1);
|
||||||
|
|
||||||
|
instance_t->SetIndexedPropertyHandler(& efl::js::index_get);
|
||||||
|
|
||||||
global->Set(v8::String::NewFromUtf8(isolate, "List"), constructor);
|
global->Set(v8::String::NewFromUtf8(isolate, "List"), constructor);
|
||||||
efl::js::register_<efl::js::eina_list>
|
// efl::js::register_<efl::js::eina_list>
|
||||||
(isolate, "push_back", &efl::js::push_back, instance_t);
|
// (isolate, "push_back", &efl::js::push_back, instance_t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,8 @@
|
||||||
static const char script[] =
|
static const char script[] =
|
||||||
"print(\"teste\");\n"
|
"print(\"teste\");\n"
|
||||||
"var l = new List();\n"
|
"var l = new List();\n"
|
||||||
"l.push_back(5);\n"
|
"print (l[0]);\n"
|
||||||
|
// "l.push_back(5);\n"
|
||||||
;
|
;
|
||||||
|
|
||||||
const char* ToCString(const v8::String::Utf8Value& value) {
|
const char* ToCString(const v8::String::Utf8Value& value) {
|
||||||
|
|
Loading…
Reference in New Issue