vp = INT_TO_JSVAL(nsIDOMSelectionListener::KEYPRESS_REASON); JS_SetProperty(jscontext, constructor, "KEYPRESS_REASON", &vp);
extern "C" NS_DOM nsresult NS_InitSelectionListenerClass(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, "SelectionListener", &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)) {    proto = JS_InitClass(jscontext,     // context                         global,        // global object                         parent_proto,  // parent proto                          &SelectionListenerClass,      // JSClass                         SelectionListener,            // JSNative ctor                         0,             // ctor args                         SelectionListenerProperties,  // proto props                         SelectionListenerMethods,     // proto funcs                         nsnull,        // ctor props (static)                         nsnull);       // ctor funcs (static)    if (nsnull == proto) {      return NS_ERROR_FAILURE;    }    if ((PR_TRUE == JS_LookupProperty(jscontext, global, "SelectionListener", &vp)) &&        JSVAL_IS_OBJECT(vp) &&        ((constructor = JSVAL_TO_OBJECT(vp)) != nsnull)) {      vp = INT_TO_JSVAL(nsIDOMSelectionListener::NO_REASON);      JS_SetProperty(jscontext, constructor, "NO_REASON", &vp);      vp = INT_TO_JSVAL(nsIDOMSelectionListener::DRAG_REASON);      JS_SetProperty(jscontext, constructor, "DRAG_REASON", &vp);      vp = INT_TO_JSVAL(nsIDOMSelectionListener::MOUSEDOWN_REASON);      JS_SetProperty(jscontext, constructor, "MOUSEDOWN_REASON", &vp);      vp = INT_TO_JSVAL(nsIDOMSelectionListener::MOUSEUP_REASON);      JS_SetProperty(jscontext, constructor, "MOUSEUP_REASON", &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;}