Re: [v8-users] How to pass the second parameter of ObjectTemplate::New in Google V8?
Same question: http://stackoverflow.com/questions/43909594/ On Fri, May 12, 2017 at 7:40 PM, Ben Noordhuis wrote: > On Thu, May 11, 2017 at 11:02 AM, XadillaX Scarlet > wrote: > > I know creating an ObjectTemplate and we can do several things to it. > But my > > question is not about those well-known things. > > > > I want to know how to pass the second parameter. > > > > As the official guide said: > > > > Each function template has an associated object template. This is used to > > configure objects created with this function as their constructor. > > > > And the second parameter of ObjectTemplate::New is a constructor typed by > > FunctionTemplate. > > > > static Local New(Isolate *isolate, > Local > > constructor = Local()); > > > > That means something like this: > > > > void Constructor(const FunctionCallbackInfo& args) > > { > > // ... > > } > > > > Local _constructor = FunctionTemplate::New(isolate, > > Constructor); > > Local tpl = ObjectTemplate::New(isolate, _constructor); > > > > Who can give me a demo that how to implement the Constructor function. > > > > I tried this, but failed: > > > > void Constructor(const FunctionCallbackInfo& args) > > { > > Isolate* isolate = args.GetIsolate(); > > args.This()->Set(String::NewFromUtf8(isolate, "value"), > > Number::New(isolate, 233)); > > args.GetReturnValue().Set(args.This()); > > } > > > > By the way, I know the use case of accessors and so on, I just want to > know > > how to use the second parameter. > > When you say 'failed', what exactly do you mean? Is the function not > called or don't you see the .value property on the new object? > > -- > -- > 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. > 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. For more options, visit https://groups.google.com/d/optout.
Re: [v8-users] How to pass the second parameter of ObjectTemplate::New in Google V8?
On Thu, May 11, 2017 at 11:02 AM, XadillaX Scarlet wrote: > I know creating an ObjectTemplate and we can do several things to it. But my > question is not about those well-known things. > > I want to know how to pass the second parameter. > > As the official guide said: > > Each function template has an associated object template. This is used to > configure objects created with this function as their constructor. > > And the second parameter of ObjectTemplate::New is a constructor typed by > FunctionTemplate. > > static Local New(Isolate *isolate, Local > constructor = Local()); > > That means something like this: > > void Constructor(const FunctionCallbackInfo& args) > { > // ... > } > > Local _constructor = FunctionTemplate::New(isolate, > Constructor); > Local tpl = ObjectTemplate::New(isolate, _constructor); > > Who can give me a demo that how to implement the Constructor function. > > I tried this, but failed: > > void Constructor(const FunctionCallbackInfo& args) > { > Isolate* isolate = args.GetIsolate(); > args.This()->Set(String::NewFromUtf8(isolate, "value"), > Number::New(isolate, 233)); > args.GetReturnValue().Set(args.This()); > } > > By the way, I know the use case of accessors and so on, I just want to know > how to use the second parameter. When you say 'failed', what exactly do you mean? Is the function not called or don't you see the .value property on the new object? -- -- 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. For more options, visit https://groups.google.com/d/optout.
[v8-users] Size of the V8 static library
We are working on the V8 version 5.3.332 & we choose to compile it as static library. We compiled the library with the following configuration. MAKE_TARGET="android_$BUILD_LIB_VERSION.$BUILD_MODE" make $MAKE_TARGET -j1 snapshot=off debuggersupport=off GYPFLAGS="-Dandroid_ndk_root=$NDK_DIR -Dv8_use_snapshot='false' -Dv8_enable_i18n_support=0" ANDROID_NDK_ROOT=$NDK_DIR With the above configuration, release version of libv8_base.a is around 35MB in size. So my question is, is V8 expected to be 35MB in size with i18n & snapshot support off ? is there any additional flags which help us to get the v8 size reduced further ? One more observation is, even if we pass debuggersupport=off , we are still able to build & debug my JS app. So our expectation here is, debug API's would be stripped off from library and no more runtime JS debug support available. Please correct if we are not passing the build configuration properly & suggest . -- -- 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. For more options, visit https://groups.google.com/d/optout.