Why not just have an object property on the world thing that is a 
Handle<Function> ?

On Saturday, October 5, 2013 4:07:08 PM UTC-4, James Lomax wrote:
>
> Hi, this is somethings that's had me stumped for the past 6 hours now..
>
> I have an object template which has a setter and getter for the object 
> "update" which simply set/get an object handle accessible to both the 
> setter and getter (see "Things I've tried".) An object is instantiated 
> within the global context called "world" from this object template. A 
> script is then run which sets "world.update" to a function with a basic 
> output message. The program then gets the update function and calls it 
> which works exactly as intended - printing some output. The program then 
> gets the update function again, but the update function is now a string - 
> the output from the original call. Trying to call it leads to an exception.
>
> The code: http://pastebin.com/i33nLWby
> The script (main.js): http://pastebin.com/X3GZRdbV
> The output:
>
> Set update() [update]
> Get update() [update]
> Did a world.update()
> Get update() [update]
> Caught2: Uncaught TypeError: Did a world.update()
>  is not a function
>
> Without the object template (i.e. with just a regular object in javascript 
> without the getter/setter combination) the program functions fine but I'd 
> like to be able to use this to have the script manage callbacks.
>
> Why does this happen and what am I doing wrong?
>
> Things I've tried:
>
> - In the code I use an internal field pointing to a Handle<Function> 
> object though I have tried using a global variable and using plain old 
> object handles - no differences were noted here.
> - Get'ing the update function but not calling, then get'ing again. This 
> proves the call is part of the cause
> - Get'ing and calling, followed by calling from the internal field (no 
> difference.)
> - Calling directly from the internal field (worldUpdateFunc.func); first 
> call is successful, after this the internal field is no longer a function 
> (can't figure out what it is as it returns false to all the Is* functions) 
> and the program segfaults somewhere random in V8??
>
> Thanks, James.
>

-- 
-- 
v8-users mailing list
[email protected]
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to