[webkit-help] New to webkit

LG lgmagic at gmail.com
Mon Aug 3 05:36:21 PDT 2009


But is the location to place the file and the source code looks fine??

On Mon, Aug 3, 2009 at 6:00 PM, Jack Wootton <jackwootton at gmail.com> wrote:

> I have only modified an old s60 branch of webkit so can't help you on
> where to put the files and compile it, since this is done differently
> on s60.  I'm sure someone who knows more can help with this (I would
> be interested too). However in the list of errors you get you don't
> have JSObjectCallAsFunction or JSObjectSetProperty. Presumably these
> are not undefined references?  I had a similar problem on an old S60
> branch, I posted about it on Forum Nokia here
> http://discussion.forum.nokia.com/forum/showthread.php?t=172429 but
> received no help (but since you're using SquirrelFish I doubt it's the
> same issue).
>
> On Mon, Aug 3, 2009 at 12:56 PM, LG<lgmagic at gmail.com> wrote:
> > Hi Jack,
> >
> > thanks for the info,
> >
> > the problem here is i tried this and didnot work
> > i ll elaborate on what i have tried
> >
> > 1. i have created a class in JavascriptCore/API
> >
> > test.cpp
> >
> > #include "UnusedParam.h"
> > #include <JavaScriptCore/JavaScript.h>
> > #include <assert.h>
> > #include <math.h>
> > #include <setjmp.h>
> >
> >
> > static JSGlobalContextRef context = 0;
> > JSValueRef v;
> > JSValueRef exception;
> > JSStringRef functionBody;
> > JSObjectRef function;
> >
> > int main()
> > {
> >
> >     //create a class with a name
> >     JSStringRef calObjectName =
> JSStringCreateWithUTF8CString("calendar");
> >
> >     //create a class definition
> >     JSClassDefinition calObjectDef;
> >     calObjectDef.version = 1;
> >     //calObjectDef.className = calObjectName
> >
> >
> >     //create a context
> >     //context = JSGlobalContextCreate(NULL);
> >     //assert(JSValueIsObject(context, globalObject));
> >
> >     //create the class
> >     JSClassRef globalObjectClass = JSClassCreate(&calObjectDef);
> >
> >     //create a global context
> >     JSGlobalContextRef context =
> JSGlobalContextCreate(globalObjectClass);
> >         JSObjectRef globalObject = JSContextGetGlobalObject(context);
> >
> >     //make the object
> >     JSObjectRef calObject = JSObjectMake(context, globalObjectClass,
> NULL);
> >
> >
> >     //set properties
> >     JSObjectSetProperty(context, globalObject, calObjectName, calObject,
> > kJSPropertyAttributeNone, NULL);
> >
> >
> >     exception = NULL;
> >     v = NULL;
> >
> >     JSStringRef getCal = JSStringCreateWithUTF8CString("getCalendars");
> >     functionBody = JSStringCreateWithUTF8CString("return NULL;");
> >     function = JSObjectMakeFunction(context, getCal,0, NULL,
> functionBody,
> > NULL, 1, &exception);
> >     assert(function && !exception);
> >     JSValueRef arguments[] = { JSValueMakeNumber(context, 2) };
> >     v = JSObjectCallAsFunction(context, function, NULL, 1, arguments,
> > &exception);
> >     JSStringRelease(getCal);
> >     JSStringRelease(functionBody);
> >
> >     return 1;
> > }
> >
> >
> > 2. i added this to the make file and i get the following errors
> >
> > undefined reference to `JSStringCreateWithUTF8CString`
> > undefined reference to `JSClassCreate`
> > undefined reference to `JSGlobalContextCreate`
> >
> > etc
> >
> > i am not sure where to put the file and compile
> > please guide me through the approach
> >
> >
> >
> >
> > On Mon, Aug 3, 2009 at 2:29 PM, Jack Wootton <jackwootton at gmail.com>
> wrote:
> >>
> >> Hello,
> >>
> >> If you mean add a new JavaScript object, then here is a reply I wrote
> >> some time ago (copied and pasted).
> >>
> >> Here is the API:
> >>
> >>
> >>
> http://gemma.apple.com/documentation/Carbon/Reference/WebKit_JavaScriptCore_Ref/index.html#//apple_ref/doc/framework/javascriptcore_fw
> >>
> >> If this is what you wish to do, then the following is a rough guide of
> >> what you need to do:
> >>
> >> 1. Create an empty class definition, you can create an empty class
> >> definition using kJSClassDefinitionEmpty.
> >> 2. Use the class definition with the JSCoreAPI method "JSClassCreate"
> >> to create your class.
> >> 3. Use your new class with JSObjectMake to create your new JSObject
> >> (this will be your widget object).
> >> 4  Use JSObjectSetProperty to add your new JSObject as a property of
> >> the Window object.
> >>
> >> It maybe useful to look at the following files in the
> >> JavaScriptCore (Although, personally I didn't find them particularly
> >> easy to understand.)
> >>
> >> JavaScriptCore\API\testapi.c
> >> testapi.js
> >>
> >>
> >> There are also some example programs that do what you want to do, only
> >> with different objects.
> >>
> >> JSPong: http://developer.apple.com/SampleCode/JSPong/index.html
> >>
> >> JSInterpreter:
> >> http://developer.apple.com/samplecode/JSInterpreter/index.html
> >>
> >> More programs can be found here:
> >>
> >> http://developer.apple.com/SampleCode/Cocoa/idxInternetWeb-date.html
> >>
> >> On Mon, Aug 3, 2009 at 5:34 AM, LG<lgmagic at gmail.com> wrote:
> >> > Hi all,
> >> >
> >> > i am new to webkit and i need to add an new object/api to javascript
> >> > core
> >> > can someone share and example and tell me how to compile it in webkit
> >> >
> >> > anyhelp would be useful
> >> > thanks a lot
> >> >
> >> >
> >> > --
> >> > Ganesh
> >> >
> >> > _______________________________________________
> >> > webkit-help mailing list
> >> > webkit-help at lists.webkit.org
> >> > http://lists.webkit.org/mailman/listinfo.cgi/webkit-help
> >> >
> >> >
> >>
> >>
> >>
> >> --
> >> Regards
> >> Jack
> >
> >
> >
> > --
> > LG
> >
>
>
>
> --
> Regards
> Jack
>



-- 
LG
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-help/attachments/20090803/180aea5a/attachment.html>


More information about the webkit-help mailing list