All objects can now be transformed into strings which allows them to be used as
hash indexes. Some rules do still apply. If an object is lost (freed....)
another object may take on the name of the lost one. The object address is used
to create a string in the form "#(0x123abc45)". NULL has the string "#NULL".
So arr[NULL] is the same as arr["#NULL"], and similar for the objects.
char *script_obj_as_string (script_obj_t *obj) /* reply is strdupped and may be NULL */
{
+ char *reply;
script_obj_t *string_obj = script_obj_as_obj_type (obj, SCRIPT_OBJ_TYPE_STRING);
if (string_obj) return strdup (string_obj->data.string);
string_obj = script_obj_as_obj_type (obj, SCRIPT_OBJ_TYPE_NUMBER);
if (string_obj)
{
- char *reply;
asprintf (&reply, "%g", string_obj->data.number);
return reply;
}
- return NULL;
+ if (script_obj_is_null (obj))
+ return strdup("#NULL");
+ asprintf (&reply, "#(0x%x)", (int) obj);
+ return reply;
}
static void *script_obj_direct_as_native_of_class (script_obj_t *obj,