MCPcopy Create free account
hub / github.com/OpenFodder/openfodder / dukglue_set_base_class

Function dukglue_set_base_class

Source/Utils/dukglue/register_class.h:51–77  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

49
50template<class Base, class Derived>
51void dukglue_set_base_class(duk_context* ctx)
52{
53 static_assert(!std::is_pointer<Base>::value && !std::is_pointer<Derived>::value
54 && !std::is_const<Base>::value && !std::is_const<Derived>::value, "Use bare class names.");
55 static_assert(std::is_base_of<Base, Derived>::value, "Invalid class hierarchy!");
56
57 using namespace dukglue::detail;
58
59 // Derived.type_info->set_base(Base.type_info)
60 ProtoManager::push_prototype<Derived>(ctx);
61 duk_get_prop_string(ctx, -1, "\xFF" "type_info");
62 TypeInfo* derived_type_info = static_cast<TypeInfo*>(duk_require_pointer(ctx, -1));
63 duk_pop_2(ctx);
64
65 ProtoManager::push_prototype<Base>(ctx);
66 duk_get_prop_string(ctx, -1, "\xFF" "type_info");
67 TypeInfo* base_type_info = static_cast<TypeInfo*>(duk_require_pointer(ctx, -1));
68 duk_pop_2(ctx);
69
70 derived_type_info->set_base(base_type_info);
71
72 // also set up the prototype chain
73 ProtoManager::push_prototype<Derived>(ctx);
74 ProtoManager::push_prototype<Base>(ctx);
75 duk_set_prototype(ctx, -2);
76 duk_pop(ctx);
77}
78
79// methods
80template<typename T, T Value, class Cls, typename RetType, typename... Ts>

Callers

nothing calls this directly

Calls 1

set_baseMethod · 0.80

Tested by

no test coverage detected