Add `String char(int ascii)` function to GDScript and Visual Script
Just hope it doesn't crashes with that much pointer math... 😄
This commit is contained in:
parent
78d97b060a
commit
513c0265c4
|
@ -88,6 +88,7 @@ const char *GDFunctions::get_func_name(Function p_func) {
|
||||||
"convert",
|
"convert",
|
||||||
"typeof",
|
"typeof",
|
||||||
"type_exists",
|
"type_exists",
|
||||||
|
"char",
|
||||||
"str",
|
"str",
|
||||||
"print",
|
"print",
|
||||||
"printt",
|
"printt",
|
||||||
|
@ -538,6 +539,12 @@ void GDFunctions::call(Function p_func,const Variant **p_args,int p_arg_count,Va
|
||||||
r_ret = ObjectTypeDB::type_exists(*p_args[0]);
|
r_ret = ObjectTypeDB::type_exists(*p_args[0]);
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
|
case TEXT_CHAR: {
|
||||||
|
VALIDATE_ARG_COUNT(1);
|
||||||
|
VALIDATE_ARG_NUM(0);
|
||||||
|
CharType result[2] = {*p_args[0], 0};
|
||||||
|
r_ret=String(result);
|
||||||
|
} break;
|
||||||
case TEXT_STR: {
|
case TEXT_STR: {
|
||||||
|
|
||||||
String str;
|
String str;
|
||||||
|
@ -1133,6 +1140,7 @@ bool GDFunctions::is_deterministic(Function p_func) {
|
||||||
case TYPE_CONVERT:
|
case TYPE_CONVERT:
|
||||||
case TYPE_OF:
|
case TYPE_OF:
|
||||||
case TYPE_EXISTS:
|
case TYPE_EXISTS:
|
||||||
|
case TEXT_CHAR:
|
||||||
case TEXT_STR:
|
case TEXT_STR:
|
||||||
case COLOR8:
|
case COLOR8:
|
||||||
// enable for debug only, otherwise not desirable - case GEN_RANGE:
|
// enable for debug only, otherwise not desirable - case GEN_RANGE:
|
||||||
|
@ -1402,6 +1410,13 @@ MethodInfo GDFunctions::get_info(Function p_func) {
|
||||||
mi.return_val.type=Variant::BOOL;
|
mi.return_val.type=Variant::BOOL;
|
||||||
return mi;
|
return mi;
|
||||||
|
|
||||||
|
} break;
|
||||||
|
case TEXT_CHAR: {
|
||||||
|
|
||||||
|
MethodInfo mi("char",PropertyInfo(Variant::INT,"ascii"));
|
||||||
|
mi.return_val.type=Variant::STRING;
|
||||||
|
return mi;
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
case TEXT_STR: {
|
case TEXT_STR: {
|
||||||
|
|
||||||
|
|
|
@ -82,6 +82,7 @@ public:
|
||||||
TYPE_CONVERT,
|
TYPE_CONVERT,
|
||||||
TYPE_OF,
|
TYPE_OF,
|
||||||
TYPE_EXISTS,
|
TYPE_EXISTS,
|
||||||
|
TEXT_CHAR,
|
||||||
TEXT_STR,
|
TEXT_STR,
|
||||||
TEXT_PRINT,
|
TEXT_PRINT,
|
||||||
TEXT_PRINT_TABBED,
|
TEXT_PRINT_TABBED,
|
||||||
|
|
|
@ -55,6 +55,7 @@ const char* VisualScriptBuiltinFunc::func_name[VisualScriptBuiltinFunc::FUNC_MAX
|
||||||
"convert",
|
"convert",
|
||||||
"typeof",
|
"typeof",
|
||||||
"type_exists",
|
"type_exists",
|
||||||
|
"char",
|
||||||
"str",
|
"str",
|
||||||
"print",
|
"print",
|
||||||
"printerr",
|
"printerr",
|
||||||
|
@ -141,6 +142,7 @@ int VisualScriptBuiltinFunc::get_func_argument_count(BuiltinFunc p_func) {
|
||||||
case LOGIC_NEAREST_PO2:
|
case LOGIC_NEAREST_PO2:
|
||||||
case OBJ_WEAKREF:
|
case OBJ_WEAKREF:
|
||||||
case TYPE_OF:
|
case TYPE_OF:
|
||||||
|
case TEXT_CHAR:
|
||||||
case TEXT_STR:
|
case TEXT_STR:
|
||||||
case TEXT_PRINT:
|
case TEXT_PRINT:
|
||||||
case TEXT_PRINTERR:
|
case TEXT_PRINTERR:
|
||||||
|
@ -361,6 +363,12 @@ PropertyInfo VisualScriptBuiltinFunc::get_input_value_port_info(int p_idx) const
|
||||||
|
|
||||||
return PropertyInfo(Variant::STRING,"type");
|
return PropertyInfo(Variant::STRING,"type");
|
||||||
|
|
||||||
|
} break;
|
||||||
|
case TEXT_CHAR: {
|
||||||
|
|
||||||
|
return PropertyInfo(Variant::INT,"ascii");
|
||||||
|
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
case TEXT_STR: {
|
case TEXT_STR: {
|
||||||
|
|
||||||
|
@ -517,6 +525,7 @@ PropertyInfo VisualScriptBuiltinFunc::get_output_value_port_info(int p_idx) cons
|
||||||
t=Variant::BOOL;
|
t=Variant::BOOL;
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
|
case TEXT_CHAR:
|
||||||
case TEXT_STR: {
|
case TEXT_STR: {
|
||||||
|
|
||||||
t=Variant::STRING;
|
t=Variant::STRING;
|
||||||
|
@ -974,6 +983,13 @@ void VisualScriptBuiltinFunc::exec_func(BuiltinFunc p_func,const Variant** p_inp
|
||||||
|
|
||||||
*r_return = ObjectTypeDB::type_exists(*p_inputs[0]);
|
*r_return = ObjectTypeDB::type_exists(*p_inputs[0]);
|
||||||
|
|
||||||
|
} break;
|
||||||
|
case VisualScriptBuiltinFunc::TEXT_CHAR: {
|
||||||
|
|
||||||
|
CharType result[2] = {*p_inputs[0], 0};
|
||||||
|
|
||||||
|
*r_return=String(result);
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
case VisualScriptBuiltinFunc::TEXT_STR: {
|
case VisualScriptBuiltinFunc::TEXT_STR: {
|
||||||
|
|
||||||
|
@ -1213,6 +1229,7 @@ void register_visual_script_builtin_func_node() {
|
||||||
VisualScriptLanguage::singleton->add_register_func("functions/built_in/convert",create_builtin_func_node<VisualScriptBuiltinFunc::TYPE_CONVERT>);
|
VisualScriptLanguage::singleton->add_register_func("functions/built_in/convert",create_builtin_func_node<VisualScriptBuiltinFunc::TYPE_CONVERT>);
|
||||||
VisualScriptLanguage::singleton->add_register_func("functions/built_in/typeof",create_builtin_func_node<VisualScriptBuiltinFunc::TYPE_OF>);
|
VisualScriptLanguage::singleton->add_register_func("functions/built_in/typeof",create_builtin_func_node<VisualScriptBuiltinFunc::TYPE_OF>);
|
||||||
VisualScriptLanguage::singleton->add_register_func("functions/built_in/type_exists",create_builtin_func_node<VisualScriptBuiltinFunc::TYPE_EXISTS>);
|
VisualScriptLanguage::singleton->add_register_func("functions/built_in/type_exists",create_builtin_func_node<VisualScriptBuiltinFunc::TYPE_EXISTS>);
|
||||||
|
VisualScriptLanguage::singleton->add_register_func("functions/built_in/char",create_builtin_func_node<VisualScriptBuiltinFunc::TEXT_CHAR>);
|
||||||
VisualScriptLanguage::singleton->add_register_func("functions/built_in/str",create_builtin_func_node<VisualScriptBuiltinFunc::TEXT_STR>);
|
VisualScriptLanguage::singleton->add_register_func("functions/built_in/str",create_builtin_func_node<VisualScriptBuiltinFunc::TEXT_STR>);
|
||||||
VisualScriptLanguage::singleton->add_register_func("functions/built_in/print",create_builtin_func_node<VisualScriptBuiltinFunc::TEXT_PRINT>);
|
VisualScriptLanguage::singleton->add_register_func("functions/built_in/print",create_builtin_func_node<VisualScriptBuiltinFunc::TEXT_PRINT>);
|
||||||
VisualScriptLanguage::singleton->add_register_func("functions/built_in/printerr",create_builtin_func_node<VisualScriptBuiltinFunc::TEXT_PRINTERR>);
|
VisualScriptLanguage::singleton->add_register_func("functions/built_in/printerr",create_builtin_func_node<VisualScriptBuiltinFunc::TEXT_PRINTERR>);
|
||||||
|
|
|
@ -57,6 +57,7 @@ public:
|
||||||
TYPE_CONVERT,
|
TYPE_CONVERT,
|
||||||
TYPE_OF,
|
TYPE_OF,
|
||||||
TYPE_EXISTS,
|
TYPE_EXISTS,
|
||||||
|
TEXT_CHAR,
|
||||||
TEXT_STR,
|
TEXT_STR,
|
||||||
TEXT_PRINT,
|
TEXT_PRINT,
|
||||||
TEXT_PRINTERR,
|
TEXT_PRINTERR,
|
||||||
|
|
Loading…
Reference in New Issue