Subj : JS_AddNamedRoot To : netscape.public.mozilla.jseng From : "aadamov" Date : Sun Jan 04 2004 10:22 pm Followinf up on the previous message. I did create a generic wrapper for DOM embedded in SpiderMonkey, but... Couple of buts: 1) I would still like to know if there is well thought through "standart" implementation for that; 2) I am stuck trying to use JS_AddNamedRoot in order to instantiate root of the DOM object in JS context. In fact I run into problem using JS_AddNamedRoot even for standart types. For instance: std::string name = "red"; JSString *jstr = JS_NewStringCopyN(cx, name.c_str(), name.length()); JS_AddNamedRoot( cx, (void*)jstr, "myRoot" ); std::string script = "myRoot;"; jsval rval; uintN lineno = 0; JSBool ok = JS_EvaluateScript(cx, globalObj, script.c_str(), script.length(), "script", lineno, &rval); Evaluating above script I get JS_FALSE return value. I guess it only makes sense, since I am passing a void pointer to jstr in my call to JS_AddNamedRoot. How in life would runtime know what type of an object I just passed to it. That is unles there is some kind of reflection mechanism build into it. Better off going to sleep now. .