Merge pull request #11161 from Noshyaar/pr-lenstr

Implement String len()
This commit is contained in:
Poommetee Ketson 2017-09-12 04:26:33 +07:00 committed by GitHub
commit 5b3527ec82
1 changed files with 11 additions and 3 deletions

View File

@ -1177,20 +1177,28 @@ void GDFunctions::call(Function p_func, const Variant **p_args, int p_arg_count,
VALIDATE_ARG_COUNT(1); VALIDATE_ARG_COUNT(1);
switch (p_args[0]->get_type()) { switch (p_args[0]->get_type()) {
case Variant::STRING: {
String d = *p_args[0];
r_ret = d.length();
} break;
case Variant::DICTIONARY: { case Variant::DICTIONARY: {
Dictionary d = *p_args[0]; Dictionary d = *p_args[0];
r_ret = d.size(); r_ret = d.size();
} break; } break;
case Variant::ARRAY: { case Variant::ARRAY: {
Array d = *p_args[0]; Array d = *p_args[0];
r_ret = d.size(); r_ret = d.size();
} break; } break;
case Variant::POOL_BYTE_ARRAY: { case Variant::POOL_BYTE_ARRAY: {
PoolVector<uint8_t> d = *p_args[0]; PoolVector<uint8_t> d = *p_args[0];
r_ret = d.size(); r_ret = d.size();
} break; } break;
case Variant::POOL_INT_ARRAY: { case Variant::POOL_INT_ARRAY: {
PoolVector<int> d = *p_args[0]; PoolVector<int> d = *p_args[0];
r_ret = d.size(); r_ret = d.size();
} break; } break;
@ -1200,14 +1208,14 @@ void GDFunctions::call(Function p_func, const Variant **p_args, int p_arg_count,
r_ret = d.size(); r_ret = d.size();
} break; } break;
case Variant::POOL_STRING_ARRAY: { case Variant::POOL_STRING_ARRAY: {
PoolVector<String> d = *p_args[0]; PoolVector<String> d = *p_args[0];
r_ret = d.size(); r_ret = d.size();
} break; } break;
case Variant::POOL_VECTOR2_ARRAY: { case Variant::POOL_VECTOR2_ARRAY: {
PoolVector<Vector2> d = *p_args[0]; PoolVector<Vector2> d = *p_args[0];
r_ret = d.size(); r_ret = d.size();
} break; } break;
case Variant::POOL_VECTOR3_ARRAY: { case Variant::POOL_VECTOR3_ARRAY: {