Add shorthand for using singleton string names
This commit is contained in:
parent
916ea002c1
commit
a262d2d881
77 changed files with 382 additions and 380 deletions
|
|
@ -2038,15 +2038,15 @@ void GDScriptInstance::notification(int p_notification, bool p_reversed) {
|
|||
}
|
||||
|
||||
String GDScriptInstance::to_string(bool *r_valid) {
|
||||
if (has_method(CoreStringNames::get_singleton()->_to_string)) {
|
||||
if (has_method(CoreStringName(_to_string))) {
|
||||
Callable::CallError ce;
|
||||
Variant ret = callp(CoreStringNames::get_singleton()->_to_string, nullptr, 0, ce);
|
||||
Variant ret = callp(CoreStringName(_to_string), nullptr, 0, ce);
|
||||
if (ce.error == Callable::CallError::CALL_OK) {
|
||||
if (ret.get_type() != Variant::STRING) {
|
||||
if (r_valid) {
|
||||
*r_valid = false;
|
||||
}
|
||||
ERR_FAIL_V_MSG(String(), "Wrong type for " + CoreStringNames::get_singleton()->_to_string + ", must be a String.");
|
||||
ERR_FAIL_V_MSG(String(), "Wrong type for " + CoreStringName(_to_string) + ", must be a String.");
|
||||
}
|
||||
if (r_valid) {
|
||||
*r_valid = true;
|
||||
|
|
|
|||
|
|
@ -231,7 +231,7 @@ bool GDScriptAnalyzer::has_member_name_conflict_in_native_type(const StringName
|
|||
if (ClassDB::has_integer_constant(p_native_type_string, p_member_name)) {
|
||||
return true;
|
||||
}
|
||||
if (p_member_name == CoreStringNames::get_singleton()->_script) {
|
||||
if (p_member_name == CoreStringName(script)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -2172,7 +2172,7 @@ void GDScriptAnalyzer::resolve_for(GDScriptParser::ForNode *p_for) {
|
|||
List<GDScriptParser::DataType> par_types;
|
||||
int default_arg_count = 0;
|
||||
BitField<MethodFlags> method_flags;
|
||||
if (get_function_signature(p_for->list, false, list_type, CoreStringNames::get_singleton()->_iter_get, return_type, par_types, default_arg_count, method_flags)) {
|
||||
if (get_function_signature(p_for->list, false, list_type, CoreStringName(_iter_get), return_type, par_types, default_arg_count, method_flags)) {
|
||||
variable_type = return_type;
|
||||
variable_type.type_source = list_type.type_source;
|
||||
} else if (!list_type.is_hard_type()) {
|
||||
|
|
|
|||
|
|
@ -346,7 +346,7 @@ GDScriptCodeGenerator::Address GDScriptCompiler::_parse_expression(CodeGen &code
|
|||
scr = scr->_base;
|
||||
}
|
||||
|
||||
if (nc && (identifier == CoreStringNames::get_singleton()->_free || ClassDB::has_signal(nc->get_name(), identifier) || ClassDB::has_method(nc->get_name(), identifier))) {
|
||||
if (nc && (identifier == CoreStringName(free_) || ClassDB::has_signal(nc->get_name(), identifier) || ClassDB::has_method(nc->get_name(), identifier))) {
|
||||
// Get like it was a property.
|
||||
GDScriptCodeGenerator::Address temp = codegen.add_temporary(); // TODO: Get type here.
|
||||
GDScriptCodeGenerator::Address self(GDScriptCodeGenerator::Address::SELF);
|
||||
|
|
|
|||
|
|
@ -1741,7 +1741,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||
if (base_type == Variant::OBJECT) {
|
||||
if (base_obj) {
|
||||
MethodBind *method = ClassDB::get_method(base_class, *methodname);
|
||||
if (*methodname == CoreStringNames::get_singleton()->_free || (method && !method->has_return())) {
|
||||
if (*methodname == CoreStringName(free_) || (method && !method->has_return())) {
|
||||
err_text = R"(Trying to get a return value of a method that returns "void")";
|
||||
OPCODE_BREAK;
|
||||
}
|
||||
|
|
@ -3097,7 +3097,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||
const Variant *args[] = { &vref };
|
||||
|
||||
Callable::CallError ce;
|
||||
Variant has_next = obj->callp(CoreStringNames::get_singleton()->_iter_init, args, 1, ce);
|
||||
Variant has_next = obj->callp(CoreStringName(_iter_init), args, 1, ce);
|
||||
|
||||
#ifdef DEBUG_ENABLED
|
||||
if (ref.size() != 1 || ce.error != Callable::CallError::CALL_OK) {
|
||||
|
|
@ -3113,7 +3113,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||
*counter = ref[0];
|
||||
|
||||
GET_VARIANT_PTR(iterator, 2);
|
||||
*iterator = obj->callp(CoreStringNames::get_singleton()->_iter_get, (const Variant **)&counter, 1, ce);
|
||||
*iterator = obj->callp(CoreStringName(_iter_get), (const Variant **)&counter, 1, ce);
|
||||
#ifdef DEBUG_ENABLED
|
||||
if (ce.error != Callable::CallError::CALL_OK) {
|
||||
err_text = vformat(R"(There was an error calling "_iter_get" on iterator object of type %s.)", *container);
|
||||
|
|
@ -3431,7 +3431,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||
const Variant *args[] = { &vref };
|
||||
|
||||
Callable::CallError ce;
|
||||
Variant has_next = obj->callp(CoreStringNames::get_singleton()->_iter_next, args, 1, ce);
|
||||
Variant has_next = obj->callp(CoreStringName(_iter_next), args, 1, ce);
|
||||
|
||||
#ifdef DEBUG_ENABLED
|
||||
if (ref.size() != 1 || ce.error != Callable::CallError::CALL_OK) {
|
||||
|
|
@ -3447,7 +3447,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||
*counter = ref[0];
|
||||
|
||||
GET_VARIANT_PTR(iterator, 2);
|
||||
*iterator = obj->callp(CoreStringNames::get_singleton()->_iter_get, (const Variant **)&counter, 1, ce);
|
||||
*iterator = obj->callp(CoreStringName(_iter_get), (const Variant **)&counter, 1, ce);
|
||||
#ifdef DEBUG_ENABLED
|
||||
if (ce.error != Callable::CallError::CALL_OK) {
|
||||
err_text = vformat(R"(There was an error calling "_iter_get" on iterator object of type %s.)", *container);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue