[webkit-help] Prototype and object creation

demallien demallien at me.com
Mon Aug 9 08:41:25 PDT 2010


here's the only response I managed to get when I posted the question on webkit-dev about a 6 months:


The pertinent part of the answer was the following from the ECMAScript specification:
13.2.2 [[Construct]]
When the [[Construct]] internal method for a Function object F is called with a possibly empty list of arguments, the following steps are taken:
Let obj be a newly created native ECMAScript object.
Set all the internal methods of obj as specified in 8.12.
Set the [[Class]] internal property of obj to "Object".
Set the [[Extensible]] internal property of obj to true.
Let proto be the value of calling the [[Get]] internal property of F with argument "prototype".
If Type(proto) is Object, set the [[Prototype]] internal property of obj to proto.
If Type(proto) is not Object, set the [[Prototype]] internal property of obj to the standard built-in Object prototype object as described in 15.2.4.
Let result be the result of calling the [[Call]] internal property of F, providing obj as the this value and providing the argument list passed into [[Construct]] as args.
If Type(result)

I have to admit that it didn't really help me very much, but as I was roundly scolded for asking the question on webkit-dev, and when I asked a follow up question on webkit-help, no-one answered, I just let the whole thing drop and moved to a more classic object system, rather than using prototypes.

If you manage to get it figured out, I'd love it if you could post an example showing how you did it


Date: Sun, 08 Aug 2010 14:14:50 +0530
From: "Subramanian RS" <symsrs at ovi.com>
To: webkit-help at lists.webkit.org
Subject: [webkit-help] Prototype and object creation
<20100808084450.2918746D357 at c-in3ws--02-08.sv2.lotuslive.com>
Content-Type: text/plain; charset="utf-8"


I am using the JSAPIs provided as part of the Javascript core. So far I am successfully created the objects and getting the callbacks etc... But I am not getting the callback if the object creation is under a jQuery extend with a prototype.

jQuery.extend(someobject.prototype, {
init: function(){

var obj = new MyObject(...); /// whenever this line is executed I am not getting the constructor callback

In the normal way the MyObject can be created but not when extending.

I am using JSObjectMake to create the JSObjectRef and I tried to use the JSObjectSetPrototype. I am implementing JSObjectCallAsConstructorCallback callback. But nothing seems to be working and I am not getting hit on this callback.

I debugged the webkit code and I am getting a plain JSObject that is created in the interpreter 

ConstructType constructType = v.getConstructData(constructData);

constructType always returns ConstructTypeJS. I believe I should get the ConstructTypeHost as the construct type.

Could someone point me what I could be doing wrong and any steps I missed?

Thanks in advance,

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-help/attachments/20100809/7e60b7ac/attachment.html>

More information about the webkit-help mailing list