Files
cocos4/native/tools/bindings-generator/targets/spidermonkey/templates/enum.c
T
minggo 5410a48a58 Implement more logic in native (#4131)
Co-authored-by: bofeng.song <bofeng.song@chukong-inc.com>
Co-authored-by: dumganhar <dumganhar@gmail.com>
Co-authored-by: mmyduckx <308303735@qq.com>
Co-authored-by: Patrice Jiang <397136899@qq.com>
Co-authored-by: 江战 <40414978+PatriceJiang@users.noreply.github.com>
2022-01-07 18:39:40 +08:00

22 lines
847 B
C

#set fields = $current_class.fields
template<>
bool sevalue_to_native(const se::Value &from, ${current_class.namespaced_class_name} *to, se::Object *ctx) // NOLINT(readability-identifier-naming)
{
typedef typename std::underlying_type_t<${current_class.namespaced_class_name}> under_type;
under_type tmp;
if(sevalue_to_native(from, &tmp, ctx)) { *to = static_cast<${current_class.namespaced_class_name}>(tmp); return true;}
return false;
}
int js_register_${generator.prefix}_${current_class.nested_class_name}(se::Object* obj) // NOLINT(readability-identifier-naming)
{
auto enum_kls = se::Object::createPlainObject();
#for m in fields
enum_kls->setProperty("${m['name']}", se::Value(${m['value']}));
#end for
obj->setProperty("${current_class.target_class_name}", se::Value(enum_kls));
return true;
}