]> git.ipfire.org Git - thirdparty/plymouth.git/commitdiff
[script] Strings automatically adopt from the global String template
authorCharlie Brej <cbrej@cs.man.ac.uk>
Wed, 24 Mar 2010 15:55:59 +0000 (15:55 +0000)
committerCharlie Brej <cbrej@cs.man.ac.uk>
Wed, 24 Mar 2010 15:59:02 +0000 (15:59 +0000)
This means string operations now can be applied on raw strings rather than
having to cast them using the String() class template wrapper.

String("something").CharAt(3)
now becomes simply:
"something".CharAt(3)

src/plugins/splash/script/script-execute.c

index f986957e5245ff4cecb2de41a384f9802b344405..19a831d0cbc597e840419d29bda54ca02d5b278c 100644 (file)
@@ -302,7 +302,18 @@ static script_obj_t *script_evaluate_func (script_state_t *state,
       this_obj = script_evaluate (state, name_exp->data.dual.sub_a);
       char *this_key_name = script_obj_as_string (this_key);
       script_obj_unref (this_key);
-      func_obj = script_obj_hash_get_element (this_obj, this_key_name);
+      func_obj = script_obj_hash_peek_element (this_obj, this_key_name);
+
+      if (!func_obj && script_obj_is_string (this_obj))
+        {
+          script_obj_t *string_hash = script_obj_hash_peek_element (state->global, "String");
+          func_obj = script_obj_hash_peek_element (string_hash, this_key_name);
+          script_obj_unref (func_obj);
+        }
+
+      if (!func_obj)
+        func_obj = script_obj_hash_get_element (this_obj, this_key_name);
+
       free(this_key_name);
     }
   else if (name_exp->type == SCRIPT_EXP_TYPE_TERM_VAR)