jsval vp; if (PR_TRUE == JS_GetProperty(aContext, global, node.name, &vp)) { if (JSVAL_IS_OBJECT(vp)) { jsval value = INT_TO_JSVAL(1); JS_SetProperty(aContext, JSVAL_TO_OBJECT(vp), "DOCUMENT", &value); value = INT_TO_JSVAL(2); JS_SetProperty(aContext, JSVAL_TO_OBJECT(vp), "ELEMENT", &value); value = INT_TO_JSVAL(3); JS_SetProperty(aContext, JSVAL_TO_OBJECT(vp), "ATTRIBUTE", &value); value = INT_TO_JSVAL(4); JS_SetProperty(aContext, JSVAL_TO_OBJECT(vp), "PI", &value); value = INT_TO_JSVAL(5); JS_SetProperty(aContext, JSVAL_TO_OBJECT(vp), "COMMENT", &value); value = INT_TO_JSVAL(6); JS_SetProperty(aContext, JSVAL_TO_OBJECT(vp), "TEXT", &value); } }
nsresult NS_InitNodeClass(JSContext *aContext, JSObject **aPrototype){  // look in the global object for this class prototype  jsval vp;  static JSObject *proto = nsnull;  if (nsnull == proto) {    proto = JS_InitClass(aContext, // context                          JS_GetGlobalObject(aContext), // global object                          NULL, // parent proto                           &node, // JSClass                          Node, // JSNative ctor                          0, // ctor args                          NULL, // proto props                          nodeMethods, // proto funcs                          NULL, // ctor props (static)                          NULL); // ctor funcs (static)    if (nsnull == proto) {      return NS_ERROR_FAILURE;    }  }  if (nsnull != aPrototype) {    *aPrototype = proto;  }  return NS_OK;}