[webkit-help] Prototype and object creation

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


Rs, 

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

http://www.mail-archive.com/webkit-dev@lists.webkit.org/msg10066.html

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:
1.
Let obj be a newly created native ECMAScript object.
2.
Set all the internal methods of obj as specified in 8.12.
3.
Set the [[Class]] internal property of obj to "Object".
4.
Set the [[Extensible]] internal property of obj to true.
5.
Let proto be the value of calling the [[Get]] internal property of F with argument "prototype".
6.
If Type(proto) is Object, set the [[Prototype]] internal property of obj to proto.
7.
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.
8.
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.
9.
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

Alli



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
Message-ID:
<20100808084450.2918746D357 at c-in3ws--02-08.sv2.lotuslive.com>
Content-Type: text/plain; charset="utf-8"

Hi,

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,
Rs


-------------- 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