• Philip Chimento's avatar
    jsapi-class: GJS_DEFINE_PROTO stores protos in global slots · 8807af7a
    Philip Chimento authored
    This refactors the GJS_DEFINE_PROTO family of macros to store the created
    prototype objects in slots on the global object. We split up the
    gjs_WHATEVER_create_proto() function into two functions: one that must be
    called at least once for each type to define the class, store the prototype
    in a global slot, and define the constructor as a property on a passed-in
    module or global object, gjs_WHATEVER_define_proto(); and one that
    retrieves the prototype from its global slot, gjs_WHATEVER_get_proto().
    
    We also add two macros, GJS_DEFINE_PROTO_WITH_PARENT and
    GJS_DEFINE_PROTO_ABSTRACT_WITH_PARENT, which also move the definition of
    the parent to compile time rather than runtime, and keep it in the same
    place as the rest of each class's macro definition. Similarly, previously
    we had to pass the parent prototype object to gjs_WHATEVER_create_proto().
    
    This mostly affects the cairo module.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=614413
    8807af7a
cairo-private.h 8.71 KB