This commit is contained in:
kipp 1998-07-15 18:55:53 +00:00
Родитель fa75ba5dda
Коммит 7f10feb16a
16 изменённых файлов: 0 добавлений и 7435 удалений

Просмотреть файл

@ -1,44 +0,0 @@
#!gmake
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
DEPTH=../../..
LIBRARY_NAME = domcore_s
CPPSRCS = \
nsJSNode.cpp \
nsJSData.cpp \
nsJSDocument.cpp \
nsJSDocumentFragment.cpp\
nsJSElement.cpp \
nsJSNamedNodeMap.cpp \
nsJSNodeList.cpp \
nsJSText.cpp \
nsJSAttribute.cpp \
$(NULL)
LIBRARY_NAME = jsdom
DEFINES = -D_IMPL_NS_DOM
MODULE = raptor
REQUIRES = xpcom raptor dom js netlib
MKSHLIB :=
include $(DEPTH)/config/rules.mk

Просмотреть файл

@ -1,58 +0,0 @@
#!nmake
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
DEPTH=..\..\..
IGNORE_MANIFEST=1
LIBRARY_NAME=domcore_s
MODULE=raptor
REQUIRES=xpcom raptor js netlib
DEFINES=-D_IMPL_NS_DOM -DWIN32_LEAN_AND_MEAN
CPPSRCS = \
nsJSNode.cpp \
nsJSData.cpp \
nsJSDocument.cpp \
nsJSDocumentFragment.cpp\
nsJSElement.cpp \
nsJSNamedNodeMap.cpp \
nsJSNodeList.cpp \
nsJSText.cpp \
nsJSAttribute.cpp \
$(NULL)
CPP_OBJS= .\$(OBJDIR)\nsJSNode.obj .\$(OBJDIR)\nsJSDocument.obj \
.\$(OBJDIR)\nsJSElement.obj .\$(OBJDIR)\nsJSText.obj \
.\$(OBJDIR)\nsJSNodeList.obj .\$(OBJDIR)\nsJSAttribute.obj \
.\$(OBJDIR)\nsJSNamedNodeMap.obj .\$(OBJDIR)\nsJSDocumentFragment.obj \
.\$(OBJDIR)\nsJSData.obj
LINCS=-I$(XPDIST)\public\xpcom -I$(XPDIST)\public\raptor -I$(XPDIST)\public\dom -I$(XPDIST)\public\js -I$(PUBLIC)\netlib
LCFLAGS = \
$(LCFLAGS) \
$(DEFINES) \
$(NULL)
include <$(DEPTH)\config\rules.mak>
libs:: $(LIBRARY)
$(MAKE_INSTALL) $(LIBRARY) $(DIST)\lib
clobber::
rm -f $(DIST)\lib\$(LIBRARY_NAME).lib

Просмотреть файл

@ -1,384 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/* AUTO-GENERATED. DO NOT EDIT!!! */
#include "jsapi.h"
#include "nscore.h"
#include "nsIScriptContext.h"
#include "nsIJSScriptObject.h"
#include "nsIScriptObjectOwner.h"
#include "nsIScriptGlobalObject.h"
#include "nsIPtr.h"
#include "nsString.h"
#include "nsIDOMAttribute.h"
static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID);
static NS_DEFINE_IID(kIJSScriptObjectIID, NS_IJSSCRIPTOBJECT_IID);
static NS_DEFINE_IID(kIScriptGlobalObjectIID, NS_ISCRIPTGLOBALOBJECT_IID);
static NS_DEFINE_IID(kIAttributeIID, NS_IDOMATTRIBUTE_IID);
NS_DEF_PTR(nsIDOMAttribute);
//
// Attribute property ids
//
enum Attribute_slots {
ATTRIBUTE_NAME = -11,
ATTRIBUTE_SPECIFIED = -12,
ATTRIBUTE_VALUE = -13
};
/***********************************************************************/
//
// Attribute Properties Getter
//
PR_STATIC_CALLBACK(JSBool)
GetAttributeProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
{
nsIDOMAttribute *a = (nsIDOMAttribute*)JS_GetPrivate(cx, obj);
// If there's no private data, this must be the prototype, so ignore
if (nsnull == a) {
return JS_TRUE;
}
if (JSVAL_IS_INT(id)) {
switch(JSVAL_TO_INT(id)) {
case ATTRIBUTE_NAME:
{
nsAutoString prop;
if (NS_OK == a->GetName(prop)) {
JSString *jsstring = JS_NewUCStringCopyN(cx, prop, prop.Length());
// set the return value
*vp = STRING_TO_JSVAL(jsstring);
}
else {
return JS_FALSE;
}
break;
}
case ATTRIBUTE_SPECIFIED:
{
PRBool prop;
if (NS_OK == a->GetSpecified(&prop)) {
*vp = BOOLEAN_TO_JSVAL(prop);
}
else {
return JS_FALSE;
}
break;
}
case ATTRIBUTE_VALUE:
{
nsAutoString prop;
if (NS_OK == a->GetValue(prop)) {
JSString *jsstring = JS_NewUCStringCopyN(cx, prop, prop.Length());
// set the return value
*vp = STRING_TO_JSVAL(jsstring);
}
else {
return JS_FALSE;
}
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;
}
}
}
}
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 PR_TRUE;
}
/***********************************************************************/
//
// Attribute Properties Setter
//
PR_STATIC_CALLBACK(JSBool)
SetAttributeProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
{
nsIDOMAttribute *a = (nsIDOMAttribute*)JS_GetPrivate(cx, obj);
// If there's no private data, this must be the prototype, so ignore
if (nsnull == a) {
return JS_TRUE;
}
if (JSVAL_IS_INT(id)) {
switch(JSVAL_TO_INT(id)) {
case ATTRIBUTE_SPECIFIED:
{
PRBool prop;
JSBool temp;
if (JSVAL_IS_BOOLEAN(*vp) && JS_ValueToBoolean(cx, *vp, &temp)) {
prop = (PRBool)temp;
}
else {
JS_ReportError(cx, "Parameter must be a boolean");
return JS_FALSE;
}
a->SetSpecified(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;
}
}
}
}
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 PR_TRUE;
}
//
// Attribute finalizer
//
PR_STATIC_CALLBACK(void)
FinalizeAttribute(JSContext *cx, JSObject *obj)
{
nsIDOMAttribute *a = (nsIDOMAttribute*)JS_GetPrivate(cx, obj);
if (nsnull != a) {
// get the js object
nsIScriptObjectOwner *owner = nsnull;
if (NS_OK == a->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) {
owner->ResetScriptObject();
NS_RELEASE(owner);
}
NS_RELEASE(a);
}
}
//
// Attribute enumerate
//
PR_STATIC_CALLBACK(JSBool)
EnumerateAttribute(JSContext *cx, JSObject *obj)
{
nsIDOMAttribute *a = (nsIDOMAttribute*)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;
}
//
// Attribute resolve
//
PR_STATIC_CALLBACK(JSBool)
ResolveAttribute(JSContext *cx, JSObject *obj, jsval id)
{
nsIDOMAttribute *a = (nsIDOMAttribute*)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;
}
/***********************************************************************/
//
// class for Attribute
//
JSClass AttributeClass = {
"Attribute",
JSCLASS_HAS_PRIVATE,
JS_PropertyStub,
JS_PropertyStub,
GetAttributeProperty,
SetAttributeProperty,
EnumerateAttribute,
ResolveAttribute,
JS_ConvertStub,
FinalizeAttribute
};
//
// Attribute class properties
//
static JSPropertySpec AttributeProperties[] =
{
{"name", ATTRIBUTE_NAME, JSPROP_ENUMERATE | JSPROP_READONLY},
{"specified", ATTRIBUTE_SPECIFIED, JSPROP_ENUMERATE},
{"value", ATTRIBUTE_VALUE, JSPROP_ENUMERATE | JSPROP_READONLY},
{0}
};
//
// Attribute class methods
//
static JSFunctionSpec AttributeMethods[] =
{
{0}
};
//
// Attribute constructor
//
PR_STATIC_CALLBACK(JSBool)
Attribute(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
return JS_TRUE;
}
//
// Attribute class initialization
//
nsresult NS_InitAttributeClass(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, "Attribute", &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_InitNodeClass(aContext, (void **)&parent_proto)) {
return NS_ERROR_FAILURE;
}
proto = JS_InitClass(jscontext, // context
global, // global object
parent_proto, // parent proto
&AttributeClass, // JSClass
Attribute, // JSNative ctor
0, // ctor args
AttributeProperties, // proto props
AttributeMethods, // proto funcs
nsnull, // ctor props (static)
nsnull); // ctor funcs (static)
if (nsnull == proto) {
return NS_ERROR_FAILURE;
}
}
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;
}
//
// Method for creating a new Attribute JavaScript object
//
extern "C" NS_DOM nsresult NS_NewScriptAttribute(nsIScriptContext *aContext, nsIDOMAttribute *aSupports, nsISupports *aParent, void **aReturn)
{
NS_PRECONDITION(nsnull != aContext && nsnull != aSupports && nsnull != aReturn, "null argument to NS_NewScriptAttribute");
JSObject *proto;
JSObject *parent;
nsIScriptObjectOwner *owner;
JSContext *jscontext = (JSContext *)aContext->GetNativeContext();
if (nsnull == aParent) {
parent = nsnull;
}
else if (NS_OK == aParent->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) {
if (NS_OK != owner->GetScriptObject(aContext, (void **)&parent)) {
NS_RELEASE(owner);
return NS_ERROR_FAILURE;
}
NS_RELEASE(owner);
}
else {
return NS_ERROR_FAILURE;
}
if (NS_OK != NS_InitAttributeClass(aContext, (void **)&proto)) {
return NS_ERROR_FAILURE;
}
// create a js object for this class
*aReturn = JS_NewObject(jscontext, &AttributeClass, proto, parent);
if (nsnull != *aReturn) {
// connect the native object to the js object
JS_SetPrivate(jscontext, (JSObject *)*aReturn, aSupports);
NS_ADDREF(aSupports);
}
else {
return NS_ERROR_FAILURE;
}
return NS_OK;
}

Просмотреть файл

@ -1,322 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/* AUTO-GENERATED. DO NOT EDIT!!! */
#include "jsapi.h"
#include "nscore.h"
#include "nsIScriptContext.h"
#include "nsIJSScriptObject.h"
#include "nsIScriptObjectOwner.h"
#include "nsIScriptGlobalObject.h"
#include "nsIPtr.h"
#include "nsString.h"
#include "nsIDOMCDATASection.h"
static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID);
static NS_DEFINE_IID(kIJSScriptObjectIID, NS_IJSSCRIPTOBJECT_IID);
static NS_DEFINE_IID(kIScriptGlobalObjectIID, NS_ISCRIPTGLOBALOBJECT_IID);
static NS_DEFINE_IID(kICDATASectionIID, NS_IDOMCDATASECTION_IID);
NS_DEF_PTR(nsIDOMCDATASection);
/***********************************************************************/
//
// CDATASection Properties Getter
//
PR_STATIC_CALLBACK(JSBool)
GetCDATASectionProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
{
nsIDOMCDATASection *a = (nsIDOMCDATASection*)JS_GetPrivate(cx, obj);
// If there's no private data, this must be the prototype, so ignore
if (nsnull == a) {
return JS_TRUE;
}
if (JSVAL_IS_INT(id)) {
switch(JSVAL_TO_INT(id)) {
case 0:
default:
{
nsIJSScriptObject *object;
if (NS_OK == a->QueryInterface(kIJSScriptObjectIID, (void**)&object)) {
PRBool rval;
rval = object->GetProperty(cx, id, vp);
NS_RELEASE(object);
return rval;
}
}
}
}
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 PR_TRUE;
}
/***********************************************************************/
//
// CDATASection Properties Setter
//
PR_STATIC_CALLBACK(JSBool)
SetCDATASectionProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
{
nsIDOMCDATASection *a = (nsIDOMCDATASection*)JS_GetPrivate(cx, obj);
// If there's no private data, this must be the prototype, so ignore
if (nsnull == a) {
return JS_TRUE;
}
if (JSVAL_IS_INT(id)) {
switch(JSVAL_TO_INT(id)) {
case 0:
default:
{
nsIJSScriptObject *object;
if (NS_OK == a->QueryInterface(kIJSScriptObjectIID, (void**)&object)) {
PRBool rval;
rval = object->SetProperty(cx, id, vp);
NS_RELEASE(object);
return rval;
}
}
}
}
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 PR_TRUE;
}
//
// CDATASection finalizer
//
PR_STATIC_CALLBACK(void)
FinalizeCDATASection(JSContext *cx, JSObject *obj)
{
nsIDOMCDATASection *a = (nsIDOMCDATASection*)JS_GetPrivate(cx, obj);
if (nsnull != a) {
// get the js object
nsIScriptObjectOwner *owner = nsnull;
if (NS_OK == a->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) {
owner->ResetScriptObject();
NS_RELEASE(owner);
}
NS_RELEASE(a);
}
}
//
// CDATASection enumerate
//
PR_STATIC_CALLBACK(JSBool)
EnumerateCDATASection(JSContext *cx, JSObject *obj)
{
nsIDOMCDATASection *a = (nsIDOMCDATASection*)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;
}
//
// CDATASection resolve
//
PR_STATIC_CALLBACK(JSBool)
ResolveCDATASection(JSContext *cx, JSObject *obj, jsval id)
{
nsIDOMCDATASection *a = (nsIDOMCDATASection*)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;
}
/***********************************************************************/
//
// class for CDATASection
//
JSClass CDATASectionClass = {
"CDATASection",
JSCLASS_HAS_PRIVATE,
JS_PropertyStub,
JS_PropertyStub,
GetCDATASectionProperty,
SetCDATASectionProperty,
EnumerateCDATASection,
ResolveCDATASection,
JS_ConvertStub,
FinalizeCDATASection
};
//
// CDATASection class properties
//
static JSPropertySpec CDATASectionProperties[] =
{
{0}
};
//
// CDATASection class methods
//
static JSFunctionSpec CDATASectionMethods[] =
{
{0}
};
//
// CDATASection constructor
//
PR_STATIC_CALLBACK(JSBool)
CDATASection(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
return JS_TRUE;
}
//
// CDATASection class initialization
//
nsresult NS_InitCDATASectionClass(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, "CDATASection", &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_InitTextClass(aContext, (void **)&parent_proto)) {
return NS_ERROR_FAILURE;
}
proto = JS_InitClass(jscontext, // context
global, // global object
parent_proto, // parent proto
&CDATASectionClass, // JSClass
CDATASection, // JSNative ctor
0, // ctor args
CDATASectionProperties, // proto props
CDATASectionMethods, // proto funcs
nsnull, // ctor props (static)
nsnull); // ctor funcs (static)
if (nsnull == proto) {
return NS_ERROR_FAILURE;
}
}
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;
}
//
// Method for creating a new CDATASection JavaScript object
//
extern "C" NS_DOM nsresult NS_NewScriptCDATASection(nsIScriptContext *aContext, nsIDOMCDATASection *aSupports, nsISupports *aParent, void **aReturn)
{
NS_PRECONDITION(nsnull != aContext && nsnull != aSupports && nsnull != aReturn, "null argument to NS_NewScriptCDATASection");
JSObject *proto;
JSObject *parent;
nsIScriptObjectOwner *owner;
JSContext *jscontext = (JSContext *)aContext->GetNativeContext();
if (nsnull == aParent) {
parent = nsnull;
}
else if (NS_OK == aParent->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) {
if (NS_OK != owner->GetScriptObject(aContext, (void **)&parent)) {
NS_RELEASE(owner);
return NS_ERROR_FAILURE;
}
NS_RELEASE(owner);
}
else {
return NS_ERROR_FAILURE;
}
if (NS_OK != NS_InitCDATASectionClass(aContext, (void **)&proto)) {
return NS_ERROR_FAILURE;
}
// create a js object for this class
*aReturn = JS_NewObject(jscontext, &CDATASectionClass, proto, parent);
if (nsnull != *aReturn) {
// connect the native object to the js object
JS_SetPrivate(jscontext, (JSObject *)*aReturn, aSupports);
NS_ADDREF(aSupports);
}
else {
return NS_ERROR_FAILURE;
}
return NS_OK;
}

Просмотреть файл

