Re: [v8-users] Variable value declaration

2016-02-04 Thread Jakob Kummerow
Shouldn't make a difference in most cases. Personally, I'd go for: 3) var x = value ? 2 : 1; which, per the JavaScript spec, is semantically equivalent to (1) anyway, but more concise. On Wed, Feb 3, 2016 at 9:16 PM, Arthur Shefer wrote: > Hello, fast question - what is the best approach for v

Re: [v8-users] Variable value declaration

2016-02-04 Thread Arthur Shefer
Yes, but there can be a lot more complex cases, just wondering if declaring variable faster helps v8 to optimize code faster/cheaper. On Thursday, February 4, 2016 at 10:37:09 AM UTC+2, Jakob Kummerow wrote: > > Shouldn't make a difference in most cases. Personally, I'd go for: > > 3) var x = val

Re: [v8-users] What happens when you throw a C++ exception from a FunctionTemplate callback function?

2016-02-04 Thread Jakob Kummerow
All of V8 is compiled with -fno-exceptions, so it doesn't support C++ exceptions. You could try building without that flag, but then you'd be entirely on your own you find that something doesn't work (and I'm pretty sure that something wouldn't work -- V8 code is not written to be exception safe).

Re: [v8-users] What happens when you throw a C++ exception from a FunctionTemplate callback function?

2016-02-04 Thread Zac Hansen
Good to know, thank you. On Thursday, February 4, 2016 at 12:45:20 AM UTC-8, Jakob Kummerow wrote: > > All of V8 is compiled with -fno-exceptions, so it doesn't support C++ > exceptions. You could try building without that flag, but then you'd be > entirely on your own you find that something do

[v8-users] V8 and boost+python

2016-02-04 Thread Daniel Burchardt
Hi, I try create v8 module to python used boost and i have problem: #include using namespace std; #include #include #include #include "include/libplatform/libplatform.h" #include "include/v8.h" using namespace v8; const char* say_hello(const char* name) { return name; } #include #in

[v8-users] How can functions be added to instance templates?

2016-02-04 Thread vmjoshi
This recent commit 6a118774 breaks the ability to set functions as data properties on templates (ie. Template::Set will assert on a value argument that is a JSReceiver). To be more explicit, the following code no longer

Re: [v8-users] V8 and boost+python

2016-02-04 Thread Ben Noordhuis
On Thu, Feb 4, 2016 at 7:41 PM, Daniel Burchardt wrote: > Hi, > > I try create v8 module to python used boost and i have problem: > > #include > > using namespace std; > > #include > #include > #include > #include "include/libplatform/libplatform.h" > #include "include/v8.h" > > using namespac

Re: [v8-users] V8 and boost+python

2016-02-04 Thread Daniel Burchardt
Thank you W dniu czwartek, 4 lutego 2016 21:52:53 UTC+1 użytkownik Ben Noordhuis napisał: > > On Thu, Feb 4, 2016 at 7:41 PM, Daniel Burchardt > > wrote: > > Hi, > > > > I try create v8 module to python used boost and i have problem: > > > > #include > > > > using namespace std; > > >

[v8-users] Re: How can functions be added to instance templates?

2016-02-04 Thread Zac Hansen
On Thursday, February 4, 2016 at 12:44:39 PM UTC-8, vmj...@extrahop.com wrote: > > This recent commit 6a118774 > > breaks > the ability to set functions as data properties on templates (ie. > Template::Set will assert

[v8-users] How to get the original type on a native c++ object from v8::Object's internal fields?

2016-02-04 Thread Zac Hansen
I'm in a FunctionTemplate callback and about to call a function that expects parameters of a certain type and I want to make sure that the variable backing the object is of the right type. I know the type the function wants (T), but you can't call dynamic_cast(my_void_ptr). Unless I'm missi

Re: [v8-users] How to get the original type on a native c++ object from v8::Object's internal fields?

2016-02-04 Thread Louis Santillan
First, is the Function callback calling a C++ native function, a JS function or another C++ defined Function callback? Providing some code might make the issue more obvious. Second, v8.h has all the JS ("container") types defined. Start there when defining variables. You can often use the v8 ty

Re: [v8-users] How to get the original type on a native c++ object from v8::Object's internal fields?

2016-02-04 Thread Zac Hansen
Very pseudocode-y: class Foo {}; function f(Foo * f){} static void callback(const v8::FunctionCallbackInfo& args) { void * internal_field = args[0].GetInternalField(0); // this skips a bunch of casts and such } // create the function called "foo" ft = FunctionTemplate( callback); context

Re: [v8-users] How to get the original type on a native c++ object from v8::Object's internal fields?

2016-02-04 Thread Zac Hansen
Crap, that last reply was early.. I hit tab/space anda it went to "POST"... > Very pseudocode-y: > > class Foo {}; > > function f(Foo * f){} > > static void callback(const v8::FunctionCallbackInfo& args) { >void * internal_field = args[0].GetInternalField(0); // this skips a > bunch of c

[v8-users] Re: How to get the original type on a native c++ object from v8::Object's internal fields?

2016-02-04 Thread Zac Hansen
Thinking more about this problem, I realize it's actually quite involved. Without some sort of type information about what's being stored, it doesn't seem possible to see if something is a derived class of an arbitrary type. Also, introducing some sort of templated pointer type to External wou