สวัสดี ในวันที่ วันศุกร์ที่ 5 มิถุนายน ค.ศ. 2020 เวลา 9 นาฬิกา 43 นาที 28 วินาที UTC+7 almo...@gmail.com เขียนว่า:
> [Back to this one year later :D] > > I defined a new public member on v8::Function called 'GetData' that > returns the data argument specified when the function was created. Seems to > be working fine, here's the code in case someone wants to give it a quick > glance: > > > > > > > > > > > > > > > > > *v8::Local<v8::Value> Function::GetData() const { > i::Handle<i::JSReceiver> self = Utils::OpenHandle(this); i::Isolate* > isolate = self->GetIsolate(); if(self->IsJSFunction()) { > i::Handle<i::JSFunction> jsf = i::Handle<i::JSFunction>::cast(self); > i::SharedFunctionInfo sfi = jsf->shared(); if(sfi.IsApiFunction()) { > i::FunctionTemplateInfo fti = sfi.get_api_func_data(); > i::CallHandlerInfo chi = i::CallHandlerInfo::cast(fti.call_code()); > i::Object o = chi.data(); i::Handle<i::Object> ho = > i::Handle<i::Object>(o, isolate); return ToApiHandle<v8::Value>(ho); > } } return v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate));}* > > It is very verbose on purpose. I will submit a CL soon, I am reading the > requirements :) > > Best, > Alex. > > On Fri, Apr 12, 2019 at 9:27 AM Al Mo <almo...@gmail.com> wrote: > >> I eventually solved it by binding a Private symbol with an external value >> to the Function object. >> >> That solves it for the moment. I would love to contribute back to v8 but >> I'm very limited in time now. As soon as I find some time, I will submit a >> CL with an approach based on your suggestion. >> >> Thanks. >> >> On Sunday, April 7, 2019 at 2:43:31 AM UTC+3, Al Mo wrote: >>> >>> I'm new here so first of all: Hi Everyone :D >>> >>> So, let's say I make a function this way: >>> >>> v8::Function::New(<Isolate>, <C_Function>, <Data_Value>); >>> >>> >>> I can then get the <Data_Value> when the Function is invoked with >>> something like: FunctionCallbackInfo->GetData(). >>> >>> This is useful for many things. I'm looking for a way to be able to >>> inspect this data value for a previously defined Function object. Something >>> like Function->GetData(), you get the idea. >>> >>> So far I haven't succeeded and I've read the docs from a to z. Any ideas? >>> >> -- >> -- >> v8-users mailing list >> v8-u...@googlegroups.com >> http://groups.google.com/group/v8-users >> --- >> You received this message because you are subscribed to the Google Groups >> "v8-users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to v8-users+u...@googlegroups.com. >> For more options, visit https://groups.google.com/d/optout. >> > -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups "v8-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/v8-users/51f0b993-a52c-49c4-a4ac-b10d0e3a8cc3n%40googlegroups.com.