mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-06 19:42:39 +08:00
5410a48a58
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>
22 lines
847 B
C
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;
|
|
}
|