Hi all,
I'm trying to create a custom class that is a Clutter.Clone plus some
extra methods.
I'm using the GNOME javascript bindings (from gobject introspection)
to do this, and am having difficulty getting the inheritance working
properly.

I asked around at stackoverflow about this sort of thing first to
avoid spamming the list with javascript questions, but the answers
given there did not work on the Clutter classes, so I'm asking here.

First, in GNOME 3.4 I can do:

Toon = new Lang.Class({ // Lang is imports.lang
    Name: 'Toon',
    Extends: Clutter.Clone,
    other methods here.
});

This works fantastic - if I do `var toon = new Toon( a_clutter_texture
);` everything works fine.

However in GNOME 3.2 the `Lang.Class` method doesn't seem to be there,
and in my asking around I've been told the "standard" way to make a
subclass in JS is like so:

Toon = function() {
    Clutter.Clone.call(this,arguments); // this gives Toon all the
properties/methods of Clutter.Clone
    // toon-specific initialisation code here
}
Toon.prototype = new Clutter.Clone;
Toon.prototype.method = function... // add all the toon-specific methods here

However when I do `var toon = new Toon()` or `var toon = new Toon(
a_clutter_texture )`, I get "Constructor called as normal method. Use
'new SomeObject()' not 'SomeObject()'."

So then I tried replacing the `Clutter.Clone.call(this,arguments)`
with `Clutter.Clone.new.call(this,arguments)`. I now get the error
"Object 0xb681b1c0 proto 0xb6802078 doesn't have a
dynamically-registered class, it has Arguments".

I thought this might be somehow because of me using the special
`arguments` keyword, so I even tried `Clutter.Clone.new.call(this, new
Clutter.Texture())`, and I get the same message as above but instead
of "Arguments" I get "Object".

I've even tried:

Toon = function() {};
Toon.prototype = new Clutter.Clone;
Toon.prototype.method = function ... //toon-specific methods

In this case I get no errors on `var Toon = new Toon(
a_clutter_texture )`, but when I try using a non-toon method like
`Toon.set_position(0,0)`, I get the 'Object 0x... proto 0x... doesn't
have a dynamically-registered class, it has Object' message again,
which indicates to me that Toon is somehow not being recognised as a
Clutter.Clone.

Is anyone able to tell me where I'm going wrong?
Thanks in advance.
_______________________________________________
clutter-app-devel-list mailing list
clutter-app-devel-list@clutter-project.org
http://lists.clutter-project.org/listinfo/clutter-app-devel-list

Reply via email to