Closed Bug 645409 Opened 13 years ago Closed 13 years ago

ANI: nativegen should emit synthetic C++ classes AS3 interfaces, if possible

Categories

(Tamarin Graveyard :: Virtual Machine, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: stejohns, Assigned: stejohns)

References

Details

Attachments

(1 file, 1 obsolete file)

the one hole in synthetic classes are AS3 Interfaces, which reduce to ScriptObject. We should try to emit wrappers for these, too, if possible.
Assignee: nobody → stejohns
Blocks: 629757
Attached patch Patch (obsolete) — Splinter Review
Generate synthetic C++ classes for interfaces; these will be named with the suffix "Interface" (so AS3 "IFoo" -> C++ "IFooInterface"). 

Note that you can't construct interfaces (duh)... you can, however, obtain them in a couple of ways:

(1) every C++ instance class that implements an interfaces gets cheap methods to cast to the interfaces it implements, e.g.,

    interface IBar { ... }
    class Foo implements IBar { ... }

the C++ will have wrappers like

    GCRef<IBarInterface> FooObject::as_IBarInterface(); // never returns NULL


(2) the ClassManifest provides "Class" objects for each interface; these are really just convenient placeholders to put isType/asType/coerceToType methods. e.g., for the above,

    GCRef<IBarInterface> i = builtinClasses()->get_IBarClass()->coerceToType(someObj);
Attachment #548319 - Flags: superreview?(edwsmith)
Attachment #548319 - Flags: review?(rulohani)
This doesn't make a big difference in the avmshell codebase, but in Flash, it adds desired typesafety (where we currently have to declare things "ScriptObject", and it also paves the way for bug 634638 to be implemented more robustly (since we can implement callin wrappers for interface methods while we're here).
Attached patch Patch v2Splinter Review
Minor modifications to pacify GCC 4.4+
Attachment #548319 - Attachment is obsolete: true
Attachment #548319 - Flags: superreview?(edwsmith)
Attachment #548319 - Flags: review?(rulohani)
Attachment #548336 - Flags: superreview?(edwsmith)
Attachment #548336 - Flags: review?(rulohani)
Will this help make it possible to version interfaces? I'd dearly love to add a method to IEventDispatcher without breaking the world.
Hmm... offhand, no, I don't think it would make that easier. The best approach would probably to make an IEventDispatcher2 that extends IEventDispatcher.
pushed to TR in advance of review: 6489:8b8081a5bf83
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
Attachment #548336 - Flags: review?(rulohani) → review+
Attachment #548336 - Flags: superreview?(edwsmith)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: