Re: [webkit-dev] KJS::JSObject question

2009-05-17 Thread Darin Adler

On May 15, 2009, at 7:35 AM, Jack Wootton wrote:


4. Create the context:

JSGlobalContextRef context = JSGlobalContextCreate(globalObjectClass);


You will only do this if you’re using JavaScript outside of a web  
page. If you want to do this in conjunction with WebKit you’ll need to  
get the context from WebKit APIs. On Mac OS X the relevant API is - 
[WebFrame globalContext].


1. Who should share the context?  Is a single context used for a  
single webpage / frame?


See my answer above.

2. Where do I define the class that will actually handle the  
implementation of any methods on my new object?


I don’t understand the “where” question. Do it wherever makes sense in  
your program, and call JSClassCreate. Then when it's time to make an  
object, pass the JSClassRef to JSObjectMake.


3. The object has been made using JSObjectMake, but how is it  
added to WebKit?


A common thing to do is to create an object and then put it in a  
property of the window object, which is the global object inside the  
web browser. That’s done on Mac OS X by implementing the  
webView:windowScriptObjectAvailable: method of the frame load  
delegate. The window script object is a WebScriptObject, and you can  
get the JSObject version of it by calling the JSObject method on it.  
Then you can set your object as a property of the window object with  
the JSObjectSetProperty function.


-- Darin

___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev


[webkit-dev] building errors about cmd.exe

2009-05-17 Thread sitan2006
nbsp;
nbsp;Hi, there's some errors when I built webkit on Windows following 
instructions on webkit.org. It seems to be something wrong with cmd.exe.
I've read a lot of posts in this maillist, and found no solution for this kind 
of error.
I post it again, hoping to move further.
nbsp;
Attached is my error info:
nbsp;
*
16-- Build started: Project: TestNetscapePlugin, Configuration: Release 
Win32 --
16Performing Pre-Build Event...
16Project : error PRJ0002 : Error result 1 returned from 
'c:\WINDOWS\system32\cmd.exe'.
16Project : warning PRJ0018 : The following environment variables were not 
found:
16$(PRODUCTION)
16Build log was saved at 
file://C:\cygwin\home\Administrator\WebKit\WebKitBuild\obj\TestNetscapePlugin\Release\BuildLog.htm
16TestNetscapePlugin - 1 error(s), 0 warning(s)
17-- Build started: Project: ImageDiff, Configuration: Release Win32 --
17Performing Pre-Build Event...
17Project : error PRJ0002 : Error result 1 returned from 
'c:\WINDOWS\system32\cmd.exe'.
17Project : warning PRJ0018 : The following environment variables were not 
found:
17$(PRODUCTION)
17Build log was saved at 
file://C:\cygwin\home\Administrator\WebKit\WebKitBuild\obj\ImageDiff\Release\BuildLog.htm
17ImageDiff - 1 error(s), 0 warning(s)
18-- Build started: Project: DumpRenderTree, Configuration: Release Win32 
--
18Performing Pre-Build Event...
18Project : error PRJ0002 : Error result 1 returned from 
'c:\WINDOWS\system32\cmd.exe'.
18Project : warning PRJ0018 : The following environment variables were not 
found:
18$(PRODUCTION)
18Build log was saved at 
file://C:\cygwin\home\Administrator\WebKit\WebKitBuild\obj\DumpRenderTree\Release\BuildLog.htm
18DumpRenderTree - 1 error(s), 0 warning(s)
== Build: 15 succeeded, 3 failed, 0 up-to-date, 0 skipped ==

