vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_META); JS_SetProperty(jscontext, constructor, "DOM_VK_META", &vp);
extern "C" NS_DOM nsresult NS_InitKeyEventClass(nsIScriptContext *aContext, void **aPrototype){  JSContext *jscontext = (JSContext *)aContext->GetNativeContext();  JSObject *proto = nsnull;  JSObject *constructor = nsnull;  JSObject *parent_proto = nsnull;  JSObject *global = JS_GetGlobalObject(jscontext);  jsval vp;  if ((PR_TRUE != JS_LookupProperty(jscontext, global, "KeyEvent", &vp)) ||      !JSVAL_IS_OBJECT(vp) ||      ((constructor = JSVAL_TO_OBJECT(vp)) == nsnull) ||      (PR_TRUE != JS_LookupProperty(jscontext, JSVAL_TO_OBJECT(vp), "prototype", &vp)) ||       !JSVAL_IS_OBJECT(vp)) {    if (NS_OK != NS_InitUIEventClass(aContext, (void **)&parent_proto)) {      return NS_ERROR_FAILURE;    }    proto = JS_InitClass(jscontext,     // context                         global,        // global object                         parent_proto,  // parent proto                          &KeyEventClass,      // JSClass                         KeyEvent,            // JSNative ctor                         0,             // ctor args                         KeyEventProperties,  // proto props                         KeyEventMethods,     // proto funcs                         nsnull,        // ctor props (static)                         nsnull);       // ctor funcs (static)    if (nsnull == proto) {      return NS_ERROR_FAILURE;    }    if ((PR_TRUE == JS_LookupProperty(jscontext, global, "KeyEvent", &vp)) &&        JSVAL_IS_OBJECT(vp) &&        ((constructor = JSVAL_TO_OBJECT(vp)) != nsnull)) {      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_CANCEL);      JS_SetProperty(jscontext, constructor, "DOM_VK_CANCEL", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_BACK_SPACE);      JS_SetProperty(jscontext, constructor, "DOM_VK_BACK_SPACE", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_TAB);      JS_SetProperty(jscontext, constructor, "DOM_VK_TAB", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_CLEAR);      JS_SetProperty(jscontext, constructor, "DOM_VK_CLEAR", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_RETURN);      JS_SetProperty(jscontext, constructor, "DOM_VK_RETURN", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_ENTER);      JS_SetProperty(jscontext, constructor, "DOM_VK_ENTER", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_SHIFT);      JS_SetProperty(jscontext, constructor, "DOM_VK_SHIFT", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_CONTROL);      JS_SetProperty(jscontext, constructor, "DOM_VK_CONTROL", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_ALT);      JS_SetProperty(jscontext, constructor, "DOM_VK_ALT", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_PAUSE);      JS_SetProperty(jscontext, constructor, "DOM_VK_PAUSE", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_CAPS_LOCK);      JS_SetProperty(jscontext, constructor, "DOM_VK_CAPS_LOCK", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_ESCAPE);      JS_SetProperty(jscontext, constructor, "DOM_VK_ESCAPE", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_SPACE);      JS_SetProperty(jscontext, constructor, "DOM_VK_SPACE", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_PAGE_UP);      JS_SetProperty(jscontext, constructor, "DOM_VK_PAGE_UP", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_PAGE_DOWN);      JS_SetProperty(jscontext, constructor, "DOM_VK_PAGE_DOWN", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_END);      JS_SetProperty(jscontext, constructor, "DOM_VK_END", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_HOME);      JS_SetProperty(jscontext, constructor, "DOM_VK_HOME", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_LEFT);      JS_SetProperty(jscontext, constructor, "DOM_VK_LEFT", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_UP);      JS_SetProperty(jscontext, constructor, "DOM_VK_UP", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_RIGHT);      JS_SetProperty(jscontext, constructor, "DOM_VK_RIGHT", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_DOWN);      JS_SetProperty(jscontext, constructor, "DOM_VK_DOWN", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_PRINTSCREEN);      JS_SetProperty(jscontext, constructor, "DOM_VK_PRINTSCREEN", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_INSERT);      JS_SetProperty(jscontext, constructor, "DOM_VK_INSERT", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_DELETE);      JS_SetProperty(jscontext, constructor, "DOM_VK_DELETE", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_0);      JS_SetProperty(jscontext, constructor, "DOM_VK_0", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_1);      JS_SetProperty(jscontext, constructor, "DOM_VK_1", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_2);      JS_SetProperty(jscontext, constructor, "DOM_VK_2", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_3);      JS_SetProperty(jscontext, constructor, "DOM_VK_3", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_4);      JS_SetProperty(jscontext, constructor, "DOM_VK_4", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_5);      JS_SetProperty(jscontext, constructor, "DOM_VK_5", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_6);      JS_SetProperty(jscontext, constructor, "DOM_VK_6", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_7);      JS_SetProperty(jscontext, constructor, "DOM_VK_7", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_8);      JS_SetProperty(jscontext, constructor, "DOM_VK_8", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_9);      JS_SetProperty(jscontext, constructor, "DOM_VK_9", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_SEMICOLON);      JS_SetProperty(jscontext, constructor, "DOM_VK_SEMICOLON", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_EQUALS);      JS_SetProperty(jscontext, constructor, "DOM_VK_EQUALS", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_A);      JS_SetProperty(jscontext, constructor, "DOM_VK_A", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_B);      JS_SetProperty(jscontext, constructor, "DOM_VK_B", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_C);      JS_SetProperty(jscontext, constructor, "DOM_VK_C", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_D);      JS_SetProperty(jscontext, constructor, "DOM_VK_D", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_E);      JS_SetProperty(jscontext, constructor, "DOM_VK_E", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_F);      JS_SetProperty(jscontext, constructor, "DOM_VK_F", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_G);      JS_SetProperty(jscontext, constructor, "DOM_VK_G", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_H);      JS_SetProperty(jscontext, constructor, "DOM_VK_H", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_I);      JS_SetProperty(jscontext, constructor, "DOM_VK_I", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_J);      JS_SetProperty(jscontext, constructor, "DOM_VK_J", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_K);      JS_SetProperty(jscontext, constructor, "DOM_VK_K", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_L);      JS_SetProperty(jscontext, constructor, "DOM_VK_L", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_M);      JS_SetProperty(jscontext, constructor, "DOM_VK_M", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_N);      JS_SetProperty(jscontext, constructor, "DOM_VK_N", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_O);      JS_SetProperty(jscontext, constructor, "DOM_VK_O", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_P);      JS_SetProperty(jscontext, constructor, "DOM_VK_P", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_Q);      JS_SetProperty(jscontext, constructor, "DOM_VK_Q", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_R);      JS_SetProperty(jscontext, constructor, "DOM_VK_R", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_S);      JS_SetProperty(jscontext, constructor, "DOM_VK_S", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_T);      JS_SetProperty(jscontext, constructor, "DOM_VK_T", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_U);      JS_SetProperty(jscontext, constructor, "DOM_VK_U", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_V);      JS_SetProperty(jscontext, constructor, "DOM_VK_V", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_W);      JS_SetProperty(jscontext, constructor, "DOM_VK_W", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_X);      JS_SetProperty(jscontext, constructor, "DOM_VK_X", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_Y);      JS_SetProperty(jscontext, constructor, "DOM_VK_Y", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_Z);      JS_SetProperty(jscontext, constructor, "DOM_VK_Z", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_NUMPAD0);      JS_SetProperty(jscontext, constructor, "DOM_VK_NUMPAD0", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_NUMPAD1);      JS_SetProperty(jscontext, constructor, "DOM_VK_NUMPAD1", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_NUMPAD2);      JS_SetProperty(jscontext, constructor, "DOM_VK_NUMPAD2", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_NUMPAD3);      JS_SetProperty(jscontext, constructor, "DOM_VK_NUMPAD3", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_NUMPAD4);      JS_SetProperty(jscontext, constructor, "DOM_VK_NUMPAD4", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_NUMPAD5);      JS_SetProperty(jscontext, constructor, "DOM_VK_NUMPAD5", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_NUMPAD6);      JS_SetProperty(jscontext, constructor, "DOM_VK_NUMPAD6", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_NUMPAD7);      JS_SetProperty(jscontext, constructor, "DOM_VK_NUMPAD7", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_NUMPAD8);      JS_SetProperty(jscontext, constructor, "DOM_VK_NUMPAD8", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_NUMPAD9);      JS_SetProperty(jscontext, constructor, "DOM_VK_NUMPAD9", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_MULTIPLY);      JS_SetProperty(jscontext, constructor, "DOM_VK_MULTIPLY", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_ADD);      JS_SetProperty(jscontext, constructor, "DOM_VK_ADD", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_SEPARATOR);      JS_SetProperty(jscontext, constructor, "DOM_VK_SEPARATOR", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_SUBTRACT);      JS_SetProperty(jscontext, constructor, "DOM_VK_SUBTRACT", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_DECIMAL);      JS_SetProperty(jscontext, constructor, "DOM_VK_DECIMAL", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_DIVIDE);      JS_SetProperty(jscontext, constructor, "DOM_VK_DIVIDE", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_F1);      JS_SetProperty(jscontext, constructor, "DOM_VK_F1", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_F2);      JS_SetProperty(jscontext, constructor, "DOM_VK_F2", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_F3);      JS_SetProperty(jscontext, constructor, "DOM_VK_F3", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_F4);      JS_SetProperty(jscontext, constructor, "DOM_VK_F4", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_F5);      JS_SetProperty(jscontext, constructor, "DOM_VK_F5", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_F6);      JS_SetProperty(jscontext, constructor, "DOM_VK_F6", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_F7);      JS_SetProperty(jscontext, constructor, "DOM_VK_F7", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_F8);      JS_SetProperty(jscontext, constructor, "DOM_VK_F8", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_F9);      JS_SetProperty(jscontext, constructor, "DOM_VK_F9", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_F10);      JS_SetProperty(jscontext, constructor, "DOM_VK_F10", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_F11);      JS_SetProperty(jscontext, constructor, "DOM_VK_F11", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_F12);      JS_SetProperty(jscontext, constructor, "DOM_VK_F12", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_F13);      JS_SetProperty(jscontext, constructor, "DOM_VK_F13", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_F14);      JS_SetProperty(jscontext, constructor, "DOM_VK_F14", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_F15);      JS_SetProperty(jscontext, constructor, "DOM_VK_F15", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_F16);      JS_SetProperty(jscontext, constructor, "DOM_VK_F16", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_F17);      JS_SetProperty(jscontext, constructor, "DOM_VK_F17", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_F18);      JS_SetProperty(jscontext, constructor, "DOM_VK_F18", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_F19);      JS_SetProperty(jscontext, constructor, "DOM_VK_F19", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_F20);      JS_SetProperty(jscontext, constructor, "DOM_VK_F20", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_F21);      JS_SetProperty(jscontext, constructor, "DOM_VK_F21", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_F22);      JS_SetProperty(jscontext, constructor, "DOM_VK_F22", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_F23);      JS_SetProperty(jscontext, constructor, "DOM_VK_F23", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_F24);      JS_SetProperty(jscontext, constructor, "DOM_VK_F24", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_NUM_LOCK);      JS_SetProperty(jscontext, constructor, "DOM_VK_NUM_LOCK", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_SCROLL_LOCK);      JS_SetProperty(jscontext, constructor, "DOM_VK_SCROLL_LOCK", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_COMMA);      JS_SetProperty(jscontext, constructor, "DOM_VK_COMMA", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_PERIOD);      JS_SetProperty(jscontext, constructor, "DOM_VK_PERIOD", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_SLASH);      JS_SetProperty(jscontext, constructor, "DOM_VK_SLASH", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_BACK_QUOTE);      JS_SetProperty(jscontext, constructor, "DOM_VK_BACK_QUOTE", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_OPEN_BRACKET);      JS_SetProperty(jscontext, constructor, "DOM_VK_OPEN_BRACKET", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_BACK_SLASH);      JS_SetProperty(jscontext, constructor, "DOM_VK_BACK_SLASH", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_CLOSE_BRACKET);      JS_SetProperty(jscontext, constructor, "DOM_VK_CLOSE_BRACKET", &vp);      vp = INT_TO_JSVAL(nsIDOMKeyEvent::DOM_VK_QUOTE);      JS_SetProperty(jscontext, constructor, "DOM_VK_QUOTE", &vp);    }  }  else if ((nsnull != constructor) && JSVAL_IS_OBJECT(vp)) {    proto = JSVAL_TO_OBJECT(vp);  }  else {    return NS_ERROR_FAILURE;  }  if (aPrototype) {    *aPrototype = proto;  }  return NS_OK;}