On Feb 3, 2014, at 9:04 AM, Honey <[email protected]> wrote:

> I have exposed a function setObject() through webkit idl. Suppose i have a 
> javascript class like
> 
> function Player () { var speed = 5; var x = 50; var y = 50;}

I presume you meant:

function Player() { this.speed = 5; this.x = 50; this.y = 50; }

Since your original code means that the variables speed, x, and y are local and 
therefore dead at the point where you call setObject().

> var p = new Player();
> setObject(p);
> 
> In webkit, i am getting the p as JSValue object. I want to retrieve the value 
> of x through this JSValue object. how can i do that?

JSValue has this API:

    JSValue::get(ExecState*, PropertyName)

So, jf you have "JSValue p" then you can do something like:

    JSValue x = p.get(exec, Identifier(exec, "x"))

Where "exec" is an ExecState* or CallFrame* that you have lying around.  If 
you're in the C++ code for your setObject(), then presumably someone is passing 
you one of those things, somehow.

-Filip


> any help would be appreciated..
> 
> 
> Sent from my iPad
> _______________________________________________
> webkit-dev mailing list
> [email protected]
> https://lists.webkit.org/mailman/listinfo/webkit-dev

_______________________________________________
webkit-dev mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-dev

Reply via email to