= BUILD FAILED ==
Please ensure you have run WebKit/WebKitTools/Scripts/update-webkit to install 
depenedencies.
You can view build errors by checking the BuildLog.htm files located at:
/home/Administrator/WebKit/WebKitBuild/obj/project/config.
***
nbsp;
PS:nbsp; It'snbsp; really depressing these 3 errors occur at the very last, 
all the things before are fine.
And another important thing is :
if I run build-webkit again, I will get succeeded, the info is :
nbsp;
***
1JavaScriptCoreGenerated - 0 error(s), 0 warning(s)
2-- Build started: Project: WebCoreGenerated, Configuration: Release Win32 
--
2Performing Makefile project actions
2make: Nothing to be done for `all'.
2make: Nothing to be done for `all'.
2Build log was saved at 
file://C:\cygwin\home\Administrator\WebKit\WebKitBuild\obj\WebCoreGenerated\Release\BuildLog.htm
2WebCoreGenerated - 0 error(s), 0 warning(s)
3-- Build started: Project: InterfacesGenerated, Configuration: Release 
Win32 --
3Performing Makefile project actions
3make: Nothing to be done for `all'.
3Build log was saved at 
file://C:\cygwin\home\Administrator\WebKit\WebKitBuild\obj\InterfacesGenerated\Release\BuildLog.htm
3InterfacesGenerated - 0 error(s), 0 warning(s)
4-- Build started: Project: TestNetscapePlugin, Configuration: Release 
Win32 --
4Performing Pre-Build Event...
4Compiling...
4### COMPILING 3 FILES USING AT MOST 2 PARALLEL INSTANCES OF cl.exe 
###
4main.cpp
4TestObject.cpp
4PluginObject.cpp
4Compiling resources...
4Performing Pre-Link Event...
4Linking...
4nbsp;nbsp; Creating library 
C:\cygwin\home\Administrator\WebKit\WebKitBuild\lib\npTestNetscapePlugin.lib 
and object 
C:\cygwin\home\Administrator\WebKit\WebKitBuild\lib\npTestNetscapePlugin.exp
4Generating code
4Finished generating code
4Embedding manifest...
4Performing Post-Build Event...
4Project : warning PRJ0018 : The following environment variables were not 
found:
4$(PRODUCTION)
4Build log was saved at 
file://C:\cygwin\home\Administrator\WebKit\WebKitBuild\obj\TestNetscapePlugin\Release\BuildLog.htm
4TestNetscapePlugin - 0 error(s), 0 warning(s)
5-- Build started: Project: ImageDiff, Configuration: Release Win32 --
5Performing Pre-Build Event...
5Compiling...
5### COMPILING 1 FILES USING AT MOST 2 PARALLEL INSTANCES OF cl.exe 
###
5ImageDiffCG.cpp
5Performing Pre-Link Event...
5Linking...
5Generating code
5Finished generating code
5Embedding manifest...
5Performing Post-Build Event...
5Project : warning PRJ0018 : The following environment variables were not 
found:
5$(PRODUCTION)
5Build log was saved at 
file://C:\cygwin\home\Administrator\WebKit\WebKitBuild\obj\ImageDiff\Release\BuildLog.htm
5ImageDiff - 0 error(s), 0 warning(s)
6-- Build started: Project: DumpRenderTree, Configuration: Release Win32 
--
6Performing Pre-Build Event...

Re: [webkit-dev] JSObjectCallAsFunctionCallback question

2009-05-17 Thread Xiong
Hi, Su

Yes, this is the key point of the problem.

In my program, many Object use the same staticFunc entry[Program
Architecture].

So, in the getValue_cb callback function, we need do extra two things:

1.Get the Object name, here is myObject; [WE CAN NOW]
2.Get the propertyName of the method, here is getValues; [WE CAN NOT NOW]

After both get the Object and method's name, we can identify another
callback function.

Therefore, implement a way to get the propertyName of the method via
'function object' is needed.

Thanks.

-Xiong

On Fri, May 15, 2009 at 3:28 PM, Zhe Su james...@gmail.com wrote:

 AFAIK, there is no way to achieve what you want by using staticFunc
 structure. Of course, if you use different C functions for each staticFunc
 entry, you actually don't need the name.

 Regards
 James Su


 On Fri, May 15, 2009 at 3:24 PM, Xiong browse...@gmail.com wrote:

 Thanks Su.

 I think i know you mean.

 To get the method name [getValue] via attach a private data to function
 object which create by JSObjectMake().

 Yes, it's a better way, but not for me.

 In my program, we have many Object and it's method and now all in
 staticFunc structure.

 Thanks again.

 -Xiong


 On Fri, May 15, 2009 at 11:57 AM, Zhe Su james...@gmail.com wrote:

 If you create a JSObject with JSObjectMake() function, you can have a
 private data associated to the newly created JSObject. You can store
 anything you want in the private data. So following approach might be
 feasible for you:

 1. define a special JSClass for your function, which has finalize and
 callAsFunction set. In finalize() method, you need destroy the private data
 associated to the JSObject, if necessary. callAsFunction points to your
 getValue_cb.
 2. create the getValue function object by calling JSObjectMake() with the
 function name getValue as private data.
 3. attach the function object to myObject with name getValue. It might
 be done in myObject class's initialize() method.
 4. in getValue_cb function you can retrieve the private data (which
 contains the name) by calling JSObjectGetPrivate(function).

 The only drawback of this approach: you can't declare the function
 statically in staticFunctions.

 Regards
 James Su

 On Fri, May 15, 2009 at 10:53 AM, Xiong browse...@gmail.com wrote:

 Thanks Darin.

 For the first problem, as you said, all the functions are objects, and
 also have **properties**.

 So,can we add a member for the function object to store the method
 name[here is getValues] in theoretical ?

 And this also like the JSObjectRef object variable in the callback
 prototype,we can get the class name like this:

 toJS(object)-className().data()

 Thanks.

 -Xiong


 On Fri, May 15, 2009 at 10:29 AM, Darin Adler da...@apple.com wrote:

 On May 14, 2009, at 7:03 PM, Xiong wrote:

  1what is the purpose of the JSObjectRef function variable? In my
 case, we never use.


 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.

  2In this function, i want to get the propertyName of the method,
 in this case, we need getValues, can be implemented ?


 No, there's no way to do that, for a good architectural reason.

 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.

 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.

-- Darin



 ___
 webkit-dev mailing list
 webkit-dev@lists.webkit.org
 http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev





___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev