Slimmed down DOM code by creating a few utility functions for conversion, etc. Fixed bug 1656 - bug in generator with an enum value of 0.
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
/* AUTO-GENERATED. DO NOT EDIT!!! */
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "nsJSUtils.h"
|
||||
#include "nscore.h"
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsIJSScriptObject.h"
|
||||
@@ -98,22 +99,7 @@ GetHTMLTableRowElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp
|
||||
nsIDOMHTMLCollection* prop;
|
||||
if (NS_OK == a->GetCells(&prop)) {
|
||||
// get the js object
|
||||
if (prop != nsnull) {
|
||||
nsIScriptObjectOwner *owner = nsnull;
|
||||
if (NS_OK == prop->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) {
|
||||
JSObject *object = nsnull;
|
||||
nsIScriptContext *script_cx = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
if (NS_OK == owner->GetScriptObject(script_cx, (void**)&object)) {
|
||||
// set the return value
|
||||
*vp = OBJECT_TO_JSVAL(object);
|
||||
}
|
||||
NS_RELEASE(owner);
|
||||
}
|
||||
NS_RELEASE(prop);
|
||||
}
|
||||
else {
|
||||
*vp = JSVAL_NULL;
|
||||
}
|
||||
nsConvertObjectToJSVal((nsISupports *)prop, cx, vp);
|
||||
}
|
||||
else {
|
||||
return JS_FALSE;
|
||||
@@ -124,9 +110,7 @@ GetHTMLTableRowElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp
|
||||
{
|
||||
nsAutoString prop;
|
||||
if (NS_OK == a->GetAlign(prop)) {
|
||||
JSString *jsstring = JS_NewUCStringCopyN(cx, prop, prop.Length());
|
||||
// set the return value
|
||||
*vp = STRING_TO_JSVAL(jsstring);
|
||||
nsConvertStringToJSVal(prop, cx, vp);
|
||||
}
|
||||
else {
|
||||
return JS_FALSE;
|
||||
@@ -137,9 +121,7 @@ GetHTMLTableRowElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp
|
||||
{
|
||||
nsAutoString prop;
|
||||
if (NS_OK == a->GetBgColor(prop)) {
|
||||
JSString *jsstring = JS_NewUCStringCopyN(cx, prop, prop.Length());
|
||||
// set the return value
|
||||
*vp = STRING_TO_JSVAL(jsstring);
|
||||
nsConvertStringToJSVal(prop, cx, vp);
|
||||
}
|
||||
else {
|
||||
return JS_FALSE;
|
||||
@@ -150,9 +132,7 @@ GetHTMLTableRowElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp
|
||||
{
|
||||
nsAutoString prop;
|
||||
if (NS_OK == a->GetCh(prop)) {
|
||||
JSString *jsstring = JS_NewUCStringCopyN(cx, prop, prop.Length());
|
||||
// set the return value
|
||||
*vp = STRING_TO_JSVAL(jsstring);
|
||||
nsConvertStringToJSVal(prop, cx, vp);
|
||||
}
|
||||
else {
|
||||
return JS_FALSE;
|
||||
@@ -163,9 +143,7 @@ GetHTMLTableRowElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp
|
||||
{
|
||||
nsAutoString prop;
|
||||
if (NS_OK == a->GetChOff(prop)) {
|
||||
JSString *jsstring = JS_NewUCStringCopyN(cx, prop, prop.Length());
|
||||
// set the return value
|
||||
*vp = STRING_TO_JSVAL(jsstring);
|
||||
nsConvertStringToJSVal(prop, cx, vp);
|
||||
}
|
||||
else {
|
||||
return JS_FALSE;
|
||||
@@ -176,9 +154,7 @@ GetHTMLTableRowElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp
|
||||
{
|
||||
nsAutoString prop;
|
||||
if (NS_OK == a->GetVAlign(prop)) {
|
||||
JSString *jsstring = JS_NewUCStringCopyN(cx, prop, prop.Length());
|
||||
// set the return value
|
||||
*vp = STRING_TO_JSVAL(jsstring);
|
||||
nsConvertStringToJSVal(prop, cx, vp);
|
||||
}
|
||||
else {
|
||||
return JS_FALSE;
|
||||
@@ -186,25 +162,11 @@ GetHTMLTableRowElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
nsIJSScriptObject *object;
|
||||
if (NS_OK == a->QueryInterface(kIJSScriptObjectIID, (void**)&object)) {
|
||||
PRBool rval;
|
||||
rval = object->GetProperty(cx, id, vp);
|
||||
NS_RELEASE(object);
|
||||
return rval;
|
||||
}
|
||||
}
|
||||
return nsCallJSScriptObjectGetProperty(a, cx, id, vp);
|
||||
}
|
||||
}
|
||||
else {
|
||||
nsIJSScriptObject *object;
|
||||
if (NS_OK == a->QueryInterface(kIJSScriptObjectIID, (void**)&object)) {
|
||||
PRBool rval;
|
||||
rval = object->GetProperty(cx, id, vp);
|
||||
NS_RELEASE(object);
|
||||
return rval;
|
||||
}
|
||||
return nsCallJSScriptObjectGetProperty(a, cx, id, vp);
|
||||
}
|
||||
|
||||
return PR_TRUE;
|
||||
@@ -261,36 +223,20 @@ SetHTMLTableRowElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp
|
||||
case HTMLTABLEROWELEMENT_CELLS:
|
||||
{
|
||||
nsIDOMHTMLCollection* prop;
|
||||
if (JSVAL_IS_NULL(*vp)) {
|
||||
prop = nsnull;
|
||||
}
|
||||
else if (JSVAL_IS_OBJECT(*vp)) {
|
||||
JSObject *jsobj = JSVAL_TO_OBJECT(*vp);
|
||||
nsISupports *supports = (nsISupports *)JS_GetPrivate(cx, jsobj);
|
||||
if (NS_OK != supports->QueryInterface(kIHTMLCollectionIID, (void **)&prop)) {
|
||||
JS_ReportError(cx, "Parameter must be of type HTMLCollection");
|
||||
return JS_FALSE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Parameter must be an object");
|
||||
if (PR_FALSE == nsConvertJSValToObject((nsISupports **)&prop,
|
||||
kIHTMLCollectionIID, "HTMLCollection",
|
||||
cx, *vp)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
a->SetCells(prop);
|
||||
if (prop) NS_RELEASE(prop);
|
||||
NS_IF_RELEASE(prop);
|
||||
break;
|
||||
}
|
||||
case HTMLTABLEROWELEMENT_ALIGN:
|
||||
{
|
||||
nsAutoString prop;
|
||||
JSString *jsstring;
|
||||
if ((jsstring = JS_ValueToString(cx, *vp)) != nsnull) {
|
||||
prop.SetString(JS_GetStringChars(jsstring));
|
||||
}
|
||||
else {
|
||||
prop.SetString((const char *)nsnull);
|
||||
}
|
||||
nsConvertJSValToString(prop, cx, *vp);
|
||||
|
||||
a->SetAlign(prop);
|
||||
|
||||
@@ -299,13 +245,7 @@ SetHTMLTableRowElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp
|
||||
case HTMLTABLEROWELEMENT_BGCOLOR:
|
||||
{
|
||||
nsAutoString prop;
|
||||
JSString *jsstring;
|
||||
if ((jsstring = JS_ValueToString(cx, *vp)) != nsnull) {
|
||||
prop.SetString(JS_GetStringChars(jsstring));
|
||||
}
|
||||
else {
|
||||
prop.SetString((const char *)nsnull);
|
||||
}
|
||||
nsConvertJSValToString(prop, cx, *vp);
|
||||
|
||||
a->SetBgColor(prop);
|
||||
|
||||
@@ -314,13 +254,7 @@ SetHTMLTableRowElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp
|
||||
case HTMLTABLEROWELEMENT_CH:
|
||||
{
|
||||
nsAutoString prop;
|
||||
JSString *jsstring;
|
||||
if ((jsstring = JS_ValueToString(cx, *vp)) != nsnull) {
|
||||
prop.SetString(JS_GetStringChars(jsstring));
|
||||
}
|
||||
else {
|
||||
prop.SetString((const char *)nsnull);
|
||||
}
|
||||
nsConvertJSValToString(prop, cx, *vp);
|
||||
|
||||
a->SetCh(prop);
|
||||
|
||||
@@ -329,13 +263,7 @@ SetHTMLTableRowElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp
|
||||
case HTMLTABLEROWELEMENT_CHOFF:
|
||||
{
|
||||
nsAutoString prop;
|
||||
JSString *jsstring;
|
||||
if ((jsstring = JS_ValueToString(cx, *vp)) != nsnull) {
|
||||
prop.SetString(JS_GetStringChars(jsstring));
|
||||
}
|
||||
else {
|
||||
prop.SetString((const char *)nsnull);
|
||||
}
|
||||
nsConvertJSValToString(prop, cx, *vp);
|
||||
|
||||
a->SetChOff(prop);
|
||||
|
||||
@@ -344,38 +272,18 @@ SetHTMLTableRowElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp
|
||||
case HTMLTABLEROWELEMENT_VALIGN:
|
||||
{
|
||||
nsAutoString prop;
|
||||
JSString *jsstring;
|
||||
if ((jsstring = JS_ValueToString(cx, *vp)) != nsnull) {
|
||||
prop.SetString(JS_GetStringChars(jsstring));
|
||||
}
|
||||
else {
|
||||
prop.SetString((const char *)nsnull);
|
||||
}
|
||||
nsConvertJSValToString(prop, cx, *vp);
|
||||
|
||||
a->SetVAlign(prop);
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
nsIJSScriptObject *object;
|
||||
if (NS_OK == a->QueryInterface(kIJSScriptObjectIID, (void**)&object)) {
|
||||
PRBool rval;
|
||||
rval = object->SetProperty(cx, id, vp);
|
||||
NS_RELEASE(object);
|
||||
return rval;
|
||||
}
|
||||
}
|
||||
return nsCallJSScriptObjectSetProperty(a, cx, id, vp);
|
||||
}
|
||||
}
|
||||
else {
|
||||
nsIJSScriptObject *object;
|
||||
if (NS_OK == a->QueryInterface(kIJSScriptObjectIID, (void**)&object)) {
|
||||
PRBool rval;
|
||||
rval = object->SetProperty(cx, id, vp);
|
||||
NS_RELEASE(object);
|
||||
return rval;
|
||||
}
|
||||
return nsCallJSScriptObjectSetProperty(a, cx, id, vp);
|
||||
}
|
||||
|
||||
return PR_TRUE;
|
||||
@@ -388,18 +296,7 @@ SetHTMLTableRowElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp
|
||||
PR_STATIC_CALLBACK(void)
|
||||
FinalizeHTMLTableRowElement(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
nsIDOMHTMLTableRowElement *a = (nsIDOMHTMLTableRowElement*)JS_GetPrivate(cx, obj);
|
||||
|
||||
if (nsnull != a) {
|
||||
// get the js object
|
||||
nsIScriptObjectOwner *owner = nsnull;
|
||||
if (NS_OK == a->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) {
|
||||
owner->SetScriptObject(nsnull);
|
||||
NS_RELEASE(owner);
|
||||
}
|
||||
|
||||
NS_RELEASE(a);
|
||||
}
|
||||
nsGenericFinalize(cx, obj);
|
||||
}
|
||||
|
||||
|
||||
@@ -409,17 +306,7 @@ FinalizeHTMLTableRowElement(JSContext *cx, JSObject *obj)
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
EnumerateHTMLTableRowElement(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
nsIDOMHTMLTableRowElement *a = (nsIDOMHTMLTableRowElement*)JS_GetPrivate(cx, obj);
|
||||
|
||||
if (nsnull != a) {
|
||||
// get the js object
|
||||
nsIJSScriptObject *object;
|
||||
if (NS_OK == a->QueryInterface(kIJSScriptObjectIID, (void**)&object)) {
|
||||
object->EnumerateProperty(cx);
|
||||
NS_RELEASE(object);
|
||||
}
|
||||
}
|
||||
return JS_TRUE;
|
||||
return nsGenericEnumerate(cx, obj);
|
||||
}
|
||||
|
||||
|
||||
@@ -429,17 +316,7 @@ EnumerateHTMLTableRowElement(JSContext *cx, JSObject *obj)
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
ResolveHTMLTableRowElement(JSContext *cx, JSObject *obj, jsval id)
|
||||
{
|
||||
nsIDOMHTMLTableRowElement *a = (nsIDOMHTMLTableRowElement*)JS_GetPrivate(cx, obj);
|
||||
|
||||
if (nsnull != a) {
|
||||
// get the js object
|
||||
nsIJSScriptObject *object;
|
||||
if (NS_OK == a->QueryInterface(kIJSScriptObjectIID, (void**)&object)) {
|
||||
object->Resolve(cx, id);
|
||||
NS_RELEASE(object);
|
||||
}
|
||||
}
|
||||
return JS_TRUE;
|
||||
return nsGenericResolve(cx, obj, id);
|
||||
}
|
||||
|
||||
|
||||
@@ -472,22 +349,7 @@ HTMLTableRowElementInsertCell(JSContext *cx, JSObject *obj, uintN argc, jsval *a
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (nativeRet != nsnull) {
|
||||
nsIScriptObjectOwner *owner = nsnull;
|
||||
if (NS_OK == nativeRet->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) {
|
||||
JSObject *object = nsnull;
|
||||
nsIScriptContext *script_cx = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
if (NS_OK == owner->GetScriptObject(script_cx, (void**)&object)) {
|
||||
// set the return value
|
||||
*rval = OBJECT_TO_JSVAL(object);
|
||||
}
|
||||
NS_RELEASE(owner);
|
||||
}
|
||||
NS_RELEASE(nativeRet);
|
||||
}
|
||||
else {
|
||||
*rval = JSVAL_NULL;
|
||||
}
|
||||
nsConvertObjectToJSVal(nativeRet, cx, rval);
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function insertCell requires 1 parameters");
|
||||
|
||||
Reference in New Issue
Block a user