Thanks Darin.<br><br>For the first problem, as you said, all the functions are objects, and also have **properties**.<br><br>So,can we add a member for the "function object" to store the method name[here is "getValues"] in theoretical ?<br>
<br>And this also like the "JSObjectRef object" variable in the callback prototype,we can get the class name like this:<br><br>toJS(object)->className().data()<br><br>Thanks.<br><br>-Xiong<br><br><div class="gmail_quote">
On Fri, May 15, 2009 at 10:29 AM, Darin Adler <span dir="ltr"><<a href="mailto:darin@apple.com">darin@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im">On May 14, 2009, at 7:03 PM, Xiong wrote:<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
1 what is the purpose of the "JSObjectRef function" variable? In my case, we never use.<br>
</blockquote>
<br></div>
It’s fine to not use this if you don’t need to. In JavaScript, functions are objects. Like other objects they can have properties. This argument is passed to your C implementation so that it can get access to properties of the function object if it has some reason to. In many cases there is no need to do this.<div class="im">
<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
2 In this function, i want to get the propertyName of the method, in this case, we need "getValues", can be implemented ?<br>
</blockquote>
<br></div>
No, there's no way to do that, for a good architectural reason.<br>
<br>
A JavaScript function is a first class object. Using JSObjectMake will create an object with a prototype that has functions stored in its properties, but there’s nothing to prevent the JavaScript program from taking that function and storing it somewhere else, in a property with another name. When the function is called, it’s just an object, and there’s no way to go back in time and find out where that object came from.<br>
<br>
Consider the similar situation of a data property. When you get the length of an array, it's a number 1, not a number 1 that knows it came from a property named "length".<br><font color="#888888">
<br>
-- Darin<br>
<br>
</font></blockquote></div><br>