shithub: libmujs

Download patch

ref: ce0a690a04a172b183020b650ac5e6742885a095
parent: 3da05690f11c1476cf7981c0709aed828c80e44d
author: Tor Andersson <[email protected]>
date: Sun Jan 19 09:25:00 EST 2014

Create readonly length property on string objects.

--- a/jsobject.c
+++ b/jsobject.c
@@ -54,6 +54,15 @@
 {
 	js_Object *obj = jsR_newobject(J, JS_CSTRING, J->String_prototype);
 	obj->u.string = v;
+	{
+		js_Property *ref;
+		ref = jsR_setproperty(J, obj, "length");
+		ref->value.type = JS_TNUMBER;
+		ref->value.u.number = strlen(v);
+		ref->readonly = 1;
+		ref->dontenum = 1;
+		ref->dontconf = 1;
+	}
 	return obj;
 }