@ -1,322 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/* AUTO-GENERATED. DO NOT EDIT!!! */
#include "jsapi.h"
#include "nscore.h"
#include "nsIScriptContext.h"
#include "nsIJSScriptObject.h"
#include "nsIScriptObjectOwner.h"
#include "nsIScriptGlobalObject.h"
#include "nsIPtr.h"
#include "nsString.h"
#include "nsIDOMComment.h"
static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID);
static NS_DEFINE_IID(kIJSScriptObjectIID, NS_IJSSCRIPTOBJECT_IID);
static NS_DEFINE_IID(kIScriptGlobalObjectIID, NS_ISCRIPTGLOBALOBJECT_IID);
static NS_DEFINE_IID(kICommentIID, NS_IDOMCOMMENT_IID);
NS_DEF_PTR(nsIDOMComment);
/***********************************************************************/
//
// Comment Properties Getter
//
PR_STATIC_CALLBACK(JSBool)
GetCommentProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
{
nsIDOMComment *a = (nsIDOMComment*)JS_GetPrivate(cx, obj);
// If there's no private data, this must be the prototype, so ignore
if (nsnull == a) {
return JS_TRUE;
}
if (JSVAL_IS_INT(id)) {
switch(JSVAL_TO_INT(id)) {
case 0:
default:
{
nsIJSScriptObject *object;
if (NS_OK == a->QueryInterface(kIJSScriptObjectIID, (void**)&object)) {
PRBool rval;
rval = object->GetProperty(cx, id, vp);
NS_RELEASE(object);
return rval;
}
}
}
}
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 PR_TRUE;
}
/***********************************************************************/
//
// Comment Properties Setter
//
PR_STATIC_CALLBACK(JSBool)
SetCommentProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
{
nsIDOMComment *a = (nsIDOMComment*)JS_GetPrivate(cx, obj);
// If there's no private data, this must be the prototype, so ignore
if (nsnull == a) {
return JS_TRUE;
}
if (JSVAL_IS_INT(id)) {
switch(JSVAL_TO_INT(id)) {
case 0:
default:
{
nsIJSScriptObject *object;
if (NS_OK == a->QueryInterface(kIJSScriptObjectIID, (void**)&object)) {
PRBool rval;
rval = object->SetProperty(cx, id, vp);
NS_RELEASE(object);
return rval;
}
}
}
}
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 PR_TRUE;
}
//
// Comment finalizer
//
PR_STATIC_CALLBACK(void)
FinalizeComment(JSContext *cx, JSObject *obj)
{
nsIDOMComment *a = (nsIDOMComment*)JS_GetPrivate(cx, obj);
if (nsnull != a) {
// get the js object
nsIScriptObjectOwner *owner = nsnull;
if (NS_OK == a->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) {
owner->ResetScriptObject();
NS_RELEASE(owner);
}
NS_RELEASE(a);
}
}
//
// Comment enumerate
//
PR_STATIC_CALLBACK(JSBool)
EnumerateComment(JSContext *cx, JSObject *obj)
{
nsIDOMComment *a = (nsIDOMComment*)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;
}
//
// Comment resolve
//
PR_STATIC_CALLBACK(JSBool)
ResolveComment(JSContext *cx, JSObject *obj, jsval id)
{
nsIDOMComment *a = (nsIDOMComment*)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;
}
/***********************************************************************/
//
// class for Comment
//
JSClass CommentClass = {
"Comment",
JSCLASS_HAS_PRIVATE,
JS_PropertyStub,
JS_PropertyStub,
GetCommentProperty,
SetCommentProperty,
EnumerateComment,
ResolveComment,
JS_ConvertStub,
FinalizeComment
};
//
// Comment class properties
//
static JSPropertySpec CommentProperties[] =
{
{0}
};
//
// Comment class methods
//
static JSFunctionSpec CommentMethods[] =
{
{0}
};
//
// Comment constructor
//
PR_STATIC_CALLBACK(JSBool)
Comment(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
return JS_TRUE;
}
//
// Comment class initialization
//
nsresult NS_InitCommentClass(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, "Comment", &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_InitDataClass(aContext, (void **)&parent_proto)) {
return NS_ERROR_FAILURE;
}
proto = JS_InitClass(jscontext, // context
global, // global object
parent_proto, // parent proto
&CommentClass, // JSClass
Comment, // JSNative ctor
0, // ctor args
CommentProperties, // proto props
CommentMethods, // proto funcs
nsnull, // ctor props (static)
nsnull); // ctor funcs (static)
if (nsnull == proto) {
return NS_ERROR_FAILURE;
}
}
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;
}
//
// Method for creating a new Comment JavaScript object
//
extern "C" NS_DOM nsresult NS_NewScriptComment(nsIScriptContext *aContext, nsIDOMComment *aSupports, nsISupports *aParent, void **aReturn)
{
NS_PRECONDITION(nsnull != aContext && nsnull != aSupports && nsnull != aReturn, "null argument to NS_NewScriptComment");
JSObject *proto;
JSObject *parent;
nsIScriptObjectOwner *owner;
JSContext *jscontext = (JSContext *)aContext->GetNativeContext();
if (nsnull == aParent) {
parent = nsnull;
}
else if (NS_OK == aParent->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) {
if (NS_OK != owner->GetScriptObject(aContext, (void **)&parent)) {
NS_RELEASE(owner);
return NS_ERROR_FAILURE;
}
NS_RELEASE(owner);
}
else {
return NS_ERROR_FAILURE;
}
if (NS_OK != NS_InitCommentClass(aContext, (void **)&proto)) {
return NS_ERROR_FAILURE;
}
// create a js object for this class
*aReturn = JS_NewObject(jscontext, &CommentClass, proto, parent);
if (nsnull != *aReturn) {
// connect the native object to the js object
JS_SetPrivate(jscontext, (JSObject *)*aReturn, aSupports);
NS_ADDREF(aSupports);
}
else {
return NS_ERROR_FAILURE;
}
return NS_OK;
}

Просмотреть файл

@ -1,425 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/* AUTO-GENERATED. DO NOT EDIT!!! */
#include "jsapi.h"
#include "nscore.h"
#include "nsIScriptContext.h"
#include "nsIJSScriptObject.h"
#include "nsIScriptObjectOwner.h"
#include "nsIScriptGlobalObject.h"
#include "nsIPtr.h"
#include "nsString.h"
#include "nsIDOMDocument.h"
#include "nsIDOMDOM.h"
static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID);
static NS_DEFINE_IID(kIJSScriptObjectIID, NS_IJSSCRIPTOBJECT_IID);
static NS_DEFINE_IID(kIScriptGlobalObjectIID, NS_ISCRIPTGLOBALOBJECT_IID);
static NS_DEFINE_IID(kIDocumentIID, NS_IDOMDOCUMENT_IID);
static NS_DEFINE_IID(kIDOMIID, NS_IDOMDOM_IID);
NS_DEF_PTR(nsIDOMDocument);
NS_DEF_PTR(nsIDOMDOM);
/***********************************************************************/
//
// DOM Properties Getter
//
PR_STATIC_CALLBACK(JSBool)
GetDOMProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
{
nsIDOMDOM *a = (nsIDOMDOM*)JS_GetPrivate(cx, obj);
// If there's no private data, this must be the prototype, so ignore
if (nsnull == a) {
return JS_TRUE;
}
if (JSVAL_IS_INT(id)) {
switch(JSVAL_TO_INT(id)) {
case 0:
default:
{
nsIJSScriptObject *object;
if (NS_OK == a->QueryInterface(kIJSScriptObjectIID, (void**)&object)) {
PRBool rval;
rval = object->GetProperty(cx, id, vp);
NS_RELEASE(object);
return rval;
}
}
}
}
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 PR_TRUE;
}
/***********************************************************************/
//
// DOM Properties Setter
//
PR_STATIC_CALLBACK(JSBool)
SetDOMProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
{
nsIDOMDOM *a = (nsIDOMDOM*)JS_GetPrivate(cx, obj);
// If there's no private data, this must be the prototype, so ignore
if (nsnull == a) {
return JS_TRUE;
}
if (JSVAL_IS_INT(id)) {
switch(JSVAL_TO_INT(id)) {
case 0:
default:
{
nsIJSScriptObject *object;
if (NS_OK == a->QueryInterface(kIJSScriptObjectIID, (void**)&object)) {
PRBool rval;
rval = object->SetProperty(cx, id, vp);
NS_RELEASE(object);
return rval;
}
}
}
}
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 PR_TRUE;
}
//
// DOM finalizer
//
PR_STATIC_CALLBACK(void)
FinalizeDOM(JSContext *cx, JSObject *obj)
{
nsIDOMDOM *a = (nsIDOMDOM*)JS_GetPrivate(cx, obj);
if (nsnull != a) {
// get the js object
nsIScriptObjectOwner *owner = nsnull;
if (NS_OK == a->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) {
owner->ResetScriptObject();
NS_RELEASE(owner);
}
NS_RELEASE(a);
}
}
//
// DOM enumerate
//
PR_STATIC_CALLBACK(JSBool)
EnumerateDOM(JSContext *cx, JSObject *obj)
{
nsIDOMDOM *a = (nsIDOMDOM*)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;
}
//
// DOM resolve
//
PR_STATIC_CALLBACK(JSBool)
ResolveDOM(JSContext *cx, JSObject *obj, jsval id)
{
nsIDOMDOM *a = (nsIDOMDOM*)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;
}
//
// Native method CreateDocument
//
PR_STATIC_CALLBACK(JSBool)
DOMCreateDocument(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMDOM *nativeThis = (nsIDOMDOM*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
nsIDOMDocument* nativeRet;
nsAutoString b0;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if (nsnull == nativeThis) {
return JS_TRUE;
}
if (argc >= 1) {
JSString *jsstring0 = JS_ValueToString(cx, argv[0]);
if (nsnull != jsstring0) {
b0.SetString(JS_GetStringChars(jsstring0));
}
else {
b0.SetString(""); // Should this really be null??
}
if (NS_OK != nativeThis->CreateDocument(b0, &nativeRet)) {
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;
}
}
else {
JS_ReportError(cx, "Function createDocument requires 1 parameters");
return JS_FALSE;
}
return JS_TRUE;
}
//
// Native method HasFeature
//
PR_STATIC_CALLBACK(JSBool)
DOMHasFeature(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMDOM *nativeThis = (nsIDOMDOM*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
PRBool nativeRet;
nsAutoString b0;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if (nsnull == nativeThis) {
return JS_TRUE;
}
if (argc >= 1) {
JSString *jsstring0 = JS_ValueToString(cx, argv[0]);
if (nsnull != jsstring0) {
b0.SetString(JS_GetStringChars(jsstring0));
}
else {
b0.SetString(""); // Should this really be null??
}
if (NS_OK != nativeThis->HasFeature(b0, &nativeRet)) {
return JS_FALSE;
}
*rval = BOOLEAN_TO_JSVAL(nativeRet);
}
else {
JS_ReportError(cx, "Function hasFeature requires 1 parameters");
return JS_FALSE;
}
return JS_TRUE;
}
/***********************************************************************/
//
// class for DOM
//
JSClass DOMClass = {
"DOM",
JSCLASS_HAS_PRIVATE,
JS_PropertyStub,
JS_PropertyStub,
GetDOMProperty,
SetDOMProperty,
EnumerateDOM,
ResolveDOM,
JS_ConvertStub,
FinalizeDOM
};
//
// DOM class properties
//
static JSPropertySpec DOMProperties[] =
{
{0}
};
//
// DOM class methods
//
static JSFunctionSpec DOMMethods[] =
{
{"createDocument", DOMCreateDocument, 1},
{"hasFeature", DOMHasFeature, 1},
{0}
};
//
// DOM constructor
//
PR_STATIC_CALLBACK(JSBool)
DOM(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
return JS_TRUE;
}
//
// DOM class initialization
//
nsresult NS_InitDOMClass(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, "DOM", &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
&DOMClass, // JSClass
DOM, // JSNative ctor
0, // ctor args
DOMProperties, // proto props
DOMMethods, // proto funcs
nsnull, // ctor props (static)
nsnull); // ctor funcs (static)
if (nsnull == proto) {
return NS_ERROR_FAILURE;
}
}
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;
}
//
// Method for creating a new DOM JavaScript object
//
extern "C" NS_DOM nsresult NS_NewScriptDOM(nsIScriptContext *aContext, nsIDOMDOM *aSupports, nsISupports *aParent, void **aReturn)
{
NS_PRECONDITION(nsnull != aContext && nsnull != aSupports && nsnull != aReturn, "null argument to NS_NewScriptDOM");
JSObject *proto;
JSObject *parent;
nsIScriptObjectOwner *owner;
JSContext *jscontext = (JSContext *)aContext->GetNativeContext();
if (nsnull == aParent) {
parent = nsnull;
}
else if (NS_OK == aParent->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) {
if (NS_OK != owner->GetScriptObject(aContext, (void **)&parent)) {
NS_RELEASE(owner);
return NS_ERROR_FAILURE;
}
NS_RELEASE(owner);
}
else {
return NS_ERROR_FAILURE;
}
if (NS_OK != NS_InitDOMClass(aContext, (void **)&proto)) {
return NS_ERROR_FAILURE;
}
// create a js object for this class
*aReturn = JS_NewObject(jscontext, &DOMClass, proto, parent);
if (nsnull != *aReturn) {
// connect the native object to the js object
JS_SetPrivate(jscontext, (JSObject *)*aReturn, aSupports);
NS_ADDREF(aSupports);
}
else {
return NS_ERROR_FAILURE;
}
return NS_OK;
}

Просмотреть файл

@ -1,610 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/* AUTO-GENERATED. DO NOT EDIT!!! */
#include "jsapi.h"
#include "nscore.h"
#include "nsIScriptContext.h"
#include "nsIJSScriptObject.h"
#include "nsIScriptObjectOwner.h"
#include "nsIScriptGlobalObject.h"
#include "nsIPtr.h"
#include "nsString.h"
#include "nsIDOMData.h"
static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID);
static NS_DEFINE_IID(kIJSScriptObjectIID, NS_IJSSCRIPTOBJECT_IID);
static NS_DEFINE_IID(kIScriptGlobalObjectIID, NS_ISCRIPTGLOBALOBJECT_IID);
static NS_DEFINE_IID(kIDataIID, NS_IDOMDATA_IID);
NS_DEF_PTR(nsIDOMData);
//
// Data property ids
//
enum Data_slots {
DATA_DATA = -11,
DATA_SIZE = -12
};
/***********************************************************************/
//
// Data Properties Getter
//
PR_STATIC_CALLBACK(JSBool)
GetDataProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
{
nsIDOMData *a = (nsIDOMData*)JS_GetPrivate(cx, obj);
// If there's no private data, this must be the prototype, so ignore
if (nsnull == a) {
return JS_TRUE;
}
if (JSVAL_IS_INT(id)) {
switch(JSVAL_TO_INT(id)) {
case DATA_DATA:
{
nsAutoString prop;
if (NS_OK == a->GetData(prop)) {
JSString *jsstring = JS_NewUCStringCopyN(cx, prop, prop.Length());
// set the return value
*vp = STRING_TO_JSVAL(jsstring);
}
else {
return JS_FALSE;
}
break;
}
case DATA_SIZE:
{
PRUint32 prop;
if (NS_OK == a->GetSize(&prop)) {
*vp = INT_TO_JSVAL(prop);
}
else {
return JS_FALSE;
}
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;
}
}
}
}
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 PR_TRUE;
}
/***********************************************************************/
//
// Data Properties Setter
//
PR_STATIC_CALLBACK(JSBool)
SetDataProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
{
nsIDOMData *a = (nsIDOMData*)JS_GetPrivate(cx, obj);
// If there's no private data, this must be the prototype, so ignore
if (nsnull == a) {
return JS_TRUE;
}
if (JSVAL_IS_INT(id)) {
switch(JSVAL_TO_INT(id)) {
case DATA_DATA:
{
nsAutoString prop;
JSString *jsstring;
if ((jsstring = JS_ValueToString(cx, *vp)) != nsnull) {
prop.SetString(JS_GetStringChars(jsstring));
}
else {
prop.SetString((const char *)nsnull);
}
a->SetData(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;
}
}
}
}
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 PR_TRUE;
}
//
// Data finalizer
//
PR_STATIC_CALLBACK(void)
FinalizeData(JSContext *cx, JSObject *obj)
{
nsIDOMData *a = (nsIDOMData*)JS_GetPrivate(cx, obj);
if (nsnull != a) {
// get the js object
nsIScriptObjectOwner *owner = nsnull;
if (NS_OK == a->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) {
owner->ResetScriptObject();
NS_RELEASE(owner);
}
NS_RELEASE(a);
}
}
//
// Data enumerate
//
PR_STATIC_CALLBACK(JSBool)
EnumerateData(JSContext *cx, JSObject *obj)
{
nsIDOMData *a = (nsIDOMData*)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;
}
//
// Data resolve
//
PR_STATIC_CALLBACK(JSBool)
ResolveData(JSContext *cx, JSObject *obj, jsval id)
{
nsIDOMData *a = (nsIDOMData*)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;
}
//
// Native method Substring
//
PR_STATIC_CALLBACK(JSBool)
DataSubstring(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMData *nativeThis = (nsIDOMData*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
nsAutoString nativeRet;
PRUint32 b0;
PRUint32 b1;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if (nsnull == nativeThis) {
return JS_TRUE;
}
if (argc >= 2) {
if (!JS_ValueToInt32(cx, argv[0], (int32 *)&b0)) {
JS_ReportError(cx, "Parameter must be a number");
return JS_FALSE;
}
if (!JS_ValueToInt32(cx, argv[1], (int32 *)&b1)) {
JS_ReportError(cx, "Parameter must be a number");
return JS_FALSE;
}
if (NS_OK != nativeThis->Substring(b0, b1, nativeRet)) {
return JS_FALSE;
}
JSString *jsstring = JS_NewUCStringCopyN(cx, nativeRet, nativeRet.Length());
// set the return value
*rval = STRING_TO_JSVAL(jsstring);
}
else {
JS_ReportError(cx, "Function substring requires 2 parameters");
return JS_FALSE;
}
return JS_TRUE;
}
//
// Native method Append
//
PR_STATIC_CALLBACK(JSBool)
DataAppend(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMData *nativeThis = (nsIDOMData*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
nsAutoString b0;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if (nsnull == nativeThis) {
return JS_TRUE;
}
if (argc >= 1) {
JSString *jsstring0 = JS_ValueToString(cx, argv[0]);
if (nsnull != jsstring0) {
b0.SetString(JS_GetStringChars(jsstring0));
}
else {
b0.SetString(""); // Should this really be null??
}
if (NS_OK != nativeThis->Append(b0)) {
return JS_FALSE;
}
*rval = JSVAL_VOID;
}
else {
JS_ReportError(cx, "Function append requires 1 parameters");
return JS_FALSE;
}
return JS_TRUE;
}
//
// Native method Insert
//
PR_STATIC_CALLBACK(JSBool)
DataInsert(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMData *nativeThis = (nsIDOMData*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
PRUint32 b0;
nsAutoString b1;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if (nsnull == nativeThis) {
return JS_TRUE;
}
if (argc >= 2) {
if (!JS_ValueToInt32(cx, argv[0], (int32 *)&b0)) {
JS_ReportError(cx, "Parameter must be a number");
return JS_FALSE;
}
JSString *jsstring1 = JS_ValueToString(cx, argv[1]);
if (nsnull != jsstring1) {
b1.SetString(JS_GetStringChars(jsstring1));
}
else {
b1.SetString(""); // Should this really be null??
}
if (NS_OK != nativeThis->Insert(b0, b1)) {
return JS_FALSE;
}
*rval = JSVAL_VOID;
}
else {
JS_ReportError(cx, "Function insert requires 2 parameters");
return JS_FALSE;
}
return JS_TRUE;
}
//
// Native method Remove
//
PR_STATIC_CALLBACK(JSBool)
DataRemove(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMData *nativeThis = (nsIDOMData*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
PRUint32 b0;
PRUint32 b1;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if (nsnull == nativeThis) {
return JS_TRUE;
}
if (argc >= 2) {
if (!JS_ValueToInt32(cx, argv[0], (int32 *)&b0)) {
JS_ReportError(cx, "Parameter must be a number");
return JS_FALSE;
}
if (!JS_ValueToInt32(cx, argv[1], (int32 *)&b1)) {
JS_ReportError(cx, "Parameter must be a number");
return JS_FALSE;
}
if (NS_OK != nativeThis->Remove(b0, b1)) {
return JS_FALSE;
}
*rval = JSVAL_VOID;
}
else {
JS_ReportError(cx, "Function remove requires 2 parameters");
return JS_FALSE;
}
return JS_TRUE;
}
//
// Native method Replace
//
PR_STATIC_CALLBACK(JSBool)
DataReplace(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMData *nativeThis = (nsIDOMData*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
PRUint32 b0;
PRUint32 b1;
nsAutoString b2;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if (nsnull == nativeThis) {
return JS_TRUE;
}
if (argc >= 3) {
if (!JS_ValueToInt32(cx, argv[0], (int32 *)&b0)) {
JS_ReportError(cx, "Parameter must be a number");
return JS_FALSE;
}
if (!JS_ValueToInt32(cx, argv[1], (int32 *)&b1)) {
JS_ReportError(cx, "Parameter must be a number");
return JS_FALSE;
}
JSString *jsstring2 = JS_ValueToString(cx, argv[2]);
if (nsnull != jsstring2) {
b2.SetString(JS_GetStringChars(jsstring2));
}
else {
b2.SetString(""); // Should this really be null??
}
if (NS_OK != nativeThis->Replace(b0, b1, b2)) {
return JS_FALSE;
}
*rval = JSVAL_VOID;
}
else {
JS_ReportError(cx, "Function replace requires 3 parameters");
return JS_FALSE;
}
return JS_TRUE;
}
/***********************************************************************/
//
// class for Data
//
JSClass DataClass = {
"Data",
JSCLASS_HAS_PRIVATE,
JS_PropertyStub,
JS_PropertyStub,
GetDataProperty,
SetDataProperty,
EnumerateData,
ResolveData,
JS_ConvertStub,
FinalizeData
};
//
// Data class properties
//
static JSPropertySpec DataProperties[] =
{
{"data", DATA_DATA, JSPROP_ENUMERATE},
{"size", DATA_SIZE, JSPROP_ENUMERATE | JSPROP_READONLY},
{0}
};
//
// Data class methods
//
static JSFunctionSpec DataMethods[] =
{
{"substring", DataSubstring, 2},
{"append", DataAppend, 1},
{"insert", DataInsert, 2},
{"remove", DataRemove, 2},
{"replace", DataReplace, 3},
{0}
};
//
// Data constructor
//
PR_STATIC_CALLBACK(JSBool)
Data(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
return JS_TRUE;
}
//
// Data class initialization
//
nsresult NS_InitDataClass(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, "Data", &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_InitNodeClass(aContext, (void **)&parent_proto)) {
return NS_ERROR_FAILURE;
}
proto = JS_InitClass(jscontext, // context
global, // global object
parent_proto, // parent proto
&DataClass, // JSClass
Data, // JSNative ctor
0, // ctor args
DataProperties, // proto props
DataMethods, // proto funcs
nsnull, // ctor props (static)
nsnull); // ctor funcs (static)
if (nsnull == proto) {
return NS_ERROR_FAILURE;
}
}
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;
}
//
// Method for creating a new Data JavaScript object
//
extern "C" NS_DOM nsresult NS_NewScriptData(nsIScriptContext *aContext, nsIDOMData *aSupports, nsISupports *aParent, void **aReturn)
{
NS_PRECONDITION(nsnull != aContext && nsnull != aSupports && nsnull != aReturn, "null argument to NS_NewScriptData");
JSObject *proto;
JSObject *parent;
nsIScriptObjectOwner *owner;
JSContext *jscontext = (JSContext *)aContext->GetNativeContext();
if (nsnull == aParent) {
parent = nsnull;
}
else if (NS_OK == aParent->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) {
if (NS_OK != owner->GetScriptObject(aContext, (void **)&parent)) {
NS_RELEASE(owner);
return NS_ERROR_FAILURE;
}
NS_RELEASE(owner);
}
else {
return NS_ERROR_FAILURE;
}
if (NS_OK != NS_InitDataClass(aContext, (void **)&proto)) {
return NS_ERROR_FAILURE;
}
// create a js object for this class
*aReturn = JS_NewObject(jscontext, &DataClass, proto, parent);
if (nsnull != *aReturn) {
// connect the native object to the js object
JS_SetPrivate(jscontext, (JSObject *)*aReturn, aSupports);
NS_ADDREF(aSupports);
}
else {
return NS_ERROR_FAILURE;
}
return NS_OK;
}

Просмотреть файл

@ -1,923 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/* AUTO-GENERATED. DO NOT EDIT!!! */
#include "jsapi.h"
#include "nscore.h"
#include "nsIScriptContext.h"
#include "nsIJSScriptObject.h"
#include "nsIScriptObjectOwner.h"
#include "nsIScriptGlobalObject.h"
#include "nsIPtr.h"
#include "nsString.h"
#include "nsIDOMElement.h"
#include "nsIDOMDocument.h"
#include "nsIDOMProcessingInstruction.h"
#include "nsIDOMNamedNodeMap.h"
#include "nsIDOMAttribute.h"
#include "nsIDOMNode.h"
#include "nsIDOMText.h"
#include "nsIDOMDocumentType.h"
#include "nsIDOMDocumentFragment.h"
#include "nsIDOMComment.h"
#include "nsIDOMNodeList.h"
static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID);
static NS_DEFINE_IID(kIJSScriptObjectIID, NS_IJSSCRIPTOBJECT_IID);
static NS_DEFINE_IID(kIScriptGlobalObjectIID, NS_ISCRIPTGLOBALOBJECT_IID);
static NS_DEFINE_IID(kIElementIID, NS_IDOMELEMENT_IID);
static NS_DEFINE_IID(kIDocumentIID, NS_IDOMDOCUMENT_IID);
static NS_DEFINE_IID(kIProcessingInstructionIID, NS_IDOMPROCESSINGINSTRUCTION_IID);
static NS_DEFINE_IID(kINamedNodeMapIID, NS_IDOMNAMEDNODEMAP_IID);
static NS_DEFINE_IID(kIAttributeIID, NS_IDOMATTRIBUTE_IID);
static NS_DEFINE_IID(kINodeIID, NS_IDOMNODE_IID);
static NS_DEFINE_IID(kITextIID, NS_IDOMTEXT_IID);
static NS_DEFINE_IID(kIDocumentTypeIID, NS_IDOMDOCUMENTTYPE_IID);
static NS_DEFINE_IID(kIDocumentFragmentIID, NS_IDOMDOCUMENTFRAGMENT_IID);
static NS_DEFINE_IID(kICommentIID, NS_IDOMCOMMENT_IID);
static NS_DEFINE_IID(kINodeListIID, NS_IDOMNODELIST_IID);
NS_DEF_PTR(nsIDOMElement);
NS_DEF_PTR(nsIDOMDocument);
NS_DEF_PTR(nsIDOMProcessingInstruction);
NS_DEF_PTR(nsIDOMNamedNodeMap);
NS_DEF_PTR(nsIDOMAttribute);
NS_DEF_PTR(nsIDOMNode);
NS_DEF_PTR(nsIDOMText);
NS_DEF_PTR(nsIDOMDocumentType);
NS_DEF_PTR(nsIDOMDocumentFragment);
NS_DEF_PTR(nsIDOMComment);
NS_DEF_PTR(nsIDOMNodeList);
//
// Document property ids
//
enum Document_slots {
DOCUMENT_DOCUMENTTYPE = -11,
DOCUMENT_PROLOG = -12,
DOCUMENT_EPILOG = -13,
DOCUMENT_DOCUMENTELEMENT = -14
};
/***********************************************************************/
//
// Document Properties Getter
//
PR_STATIC_CALLBACK(JSBool)
GetDocumentProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
{
nsIDOMDocument *a = (nsIDOMDocument*)JS_GetPrivate(cx, obj);
// If there's no private data, this must be the prototype, so ignore
if (nsnull == a) {
return JS_TRUE;
}
if (JSVAL_IS_INT(id)) {
switch(JSVAL_TO_INT(id)) {
case DOCUMENT_DOCUMENTTYPE:
{
nsIDOMDocumentType* prop;
if (NS_OK == a->GetDocumentType(&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;
}
}
else {
return JS_FALSE;
}
break;
}
case DOCUMENT_PROLOG:
{
nsIDOMNodeList* prop;
if (NS_OK == a->GetProlog(&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;
}
}
else {
return JS_FALSE;
}
break;
}
case DOCUMENT_EPILOG:
{
nsIDOMNodeList* prop;
if (NS_OK == a->GetEpilog(&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;
}
}
else {
return JS_FALSE;
}
break;
}
case DOCUMENT_DOCUMENTELEMENT:
{
nsIDOMElement* prop;
if (NS_OK == a->GetDocumentElement(&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;
}
}
else {
return JS_FALSE;
}
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;
}
}
}
}
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 PR_TRUE;
}
/***********************************************************************/
//
// Document Properties Setter
//
PR_STATIC_CALLBACK(JSBool)
SetDocumentProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
{
nsIDOMDocument *a = (nsIDOMDocument*)JS_GetPrivate(cx, obj);
// If there's no private data, this must be the prototype, so ignore
if (nsnull == a) {
return JS_TRUE;
}
if (JSVAL_IS_INT(id)) {
switch(JSVAL_TO_INT(id)) {
case 0:
default:
{
nsIJSScriptObject *object;
if (NS_OK == a->QueryInterface(kIJSScriptObjectIID, (void**)&object)) {
PRBool rval;
rval = object->SetProperty(cx, id, vp);
NS_RELEASE(object);
return rval;
}
}
}
}
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 PR_TRUE;
}
//
// Document finalizer
//
PR_STATIC_CALLBACK(void)
FinalizeDocument(JSContext *cx, JSObject *obj)
{
nsIDOMDocument *a = (nsIDOMDocument*)JS_GetPrivate(cx, obj);
if (nsnull != a) {
// get the js object
nsIScriptObjectOwner *owner = nsnull;
if (NS_OK == a->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) {
owner->ResetScriptObject();
NS_RELEASE(owner);
}
NS_RELEASE(a);
}
}
//
// Document enumerate
//
PR_STATIC_CALLBACK(JSBool)
EnumerateDocument(JSContext *cx, JSObject *obj)
{
nsIDOMDocument *a = (nsIDOMDocument*)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;
}
//
// Document resolve
//
PR_STATIC_CALLBACK(JSBool)
ResolveDocument(JSContext *cx, JSObject *obj, jsval id)
{
nsIDOMDocument *a = (nsIDOMDocument*)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;
}
//
// Native method CreateElement
//
PR_STATIC_CALLBACK(JSBool)
DocumentCreateElement(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMDocument *nativeThis = (nsIDOMDocument*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
nsIDOMElement* nativeRet;
nsAutoString b0;
nsIDOMNamedNodeMapPtr b1;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if (nsnull == nativeThis) {
return JS_TRUE;
}
if (argc >= 2) {
JSString *jsstring0 = JS_ValueToString(cx, argv[0]);
if (nsnull != jsstring0) {
b0.SetString(JS_GetStringChars(jsstring0));
}
else {
b0.SetString(""); // Should this really be null??
}
if (JSVAL_IS_NULL(argv[1])){
b1 = nsnull;
}
else if (JSVAL_IS_OBJECT(argv[1])) {
nsISupports *supports1 = (nsISupports *)JS_GetPrivate(cx, JSVAL_TO_OBJECT(argv[1]));
NS_ASSERTION(nsnull != supports1, "null pointer");
if ((nsnull == supports1) ||
(NS_OK != supports1->QueryInterface(kINamedNodeMapIID, (void **)(b1.Query())))) {
JS_ReportError(cx, "Parameter must be of type NamedNodeMap");
return JS_FALSE;
}
}
else {
JS_ReportError(cx, "Parameter must be an object");
return JS_FALSE;
}
if (NS_OK != nativeThis->CreateElement(b0, b1, &nativeRet)) {
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;
}
}
else {
JS_ReportError(cx, "Function createElement requires 2 parameters");
return JS_FALSE;
}
return JS_TRUE;
}
//
// Native method CreateDocumentFragment
//
PR_STATIC_CALLBACK(JSBool)
DocumentCreateDocumentFragment(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMDocument *nativeThis = (nsIDOMDocument*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
nsIDOMDocumentFragment* nativeRet;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if (nsnull == nativeThis) {
return JS_TRUE;
}
if (argc >= 0) {
if (NS_OK != nativeThis->CreateDocumentFragment(&nativeRet)) {
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;
}
}
else {
JS_ReportError(cx, "Function createDocumentFragment requires 0 parameters");
return JS_FALSE;
}
return JS_TRUE;
}
//
// Native method CreateTextNode
//
PR_STATIC_CALLBACK(JSBool)
DocumentCreateTextNode(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMDocument *nativeThis = (nsIDOMDocument*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
nsIDOMText* nativeRet;
nsAutoString b0;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if (nsnull == nativeThis) {
return JS_TRUE;
}
if (argc >= 1) {
JSString *jsstring0 = JS_ValueToString(cx, argv[0]);
if (nsnull != jsstring0) {
b0.SetString(JS_GetStringChars(jsstring0));
}
else {
b0.SetString(""); // Should this really be null??
}
if (NS_OK != nativeThis->CreateTextNode(b0, &nativeRet)) {
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;
}
}
else {
JS_ReportError(cx, "Function createTextNode requires 1 parameters");
return JS_FALSE;
}
return JS_TRUE;
}
//
// Native method CreateComment
//
PR_STATIC_CALLBACK(JSBool)
DocumentCreateComment(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMDocument *nativeThis = (nsIDOMDocument*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
nsIDOMComment* nativeRet;
nsAutoString b0;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if (nsnull == nativeThis) {
return JS_TRUE;
}
if (argc >= 1) {
JSString *jsstring0 = JS_ValueToString(cx, argv[0]);
if (nsnull != jsstring0) {
b0.SetString(JS_GetStringChars(jsstring0));
}
else {
b0.SetString(""); // Should this really be null??
}
if (NS_OK != nativeThis->CreateComment(b0, &nativeRet)) {
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;
}
}
else {
JS_ReportError(cx, "Function createComment requires 1 parameters");
return JS_FALSE;
}
return JS_TRUE;
}
//
// Native method CreateProcessingInstruction
//
PR_STATIC_CALLBACK(JSBool)
DocumentCreateProcessingInstruction(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMDocument *nativeThis = (nsIDOMDocument*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
nsIDOMProcessingInstruction* nativeRet;
nsAutoString b0;
nsAutoString b1;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if (nsnull == nativeThis) {
return JS_TRUE;
}
if (argc >= 2) {
JSString *jsstring0 = JS_ValueToString(cx, argv[0]);
if (nsnull != jsstring0) {
b0.SetString(JS_GetStringChars(jsstring0));
}
else {
b0.SetString(""); // Should this really be null??
}
JSString *jsstring1 = JS_ValueToString(cx, argv[1]);
if (nsnull != jsstring1) {
b1.SetString(JS_GetStringChars(jsstring1));
}
else {
b1.SetString(""); // Should this really be null??
}
if (NS_OK != nativeThis->CreateProcessingInstruction(b0, b1, &nativeRet)) {
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;
}
}
else {
JS_ReportError(cx, "Function createProcessingInstruction requires 2 parameters");
return JS_FALSE;
}
return JS_TRUE;
}
//
// Native method CreateAttribute
//
PR_STATIC_CALLBACK(JSBool)
DocumentCreateAttribute(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMDocument *nativeThis = (nsIDOMDocument*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
nsIDOMAttribute* nativeRet;
nsAutoString b0;
nsIDOMNodePtr b1;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if (nsnull == nativeThis) {
return JS_TRUE;
}
if (argc >= 2) {
JSString *jsstring0 = JS_ValueToString(cx, argv[0]);
if (nsnull != jsstring0) {
b0.SetString(JS_GetStringChars(jsstring0));
}
else {
b0.SetString(""); // Should this really be null??
}
if (JSVAL_IS_NULL(argv[1])){
b1 = nsnull;
}
else if (JSVAL_IS_OBJECT(argv[1])) {
nsISupports *supports1 = (nsISupports *)JS_GetPrivate(cx, JSVAL_TO_OBJECT(argv[1]));
NS_ASSERTION(nsnull != supports1, "null pointer");
if ((nsnull == supports1) ||
(NS_OK != supports1->QueryInterface(kINodeIID, (void **)(b1.Query())))) {
JS_ReportError(cx, "Parameter must be of type Node");
return JS_FALSE;
}
}
else {
JS_ReportError(cx, "Parameter must be an object");
return JS_FALSE;
}
if (NS_OK != nativeThis->CreateAttribute(b0, b1, &nativeRet)) {
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;
}
}
else {
JS_ReportError(cx, "Function createAttribute requires 2 parameters");
return JS_FALSE;
}
return JS_TRUE;
}
//
// Native method GetElementsByTagName
//
PR_STATIC_CALLBACK(JSBool)
DocumentGetElementsByTagName(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMDocument *nativeThis = (nsIDOMDocument*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
nsIDOMNodeList* nativeRet;
nsAutoString b0;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if (nsnull == nativeThis) {
return JS_TRUE;
}
if (argc >= 1) {
JSString *jsstring0 = JS_ValueToString(cx, argv[0]);
if (nsnull != jsstring0) {
b0.SetString(JS_GetStringChars(jsstring0));
}
else {
b0.SetString(""); // Should this really be null??
}
if (NS_OK != nativeThis->GetElementsByTagName(b0, &nativeRet)) {
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;
}
}
else {
JS_ReportError(cx, "Function getElementsByTagName requires 1 parameters");
return JS_FALSE;
}
return JS_TRUE;
}
/***********************************************************************/
//
// class for Document
//
JSClass DocumentClass = {
"Document",
JSCLASS_HAS_PRIVATE,
JS_PropertyStub,
JS_PropertyStub,
GetDocumentProperty,
SetDocumentProperty,
EnumerateDocument,
ResolveDocument,
JS_ConvertStub,
FinalizeDocument
};
//
// Document class properties
//
static JSPropertySpec DocumentProperties[] =
{
{"documentType", DOCUMENT_DOCUMENTTYPE, JSPROP_ENUMERATE | JSPROP_READONLY},
{"prolog", DOCUMENT_PROLOG, JSPROP_ENUMERATE | JSPROP_READONLY},
{"epilog", DOCUMENT_EPILOG, JSPROP_ENUMERATE | JSPROP_READONLY},
{"documentElement", DOCUMENT_DOCUMENTELEMENT, JSPROP_ENUMERATE | JSPROP_READONLY},
{0}
};
//
// Document class methods
//
static JSFunctionSpec DocumentMethods[] =
{
{"createElement", DocumentCreateElement, 2},
{"createDocumentFragment", DocumentCreateDocumentFragment, 0},
{"createTextNode", DocumentCreateTextNode, 1},
{"createComment", DocumentCreateComment, 1},
{"createProcessingInstruction", DocumentCreateProcessingInstruction, 2},
{"createAttribute", DocumentCreateAttribute, 2},
{"getElementsByTagName", DocumentGetElementsByTagName, 1},
{0}
};
//
// Document constructor
//
PR_STATIC_CALLBACK(JSBool)
Document(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
return JS_TRUE;
}
//
// Document class initialization
//
nsresult NS_InitDocumentClass(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, "Document", &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_InitDocumentFragmentClass(aContext, (void **)&parent_proto)) {
return NS_ERROR_FAILURE;
}
proto = JS_InitClass(jscontext, // context
global, // global object
parent_proto, // parent proto
&DocumentClass, // JSClass
Document, // JSNative ctor
0, // ctor args
DocumentProperties, // proto props
DocumentMethods, // proto funcs
nsnull, // ctor props (static)
nsnull); // ctor funcs (static)
if (nsnull == proto) {
return NS_ERROR_FAILURE;
}
}
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;
}
//
// Method for creating a new Document JavaScript object
//
extern "C" NS_DOM nsresult NS_NewScriptDocument(nsIScriptContext *aContext, nsIDOMDocument *aSupports, nsISupports *aParent, void **aReturn)
{
NS_PRECONDITION(nsnull != aContext && nsnull != aSupports && nsnull != aReturn, "null argument to NS_NewScriptDocument");
JSObject *proto;
JSObject *parent;
nsIScriptObjectOwner *owner;
JSContext *jscontext = (JSContext *)aContext->GetNativeContext();
if (nsnull == aParent) {
parent = nsnull;
}
else if (NS_OK == aParent->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) {
if (NS_OK != owner->GetScriptObject(aContext, (void **)&parent)) {
NS_RELEASE(owner);
return NS_ERROR_FAILURE;
}
NS_RELEASE(owner);
}
else {
return NS_ERROR_FAILURE;
}
if (NS_OK != NS_InitDocumentClass(aContext, (void **)&proto)) {
return NS_ERROR_FAILURE;
}
// create a js object for this class
*aReturn = JS_NewObject(jscontext, &DocumentClass, proto, parent);
if (nsnull != *aReturn) {
// connect the native object to the js object
JS_SetPrivate(jscontext, (JSObject *)*aReturn, aSupports);
NS_ADDREF(aSupports);
}
else {
return NS_ERROR_FAILURE;
}
return NS_OK;
}

Просмотреть файл

@ -1,358 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/* AUTO-GENERATED. DO NOT EDIT!!! */
#include "jsapi.h"
#include "nscore.h"
#include "nsIScriptContext.h"
#include "nsIJSScriptObject.h"
#include "nsIScriptObjectOwner.h"
#include "nsIScriptGlobalObject.h"
#include "nsIPtr.h"
#include "nsString.h"
#include "nsIDOMDocument.h"
#include "nsIDOMDocumentFragment.h"
static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID);
static NS_DEFINE_IID(kIJSScriptObjectIID, NS_IJSSCRIPTOBJECT_IID);
static NS_DEFINE_IID(kIScriptGlobalObjectIID, NS_ISCRIPTGLOBALOBJECT_IID);
static NS_DEFINE_IID(kIDocumentIID, NS_IDOMDOCUMENT_IID);
static NS_DEFINE_IID(kIDocumentFragmentIID, NS_IDOMDOCUMENTFRAGMENT_IID);
NS_DEF_PTR(nsIDOMDocument);
NS_DEF_PTR(nsIDOMDocumentFragment);
//
// DocumentFragment property ids
//
enum DocumentFragment_slots {
DOCUMENTFRAGMENT_MASTERDOC = -11
};
/***********************************************************************/
//
// DocumentFragment Properties Getter
//
PR_STATIC_CALLBACK(JSBool)
GetDocumentFragmentProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
{
nsIDOMDocumentFragment *a = (nsIDOMDocumentFragment*)JS_GetPrivate(cx, obj);
// If there's no private data, this must be the prototype, so ignore
if (nsnull == a) {
return JS_TRUE;
}
if (JSVAL_IS_INT(id)) {
switch(JSVAL_TO_INT(id)) {
case DOCUMENTFRAGMENT_MASTERDOC:
{
nsIDOMDocument* prop;
if (NS_OK == a->GetMasterDoc(&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;
}
}
else {
return JS_FALSE;
}
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;
}
}
}
}
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 PR_TRUE;
}
/***********************************************************************/
//
// DocumentFragment Properties Setter
//
PR_STATIC_CALLBACK(JSBool)
SetDocumentFragmentProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
{
nsIDOMDocumentFragment *a = (nsIDOMDocumentFragment*)JS_GetPrivate(cx, obj);
// If there's no private data, this must be the prototype, so ignore
if (nsnull == a) {
return JS_TRUE;
}
if (JSVAL_IS_INT(id)) {
switch(JSVAL_TO_INT(id)) {
case 0:
default:
{
nsIJSScriptObject *object;
if (NS_OK == a->QueryInterface(kIJSScriptObjectIID, (void**)&object)) {
PRBool rval;
rval = object->SetProperty(cx, id, vp);
NS_RELEASE(object);
return rval;
}
}
}
}
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 PR_TRUE;
}
//
// DocumentFragment finalizer
//
PR_STATIC_CALLBACK(void)
FinalizeDocumentFragment(JSContext *cx, JSObject *obj)
{
nsIDOMDocumentFragment *a = (nsIDOMDocumentFragment*)JS_GetPrivate(cx, obj);
if (nsnull != a) {
// get the js object
nsIScriptObjectOwner *owner = nsnull;
if (NS_OK == a->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) {
owner->ResetScriptObject();
NS_RELEASE(owner);
}
NS_RELEASE(a);
}
}
//
// DocumentFragment enumerate
//
PR_STATIC_CALLBACK(JSBool)
EnumerateDocumentFragment(JSContext *cx, JSObject *obj)
{
nsIDOMDocumentFragment *a = (nsIDOMDocumentFragment*)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;
}
//
// DocumentFragment resolve
//
PR_STATIC_CALLBACK(JSBool)
ResolveDocumentFragment(JSContext *cx, JSObject *obj, jsval id)
{
nsIDOMDocumentFragment *a = (nsIDOMDocumentFragment*)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;
}
/***********************************************************************/
//
// class for DocumentFragment
//
JSClass DocumentFragmentClass = {
"DocumentFragment",
JSCLASS_HAS_PRIVATE,
JS_PropertyStub,
JS_PropertyStub,
GetDocumentFragmentProperty,
SetDocumentFragmentProperty,
EnumerateDocumentFragment,
ResolveDocumentFragment,
JS_ConvertStub,
FinalizeDocumentFragment
};
//
// DocumentFragment class properties
//
static JSPropertySpec DocumentFragmentProperties[] =
{
{"masterDoc", DOCUMENTFRAGMENT_MASTERDOC, JSPROP_ENUMERATE | JSPROP_READONLY},
{0}
};
//
// DocumentFragment class methods
//
static JSFunctionSpec DocumentFragmentMethods[] =
{
{0}
};
//
// DocumentFragment constructor
//
PR_STATIC_CALLBACK(JSBool)
DocumentFragment(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
return JS_TRUE;
}
//
// DocumentFragment class initialization
//
nsresult NS_InitDocumentFragmentClass(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, "DocumentFragment", &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_InitNodeClass(aContext, (void **)&parent_proto)) {
return NS_ERROR_FAILURE;
}
proto = JS_InitClass(jscontext, // context
global, // global object
parent_proto, // parent proto
&DocumentFragmentClass, // JSClass
DocumentFragment, // JSNative ctor
0, // ctor args
DocumentFragmentProperties, // proto props
DocumentFragmentMethods, // proto funcs
nsnull, // ctor props (static)
nsnull); // ctor funcs (static)
if (nsnull == proto) {
return NS_ERROR_FAILURE;
}
}
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;
}
//
// Method for creating a new DocumentFragment JavaScript object
//
extern "C" NS_DOM nsresult NS_NewScriptDocumentFragment(nsIScriptContext *aContext, nsIDOMDocumentFragment *aSupports, nsISupports *aParent, void **aReturn)
{
NS_PRECONDITION(nsnull != aContext && nsnull != aSupports && nsnull != aReturn, "null argument to NS_NewScriptDocumentFragment");
JSObject *proto;
JSObject *parent;
nsIScriptObjectOwner *owner;
JSContext *jscontext = (JSContext *)aContext->GetNativeContext();
if (nsnull == aParent) {
parent = nsnull;
}
else if (NS_OK == aParent->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) {
if (NS_OK != owner->GetScriptObject(aContext, (void **)&parent)) {
NS_RELEASE(owner);
return NS_ERROR_FAILURE;
}
NS_RELEASE(owner);
}
else {
return NS_ERROR_FAILURE;
}
if (NS_OK != NS_InitDocumentFragmentClass(aContext, (void **)&proto)) {
return NS_ERROR_FAILURE;
}
// create a js object for this class
*aReturn = JS_NewObject(jscontext, &DocumentFragmentClass, proto, parent);
if (nsnull != *aReturn) {
// connect the native object to the js object
JS_SetPrivate(jscontext, (JSObject *)*aReturn, aSupports);
NS_ADDREF(aSupports);
}
else {
return NS_ERROR_FAILURE;
}
return NS_OK;
}

Просмотреть файл

@ -1,407 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/* AUTO-GENERATED. DO NOT EDIT!!! */
#include "jsapi.h"
#include "nscore.h"
#include "nsIScriptContext.h"
#include "nsIJSScriptObject.h"
#include "nsIScriptObjectOwner.h"
#include "nsIScriptGlobalObject.h"
#include "nsIPtr.h"
#include "nsString.h"
#include "nsIDOMNamedNodeMap.h"
#include "nsIDOMDocumentType.h"
static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID);
static NS_DEFINE_IID(kIJSScriptObjectIID, NS_IJSSCRIPTOBJECT_IID);
static NS_DEFINE_IID(kIScriptGlobalObjectIID, NS_ISCRIPTGLOBALOBJECT_IID);
static NS_DEFINE_IID(kINamedNodeMapIID, NS_IDOMNAMEDNODEMAP_IID);
static NS_DEFINE_IID(kIDocumentTypeIID, NS_IDOMDOCUMENTTYPE_IID);
NS_DEF_PTR(nsIDOMNamedNodeMap);
NS_DEF_PTR(nsIDOMDocumentType);
//
// DocumentType property ids
//
enum DocumentType_slots {
DOCUMENTTYPE_NAME = -11,
DOCUMENTTYPE_ENTITIES = -12
};
/***********************************************************************/
//
// DocumentType Properties Getter
//
PR_STATIC_CALLBACK(JSBool)
GetDocumentTypeProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
{
nsIDOMDocumentType *a = (nsIDOMDocumentType*)JS_GetPrivate(cx, obj);
// If there's no private data, this must be the prototype, so ignore
if (nsnull == a) {
return JS_TRUE;
}
if (JSVAL_IS_INT(id)) {
switch(JSVAL_TO_INT(id)) {
case DOCUMENTTYPE_NAME:
{
nsAutoString prop;
if (NS_OK == a->GetName(prop)) {
JSString *jsstring = JS_NewUCStringCopyN(cx, prop, prop.Length());
// set the return value
*vp = STRING_TO_JSVAL(jsstring);
}
else {
return JS_FALSE;
}
break;
}
case DOCUMENTTYPE_ENTITIES:
{
nsIDOMNamedNodeMap* prop;
if (NS_OK == a->GetEntities(&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;
}
}
else {
return JS_FALSE;
}
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;
}
}
}
}
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 PR_TRUE;
}
/***********************************************************************/
//
// DocumentType Properties Setter
//
PR_STATIC_CALLBACK(JSBool)
SetDocumentTypeProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
{
nsIDOMDocumentType *a = (nsIDOMDocumentType*)JS_GetPrivate(cx, obj);
// If there's no private data, this must be the prototype, so ignore
if (nsnull == a) {
return JS_TRUE;
}
if (JSVAL_IS_INT(id)) {
switch(JSVAL_TO_INT(id)) {
case DOCUMENTTYPE_NAME:
{
nsAutoString prop;
JSString *jsstring;
if ((jsstring = JS_ValueToString(cx, *vp)) != nsnull) {
prop.SetString(JS_GetStringChars(jsstring));
}
else {
prop.SetString((const char *)nsnull);
}
a->SetName(prop);
break;
}
case DOCUMENTTYPE_ENTITIES:
{
nsIDOMNamedNodeMap* 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(kINamedNodeMapIID, (void **)&prop)) {
JS_ReportError(cx, "Parameter must be of type NamedNodeMap");
return JS_FALSE;
}
}
else {
JS_ReportError(cx, "Parameter must be an object");
return JS_FALSE;
}
a->SetEntities(prop);
if (prop) NS_RELEASE(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;
}
}
}
}
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 PR_TRUE;
}
//
// DocumentType finalizer
//
PR_STATIC_CALLBACK(void)
FinalizeDocumentType(JSContext *cx, JSObject *obj)
{
nsIDOMDocumentType *a = (nsIDOMDocumentType*)JS_GetPrivate(cx, obj);
if (nsnull != a) {
// get the js object
nsIScriptObjectOwner *owner = nsnull;
if (NS_OK == a->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) {
owner->ResetScriptObject();
NS_RELEASE(owner);
}
NS_RELEASE(a);
}
}
//
// DocumentType enumerate
//
PR_STATIC_CALLBACK(JSBool)
EnumerateDocumentType(JSContext *cx, JSObject *obj)
{
nsIDOMDocumentType *a = (nsIDOMDocumentType*)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;
}
//
// DocumentType resolve
//
PR_STATIC_CALLBACK(JSBool)
ResolveDocumentType(JSContext *cx, JSObject *obj, jsval id)
{
nsIDOMDocumentType *a = (nsIDOMDocumentType*)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;
}
/***********************************************************************/
//
// class for DocumentType
//
JSClass DocumentTypeClass = {
"DocumentType",
JSCLASS_HAS_PRIVATE,
JS_PropertyStub,
JS_PropertyStub,
GetDocumentTypeProperty,
SetDocumentTypeProperty,
EnumerateDocumentType,
ResolveDocumentType,
JS_ConvertStub,
FinalizeDocumentType
};
//
// DocumentType class properties
//
static JSPropertySpec DocumentTypeProperties[] =
{
{"name", DOCUMENTTYPE_NAME, JSPROP_ENUMERATE},
{"entities", DOCUMENTTYPE_ENTITIES, JSPROP_ENUMERATE},
{0}
};
//
// DocumentType class methods
//
static JSFunctionSpec DocumentTypeMethods[] =
{
{0}
};
//
// DocumentType constructor
//
PR_STATIC_CALLBACK(JSBool)
DocumentType(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
return JS_TRUE;
}
//
// DocumentType class initialization
//
nsresult NS_InitDocumentTypeClass(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, "DocumentType", &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
&DocumentTypeClass, // JSClass
DocumentType, // JSNative ctor
0, // ctor args
DocumentTypeProperties, // proto props
DocumentTypeMethods, // proto funcs
nsnull, // ctor props (static)
nsnull); // ctor funcs (static)
if (nsnull == proto) {
return NS_ERROR_FAILURE;
}
}
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;
}
//
// Method for creating a new DocumentType JavaScript object
//
extern "C" NS_DOM nsresult NS_NewScriptDocumentType(nsIScriptContext *aContext, nsIDOMDocumentType *aSupports, nsISupports *aParent, void **aReturn)
{
NS_PRECONDITION(nsnull != aContext && nsnull != aSupports && nsnull != aReturn, "null argument to NS_NewScriptDocumentType");
JSObject *proto;
JSObject *parent;
nsIScriptObjectOwner *owner;
JSContext *jscontext = (JSContext *)aContext->GetNativeContext();
if (nsnull == aParent) {
parent = nsnull;
}
else if (NS_OK == aParent->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) {
if (NS_OK != owner->GetScriptObject(aContext, (void **)&parent)) {
NS_RELEASE(owner);
return NS_ERROR_FAILURE;
}
NS_RELEASE(owner);
}
else {
return NS_ERROR_FAILURE;
}
if (NS_OK != NS_InitDocumentTypeClass(aContext, (void **)&proto)) {
return NS_ERROR_FAILURE;
}
// create a js object for this class
*aReturn = JS_NewObject(jscontext, &DocumentTypeClass, proto, parent);
if (nsnull != *aReturn) {
// connect the native object to the js object
JS_SetPrivate(jscontext, (JSObject *)*aReturn, aSupports);
NS_ADDREF(aSupports);
}
else {
return NS_ERROR_FAILURE;
}
return NS_OK;
}

Просмотреть файл

@ -1,746 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/* AUTO-GENERATED. DO NOT EDIT!!! */
#include "jsapi.h"
#include "nscore.h"
#include "nsIScriptContext.h"
#include "nsIJSScriptObject.h"
#include "nsIScriptObjectOwner.h"
#include "nsIScriptGlobalObject.h"
#include "nsIPtr.h"
#include "nsString.h"
#include "nsIDOMElement.h"
#include "nsIDOMAttribute.h"
#include "nsIDOMNodeList.h"
static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID);
static NS_DEFINE_IID(kIJSScriptObjectIID, NS_IJSSCRIPTOBJECT_IID);
static NS_DEFINE_IID(kIScriptGlobalObjectIID, NS_ISCRIPTGLOBALOBJECT_IID);
static NS_DEFINE_IID(kIElementIID, NS_IDOMELEMENT_IID);
static NS_DEFINE_IID(kIAttributeIID, NS_IDOMATTRIBUTE_IID);
static NS_DEFINE_IID(kINodeListIID, NS_IDOMNODELIST_IID);
NS_DEF_PTR(nsIDOMElement);
NS_DEF_PTR(nsIDOMAttribute);
NS_DEF_PTR(nsIDOMNodeList);
//
// Element property ids
//
enum Element_slots {
ELEMENT_TAGNAME = -11
};
/***********************************************************************/
//
// Element Properties Getter
//
PR_STATIC_CALLBACK(JSBool)
GetElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
{
nsIDOMElement *a = (nsIDOMElement*)JS_GetPrivate(cx, obj);
// If there's no private data, this must be the prototype, so ignore
if (nsnull == a) {
return JS_TRUE;
}
if (JSVAL_IS_INT(id)) {
switch(JSVAL_TO_INT(id)) {
case ELEMENT_TAGNAME:
{
nsAutoString prop;
if (NS_OK == a->GetTagName(prop)) {
JSString *jsstring = JS_NewUCStringCopyN(cx, prop, prop.Length());
// set the return value
*vp = STRING_TO_JSVAL(jsstring);
}
else {
return JS_FALSE;
}
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;
}
}
}
}
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 PR_TRUE;
}
/***********************************************************************/
//
// Element Properties Setter
//
PR_STATIC_CALLBACK(JSBool)
SetElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
{
nsIDOMElement *a = (nsIDOMElement*)JS_GetPrivate(cx, obj);
// If there's no private data, this must be the prototype, so ignore
if (nsnull == a) {
return JS_TRUE;
}
if (JSVAL_IS_INT(id)) {
switch(JSVAL_TO_INT(id)) {
case 0:
default:
{
nsIJSScriptObject *object;
if (NS_OK == a->QueryInterface(kIJSScriptObjectIID, (void**)&object)) {
PRBool rval;
rval = object->SetProperty(cx, id, vp);
NS_RELEASE(object);
return rval;
}
}
}
}
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 PR_TRUE;
}
//
// Element finalizer
//
PR_STATIC_CALLBACK(void)
FinalizeElement(JSContext *cx, JSObject *obj)
{
nsIDOMElement *a = (nsIDOMElement*)JS_GetPrivate(cx, obj);
if (nsnull != a) {
// get the js object
nsIScriptObjectOwner *owner = nsnull;
if (NS_OK == a->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) {
owner->ResetScriptObject();
NS_RELEASE(owner);
}
NS_RELEASE(a);
}
}
//
// Element enumerate
//
PR_STATIC_CALLBACK(JSBool)
EnumerateElement(JSContext *cx, JSObject *obj)
{
nsIDOMElement *a = (nsIDOMElement*)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;
}
//
// Element resolve
//
PR_STATIC_CALLBACK(JSBool)
ResolveElement(JSContext *cx, JSObject *obj, jsval id)
{
nsIDOMElement *a = (nsIDOMElement*)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;
}
//
// Native method GetDOMAttribute
//
PR_STATIC_CALLBACK(JSBool)
ElementGetDOMAttribute(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMElement *nativeThis = (nsIDOMElement*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
nsAutoString nativeRet;
nsAutoString b0;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if (nsnull == nativeThis) {
return JS_TRUE;
}
if (argc >= 1) {
JSString *jsstring0 = JS_ValueToString(cx, argv[0]);
if (nsnull != jsstring0) {
b0.SetString(JS_GetStringChars(jsstring0));
}
else {
b0.SetString(""); // Should this really be null??
}
if (NS_OK != nativeThis->GetDOMAttribute(b0, nativeRet)) {
return JS_FALSE;
}
JSString *jsstring = JS_NewUCStringCopyN(cx, nativeRet, nativeRet.Length());
// set the return value
*rval = STRING_TO_JSVAL(jsstring);
}
else {
JS_ReportError(cx, "Function getDOMAttribute requires 1 parameters");
return JS_FALSE;
}
return JS_TRUE;
}
//
// Native method SetDOMAttribute
//
PR_STATIC_CALLBACK(JSBool)
ElementSetDOMAttribute(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMElement *nativeThis = (nsIDOMElement*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
nsAutoString b0;
nsAutoString b1;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if (nsnull == nativeThis) {
return JS_TRUE;
}
if (argc >= 2) {
JSString *jsstring0 = JS_ValueToString(cx, argv[0]);
if (nsnull != jsstring0) {
b0.SetString(JS_GetStringChars(jsstring0));
}
else {
b0.SetString(""); // Should this really be null??
}
JSString *jsstring1 = JS_ValueToString(cx, argv[1]);
if (nsnull != jsstring1) {
b1.SetString(JS_GetStringChars(jsstring1));
}
else {
b1.SetString(""); // Should this really be null??
}
if (NS_OK != nativeThis->SetDOMAttribute(b0, b1)) {
return JS_FALSE;
}
*rval = JSVAL_VOID;
}
else {
JS_ReportError(cx, "Function setDOMAttribute requires 2 parameters");
return JS_FALSE;
}
return JS_TRUE;
}
//
// Native method RemoveAttribute
//
PR_STATIC_CALLBACK(JSBool)
ElementRemoveAttribute(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMElement *nativeThis = (nsIDOMElement*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
nsAutoString b0;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if (nsnull == nativeThis) {
return JS_TRUE;
}
if (argc >= 1) {
JSString *jsstring0 = JS_ValueToString(cx, argv[0]);
if (nsnull != jsstring0) {
b0.SetString(JS_GetStringChars(jsstring0));
}
else {
b0.SetString(""); // Should this really be null??
}
if (NS_OK != nativeThis->RemoveAttribute(b0)) {
return JS_FALSE;
}
*rval = JSVAL_VOID;
}
else {
JS_ReportError(cx, "Function removeAttribute requires 1 parameters");
return JS_FALSE;
}
return JS_TRUE;
}
//
// Native method GetAttributeNode
//
PR_STATIC_CALLBACK(JSBool)
ElementGetAttributeNode(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMElement *nativeThis = (nsIDOMElement*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
nsIDOMAttribute* nativeRet;
nsAutoString b0;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if (nsnull == nativeThis) {
return JS_TRUE;
}
if (argc >= 1) {
JSString *jsstring0 = JS_ValueToString(cx, argv[0]);
if (nsnull != jsstring0) {
b0.SetString(JS_GetStringChars(jsstring0));
}
else {
b0.SetString(""); // Should this really be null??
}
if (NS_OK != nativeThis->GetAttributeNode(b0, &nativeRet)) {
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;
}
}
else {
JS_ReportError(cx, "Function getAttributeNode requires 1 parameters");
return JS_FALSE;
}
return JS_TRUE;
}
//
// Native method SetAttributeNode
//
PR_STATIC_CALLBACK(JSBool)
ElementSetAttributeNode(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMElement *nativeThis = (nsIDOMElement*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
nsIDOMAttributePtr b0;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if (nsnull == nativeThis) {
return JS_TRUE;
}
if (argc >= 1) {
if (JSVAL_IS_NULL(argv[0])){
b0 = nsnull;
}
else if (JSVAL_IS_OBJECT(argv[0])) {
nsISupports *supports0 = (nsISupports *)JS_GetPrivate(cx, JSVAL_TO_OBJECT(argv[0]));
NS_ASSERTION(nsnull != supports0, "null pointer");
if ((nsnull == supports0) ||
(NS_OK != supports0->QueryInterface(kIAttributeIID, (void **)(b0.Query())))) {
JS_ReportError(cx, "Parameter must be of type Attribute");
return JS_FALSE;
}
}
else {
JS_ReportError(cx, "Parameter must be an object");
return JS_FALSE;
}
if (NS_OK != nativeThis->SetAttributeNode(b0)) {
return JS_FALSE;
}
*rval = JSVAL_VOID;
}
else {
JS_ReportError(cx, "Function setAttributeNode requires 1 parameters");
return JS_FALSE;
}
return JS_TRUE;
}
//
// Native method RemoveAttributeNode
//
PR_STATIC_CALLBACK(JSBool)
ElementRemoveAttributeNode(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMElement *nativeThis = (nsIDOMElement*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
nsIDOMAttributePtr b0;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if (nsnull == nativeThis) {
return JS_TRUE;
}
if (argc >= 1) {
if (JSVAL_IS_NULL(argv[0])){
b0 = nsnull;
}
else if (JSVAL_IS_OBJECT(argv[0])) {
nsISupports *supports0 = (nsISupports *)JS_GetPrivate(cx, JSVAL_TO_OBJECT(argv[0]));
NS_ASSERTION(nsnull != supports0, "null pointer");
if ((nsnull == supports0) ||
(NS_OK != supports0->QueryInterface(kIAttributeIID, (void **)(b0.Query())))) {
JS_ReportError(cx, "Parameter must be of type Attribute");
return JS_FALSE;
}
}
else {
JS_ReportError(cx, "Parameter must be an object");
return JS_FALSE;
}
if (NS_OK != nativeThis->RemoveAttributeNode(b0)) {
return JS_FALSE;
}
*rval = JSVAL_VOID;
}
else {
JS_ReportError(cx, "Function removeAttributeNode requires 1 parameters");
return JS_FALSE;
}
return JS_TRUE;
}
//
// Native method GetElementsByTagName
//
PR_STATIC_CALLBACK(JSBool)
ElementGetElementsByTagName(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMElement *nativeThis = (nsIDOMElement*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
nsIDOMNodeList* nativeRet;
nsAutoString b0;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if (nsnull == nativeThis) {
return JS_TRUE;
}
if (argc >= 1) {
JSString *jsstring0 = JS_ValueToString(cx, argv[0]);
if (nsnull != jsstring0) {
b0.SetString(JS_GetStringChars(jsstring0));
}
else {
b0.SetString(""); // Should this really be null??
}
if (NS_OK != nativeThis->GetElementsByTagName(b0, &nativeRet)) {
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;
}
}
else {
JS_ReportError(cx, "Function getElementsByTagName requires 1 parameters");
return JS_FALSE;
}
return JS_TRUE;
}
//
// Native method Normalize
//
PR_STATIC_CALLBACK(JSBool)
ElementNormalize(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMElement *nativeThis = (nsIDOMElement*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if (nsnull == nativeThis) {
return JS_TRUE;
}
if (argc >= 0) {
if (NS_OK != nativeThis->Normalize()) {
return JS_FALSE;
}
*rval = JSVAL_VOID;
}
else {
JS_ReportError(cx, "Function normalize requires 0 parameters");
return JS_FALSE;
}
return JS_TRUE;
}
/***********************************************************************/
//
// class for Element
//
JSClass ElementClass = {
"Element",
JSCLASS_HAS_PRIVATE,
JS_PropertyStub,
JS_PropertyStub,
GetElementProperty,
SetElementProperty,
EnumerateElement,
ResolveElement,
JS_ConvertStub,
FinalizeElement
};
//
// Element class properties
//
static JSPropertySpec ElementProperties[] =
{
{"tagName", ELEMENT_TAGNAME, JSPROP_ENUMERATE | JSPROP_READONLY},
{0}
};
//
// Element class methods
//
static JSFunctionSpec ElementMethods[] =
{
{"getDOMAttribute", ElementGetDOMAttribute, 1},
{"setDOMAttribute", ElementSetDOMAttribute, 2},
{"removeAttribute", ElementRemoveAttribute, 1},
{"getAttributeNode", ElementGetAttributeNode, 1},
{"setAttributeNode", ElementSetAttributeNode, 1},
{"removeAttributeNode", ElementRemoveAttributeNode, 1},
{"getElementsByTagName", ElementGetElementsByTagName, 1},
{"normalize", ElementNormalize, 0},
{0}
};
//
// Element constructor
//
PR_STATIC_CALLBACK(JSBool)
Element(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
return JS_TRUE;
}
//
// Element class initialization
//
nsresult NS_InitElementClass(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, "Element", &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_InitNodeClass(aContext, (void **)&parent_proto)) {
return NS_ERROR_FAILURE;
}
proto = JS_InitClass(jscontext, // context
global, // global object
parent_proto, // parent proto
&ElementClass, // JSClass
Element, // JSNative ctor
0, // ctor args
ElementProperties, // proto props
ElementMethods, // proto funcs
nsnull, // ctor props (static)
nsnull); // ctor funcs (static)
if (nsnull == proto) {
return NS_ERROR_FAILURE;
}
}
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;
}
//
// Method for creating a new Element JavaScript object
//
extern "C" NS_DOM nsresult NS_NewScriptElement(nsIScriptContext *aContext, nsIDOMElement *aSupports, nsISupports *aParent, void **aReturn)
{
NS_PRECONDITION(nsnull != aContext && nsnull != aSupports && nsnull != aReturn, "null argument to NS_NewScriptElement");
JSObject *proto;
JSObject *parent;
nsIScriptObjectOwner *owner;
JSContext *jscontext = (JSContext *)aContext->GetNativeContext();
if (nsnull == aParent) {
parent = nsnull;
}
else if (NS_OK == aParent->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) {
if (NS_OK != owner->GetScriptObject(aContext, (void **)&parent)) {
NS_RELEASE(owner);
return NS_ERROR_FAILURE;
}
NS_RELEASE(owner);
}
else {
return NS_ERROR_FAILURE;
}
if (NS_OK != NS_InitElementClass(aContext, (void **)&proto)) {
return NS_ERROR_FAILURE;
}
// create a js object for this class
*aReturn = JS_NewObject(jscontext, &ElementClass, proto, parent);
if (nsnull != *aReturn) {
// connect the native object to the js object
JS_SetPrivate(jscontext, (JSObject *)*aReturn, aSupports);
NS_ADDREF(aSupports);
}
else {
return NS_ERROR_FAILURE;
}
return NS_OK;
}

Просмотреть файл

@ -1,582 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/* AUTO-GENERATED. DO NOT EDIT!!! */
#include "jsapi.h"
#include "nscore.h"
#include "nsIScriptContext.h"
#include "nsIJSScriptObject.h"
#include "nsIScriptObjectOwner.h"
#include "nsIScriptGlobalObject.h"
#include "nsIPtr.h"
#include "nsString.h"
#include "nsIDOMNamedNodeMap.h"
#include "nsIDOMNode.h"
static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID);
static NS_DEFINE_IID(kIJSScriptObjectIID, NS_IJSSCRIPTOBJECT_IID);
static NS_DEFINE_IID(kIScriptGlobalObjectIID, NS_ISCRIPTGLOBALOBJECT_IID);
static NS_DEFINE_IID(kINamedNodeMapIID, NS_IDOMNAMEDNODEMAP_IID);
static NS_DEFINE_IID(kINodeIID, NS_IDOMNODE_IID);
NS_DEF_PTR(nsIDOMNamedNodeMap);
NS_DEF_PTR(nsIDOMNode);
//
// NamedNodeMap property ids
//
enum NamedNodeMap_slots {
NAMEDNODEMAP_LENGTH = -11
};
/***********************************************************************/
//
// NamedNodeMap Properties Getter
//
PR_STATIC_CALLBACK(JSBool)
GetNamedNodeMapProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
{
nsIDOMNamedNodeMap *a = (nsIDOMNamedNodeMap*)JS_GetPrivate(cx, obj);
// If there's no private data, this must be the prototype, so ignore
if (nsnull == a) {
return JS_TRUE;
}
if (JSVAL_IS_INT(id)) {
switch(JSVAL_TO_INT(id)) {
case NAMEDNODEMAP_LENGTH:
{
PRUint32 prop;
if (NS_OK == a->GetLength(&prop)) {
*vp = INT_TO_JSVAL(prop);
}
else {
return JS_FALSE;
}
break;
}
default:
{
nsIDOMNode* prop;
if (NS_OK == a->Item(JSVAL_TO_INT(id), &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;
}
}
else {
return JS_FALSE;
}
}
}
}
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 PR_TRUE;
}
/***********************************************************************/
//
// NamedNodeMap Properties Setter
//
PR_STATIC_CALLBACK(JSBool)
SetNamedNodeMapProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
{
nsIDOMNamedNodeMap *a = (nsIDOMNamedNodeMap*)JS_GetPrivate(cx, obj);
// If there's no private data, this must be the prototype, so ignore
if (nsnull == a) {
return JS_TRUE;
}
if (JSVAL_IS_INT(id)) {
switch(JSVAL_TO_INT(id)) {
case 0:
default:
{
nsIJSScriptObject *object;
if (NS_OK == a->QueryInterface(kIJSScriptObjectIID, (void**)&object)) {
PRBool rval;
rval = object->SetProperty(cx, id, vp);
NS_RELEASE(object);
return rval;
}
}
}
}
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 PR_TRUE;
}
//
// NamedNodeMap finalizer
//
PR_STATIC_CALLBACK(void)
FinalizeNamedNodeMap(JSContext *cx, JSObject *obj)
{
nsIDOMNamedNodeMap *a = (nsIDOMNamedNodeMap*)JS_GetPrivate(cx, obj);
if (nsnull != a) {
// get the js object
nsIScriptObjectOwner *owner = nsnull;
if (NS_OK == a->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) {
owner->ResetScriptObject();
NS_RELEASE(owner);
}
NS_RELEASE(a);
}
}
//
// NamedNodeMap enumerate
//
PR_STATIC_CALLBACK(JSBool)
EnumerateNamedNodeMap(JSContext *cx, JSObject *obj)
{
nsIDOMNamedNodeMap *a = (nsIDOMNamedNodeMap*)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;
}
//
// NamedNodeMap resolve
//
PR_STATIC_CALLBACK(JSBool)
ResolveNamedNodeMap(JSContext *cx, JSObject *obj, jsval id)
{
nsIDOMNamedNodeMap *a = (nsIDOMNamedNodeMap*)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;
}
//
// Native method GetNamedItem
//
PR_STATIC_CALLBACK(JSBool)
NamedNodeMapGetNamedItem(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMNamedNodeMap *nativeThis = (nsIDOMNamedNodeMap*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
nsIDOMNode* nativeRet;
nsAutoString b0;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if (nsnull == nativeThis) {
return JS_TRUE;
}
if (argc >= 1) {
JSString *jsstring0 = JS_ValueToString(cx, argv[0]);
if (nsnull != jsstring0) {
b0.SetString(JS_GetStringChars(jsstring0));
}
else {
b0.SetString(""); // Should this really be null??
}
if (NS_OK != nativeThis->GetNamedItem(b0, &nativeRet)) {
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;
}
}
else {
JS_ReportError(cx, "Function getNamedItem requires 1 parameters");
return JS_FALSE;
}
return JS_TRUE;
}
//
// Native method SetNamedItem
//
PR_STATIC_CALLBACK(JSBool)
NamedNodeMapSetNamedItem(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMNamedNodeMap *nativeThis = (nsIDOMNamedNodeMap*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
nsIDOMNodePtr b0;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if (nsnull == nativeThis) {
return JS_TRUE;
}
if (argc >= 1) {
if (JSVAL_IS_NULL(argv[0])){
b0 = nsnull;
}
else if (JSVAL_IS_OBJECT(argv[0])) {
nsISupports *supports0 = (nsISupports *)JS_GetPrivate(cx, JSVAL_TO_OBJECT(argv[0]));
NS_ASSERTION(nsnull != supports0, "null pointer");
if ((nsnull == supports0) ||
(NS_OK != supports0->QueryInterface(kINodeIID, (void **)(b0.Query())))) {
JS_ReportError(cx, "Parameter must be of type Node");
return JS_FALSE;
}
}
else {
JS_ReportError(cx, "Parameter must be an object");
return JS_FALSE;
}
if (NS_OK != nativeThis->SetNamedItem(b0)) {
return JS_FALSE;
}
*rval = JSVAL_VOID;
}
else {
JS_ReportError(cx, "Function setNamedItem requires 1 parameters");
return JS_FALSE;
}
return JS_TRUE;
}
//
// Native method RemoveNamedItem
//
PR_STATIC_CALLBACK(JSBool)
NamedNodeMapRemoveNamedItem(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMNamedNodeMap *nativeThis = (nsIDOMNamedNodeMap*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
nsIDOMNode* nativeRet;
nsAutoString b0;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if (nsnull == nativeThis) {
return JS_TRUE;
}
if (argc >= 1) {
JSString *jsstring0 = JS_ValueToString(cx, argv[0]);
if (nsnull != jsstring0) {
b0.SetString(JS_GetStringChars(jsstring0));
}
else {
b0.SetString(""); // Should this really be null??
}
if (NS_OK != nativeThis->RemoveNamedItem(b0, &nativeRet)) {
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;
}
}
else {
JS_ReportError(cx, "Function removeNamedItem requires 1 parameters");
return JS_FALSE;
}
return JS_TRUE;
}
//
// Native method Item
//
PR_STATIC_CALLBACK(JSBool)
NamedNodeMapItem(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMNamedNodeMap *nativeThis = (nsIDOMNamedNodeMap*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
nsIDOMNode* nativeRet;
PRUint32 b0;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if (nsnull == nativeThis) {
return JS_TRUE;
}
if (argc >= 1) {
if (!JS_ValueToInt32(cx, argv[0], (int32 *)&b0)) {
JS_ReportError(cx, "Parameter must be a number");
return JS_FALSE;
}
if (NS_OK != nativeThis->Item(b0, &nativeRet)) {
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;
}
}
else {
JS_ReportError(cx, "Function item requires 1 parameters");
return JS_FALSE;
}
return JS_TRUE;
}
/***********************************************************************/
//
// class for NamedNodeMap
//
JSClass NamedNodeMapClass = {
"NamedNodeMap",
JSCLASS_HAS_PRIVATE,
JS_PropertyStub,
JS_PropertyStub,
GetNamedNodeMapProperty,
SetNamedNodeMapProperty,
EnumerateNamedNodeMap,
ResolveNamedNodeMap,
JS_ConvertStub,
FinalizeNamedNodeMap
};
//
// NamedNodeMap class properties
//
static JSPropertySpec NamedNodeMapProperties[] =
{
{"length", NAMEDNODEMAP_LENGTH, JSPROP_ENUMERATE | JSPROP_READONLY},
{0}
};
//
// NamedNodeMap class methods
//
static JSFunctionSpec NamedNodeMapMethods[] =
{
{"getNamedItem", NamedNodeMapGetNamedItem, 1},
{"setNamedItem", NamedNodeMapSetNamedItem, 1},
{"removeNamedItem", NamedNodeMapRemoveNamedItem, 1},
{"item", NamedNodeMapItem, 1},
{0}
};
//
// NamedNodeMap constructor
//
PR_STATIC_CALLBACK(JSBool)
NamedNodeMap(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
return JS_TRUE;
}
//
// NamedNodeMap class initialization
//
nsresult NS_InitNamedNodeMapClass(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, "NamedNodeMap", &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
&NamedNodeMapClass, // JSClass
NamedNodeMap, // JSNative ctor
0, // ctor args
NamedNodeMapProperties, // proto props
NamedNodeMapMethods, // proto funcs
nsnull, // ctor props (static)
nsnull); // ctor funcs (static)
if (nsnull == proto) {
return NS_ERROR_FAILURE;
}
}
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;
}
//
// Method for creating a new NamedNodeMap JavaScript object
//
extern "C" NS_DOM nsresult NS_NewScriptNamedNodeMap(nsIScriptContext *aContext, nsIDOMNamedNodeMap *aSupports, nsISupports *aParent, void **aReturn)
{
NS_PRECONDITION(nsnull != aContext && nsnull != aSupports && nsnull != aReturn, "null argument to NS_NewScriptNamedNodeMap");
JSObject *proto;
JSObject *parent;
nsIScriptObjectOwner *owner;
JSContext *jscontext = (JSContext *)aContext->GetNativeContext();
if (nsnull == aParent) {
parent = nsnull;
}
else if (NS_OK == aParent->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) {
if (NS_OK != owner->GetScriptObject(aContext, (void **)&parent)) {
NS_RELEASE(owner);
return NS_ERROR_FAILURE;
}
NS_RELEASE(owner);
}
else {
return NS_ERROR_FAILURE;
}
if (NS_OK != NS_InitNamedNodeMapClass(aContext, (void **)&proto)) {
return NS_ERROR_FAILURE;
}
// create a js object for this class
*aReturn = JS_NewObject(jscontext, &NamedNodeMapClass, proto, parent);
if (nsnull != *aReturn) {
// connect the native object to the js object
JS_SetPrivate(jscontext, (JSObject *)*aReturn, aSupports);
NS_ADDREF(aSupports);
}
else {
return NS_ERROR_FAILURE;
}
return NS_OK;
}

Просмотреть файл

@ -1,992 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/* AUTO-GENERATED. DO NOT EDIT!!! */
#include "jsapi.h"
#include "nscore.h"
#include "nsIScriptContext.h"
#include "nsIJSScriptObject.h"
#include "nsIScriptObjectOwner.h"
#include "nsIScriptGlobalObject.h"
#include "nsIPtr.h"
#include "nsString.h"
#include "nsIDOMNamedNodeMap.h"
#include "nsIDOMNode.h"
#include "nsIDOMNodeList.h"
static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID);
static NS_DEFINE_IID(kIJSScriptObjectIID, NS_IJSSCRIPTOBJECT_IID);
static NS_DEFINE_IID(kIScriptGlobalObjectIID, NS_ISCRIPTGLOBALOBJECT_IID);
static NS_DEFINE_IID(kINamedNodeMapIID, NS_IDOMNAMEDNODEMAP_IID);
static NS_DEFINE_IID(kINodeIID, NS_IDOMNODE_IID);
static NS_DEFINE_IID(kINodeListIID, NS_IDOMNODELIST_IID);
NS_DEF_PTR(nsIDOMNamedNodeMap);
NS_DEF_PTR(nsIDOMNode);
NS_DEF_PTR(nsIDOMNodeList);
//
// Node property ids
//
enum Node_slots {
NODE_NODENAME = -11,
NODE_NODEVALUE = -12,
NODE_NODETYPE = -13,
NODE_PARENTNODE = -14,
NODE_CHILDNODES = -15,
NODE_HASCHILDNODES = -16,
NODE_FIRSTCHILD = -17,
NODE_LASTCHILD = -18,
NODE_PREVIOUSSIBLING = -19,
NODE_NEXTSIBLING = -110,
NODE_ATTRIBUTES = -111
};
/***********************************************************************/
//
// Node Properties Getter
//
PR_STATIC_CALLBACK(JSBool)
GetNodeProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
{
nsIDOMNode *a = (nsIDOMNode*)JS_GetPrivate(cx, obj);
// If there's no private data, this must be the prototype, so ignore
if (nsnull == a) {
return JS_TRUE;
}
if (JSVAL_IS_INT(id)) {
switch(JSVAL_TO_INT(id)) {
case NODE_NODENAME:
{
nsAutoString prop;
if (NS_OK == a->GetNodeName(prop)) {
JSString *jsstring = JS_NewUCStringCopyN(cx, prop, prop.Length());
// set the return value
*vp = STRING_TO_JSVAL(jsstring);
}
else {
return JS_FALSE;
}
break;
}
case NODE_NODEVALUE:
{
nsAutoString prop;
if (NS_OK == a->GetNodeValue(prop)) {
JSString *jsstring = JS_NewUCStringCopyN(cx, prop, prop.Length());
// set the return value
*vp = STRING_TO_JSVAL(jsstring);
}
else {
return JS_FALSE;
}
break;
}
case NODE_NODETYPE:
{
PRInt32 prop;
if (NS_OK == a->GetNodeType(&prop)) {
*vp = INT_TO_JSVAL(prop);
}
else {
return JS_FALSE;
}
break;
}
case NODE_PARENTNODE:
{
nsIDOMNode* prop;
if (NS_OK == a->GetParentNode(&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;
}
}
else {
return JS_FALSE;
}
break;
}
case NODE_CHILDNODES:
{
nsIDOMNodeList* prop;
if (NS_OK == a->GetChildNodes(&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;
}
}
else {
return JS_FALSE;
}
break;
}
case NODE_HASCHILDNODES:
{
PRBool prop;
if (NS_OK == a->GetHasChildNodes(&prop)) {
*vp = BOOLEAN_TO_JSVAL(prop);
}
else {
return JS_FALSE;
}
break;
}
case NODE_FIRSTCHILD:
{
nsIDOMNode* prop;
if (NS_OK == a->GetFirstChild(&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;
}
}
else {
return JS_FALSE;
}
break;
}
case NODE_LASTCHILD:
{
nsIDOMNode* prop;
if (NS_OK == a->GetLastChild(&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;
}
}
else {
return JS_FALSE;
}
break;
}
case NODE_PREVIOUSSIBLING:
{
nsIDOMNode* prop;
if (NS_OK == a->GetPreviousSibling(&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;
}
}
else {
return JS_FALSE;
}
break;
}
case NODE_NEXTSIBLING:
{
nsIDOMNode* prop;
if (NS_OK == a->GetNextSibling(&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;
}
}
else {
return JS_FALSE;
}
break;
}
case NODE_ATTRIBUTES:
{
nsIDOMNamedNodeMap* prop;
if (NS_OK == a->GetAttributes(&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;
}
}
else {
return JS_FALSE;
}
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;
}
}
}
}
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 PR_TRUE;
}
/***********************************************************************/
//
// Node Properties Setter
//
PR_STATIC_CALLBACK(JSBool)
SetNodeProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
{
nsIDOMNode *a = (nsIDOMNode*)JS_GetPrivate(cx, obj);
// If there's no private data, this must be the prototype, so ignore
if (nsnull == a) {
return JS_TRUE;
}
if (JSVAL_IS_INT(id)) {
switch(JSVAL_TO_INT(id)) {
case NODE_NODEVALUE:
{
nsAutoString prop;
JSString *jsstring;
if ((jsstring = JS_ValueToString(cx, *vp)) != nsnull) {
prop.SetString(JS_GetStringChars(jsstring));
}
else {
prop.SetString((const char *)nsnull);
}
a->SetNodeValue(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;
}
}
}
}
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 PR_TRUE;
}
//
// Node finalizer
//
PR_STATIC_CALLBACK(void)
FinalizeNode(JSContext *cx, JSObject *obj)
{
nsIDOMNode *a = (nsIDOMNode*)JS_GetPrivate(cx, obj);
if (nsnull != a) {
// get the js object
nsIScriptObjectOwner *owner = nsnull;
if (NS_OK == a->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) {
owner->ResetScriptObject();
NS_RELEASE(owner);
}
NS_RELEASE(a);
}
}
//
// Node enumerate
//
PR_STATIC_CALLBACK(JSBool)
EnumerateNode(JSContext *cx, JSObject *obj)
{
nsIDOMNode *a = (nsIDOMNode*)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;
}
//
// Node resolve
//
PR_STATIC_CALLBACK(JSBool)
ResolveNode(JSContext *cx, JSObject *obj, jsval id)
{
nsIDOMNode *a = (nsIDOMNode*)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;
}
//
// Native method InsertBefore
//
PR_STATIC_CALLBACK(JSBool)
NodeInsertBefore(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMNode *nativeThis = (nsIDOMNode*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
nsIDOMNode* nativeRet;
nsIDOMNodePtr b0;
nsIDOMNodePtr b1;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if (nsnull == nativeThis) {
return JS_TRUE;
}
if (argc >= 2) {
if (JSVAL_IS_NULL(argv[0])){
b0 = nsnull;
}
else if (JSVAL_IS_OBJECT(argv[0])) {
nsISupports *supports0 = (nsISupports *)JS_GetPrivate(cx, JSVAL_TO_OBJECT(argv[0]));
NS_ASSERTION(nsnull != supports0, "null pointer");
if ((nsnull == supports0) ||
(NS_OK != supports0->QueryInterface(kINodeIID, (void **)(b0.Query())))) {
JS_ReportError(cx, "Parameter must be of type Node");
return JS_FALSE;
}
}
else {
JS_ReportError(cx, "Parameter must be an object");
return JS_FALSE;
}
if (JSVAL_IS_NULL(argv[1])){
b1 = nsnull;
}
else if (JSVAL_IS_OBJECT(argv[1])) {
nsISupports *supports1 = (nsISupports *)JS_GetPrivate(cx, JSVAL_TO_OBJECT(argv[1]));
NS_ASSERTION(nsnull != supports1, "null pointer");
if ((nsnull == supports1) ||
(NS_OK != supports1->QueryInterface(kINodeIID, (void **)(b1.Query())))) {
JS_ReportError(cx, "Parameter must be of type Node");
return JS_FALSE;
}
}
else {
JS_ReportError(cx, "Parameter must be an object");
return JS_FALSE;
}
if (NS_OK != nativeThis->InsertBefore(b0, b1, &nativeRet)) {
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;
}
}
else {
JS_ReportError(cx, "Function insertBefore requires 2 parameters");
return JS_FALSE;
}
return JS_TRUE;
}
//
// Native method ReplaceChild
//
PR_STATIC_CALLBACK(JSBool)
NodeReplaceChild(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMNode *nativeThis = (nsIDOMNode*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
nsIDOMNode* nativeRet;
nsIDOMNodePtr b0;
nsIDOMNodePtr b1;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if (nsnull == nativeThis) {
return JS_TRUE;
}
if (argc >= 2) {
if (JSVAL_IS_NULL(argv[0])){
b0 = nsnull;
}
else if (JSVAL_IS_OBJECT(argv[0])) {
nsISupports *supports0 = (nsISupports *)JS_GetPrivate(cx, JSVAL_TO_OBJECT(argv[0]));
NS_ASSERTION(nsnull != supports0, "null pointer");
if ((nsnull == supports0) ||
(NS_OK != supports0->QueryInterface(kINodeIID, (void **)(b0.Query())))) {
JS_ReportError(cx, "Parameter must be of type Node");
return JS_FALSE;
}
}
else {
JS_ReportError(cx, "Parameter must be an object");
return JS_FALSE;
}
if (JSVAL_IS_NULL(argv[1])){
b1 = nsnull;
}
else if (JSVAL_IS_OBJECT(argv[1])) {
nsISupports *supports1 = (nsISupports *)JS_GetPrivate(cx, JSVAL_TO_OBJECT(argv[1]));
NS_ASSERTION(nsnull != supports1, "null pointer");
if ((nsnull == supports1) ||
(NS_OK != supports1->QueryInterface(kINodeIID, (void **)(b1.Query())))) {
JS_ReportError(cx, "Parameter must be of type Node");
return JS_FALSE;
}
}
else {
JS_ReportError(cx, "Parameter must be an object");
return JS_FALSE;
}
if (NS_OK != nativeThis->ReplaceChild(b0, b1, &nativeRet)) {
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;
}
}
else {
JS_ReportError(cx, "Function replaceChild requires 2 parameters");
return JS_FALSE;
}
return JS_TRUE;
}
//
// Native method RemoveChild
//
PR_STATIC_CALLBACK(JSBool)
NodeRemoveChild(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMNode *nativeThis = (nsIDOMNode*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
nsIDOMNode* nativeRet;
nsIDOMNodePtr b0;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if (nsnull == nativeThis) {
return JS_TRUE;
}
if (argc >= 1) {
if (JSVAL_IS_NULL(argv[0])){
b0 = nsnull;
}
else if (JSVAL_IS_OBJECT(argv[0])) {
nsISupports *supports0 = (nsISupports *)JS_GetPrivate(cx, JSVAL_TO_OBJECT(argv[0]));
NS_ASSERTION(nsnull != supports0, "null pointer");
if ((nsnull == supports0) ||
(NS_OK != supports0->QueryInterface(kINodeIID, (void **)(b0.Query())))) {
JS_ReportError(cx, "Parameter must be of type Node");
return JS_FALSE;
}
}
else {
JS_ReportError(cx, "Parameter must be an object");
return JS_FALSE;
}
if (NS_OK != nativeThis->RemoveChild(b0, &nativeRet)) {
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;
}
}
else {
JS_ReportError(cx, "Function removeChild requires 1 parameters");
return JS_FALSE;
}
return JS_TRUE;
}
//
// Native method CloneNode
//
PR_STATIC_CALLBACK(JSBool)
NodeCloneNode(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMNode *nativeThis = (nsIDOMNode*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
nsIDOMNode* nativeRet;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if (nsnull == nativeThis) {
return JS_TRUE;
}
if (argc >= 0) {
if (NS_OK != nativeThis->CloneNode(&nativeRet)) {
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;
}
}
else {
JS_ReportError(cx, "Function cloneNode requires 0 parameters");
return JS_FALSE;
}
return JS_TRUE;
}
//
// Native method Equals
//
PR_STATIC_CALLBACK(JSBool)
NodeEquals(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMNode *nativeThis = (nsIDOMNode*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
PRBool nativeRet;
nsIDOMNodePtr b0;
PRBool b1;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if (nsnull == nativeThis) {
return JS_TRUE;
}
if (argc >= 2) {
if (JSVAL_IS_NULL(argv[0])){
b0 = nsnull;
}
else if (JSVAL_IS_OBJECT(argv[0])) {
nsISupports *supports0 = (nsISupports *)JS_GetPrivate(cx, JSVAL_TO_OBJECT(argv[0]));
NS_ASSERTION(nsnull != supports0, "null pointer");
if ((nsnull == supports0) ||
(NS_OK != supports0->QueryInterface(kINodeIID, (void **)(b0.Query())))) {
JS_ReportError(cx, "Parameter must be of type Node");
return JS_FALSE;
}
}
else {
JS_ReportError(cx, "Parameter must be an object");
return JS_FALSE;
}
if (!JS_ValueToBoolean(cx, argv[1], &b1)) {
JS_ReportError(cx, "Parameter must be a boolean");
return JS_FALSE;
}
if (NS_OK != nativeThis->Equals(b0, b1, &nativeRet)) {
return JS_FALSE;
}
*rval = BOOLEAN_TO_JSVAL(nativeRet);
}
else {
JS_ReportError(cx, "Function equals requires 2 parameters");
return JS_FALSE;
}
return JS_TRUE;
}
/***********************************************************************/
//
// class for Node
//
JSClass NodeClass = {
"Node",
JSCLASS_HAS_PRIVATE,
JS_PropertyStub,
JS_PropertyStub,
GetNodeProperty,
SetNodeProperty,
EnumerateNode,
ResolveNode,
JS_ConvertStub,
FinalizeNode
};
//
// Node class properties
//
static JSPropertySpec NodeProperties[] =
{
{"nodeName", NODE_NODENAME, JSPROP_ENUMERATE | JSPROP_READONLY},
{"nodeValue", NODE_NODEVALUE, JSPROP_ENUMERATE},
{"nodeType", NODE_NODETYPE, JSPROP_ENUMERATE | JSPROP_READONLY},
{"parentNode", NODE_PARENTNODE, JSPROP_ENUMERATE | JSPROP_READONLY},
{"childNodes", NODE_CHILDNODES, JSPROP_ENUMERATE | JSPROP_READONLY},
{"hasChildNodes", NODE_HASCHILDNODES, JSPROP_ENUMERATE | JSPROP_READONLY},
{"firstChild", NODE_FIRSTCHILD, JSPROP_ENUMERATE | JSPROP_READONLY},
{"lastChild", NODE_LASTCHILD, JSPROP_ENUMERATE | JSPROP_READONLY},
{"previousSibling", NODE_PREVIOUSSIBLING, JSPROP_ENUMERATE | JSPROP_READONLY},
{"nextSibling", NODE_NEXTSIBLING, JSPROP_ENUMERATE | JSPROP_READONLY},
{"attributes", NODE_ATTRIBUTES, JSPROP_ENUMERATE | JSPROP_READONLY},
{0}
};
//
// Node class methods
//
static JSFunctionSpec NodeMethods[] =
{
{"insertBefore", NodeInsertBefore, 2},
{"replaceChild", NodeReplaceChild, 2},
{"removeChild", NodeRemoveChild, 1},
{"cloneNode", NodeCloneNode, 0},
{"equals", NodeEquals, 2},
{0}
};
//
// Node constructor
//
PR_STATIC_CALLBACK(JSBool)
Node(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
return JS_TRUE;
}
//
// Node class initialization
//
nsresult NS_InitNodeClass(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, "Node", &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
&NodeClass, // JSClass
Node, // JSNative ctor
0, // ctor args
NodeProperties, // proto props
NodeMethods, // proto funcs
nsnull, // ctor props (static)
nsnull); // ctor funcs (static)
if (nsnull == proto) {
return NS_ERROR_FAILURE;
}
if ((PR_TRUE == JS_LookupProperty(jscontext, global, "Node", &vp)) &&
JSVAL_IS_OBJECT(vp) &&
((constructor = JSVAL_TO_OBJECT(vp)) != nsnull)) {
vp = INT_TO_JSVAL(nsIDOMNode::DOCUMENT);
JS_SetProperty(jscontext, constructor, "DOCUMENT", &vp);
vp = INT_TO_JSVAL(nsIDOMNode::ELEMENT);
JS_SetProperty(jscontext, constructor, "ELEMENT", &vp);
vp = INT_TO_JSVAL(nsIDOMNode::ATTRIBUTE);
JS_SetProperty(jscontext, constructor, "ATTRIBUTE", &vp);
vp = INT_TO_JSVAL(nsIDOMNode::PROCESSING_INSTRUCTION);
JS_SetProperty(jscontext, constructor, "PROCESSING_INSTRUCTION", &vp);
vp = INT_TO_JSVAL(nsIDOMNode::COMMENT);
JS_SetProperty(jscontext, constructor, "COMMENT", &vp);
vp = INT_TO_JSVAL(nsIDOMNode::TEXT);
JS_SetProperty(jscontext, constructor, "TEXT", &vp);
vp = INT_TO_JSVAL(nsIDOMNode::CDATA_SECTION);
JS_SetProperty(jscontext, constructor, "CDATA_SECTION", &vp);
vp = INT_TO_JSVAL(nsIDOMNode::DOCUMENT_FRAGMENT);
JS_SetProperty(jscontext, constructor, "DOCUMENT_FRAGMENT", &vp);
vp = INT_TO_JSVAL(nsIDOMNode::ENTITY_DECLARATION);
JS_SetProperty(jscontext, constructor, "ENTITY_DECLARATION", &vp);
vp = INT_TO_JSVAL(nsIDOMNode::ENTITY_REFERENCE);
JS_SetProperty(jscontext, constructor, "ENTITY_REFERENCE", &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;
}
//
// Method for creating a new Node JavaScript object
//
extern "C" NS_DOM nsresult NS_NewScriptNode(nsIScriptContext *aContext, nsIDOMNode *aSupports, nsISupports *aParent, void **aReturn)
{
NS_PRECONDITION(nsnull != aContext && nsnull != aSupports && nsnull != aReturn, "null argument to NS_NewScriptNode");
JSObject *proto;
JSObject *parent;
nsIScriptObjectOwner *owner;
JSContext *jscontext = (JSContext *)aContext->GetNativeContext();
if (nsnull == aParent) {
parent = nsnull;
}
else if (NS_OK == aParent->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) {
if (NS_OK != owner->GetScriptObject(aContext, (void **)&parent)) {
NS_RELEASE(owner);
return NS_ERROR_FAILURE;
}
NS_RELEASE(owner);
}
else {
return NS_ERROR_FAILURE;
}
if (NS_OK != NS_InitNodeClass(aContext, (void **)&proto)) {
return NS_ERROR_FAILURE;
}
// create a js object for this class
*aReturn = JS_NewObject(jscontext, &NodeClass, proto, parent);
if (nsnull != *aReturn) {
// connect the native object to the js object
JS_SetPrivate(jscontext, (JSObject *)*aReturn, aSupports);
NS_ADDREF(aSupports);
}
else {
return NS_ERROR_FAILURE;
}
return NS_OK;
}

Просмотреть файл

@ -1,411 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/* AUTO-GENERATED. DO NOT EDIT!!! */
#include "jsapi.h"
#include "nscore.h"
#include "nsIScriptContext.h"
#include "nsIJSScriptObject.h"
#include "nsIScriptObjectOwner.h"
#include "nsIScriptGlobalObject.h"
#include "nsIPtr.h"
#include "nsString.h"
#include "nsIDOMNode.h"
#include "nsIDOMNodeList.h"
static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID);
static NS_DEFINE_IID(kIJSScriptObjectIID, NS_IJSSCRIPTOBJECT_IID);
static NS_DEFINE_IID(kIScriptGlobalObjectIID, NS_ISCRIPTGLOBALOBJECT_IID);
static NS_DEFINE_IID(kINodeIID, NS_IDOMNODE_IID);
static NS_DEFINE_IID(kINodeListIID, NS_IDOMNODELIST_IID);
NS_DEF_PTR(nsIDOMNode);
NS_DEF_PTR(nsIDOMNodeList);
//
// NodeList property ids
//
enum NodeList_slots {
NODELIST_LENGTH = -11
};
/***********************************************************************/
//
// NodeList Properties Getter
//
PR_STATIC_CALLBACK(JSBool)
GetNodeListProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
{
nsIDOMNodeList *a = (nsIDOMNodeList*)JS_GetPrivate(cx, obj);
// If there's no private data, this must be the prototype, so ignore
if (nsnull == a) {
return JS_TRUE;
}
if (JSVAL_IS_INT(id)) {
switch(JSVAL_TO_INT(id)) {
case NODELIST_LENGTH:
{
PRUint32 prop;
if (NS_OK == a->GetLength(&prop)) {
*vp = INT_TO_JSVAL(prop);
}
else {
return JS_FALSE;
}
break;
}
default:
{
nsIDOMNode* prop;
if (NS_OK == a->Item(JSVAL_TO_INT(id), &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;
}
}
else {
return JS_FALSE;
}
}
}
}
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 PR_TRUE;
}
/***********************************************************************/
//
// NodeList Properties Setter
//
PR_STATIC_CALLBACK(JSBool)
SetNodeListProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
{
nsIDOMNodeList *a = (nsIDOMNodeList*)JS_GetPrivate(cx, obj);
// If there's no private data, this must be the prototype, so ignore
if (nsnull == a) {
return JS_TRUE;
}
if (JSVAL_IS_INT(id)) {
switch(JSVAL_TO_INT(id)) {
case 0:
default:
{
nsIJSScriptObject *object;
if (NS_OK == a->QueryInterface(kIJSScriptObjectIID, (void**)&object)) {
PRBool rval;
rval = object->SetProperty(cx, id, vp);
NS_RELEASE(object);
return rval;
}
}
}
}
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 PR_TRUE;
}
//
// NodeList finalizer
//
PR_STATIC_CALLBACK(void)
FinalizeNodeList(JSContext *cx, JSObject *obj)
{
nsIDOMNodeList *a = (nsIDOMNodeList*)JS_GetPrivate(cx, obj);
if (nsnull != a) {
// get the js object
nsIScriptObjectOwner *owner = nsnull;
if (NS_OK == a->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) {
owner->ResetScriptObject();
NS_RELEASE(owner);
}
NS_RELEASE(a);
}
}
//
// NodeList enumerate
//
PR_STATIC_CALLBACK(JSBool)
EnumerateNodeList(JSContext *cx, JSObject *obj)
{
nsIDOMNodeList *a = (nsIDOMNodeList*)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;
}
//
// NodeList resolve
//
PR_STATIC_CALLBACK(JSBool)
ResolveNodeList(JSContext *cx, JSObject *obj, jsval id)
{
nsIDOMNodeList *a = (nsIDOMNodeList*)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;
}
//
// Native method Item
//
PR_STATIC_CALLBACK(JSBool)
NodeListItem(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMNodeList *nativeThis = (nsIDOMNodeList*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
nsIDOMNode* nativeRet;
PRUint32 b0;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if (nsnull == nativeThis) {
return JS_TRUE;
}
if (argc >= 1) {
if (!JS_ValueToInt32(cx, argv[0], (int32 *)&b0)) {
JS_ReportError(cx, "Parameter must be a number");
return JS_FALSE;
}
if (NS_OK != nativeThis->Item(b0, &nativeRet)) {
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;
}
}
else {
JS_ReportError(cx, "Function item requires 1 parameters");
return JS_FALSE;
}
return JS_TRUE;
}
/***********************************************************************/
//
// class for NodeList
//
JSClass NodeListClass = {
"NodeList",
JSCLASS_HAS_PRIVATE,
JS_PropertyStub,
JS_PropertyStub,
GetNodeListProperty,
SetNodeListProperty,
EnumerateNodeList,
ResolveNodeList,
JS_ConvertStub,
FinalizeNodeList
};
//
// NodeList class properties
//
static JSPropertySpec NodeListProperties[] =
{
{"length", NODELIST_LENGTH, JSPROP_ENUMERATE | JSPROP_READONLY},
{0}
};
//
// NodeList class methods
//
static JSFunctionSpec NodeListMethods[] =
{
{"item", NodeListItem, 1},
{0}
};
//
// NodeList constructor
//
PR_STATIC_CALLBACK(JSBool)
NodeList(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
return JS_TRUE;
}
//
// NodeList class initialization
//
nsresult NS_InitNodeListClass(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, "NodeList", &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
&NodeListClass, // JSClass
NodeList, // JSNative ctor
0, // ctor args
NodeListProperties, // proto props
NodeListMethods, // proto funcs
nsnull, // ctor props (static)
nsnull); // ctor funcs (static)
if (nsnull == proto) {
return NS_ERROR_FAILURE;
}
}
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;
}
//
// Method for creating a new NodeList JavaScript object
//
extern "C" NS_DOM nsresult NS_NewScriptNodeList(nsIScriptContext *aContext, nsIDOMNodeList *aSupports, nsISupports *aParent, void **aReturn)
{
NS_PRECONDITION(nsnull != aContext && nsnull != aSupports && nsnull != aReturn, "null argument to NS_NewScriptNodeList");
JSObject *proto;
JSObject *parent;
nsIScriptObjectOwner *owner;
JSContext *jscontext = (JSContext *)aContext->GetNativeContext();
if (nsnull == aParent) {
parent = nsnull;
}
else if (NS_OK == aParent->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) {
if (NS_OK != owner->GetScriptObject(aContext, (void **)&parent)) {
NS_RELEASE(owner);
return NS_ERROR_FAILURE;
}
NS_RELEASE(owner);
}
else {
return NS_ERROR_FAILURE;
}
if (NS_OK != NS_InitNodeListClass(aContext, (void **)&proto)) {
return NS_ERROR_FAILURE;
}
// create a js object for this class
*aReturn = JS_NewObject(jscontext, &NodeListClass, proto, parent);
if (nsnull != *aReturn) {
// connect the native object to the js object
JS_SetPrivate(jscontext, (JSObject *)*aReturn, aSupports);
NS_ADDREF(aSupports);
}
else {
return NS_ERROR_FAILURE;
}
return NS_OK;
}

Просмотреть файл

@ -1,385 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/* AUTO-GENERATED. DO NOT EDIT!!! */
#include "jsapi.h"
#include "nscore.h"
#include "nsIScriptContext.h"
#include "nsIJSScriptObject.h"
#include "nsIScriptObjectOwner.h"
#include "nsIScriptGlobalObject.h"
#include "nsIPtr.h"
#include "nsString.h"
#include "nsIDOMProcessingInstruction.h"
static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID);
static NS_DEFINE_IID(kIJSScriptObjectIID, NS_IJSSCRIPTOBJECT_IID);
static NS_DEFINE_IID(kIScriptGlobalObjectIID, NS_ISCRIPTGLOBALOBJECT_IID);
static NS_DEFINE_IID(kIProcessingInstructionIID, NS_IDOMPROCESSINGINSTRUCTION_IID);
NS_DEF_PTR(nsIDOMProcessingInstruction);
//
// ProcessingInstruction property ids
//
enum ProcessingInstruction_slots {
PROCESSINGINSTRUCTION_TARGET = -11,
PROCESSINGINSTRUCTION_DATA = -12
};
/***********************************************************************/
//
// ProcessingInstruction Properties Getter
//
PR_STATIC_CALLBACK(JSBool)
GetProcessingInstructionProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
{
nsIDOMProcessingInstruction *a = (nsIDOMProcessingInstruction*)JS_GetPrivate(cx, obj);
// If there's no private data, this must be the prototype, so ignore
if (nsnull == a) {
return JS_TRUE;
}
if (JSVAL_IS_INT(id)) {
switch(JSVAL_TO_INT(id)) {
case PROCESSINGINSTRUCTION_TARGET:
{
nsAutoString prop;
if (NS_OK == a->GetTarget(prop)) {
JSString *jsstring = JS_NewUCStringCopyN(cx, prop, prop.Length());
// set the return value
*vp = STRING_TO_JSVAL(jsstring);
}
else {
return JS_FALSE;
}
break;
}
case PROCESSINGINSTRUCTION_DATA:
{
nsAutoString prop;
if (NS_OK == a->GetData(prop)) {
JSString *jsstring = JS_NewUCStringCopyN(cx, prop, prop.Length());
// set the return value
*vp = STRING_TO_JSVAL(jsstring);
}
else {
return JS_FALSE;
}
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;
}
}
}
}
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 PR_TRUE;
}
/***********************************************************************/
//
// ProcessingInstruction Properties Setter
//
PR_STATIC_CALLBACK(JSBool)
SetProcessingInstructionProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
{
nsIDOMProcessingInstruction *a = (nsIDOMProcessingInstruction*)JS_GetPrivate(cx, obj);
// If there's no private data, this must be the prototype, so ignore
if (nsnull == a) {
return JS_TRUE;
}
if (JSVAL_IS_INT(id)) {
switch(JSVAL_TO_INT(id)) {
case PROCESSINGINSTRUCTION_TARGET:
{
nsAutoString prop;
JSString *jsstring;
if ((jsstring = JS_ValueToString(cx, *vp)) != nsnull) {
prop.SetString(JS_GetStringChars(jsstring));
}
else {
prop.SetString((const char *)nsnull);
}
a->SetTarget(prop);
break;
}
case PROCESSINGINSTRUCTION_DATA:
{
nsAutoString prop;
JSString *jsstring;
if ((jsstring = JS_ValueToString(cx, *vp)) != nsnull) {
prop.SetString(JS_GetStringChars(jsstring));
}
else {
prop.SetString((const char *)nsnull);
}
a->SetData(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;
}
}
}
}
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 PR_TRUE;
}
//
// ProcessingInstruction finalizer
//
PR_STATIC_CALLBACK(void)
FinalizeProcessingInstruction(JSContext *cx, JSObject *obj)
{
nsIDOMProcessingInstruction *a = (nsIDOMProcessingInstruction*)JS_GetPrivate(cx, obj);
if (nsnull != a) {
// get the js object
nsIScriptObjectOwner *owner = nsnull;
if (NS_OK == a->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) {
owner->ResetScriptObject();
NS_RELEASE(owner);
}
NS_RELEASE(a);
}
}
//
// ProcessingInstruction enumerate
//
PR_STATIC_CALLBACK(JSBool)
EnumerateProcessingInstruction(JSContext *cx, JSObject *obj)
{
nsIDOMProcessingInstruction *a = (nsIDOMProcessingInstruction*)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;
}
//
// ProcessingInstruction resolve
//
PR_STATIC_CALLBACK(JSBool)
ResolveProcessingInstruction(JSContext *cx, JSObject *obj, jsval id)
{
nsIDOMProcessingInstruction *a = (nsIDOMProcessingInstruction*)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;
}
/***********************************************************************/
//
// class for ProcessingInstruction
//
JSClass ProcessingInstructionClass = {
"ProcessingInstruction",
JSCLASS_HAS_PRIVATE,
JS_PropertyStub,
JS_PropertyStub,
GetProcessingInstructionProperty,
SetProcessingInstructionProperty,
EnumerateProcessingInstruction,
ResolveProcessingInstruction,
JS_ConvertStub,
FinalizeProcessingInstruction
};
//
// ProcessingInstruction class properties
//
static JSPropertySpec ProcessingInstructionProperties[] =
{
{"target", PROCESSINGINSTRUCTION_TARGET, JSPROP_ENUMERATE},
{"data", PROCESSINGINSTRUCTION_DATA, JSPROP_ENUMERATE},
{0}
};
//
// ProcessingInstruction class methods
//
static JSFunctionSpec ProcessingInstructionMethods[] =
{
{0}
};
//
// ProcessingInstruction constructor
//
PR_STATIC_CALLBACK(JSBool)
ProcessingInstruction(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
return JS_TRUE;
}
//
// ProcessingInstruction class initialization
//
nsresult NS_InitProcessingInstructionClass(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, "ProcessingInstruction", &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_InitNodeClass(aContext, (void **)&parent_proto)) {
return NS_ERROR_FAILURE;
}
proto = JS_InitClass(jscontext, // context
global, // global object
parent_proto, // parent proto
&ProcessingInstructionClass, // JSClass
ProcessingInstruction, // JSNative ctor
0, // ctor args
ProcessingInstructionProperties, // proto props
ProcessingInstructionMethods, // proto funcs
nsnull, // ctor props (static)
nsnull); // ctor funcs (static)
if (nsnull == proto) {
return NS_ERROR_FAILURE;
}
}
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;
}
//
// Method for creating a new ProcessingInstruction JavaScript object
//
extern "C" NS_DOM nsresult NS_NewScriptProcessingInstruction(nsIScriptContext *aContext, nsIDOMProcessingInstruction *aSupports, nsISupports *aParent, void **aReturn)
{
NS_PRECONDITION(nsnull != aContext && nsnull != aSupports && nsnull != aReturn, "null argument to NS_NewScriptProcessingInstruction");
JSObject *proto;
JSObject *parent;
nsIScriptObjectOwner *owner;
JSContext *jscontext = (JSContext *)aContext->GetNativeContext();
if (nsnull == aParent) {
parent = nsnull;
}
else if (NS_OK == aParent->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) {
if (NS_OK != owner->GetScriptObject(aContext, (void **)&parent)) {
NS_RELEASE(owner);
return NS_ERROR_FAILURE;
}
NS_RELEASE(owner);
}
else {
return NS_ERROR_FAILURE;
}
if (NS_OK != NS_InitProcessingInstructionClass(aContext, (void **)&proto)) {
return NS_ERROR_FAILURE;
}
// create a js object for this class
*aReturn = JS_NewObject(jscontext, &ProcessingInstructionClass, proto, parent);
if (nsnull != *aReturn) {
// connect the native object to the js object
JS_SetPrivate(jscontext, (JSObject *)*aReturn, aSupports);
NS_ADDREF(aSupports);
}
else {
return NS_ERROR_FAILURE;
}
return NS_OK;
}

Просмотреть файл

@ -1,466 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/* AUTO-GENERATED. DO NOT EDIT!!! */
#include "jsapi.h"
#include "nscore.h"
#include "nsIScriptContext.h"
#include "nsIJSScriptObject.h"
#include "nsIScriptObjectOwner.h"
#include "nsIScriptGlobalObject.h"
#include "nsIPtr.h"
#include "nsString.h"
#include "nsIDOMText.h"
static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID);
static NS_DEFINE_IID(kIJSScriptObjectIID, NS_IJSSCRIPTOBJECT_IID);
static NS_DEFINE_IID(kIScriptGlobalObjectIID, NS_ISCRIPTGLOBALOBJECT_IID);
static NS_DEFINE_IID(kITextIID, NS_IDOMTEXT_IID);
NS_DEF_PTR(nsIDOMText);
/***********************************************************************/
//
// Text Properties Getter
//
PR_STATIC_CALLBACK(JSBool)
GetTextProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
{
nsIDOMText *a = (nsIDOMText*)JS_GetPrivate(cx, obj);
// If there's no private data, this must be the prototype, so ignore
if (nsnull == a) {
return JS_TRUE;
}
if (JSVAL_IS_INT(id)) {
switch(JSVAL_TO_INT(id)) {
case 0:
default:
{
nsIJSScriptObject *object;
if (NS_OK == a->QueryInterface(kIJSScriptObjectIID, (void**)&object)) {
PRBool rval;
rval = object->GetProperty(cx, id, vp);
NS_RELEASE(object);
return rval;
}
}
}
}
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 PR_TRUE;
}
/***********************************************************************/
//
// Text Properties Setter
//
PR_STATIC_CALLBACK(JSBool)
SetTextProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
{
nsIDOMText *a = (nsIDOMText*)JS_GetPrivate(cx, obj);
// If there's no private data, this must be the prototype, so ignore
if (nsnull == a) {
return JS_TRUE;
}
if (JSVAL_IS_INT(id)) {
switch(JSVAL_TO_INT(id)) {
case 0:
default:
{
nsIJSScriptObject *object;
if (NS_OK == a->QueryInterface(kIJSScriptObjectIID, (void**)&object)) {
PRBool rval;
rval = object->SetProperty(cx, id, vp);
NS_RELEASE(object);
return rval;
}
}
}
}
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 PR_TRUE;
}
//
// Text finalizer
//
PR_STATIC_CALLBACK(void)
FinalizeText(JSContext *cx, JSObject *obj)
{
nsIDOMText *a = (nsIDOMText*)JS_GetPrivate(cx, obj);
if (nsnull != a) {
// get the js object
nsIScriptObjectOwner *owner = nsnull;
if (NS_OK == a->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) {
owner->ResetScriptObject();
NS_RELEASE(owner);
}
NS_RELEASE(a);
}
}
//
// Text enumerate
//
PR_STATIC_CALLBACK(JSBool)
EnumerateText(JSContext *cx, JSObject *obj)
{
nsIDOMText *a = (nsIDOMText*)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;
}
//
// Text resolve
//
PR_STATIC_CALLBACK(JSBool)
ResolveText(JSContext *cx, JSObject *obj, jsval id)
{
nsIDOMText *a = (nsIDOMText*)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;
}
//
// Native method SplitText
//
PR_STATIC_CALLBACK(JSBool)
TextSplitText(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMText *nativeThis = (nsIDOMText*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
nsIDOMText* nativeRet;
PRUint32 b0;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if (nsnull == nativeThis) {
return JS_TRUE;
}
if (argc >= 1) {
if (!JS_ValueToInt32(cx, argv[0], (int32 *)&b0)) {
JS_ReportError(cx, "Parameter must be a number");
return JS_FALSE;
}
if (NS_OK != nativeThis->SplitText(b0, &nativeRet)) {
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;
}
}
else {
JS_ReportError(cx, "Function splitText requires 1 parameters");
return JS_FALSE;
}
return JS_TRUE;
}
//
// Native method JoinText
//
PR_STATIC_CALLBACK(JSBool)
TextJoinText(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMText *nativeThis = (nsIDOMText*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
nsIDOMText* nativeRet;
nsIDOMTextPtr b0;
nsIDOMTextPtr b1;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if (nsnull == nativeThis) {
return JS_TRUE;
}
if (argc >= 2) {
if (JSVAL_IS_NULL(argv[0])){
b0 = nsnull;
}
else if (JSVAL_IS_OBJECT(argv[0])) {
nsISupports *supports0 = (nsISupports *)JS_GetPrivate(cx, JSVAL_TO_OBJECT(argv[0]));
NS_ASSERTION(nsnull != supports0, "null pointer");
if ((nsnull == supports0) ||
(NS_OK != supports0->QueryInterface(kITextIID, (void **)(b0.Query())))) {
JS_ReportError(cx, "Parameter must be of type Text");
return JS_FALSE;
}
}
else {
JS_ReportError(cx, "Parameter must be an object");
return JS_FALSE;
}
if (JSVAL_IS_NULL(argv[1])){
b1 = nsnull;
}
else if (JSVAL_IS_OBJECT(argv[1])) {
nsISupports *supports1 = (nsISupports *)JS_GetPrivate(cx, JSVAL_TO_OBJECT(argv[1]));
NS_ASSERTION(nsnull != supports1, "null pointer");
if ((nsnull == supports1) ||
(NS_OK != supports1->QueryInterface(kITextIID, (void **)(b1.Query())))) {
JS_ReportError(cx, "Parameter must be of type Text");
return JS_FALSE;
}
}
else {
JS_ReportError(cx, "Parameter must be an object");
return JS_FALSE;
}
if (NS_OK != nativeThis->JoinText(b0, b1, &nativeRet)) {
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;
}
}
else {
JS_ReportError(cx, "Function joinText requires 2 parameters");
return JS_FALSE;
}
return JS_TRUE;
}
/***********************************************************************/
//
// class for Text
//
JSClass TextClass = {
"Text",
JSCLASS_HAS_PRIVATE,
JS_PropertyStub,
JS_PropertyStub,
GetTextProperty,
SetTextProperty,
EnumerateText,
ResolveText,
JS_ConvertStub,
FinalizeText
};
//
// Text class properties
//
static JSPropertySpec TextProperties[] =
{
{0}
};
//
// Text class methods
//
static JSFunctionSpec TextMethods[] =
{
{"splitText", TextSplitText, 1},
{"joinText", TextJoinText, 2},
{0}
};
//
// Text constructor
//
PR_STATIC_CALLBACK(JSBool)
Text(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
return JS_TRUE;
}
//
// Text class initialization
//
nsresult NS_InitTextClass(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, "Text", &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_InitDataClass(aContext, (void **)&parent_proto)) {
return NS_ERROR_FAILURE;
}
proto = JS_InitClass(jscontext, // context
global, // global object
parent_proto, // parent proto
&TextClass, // JSClass
Text, // JSNative ctor
0, // ctor args
TextProperties, // proto props
TextMethods, // proto funcs
nsnull, // ctor props (static)
nsnull); // ctor funcs (static)
if (nsnull == proto) {
return NS_ERROR_FAILURE;
}
}
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;
}
//
// Method for creating a new Text JavaScript object
//
extern "C" NS_DOM nsresult NS_NewScriptText(nsIScriptContext *aContext, nsIDOMText *aSupports, nsISupports *aParent, void **aReturn)
{
NS_PRECONDITION(nsnull != aContext && nsnull != aSupports && nsnull != aReturn, "null argument to NS_NewScriptText");
JSObject *proto;
JSObject *parent;
nsIScriptObjectOwner *owner;
JSContext *jscontext = (JSContext *)aContext->GetNativeContext();
if (nsnull == aParent) {
parent = nsnull;
}
else if (NS_OK == aParent->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) {
if (NS_OK != owner->GetScriptObject(aContext, (void **)&parent)) {
NS_RELEASE(owner);
return NS_ERROR_FAILURE;
}
NS_RELEASE(owner);
}
else {
return NS_ERROR_FAILURE;
}
if (NS_OK != NS_InitTextClass(aContext, (void **)&proto)) {
return NS_ERROR_FAILURE;
}
// create a js object for this class
*aReturn = JS_NewObject(jscontext, &TextClass, proto, parent);
if (nsnull != *aReturn) {
// connect the native object to the js object
JS_SetPrivate(jscontext, (JSObject *)*aReturn, aSupports);
NS_ADDREF(aSupports);
}
else {
return NS_ERROR_FAILURE;
}
return NS_OK;
}