[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Gnash] AS Function and C Function
From: |
strk |
Subject: |
Re: [Gnash] AS Function and C Function |
Date: |
Fri, 10 Feb 2006 13:07:08 +0100 |
I'll expand with an example:
String.prototype.sayHello = function() { return "hello"; };
var p = new String();
trace(p.sayHello());
In the above example String is our "class".
In Gnash, the String constructor (as every other Built-in class
constructor) is a C function:
struct fn_call;
typedef void (*as_c_function_ptr)(const fn_call& fn);
So we cannot add properties to them!
I think each built-in class should be an instance
(possibly a singleton) of a function_as_object.
Comments welcome.
--strk;
On Fri, Feb 10, 2006 at 11:27:54AM +0100, strk wrote:
> I'm in the process of cleaning up the code.
> This mail should go in a developers list, but
> since Gnash has only one list I'll write it here.
>
> The question is: should we really make a distinction
> between user-defined function and built-in functions ?
>
> The question is particularly related to inheritance,
> that is: are the following to be handled differently ?
>
> var obj1 = new Date();
> var obj2 = new MyClass();
>
> I think both 'Date' and 'MyClass' should evaluate
> to the same Gnash class, which would be as_function.
>
> The as_function would be the constructor, and will
> provide a prototype to be used in the created
> instance's __proto__ member. Does it sound ?
>
> If we agree on this we should define our built-in
> classes as instances of our as_function class.
> These would likely be singletons as we don't need
> multiple String,Date,Number constructor instances.
>
> What do you think ?
>
> --strk;