зеркало из https://github.com/mozilla/pjs.git
Added autogeneration of XPCOM headers and JavaScript stub classes. Added better masking of JS-specific structures in generic interfaces. Creation of a scripting global object interface.
This commit is contained in:
Родитель
9493926876
Коммит
f2cccbb1e0
|
@ -25,6 +25,7 @@
|
|||
#include "nsIPresShell.h"
|
||||
#include "nsIDocumentObserver.h"
|
||||
#include "nsEventListenerManager.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
|
||||
#include "nsSelection.h"
|
||||
#include "nsIDOMText.h"
|
||||
|
@ -436,15 +437,17 @@ void nsDocument::ContentHasBeenRemoved(nsIContent* aContainer,
|
|||
}
|
||||
}
|
||||
|
||||
nsresult nsDocument::GetScriptObject(JSContext *aContext, void** aScriptObject)
|
||||
nsresult nsDocument::GetScriptObject(nsIScriptContext *aContext, void** aScriptObject)
|
||||
{
|
||||
nsresult res = NS_OK;
|
||||
nsIScriptGlobalObject *global = aContext->GetGlobalObject();
|
||||
|
||||
if (nsnull == mScriptObject) {
|
||||
res = NS_NewScriptDocument(aContext, this, nsnull, (JSObject**)&mScriptObject);
|
||||
res = NS_NewScriptDocument(aContext, this, global, (void**)&mScriptObject);
|
||||
}
|
||||
*aScriptObject = mScriptObject;
|
||||
|
||||
NS_RELEASE(global);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -474,14 +477,15 @@ nsresult nsDocument::GetChildNodes(nsIDOMNodeIterator **aIterator)
|
|||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
nsresult nsDocument::HasChildNodes()
|
||||
nsresult nsDocument::HasChildNodes(PRBool *aReturn)
|
||||
{
|
||||
if (nsnull != mRootContent) {
|
||||
return NS_OK;
|
||||
*aReturn = PR_TRUE;
|
||||
}
|
||||
else {
|
||||
return NS_ERROR_FAILURE;
|
||||
*aReturn = PR_FALSE;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsDocument::GetFirstChild(nsIDOMNode **aNode)
|
||||
|
@ -664,7 +668,7 @@ nsresult nsDocument::CreateAttributeList(nsIDOMAttributeList **aAttributesList)
|
|||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
nsresult nsDocument::CreateTreeIterator(nsIDOMNode **aNode, nsIDOMTreeIterator **aTreeIterator)
|
||||
nsresult nsDocument::CreateTreeIterator(nsIDOMNode *aNode, nsIDOMTreeIterator **aTreeIterator)
|
||||
{
|
||||
//XXX TBI
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include "nsVoidArray.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsIDOMEventCapturer.h"
|
||||
|
||||
class nsISelection;
|
||||
|
@ -161,14 +162,14 @@ public:
|
|||
|
||||
public:
|
||||
|
||||
NS_IMETHOD GetScriptObject(JSContext *aContext, void** aScriptObject);
|
||||
NS_IMETHOD GetScriptObject(nsIScriptContext *aContext, void** aScriptObject);
|
||||
NS_IMETHOD ResetScriptObject();
|
||||
|
||||
// nsIDOMDocument interface
|
||||
NS_IMETHOD GetNodeType(PRInt32 *aType);
|
||||
NS_IMETHOD GetParentNode(nsIDOMNode **aNode);
|
||||
NS_IMETHOD GetChildNodes(nsIDOMNodeIterator **aIterator);
|
||||
NS_IMETHOD HasChildNodes();
|
||||
NS_IMETHOD HasChildNodes(PRBool *aReturn);
|
||||
NS_IMETHOD GetFirstChild(nsIDOMNode **aNode);
|
||||
NS_IMETHOD GetPreviousSibling(nsIDOMNode **aNode);
|
||||
NS_IMETHOD GetNextSibling(nsIDOMNode **aNode);
|
||||
|
@ -194,7 +195,7 @@ public:
|
|||
nsIDOMNode *value,
|
||||
nsIDOMAttribute **aAttribute);
|
||||
NS_IMETHOD CreateAttributeList(nsIDOMAttributeList **aAttributesList);
|
||||
NS_IMETHOD CreateTreeIterator(nsIDOMNode **aNode, nsIDOMTreeIterator **aTreeIterator);
|
||||
NS_IMETHOD CreateTreeIterator(nsIDOMNode *aNode, nsIDOMTreeIterator **aTreeIterator);
|
||||
NS_IMETHOD GetElementsByTagName(nsString &aTagname, nsIDOMNodeIterator **aIterator);
|
||||
|
||||
// nsIDOMEventCapturer interface
|
||||
|
|
|
@ -23,9 +23,11 @@ DEFINES = -D_IMPL_NS_DOM
|
|||
|
||||
EXPORTS = \
|
||||
nsIScriptContext.h \
|
||||
nsIScriptObject.h \
|
||||
nsIJSScriptObject.h \
|
||||
nsIScriptObjectOwner.h \
|
||||
$(NULL)
|
||||
nsIScriptGlobalObject.h \
|
||||
nsIDOMWindow.h \
|
||||
$(NULL)
|
||||
|
||||
MODULE = dom
|
||||
|
||||
|
|
|
@ -20,15 +20,19 @@ DEPTH=../../..
|
|||
DEFINES = -D_IMPL_NS_DOM
|
||||
|
||||
EXPORTS = \
|
||||
nsDOM.h \
|
||||
nsIDOMAttribute.h \
|
||||
nsIDOMComment.h \
|
||||
nsIDOMDocument.h \
|
||||
nsIDOMElement.h \
|
||||
nsIDOMIterators.h \
|
||||
nsIDOMNode.h \
|
||||
nsIDOMPI.h \
|
||||
nsIDOMText.h \
|
||||
nsIDOMAttribute.h \
|
||||
nsIDOMAttributeList.h \
|
||||
nsIDOMComment.h \
|
||||
nsIDOMDOM.h \
|
||||
nsIDOMDocument.h \
|
||||
nsIDOMDocumentContext.h \
|
||||
nsIDOMDocumentFragment.h \
|
||||
nsIDOMElement.h \
|
||||
nsIDOMNode.h \
|
||||
nsIDOMNodeIterator.h \
|
||||
nsIDOMPI.h \
|
||||
nsIDOMText.h \
|
||||
nsIDOMTreeIterator.h
|
||||
$(NULL)
|
||||
|
||||
MODULE = dom
|
||||
|
|
|
@ -19,9 +19,10 @@ DEPTH=..\..\..
|
|||
IGNORE_MANIFEST=1
|
||||
|
||||
DEFINES=-D_IMPL_NS_DOM
|
||||
EXPORTS=nsDOM.h nsIDOMAttribute.h nsIDOMComment.h nsIDOMDocument.h \
|
||||
nsIDOMElement.h nsIDOMIterators.h nsIDOMNode.h nsIDOMPI.h \
|
||||
nsIDOMText.h
|
||||
EXPORTS=nsIDOMAttribute.h nsIDOMAttributeList.h nsIDOMComment.h \
|
||||
nsIDOMDOM.h nsIDOMDocument.h nsIDOMDocumentContext.h \
|
||||
nsIDOMDocumentFragment.h nsIDOMElement.h nsIDOMNode.h \
|
||||
nsIDOMNodeIterator.h nsIDOMPI.h nsIDOMText.h nsIDOMTreeIterator.h
|
||||
MODULE=dom
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
|
|
@ -15,150 +15,37 @@
|
|||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
/* AUTO-GENERATED. DO NOT EDIT!!! */
|
||||
|
||||
#ifndef nsIDOMAttribute_h__
|
||||
#define nsIDOMAttribute_h__
|
||||
|
||||
#include "nsDOM.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIScriptContext.h"
|
||||
|
||||
// forward declaration
|
||||
class nsIDOMNode;
|
||||
class nsIDOMAttribute;
|
||||
|
||||
#define NS_IDOMATTRIBUTE_IID \
|
||||
{ /* 8f6bca77-ce42-11d1-b724-00600891d8c9 */ \
|
||||
0x8f6bca77, 0xce42, 0x11d1, \
|
||||
{0xb7, 0x24, 0x00, 0x60, 0x08, 0x91, 0xd8, 0xc9} }
|
||||
{ 0x6f7652e0, 0xee43, 0x11d1, \
|
||||
{ 0x9b, 0xc3, 0x00, 0x60, 0x08, 0x8c, 0xa6, 0xb3 } }
|
||||
|
||||
/**
|
||||
* The Attribute object represents an attribute in an Element object. Typically the
|
||||
* allowable values for the attribute are defined in a document type definition.
|
||||
* <P>
|
||||
* The attribute's effective value is determined as follows: if this attribute has
|
||||
* been explicitly assigned any value, that value is the attribute's effective value;
|
||||
* otherwise, if there is a declaration for this attribute, and that declaration
|
||||
* includes a default value, then that default value is the attribute's effective value;
|
||||
* otherwise, the attribute has no effective value.) Note, in particular, that an
|
||||
* effective value of the null string would be returned as a Text node instance whose
|
||||
* toString method will return a zero length string (as will toString invoked directly
|
||||
* on this Attribute instance). If the attribute has no effective value, then this
|
||||
* method will return null. Note the toString method on the Attribute instance can
|
||||
* also be used to retrieve the string version of the attribute's value(s).
|
||||
*/
|
||||
class nsIDOMAttribute : public nsISupports {
|
||||
public:
|
||||
/**
|
||||
* Return the name of this attribute.
|
||||
*
|
||||
* @param aName [out] The attribute name
|
||||
* @return <b>NS_OK</b> iff the function succeeds, otherwise an error code
|
||||
*/
|
||||
NS_IMETHOD GetName(nsString &aName) = 0;
|
||||
|
||||
/**
|
||||
* Return the value of this attribute.
|
||||
*
|
||||
* @param aName [out] The attribute value
|
||||
* @return <b>NS_OK</b> iff the function succeeds, otherwise an error code
|
||||
*/
|
||||
NS_IMETHOD GetValue(nsString &aName) = 0;
|
||||
NS_IMETHOD GetValue(nsString& aValue)=0;
|
||||
NS_IMETHOD SetValue(nsString& aValue)=0;
|
||||
|
||||
/**
|
||||
* Set the value of this attribute.
|
||||
*
|
||||
* @param aName [in] The attribute value
|
||||
* @return <b>NS_OK</b> iff the function succeeds, otherwise an error code
|
||||
*/
|
||||
NS_IMETHOD SetValue(nsString &aName) = 0;
|
||||
NS_IMETHOD GetSpecified(PRBool* aSpecified)=0;
|
||||
NS_IMETHOD SetSpecified(PRBool aSpecified)=0;
|
||||
|
||||
/**
|
||||
* If this attribute was explicitly given a value in the original document,
|
||||
* this will be true; otherwise, it will be false.
|
||||
*
|
||||
* @return <b>NS_OK</b> iff the function succeeds, otherwise an error code
|
||||
*/
|
||||
NS_IMETHOD GetSpecified() = 0;
|
||||
NS_IMETHOD GetName(nsString& aReturn)=0;
|
||||
|
||||
/**
|
||||
* Set the specified value
|
||||
*
|
||||
* @param specified [in] The specified value
|
||||
* @return <b>NS_OK</b> iff the function succeeds, otherwise an error code
|
||||
*/
|
||||
NS_IMETHOD SetSpecified(PRBool specified) = 0;
|
||||
|
||||
/**
|
||||
* Returns the attribute as a string. Character and general entity
|
||||
* references will have been replaced with their values in the returned string.
|
||||
*
|
||||
* @param aString [out] The attribute as a string
|
||||
* @return <b>NS_OK</b> iff the function succeeds, otherwise an error code
|
||||
*/
|
||||
NS_IMETHOD ToString(nsString &aString) = 0;
|
||||
NS_IMETHOD ToString(nsString& aReturn)=0;
|
||||
};
|
||||
|
||||
#define NS_IDOMATTRIBUTELIST_IID \
|
||||
{ /* 8f6bca78-ce42-11d1-b724-00600891d8c9 */ \
|
||||
0x8f6bca78, 0xce42, 0x11d1, \
|
||||
{0xb7, 0x24, 0x00, 0x60, 0x08, 0x91, 0xd8, 0xc9} }
|
||||
|
||||
/**
|
||||
* AttributeList objects are used to represent collections of Attribute objects
|
||||
* which can be accessed by name. The Attribute objects contained in a AttributeList
|
||||
* may also be accessed by ordinal index. In most cases, AttributeList objects are
|
||||
* created from Element objects.
|
||||
*/
|
||||
class nsIDOMAttributeList : public nsISupports {
|
||||
public:
|
||||
/**
|
||||
* Retrieve an Attribute instance from the list by its name. If it's not present,
|
||||
* null is returned.
|
||||
*
|
||||
* @param aAttrName [in] The name of atrribute
|
||||
* @param aAttribute [out] The returned attribute
|
||||
* @return <b>NS_OK</b> iff the function succeeds, otherwise an error code
|
||||
*/
|
||||
NS_IMETHOD GetAttribute(nsString &aAttrName, nsIDOMAttribute** aAttribute) = 0;
|
||||
|
||||
/**
|
||||
* Add a new attribute to the end of the list and associate it with the given name.
|
||||
* If the name already exists, the previous Attribute object is replaced, and returned.
|
||||
* If no object of the same name exists, null is returned, and the named Attribute
|
||||
* is added to the end of the AttributeList object; that is, it is accessible via
|
||||
* the item method using the index one less than the value returned by getLength.
|
||||
*
|
||||
* @param aAttribute [in] The attribute to set
|
||||
* @return <b>NS_OK</b> iff the function succeeds, otherwise an error code
|
||||
*/
|
||||
NS_IMETHOD SetAttribute(nsIDOMAttribute *attr) = 0;
|
||||
|
||||
/**
|
||||
* Removes the Attribute instance named name from the list and returns it.
|
||||
*
|
||||
* @param aAttrName [in] The name of atrribute
|
||||
* @param aAttribute [out] The removed attribute
|
||||
* @return <b>NS_OK</b> iff the function succeeds, otherwise an error code
|
||||
*/
|
||||
NS_IMETHOD Remove(nsString &attrName, nsIDOMAttribute** aAttribute) = 0;
|
||||
|
||||
/**
|
||||
* Returns the (zero-based) indexth Attribute item in the collection.
|
||||
*
|
||||
* @param aIndex [in] The index in the list of attributes
|
||||
* @param aAttribute [out] The attribute at that index
|
||||
* @return <b>NS_OK</b> iff the function succeeds, otherwise an error code
|
||||
*/
|
||||
NS_IMETHOD Item(PRUint32 aIndex, nsIDOMAttribute** aAttribute) = 0;
|
||||
|
||||
/**
|
||||
* Returns the number of Attributes in the AttributeList instance.
|
||||
*
|
||||
* @param aLength [out] The attribute list length
|
||||
* @return <b>NS_OK</b> iff the function succeeds, otherwise an error code
|
||||
*/
|
||||
NS_IMETHOD GetLength(PRUint32 *aLength) = 0;
|
||||
};
|
||||
extern nsresult NS_InitAttributeClass(nsIScriptContext *aContext, void **aPrototype);
|
||||
|
||||
extern "C" NS_DOM NS_NewScriptAttribute(nsIScriptContext *aContext, nsIDOMAttribute *aSupports, nsISupports *aParent, void **aReturn);
|
||||
|
||||
#endif // nsIDOMAttribute_h__
|
||||
|
||||
|
|
|
@ -15,24 +15,31 @@
|
|||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
/* AUTO-GENERATED. DO NOT EDIT!!! */
|
||||
|
||||
#ifndef nsIDOMComment_h__
|
||||
#define nsIDOMComment_h__
|
||||
|
||||
#include "nsDOM.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsIDOMNode.h"
|
||||
|
||||
class nsIDOMComment;
|
||||
|
||||
#define NS_IDOMCOMMENT_IID \
|
||||
{ /* 8f6bca7a-ce42-11d1-b724-00600891d8c9 */ \
|
||||
0x8f6bca7a, 0xce42, 0x11d1, \
|
||||
{0xb7, 0x24, 0x00, 0x60, 0x08, 0x91, 0xd8, 0xc9} }
|
||||
{ 0x6f7652e2, 0xee43, 0x11d1, \
|
||||
{ 0x9b, 0xc3, 0x00, 0x60, 0x08, 0x8c, 0xa6, 0xb3 } }
|
||||
|
||||
class nsIDOMComment : public nsIDOMNode {
|
||||
public:
|
||||
//attribute UniString data;
|
||||
NS_IMETHOD GetData(nsString &aData) = 0;
|
||||
NS_IMETHOD SetData(nsString &aData) = 0;
|
||||
|
||||
NS_IMETHOD GetData(nsString& aData)=0;
|
||||
NS_IMETHOD SetData(nsString& aData)=0;
|
||||
};
|
||||
|
||||
#endif // nsIDOMComment_h__
|
||||
extern nsresult NS_InitCommentClass(nsIScriptContext *aContext, void **aPrototype);
|
||||
|
||||
extern "C" NS_DOM NS_NewScriptComment(nsIScriptContext *aContext, nsIDOMComment *aSupports, nsISupports *aParent, void **aReturn);
|
||||
|
||||
#endif // nsIDOMComment_h__
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
/* -*- 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!!! */
|
||||
|
||||
#ifndef nsIDOMDOM_h__
|
||||
#define nsIDOMDOM_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIScriptContext.h"
|
||||
|
||||
class nsIDOMDocument;
|
||||
class nsIDOMDOM;
|
||||
|
||||
#define NS_IDOMDOM_IID \
|
||||
{ 0x6f7652e6, 0xee43, 0x11d1, \
|
||||
{ 0x9b, 0xc3, 0x00, 0x60, 0x08, 0x8c, 0xa6, 0xb3 } }
|
||||
|
||||
class nsIDOMDOM : public nsISupports {
|
||||
public:
|
||||
|
||||
NS_IMETHOD CreateDocument(nsString& aType, nsIDOMDocument** aReturn)=0;
|
||||
|
||||
NS_IMETHOD HasFeature(nsString& aFeature, PRBool* aReturn)=0;
|
||||
};
|
||||
|
||||
extern nsresult NS_InitDOMClass(nsIScriptContext *aContext, void **aPrototype);
|
||||
|
||||
extern "C" NS_DOM NS_NewScriptDOM(nsIScriptContext *aContext, nsIDOMDOM *aSupports, nsISupports *aParent, void **aReturn);
|
||||
|
||||
#endif // nsIDOMDOM_h__
|
|
@ -15,242 +15,65 @@
|
|||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
/* AUTO-GENERATED. DO NOT EDIT!!! */
|
||||
|
||||
#ifndef nsIDOMDocument_h__
|
||||
#define nsIDOMDocument_h__
|
||||
|
||||
#include "nsDOM.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsIDOMDocumentFragment.h"
|
||||
|
||||
// forward declaration
|
||||
class nsIDOMDocument;
|
||||
class nsIDOMElement;
|
||||
class nsIDOMText;
|
||||
class nsIDOMComment;
|
||||
class nsIDOMPI;
|
||||
class nsIDOMAttribute;
|
||||
class nsIDOMAttributeList;
|
||||
class nsIDOMElement;
|
||||
class nsIDOMPI;
|
||||
class nsIDOMNodeIterator;
|
||||
class nsIDOMDocument;
|
||||
class nsIDOMTreeIterator;
|
||||
|
||||
#define NS_IDOMDOCUMENTCONTEXT_IID \
|
||||
{ /* 8f6bca71-ce42-11d1-b724-00600891d8c9 */ \
|
||||
0x8f6bca71, 0xce42, 0x11d1, \
|
||||
{0xb7, 0x24, 0x00, 0x60, 0x08, 0x91, 0xd8, 0xc9} }
|
||||
|
||||
/**
|
||||
* The DocumentContext object represents information that is not strictly related
|
||||
* to a document's content; rather, it provides the information about where the
|
||||
* document came from, and any additional meta-data about the document
|
||||
*/
|
||||
class nsIDOMDocumentContext : public nsISupports {
|
||||
public:
|
||||
/**
|
||||
* Return the root node of a Document Object Model.
|
||||
*
|
||||
* @param aDocument [out] The root node of a Document Object Model
|
||||
* @return <b>NS_OK</b> iff the function succeeds, otherwise an error code
|
||||
*/
|
||||
NS_IMETHOD GetDocument(nsIDOMDocument **aDocument) = 0;
|
||||
|
||||
/**
|
||||
* Set the root node of a Document Object Model.
|
||||
*
|
||||
* @param aDocument [in] The root node of a Document Object Model
|
||||
* @return <b>NS_OK</b> iff the function succeeds, otherwise an error code
|
||||
*/
|
||||
NS_IMETHOD SetDocument(nsIDOMDocument *aDocument) = 0;
|
||||
};
|
||||
|
||||
#define NS_IDOMDOCUMENTFRAGMENT_IID \
|
||||
{ /* 8f6bca72-ce42-11d1-b724-00600891d8c9 */ \
|
||||
0x8f6bca72, 0xce42, 0x11d1, \
|
||||
{0xb7, 0x24, 0x00, 0x60, 0x08, 0x91, 0xd8, 0xc9} }
|
||||
|
||||
/**
|
||||
* DocumentFragment is the "lightweight" or "minimal" document object, or the
|
||||
* handle for a "fragment" as returned by the Range operations, and it
|
||||
* (as the superclass of Document) anchors the XML/HTML tree in a full-fledged document
|
||||
*/
|
||||
class nsIDOMDocumentFragment : public nsIDOMNode {
|
||||
public:
|
||||
/**
|
||||
* Return the Document object associated with this DocumentFragment
|
||||
*
|
||||
* @param aDocument [out] The main Document
|
||||
* @return <b>NS_OK</b> iff the function succeeds, otherwise an error code
|
||||
*/
|
||||
NS_IMETHOD GetMasterDoc(nsIDOMDocument **aDocument) = 0;
|
||||
|
||||
/**
|
||||
* Set the Document object associated with this DocumentFragment
|
||||
*
|
||||
* @param aDocument [in] The main Document
|
||||
* @return <b>NS_OK</b> iff the function succeeds, otherwise an error code
|
||||
*/
|
||||
NS_IMETHOD SetMasterDoc(nsIDOMDocument *aDocument) = 0;
|
||||
};
|
||||
class nsIDOMAttribute;
|
||||
class nsIDOMNode;
|
||||
class nsIDOMText;
|
||||
class nsIDOMDocumentContext;
|
||||
class nsIDOMComment;
|
||||
|
||||
#define NS_IDOMDOCUMENT_IID \
|
||||
{ /* 8f6bca73-ce42-11d1-b724-00600891d8c9 */ \
|
||||
0x8f6bca73, 0xce42, 0x11d1, \
|
||||
{0xb7, 0x24, 0x00, 0x60, 0x08, 0x91, 0xd8, 0xc9} }
|
||||
{ 0x6f7652e3, 0xee43, 0x11d1, \
|
||||
{ 0x9b, 0xc3, 0x00, 0x60, 0x08, 0x8c, 0xa6, 0xb3 } }
|
||||
|
||||
/**
|
||||
* The Document object represents the entire HTML or XML document. Conceptually,
|
||||
* it is the root of the document tree, and provides the primary access to the
|
||||
* document's data. Since Document inherits from DocumentFragment, its children are
|
||||
* contents of the Document, e.g., the root Element, the XML prolog, any processing
|
||||
* instructions and or comments, etc.
|
||||
*<P> Since Elements, Text nodes, Comments, PIs, etc. cannot exist outside a Document,
|
||||
* the Document interface also anchors the "factory" methods that create these objects.
|
||||
*/
|
||||
class nsIDOMDocument : public nsIDOMDocumentFragment {
|
||||
public:
|
||||
/**
|
||||
* For XML, this provides access to the Document Type Definition (see DocumentType)
|
||||
* associated with this XML document. For HTML documents and XML documents without
|
||||
* a document type definition this returns the value null.
|
||||
*
|
||||
* @param aDocType [out] The document type
|
||||
* @return <b>NS_OK</b> iff the function succeeds, otherwise an error code
|
||||
*/
|
||||
NS_IMETHOD GetDocumentType(nsIDOMNode **aDocType) = 0;
|
||||
public:
|
||||
|
||||
/**
|
||||
* For XML, this sets the Document Type Definition (see DocumentType)
|
||||
* associated with this XML document. For HTML documents and XML documents without
|
||||
* a document type definition this is a noop.
|
||||
*
|
||||
* @param aDocType [in] The document type
|
||||
* @return <b>NS_OK</b> iff the function succeeds, otherwise an error code
|
||||
*/
|
||||
NS_IMETHOD SetDocumentType(nsIDOMNode *aNode) = 0;
|
||||
|
||||
/**
|
||||
* This is a "convenience" function to jump directly to the child node
|
||||
* that is the root element of the document
|
||||
*
|
||||
* @param aElement [out] The root element
|
||||
* @return <b>NS_OK</b> iff the function succeeds, otherwise an error code
|
||||
*/
|
||||
NS_IMETHOD GetDocumentElement(nsIDOMElement **aElement) = 0;
|
||||
NS_IMETHOD GetDocumentType(nsIDOMNode** aDocumentType)=0;
|
||||
NS_IMETHOD SetDocumentType(nsIDOMNode* aDocumentType)=0;
|
||||
|
||||
/**
|
||||
* This is a "convenience" function to set the child node
|
||||
* that is the root element of the document
|
||||
*
|
||||
* @param aElement [out] The root element
|
||||
* @return <b>NS_OK</b> iff the function succeeds, otherwise an error code
|
||||
*/
|
||||
NS_IMETHOD SetDocumentElement(nsIDOMElement *aElement) = 0;
|
||||
NS_IMETHOD GetDocumentElement(nsIDOMElement** aDocumentElement)=0;
|
||||
NS_IMETHOD SetDocumentElement(nsIDOMElement* aDocumentElement)=0;
|
||||
|
||||
/**
|
||||
* Return the DocumentContext
|
||||
*
|
||||
* @param aContext [out] The DocumentContext
|
||||
* @return <b>NS_OK</b> iff the function succeeds, otherwise an error code
|
||||
*/
|
||||
NS_IMETHOD GetDocumentContext(nsIDOMDocumentContext **aDocContext) = 0;
|
||||
NS_IMETHOD GetDocumentContext(nsIDOMDocumentContext** aDocumentContext)=0;
|
||||
NS_IMETHOD SetDocumentContext(nsIDOMDocumentContext* aDocumentContext)=0;
|
||||
|
||||
/**
|
||||
* Set the DocumentContext
|
||||
*
|
||||
* @param aContext [in] The DocumentContext
|
||||
* @return <b>NS_OK</b> iff the function succeeds, otherwise an error code
|
||||
*/
|
||||
NS_IMETHOD SetDocumentContext(nsIDOMDocumentContext *aContext) = 0;
|
||||
NS_IMETHOD CreateDocumentContext(nsIDOMDocumentContext** aReturn)=0;
|
||||
|
||||
/**
|
||||
* Create and return a new DocumentContext.
|
||||
*
|
||||
* @param aDocContext [out] The new context
|
||||
* @return <b>NS_OK</b> iff the function succeeds, otherwise an error code
|
||||
*/
|
||||
NS_IMETHOD CreateDocumentContext(nsIDOMDocumentContext **aDocContext) = 0;
|
||||
NS_IMETHOD CreateElement(nsString& aTagName, nsIDOMAttributeList* aAttributes, nsIDOMElement** aReturn)=0;
|
||||
|
||||
/**
|
||||
* Create an element based on the tagName. Note that the instance returned may
|
||||
* implement an interface derived from Element. The attributes parameter can be
|
||||
* null if no attributes are specified for the new Element
|
||||
*
|
||||
* @param aTagName [in] The name of the element type to instantiate
|
||||
* @param aAttributes [in] The set of attributes for the element
|
||||
* @param aElement [out] The new element
|
||||
* @return <b>NS_OK</b> iff the function succeeds, otherwise an error code
|
||||
*/
|
||||
NS_IMETHOD CreateElement(nsString &aTagName,
|
||||
nsIDOMAttributeList *aAttributes,
|
||||
nsIDOMElement **aElement) = 0;
|
||||
NS_IMETHOD CreateTextNode(nsString& aData, nsIDOMText** aReturn)=0;
|
||||
|
||||
/**
|
||||
* Create and return a new Text node.
|
||||
*
|
||||
* @param aData [in] The data for the node
|
||||
* @param aTextNode [out] The new text node
|
||||
* @return <b>NS_OK</b> iff the function succeeds, otherwise an error code
|
||||
*/
|
||||
NS_IMETHOD CreateTextNode(nsString &aData, nsIDOMText** aTextNode) = 0;
|
||||
NS_IMETHOD CreateComment(nsString& aData, nsIDOMComment** aReturn)=0;
|
||||
|
||||
/**
|
||||
* Create a Comment node given the specified string
|
||||
*
|
||||
* @param aData [in] The data for the node
|
||||
* @param aComment [out] The new Comment object.
|
||||
* @return <b>NS_OK</b> iff the function succeeds, otherwise an error code
|
||||
*/
|
||||
NS_IMETHOD CreateComment(nsString &aData, nsIDOMComment **aComment) = 0;
|
||||
NS_IMETHOD CreatePI(nsString& aName, nsString& aData, nsIDOMPI** aReturn)=0;
|
||||
|
||||
/**
|
||||
* Create a PI node given the specified name and data strings.
|
||||
*
|
||||
* @param aName [in] The name part of the PI.
|
||||
* @param aData [in] The data for the node.
|
||||
* @param aPI [out] The new PI object
|
||||
* @return <b>NS_OK</b> iff the function succeeds, otherwise an error code
|
||||
*/
|
||||
NS_IMETHOD CreatePI(nsString &aName, nsString &aData, nsIDOMPI **aPI) = 0;
|
||||
NS_IMETHOD CreateAttribute(nsString& aName, nsIDOMNode* aValue, nsIDOMAttribute** aReturn)=0;
|
||||
|
||||
/**
|
||||
* Create an Attribute of the given name and specified value. Note that the
|
||||
* Attribute instance can then be set on an Element using the setAttribute method
|
||||
*
|
||||
* @param aName [in] The name of the attribute
|
||||
* @param value [in] The value of the attribute.
|
||||
* @param aAttribute [out] A new Attribute object.
|
||||
* @return <b>NS_OK</b> iff the function succeeds, otherwise an error code
|
||||
*/
|
||||
NS_IMETHOD CreateAttribute(nsString &aName,
|
||||
nsIDOMNode *value,
|
||||
nsIDOMAttribute **aAttribute) = 0;
|
||||
|
||||
/**
|
||||
* Create an empty AttributeList
|
||||
*
|
||||
* @param aAttributesList [out] The new AttributeList
|
||||
* @return <b>NS_OK</b> iff the function succeeds, otherwise an error code
|
||||
*/
|
||||
NS_IMETHOD CreateAttributeList(nsIDOMAttributeList **aAttributesList) = 0;
|
||||
NS_IMETHOD CreateAttributeList(nsIDOMAttributeList** aReturn)=0;
|
||||
|
||||
/**
|
||||
* Create a TreeIterator anchored on a given node.
|
||||
*
|
||||
* @param aNode [in] The "root" node of this tree iterator.
|
||||
* @param aTreeIterator [out] A new TreeIterator object.
|
||||
* @return <b>NS_OK</b> iff the function succeeds, otherwise an error code
|
||||
*/
|
||||
NS_IMETHOD CreateTreeIterator(nsIDOMNode **aNode, nsIDOMTreeIterator **aTreeIterator) = 0;
|
||||
NS_IMETHOD CreateTreeIterator(nsIDOMNode* aNode, nsIDOMTreeIterator** aReturn)=0;
|
||||
|
||||
/**
|
||||
* Returns an iterator through all subordinate Elements with a given tag name.
|
||||
*
|
||||
* @param aTagname [in] The name of the tag to match on
|
||||
* @param aIterator [out] A new NodeIterator object.
|
||||
* @return <b>NS_OK</b> iff the function succeeds, otherwise an error code
|
||||
*/
|
||||
NS_IMETHOD GetElementsByTagName(nsString &aTagname, nsIDOMNodeIterator **aIterator) = 0;
|
||||
NS_IMETHOD GetElementsByTagName(nsString& aTagname, nsIDOMNodeIterator** aReturn)=0;
|
||||
};
|
||||
|
||||
#endif // nsIDOMDocument_h__
|
||||
extern nsresult NS_InitDocumentClass(nsIScriptContext *aContext, void **aPrototype);
|
||||
|
||||
extern "C" NS_DOM NS_NewScriptDocument(nsIScriptContext *aContext, nsIDOMDocument *aSupports, nsISupports *aParent, void **aReturn);
|
||||
|
||||
#endif // nsIDOMDocument_h__
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
/* -*- 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!!! */
|
||||
|
||||
#ifndef nsIDOMDocumentFragment_h__
|
||||
#define nsIDOMDocumentFragment_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsIDOMNode.h"
|
||||
|
||||
class nsIDOMDocument;
|
||||
class nsIDOMDocumentFragment;
|
||||
|
||||
#define NS_IDOMDOCUMENTFRAGMENT_IID \
|
||||
{ 0x6f7652e5, 0xee43, 0x11d1, \
|
||||
{ 0x9b, 0xc3, 0x00, 0x60, 0x08, 0x8c, 0xa6, 0xb3 } }
|
||||
|
||||
class nsIDOMDocumentFragment : public nsIDOMNode {
|
||||
public:
|
||||
|
||||
NS_IMETHOD GetMasterDoc(nsIDOMDocument** aMasterDoc)=0;
|
||||
NS_IMETHOD SetMasterDoc(nsIDOMDocument* aMasterDoc)=0;
|
||||
};
|
||||
|
||||
extern nsresult NS_InitDocumentFragmentClass(nsIScriptContext *aContext, void **aPrototype);
|
||||
|
||||
extern "C" NS_DOM NS_NewScriptDocumentFragment(nsIScriptContext *aContext, nsIDOMDocumentFragment *aSupports, nsISupports *aParent, void **aReturn);
|
||||
|
||||
#endif // nsIDOMDocumentFragment_h__
|
|
@ -15,119 +15,51 @@
|
|||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
/* AUTO-GENERATED. DO NOT EDIT!!! */
|
||||
|
||||
#ifndef nsIDOMElement_h__
|
||||
#define nsIDOMElement_h__
|
||||
|
||||
#include "nsDOM.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsIDOMNode.h"
|
||||
|
||||
// forward declaration
|
||||
class nsIDOMAttribute;
|
||||
class nsIDOMAttributeList;
|
||||
class nsIDOMElement;
|
||||
class nsIDOMNodeIterator;
|
||||
class nsIDOMAttribute;
|
||||
|
||||
#define NS_IDOMELEMENT_IID \
|
||||
{ /* 8f6bca79-ce42-11d1-b724-00600891d8c9 */ \
|
||||
0x8f6bca79, 0xce42, 0x11d1, \
|
||||
{0xb7, 0x24, 0x00, 0x60, 0x08, 0x91, 0xd8, 0xc9} }
|
||||
{ 0x6f7652e7, 0xee43, 0x11d1, \
|
||||
{ 0x9b, 0xc3, 0x00, 0x60, 0x08, 0x8c, 0xa6, 0xb3 } }
|
||||
|
||||
/**
|
||||
* By far the vast majority (apart from text) of node types that authors will generally
|
||||
* encounter when traversing a document will be Element nodes. These objects represent
|
||||
* both the element itself, as well as any contained nodes.
|
||||
*/
|
||||
class nsIDOMElement : public nsIDOMNode {
|
||||
public:
|
||||
/**
|
||||
* This method returns the string that is the element's name
|
||||
*
|
||||
* @param newChild [out] The tag name
|
||||
* @return <b>NS_OK</b> iff the function succeeds, otherwise an error code
|
||||
*/
|
||||
NS_IMETHOD GetTagName(nsString &aName) = 0;
|
||||
|
||||
/**
|
||||
* The attributes for this element.
|
||||
*
|
||||
* @param aAttributeList [out] The AttributeList
|
||||
* @return <b>NS_OK</b> iff the function succeeds, otherwise an error code
|
||||
*/
|
||||
NS_IMETHOD GetAttributes(nsIDOMAttributeList **aAttributeList) = 0;
|
||||
NS_IMETHOD GetTagName(nsString& aReturn)=0;
|
||||
|
||||
/**
|
||||
* Retrieves an attribute value by name from an Element object.
|
||||
* <I> NOTE: the name of this function will change to GetAttribute in a subsequent
|
||||
* release </I>
|
||||
*
|
||||
* @param aName [in] The attribute name
|
||||
* @param aValue [out] The attribute value as a string
|
||||
* @return <b>NS_OK</b> iff the function succeeds, otherwise an error code
|
||||
*/
|
||||
NS_IMETHOD GetDOMAttribute(nsString &aName, nsString &aValue) = 0;
|
||||
NS_IMETHOD GetAttributes(nsIDOMAttributeList** aReturn)=0;
|
||||
|
||||
/**
|
||||
* Set an attribute value from an Element object.
|
||||
* <I> NOTE: the name of this function will change to SetAttribute in a subsequent
|
||||
* release </I>
|
||||
*
|
||||
* @param aName [in] The attribute name
|
||||
* @param aValue [in] The attribute value as a string
|
||||
* @return <b>NS_OK</b> iff the function succeeds, otherwise an error code
|
||||
*/
|
||||
NS_IMETHOD SetDOMAttribute(nsString &aName, nsString &aValue) = 0;
|
||||
NS_IMETHOD GetDOMAttribute(nsString& aName, nsString& aReturn)=0;
|
||||
|
||||
/**
|
||||
* Remove the specified attribute
|
||||
*
|
||||
* @param aName [in] The attribute name
|
||||
* @return <b>NS_OK</b> iff the function succeeds, otherwise an error code
|
||||
*/
|
||||
NS_IMETHOD RemoveAttribute(nsString &aName) = 0;
|
||||
NS_IMETHOD SetDOMAttribute(nsString& aName, nsString& aValue)=0;
|
||||
|
||||
/**
|
||||
* Retrieves an Attribute node by name from an Element object.
|
||||
*
|
||||
* @param aName [in] The name of the attribute to retrieve
|
||||
* @param aAttribute [out] The attribute with the given name
|
||||
* @return <b>NS_OK</b> iff the function succeeds, otherwise an error code
|
||||
*/
|
||||
NS_IMETHOD GetAttributeNode(nsString &aName, nsIDOMAttribute **aAttribute) = 0;
|
||||
NS_IMETHOD RemoveAttribute(nsString& aName)=0;
|
||||
|
||||
/**
|
||||
* Set an Attribute node by name from an Element object.
|
||||
*
|
||||
* @param aAttribute [in] The attribute to set
|
||||
* @return <b>NS_OK</b> iff the function succeeds, otherwise an error code
|
||||
*/
|
||||
NS_IMETHOD SetAttributeNode(nsIDOMAttribute *aAttribute) = 0;
|
||||
NS_IMETHOD GetAttributeNode(nsString& aName, nsIDOMAttribute** aReturn)=0;
|
||||
|
||||
/**
|
||||
* Removes the specified attribute/value pair from an Element node object.
|
||||
*
|
||||
* @param aAttribute [in] The attribute to remove
|
||||
* @return <b>NS_OK</b> iff the function succeeds, otherwise an error code
|
||||
*/
|
||||
NS_IMETHOD RemoveAttributeNode(nsIDOMAttribute *aAttribute) = 0;
|
||||
NS_IMETHOD SetAttributeNode(nsIDOMAttribute* aNewAttr)=0;
|
||||
|
||||
/**
|
||||
* Returns an iterator through all subordinate elements with a given tag name.
|
||||
*
|
||||
* @param aName [in] The name of the tag to match on
|
||||
* @param aIterator [out] The iterator
|
||||
* @return <b>NS_OK</b> iff the function succeeds, otherwise an error code
|
||||
*/
|
||||
NS_IMETHOD GetElementsByTagName(nsString &aName,nsIDOMNodeIterator **aIterator) = 0;
|
||||
NS_IMETHOD RemoveAttributeNode(nsIDOMAttribute* aOldAttr)=0;
|
||||
|
||||
/**
|
||||
* Puts all Tet nodes in the sub-tree underneath this Element into a "normal"
|
||||
* form where only markup (e.g., tags, comments, PIs, CDATASections, and and
|
||||
* entity references separates Text nodes.
|
||||
*
|
||||
* @return <b>NS_OK</b> iff the function succeeds, otherwise an error code
|
||||
*/
|
||||
NS_IMETHOD Normalize() = 0;
|
||||
NS_IMETHOD GetElementsByTagName(nsString& aTagname, nsIDOMNodeIterator** aReturn)=0;
|
||||
|
||||
NS_IMETHOD Normalize()=0;
|
||||
};
|
||||
|
||||
#endif // nsIDOMElement_h__
|
||||
extern nsresult NS_InitElementClass(nsIScriptContext *aContext, void **aPrototype);
|
||||
|
||||
extern "C" NS_DOM NS_NewScriptElement(nsIScriptContext *aContext, nsIDOMElement *aSupports, nsISupports *aParent, void **aReturn);
|
||||
|
||||
#endif // nsIDOMElement_h__
|
||||
|
|
|
@ -15,139 +15,56 @@
|
|||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
/* AUTO-GENERATED. DO NOT EDIT!!! */
|
||||
|
||||
#ifndef nsIDOMNode_h__
|
||||
#define nsIDOMNode_h__
|
||||
|
||||
#include "nsDOM.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIScriptContext.h"
|
||||
|
||||
// forward declaration
|
||||
class nsIDOMNodeIterator;
|
||||
class nsIDOMNode;
|
||||
|
||||
#define NS_IDOMNODE_IID \
|
||||
{ /* 8f6bca74-ce42-11d1-b724-00600891d8c9 */ \
|
||||
0x8f6bca74, 0xce42, 0x11d1, \
|
||||
{0xb7, 0x24, 0x00, 0x60, 0x08, 0x91, 0xd8, 0xc9} }
|
||||
{ 0x6f7652e8, 0xee43, 0x11d1, \
|
||||
{ 0x9b, 0xc3, 0x00, 0x60, 0x08, 0x8c, 0xa6, 0xb3 } }
|
||||
|
||||
/**
|
||||
* The Node object is the primary datatype for the entire Document
|
||||
* Object Model. It represents a single node in the document
|
||||
* tree. Nodes may have, but are not required to have, an arbitrary
|
||||
* number of child nodes. */
|
||||
class nsIDOMNode : public nsISupports {
|
||||
public:
|
||||
// NodeType
|
||||
enum NodeType {
|
||||
DOCUMENT = 1,
|
||||
ELEMENT = 2,
|
||||
ATTRIBUTE = 3,
|
||||
PI = 4,
|
||||
COMMENT = 5,
|
||||
TEXT = 6
|
||||
enum {
|
||||
DOCUMENT = 1,
|
||||
ELEMENT = 2,
|
||||
ATTRIBUTE = 3,
|
||||
PI = 4,
|
||||
COMMENT = 5,
|
||||
TEXT = 6
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns an indication of the underlying Node object's type.
|
||||
*
|
||||
* @param aType [out] The type of the node.
|
||||
* @return <b>NS_OK</b> iff the function succeeds, otherwise an error code
|
||||
*/
|
||||
NS_IMETHOD GetNodeType(PRInt32 *aType) = 0;
|
||||
NS_IMETHOD GetNodeType(PRInt32* aReturn)=0;
|
||||
|
||||
/**
|
||||
* Returns the parent of the given Node instance. If this node is
|
||||
* the root of the document object tree, or if the node has not been
|
||||
* added to a document tree, null is returned.
|
||||
*
|
||||
* @param aNode [out] The parent of the node.
|
||||
* @return <b>NS_OK</b> iff the function succeeds, otherwise an error code
|
||||
*/
|
||||
NS_IMETHOD GetParentNode(nsIDOMNode **aNode) = 0;
|
||||
NS_IMETHOD GetParentNode(nsIDOMNode** aReturn)=0;
|
||||
|
||||
/**
|
||||
* Returns a NodeIterator object that will enumerate all children
|
||||
* of this node. If there are no children, an iterator that will
|
||||
* return no nodes is returned. The content of the returned
|
||||
* NodeIterator is "live" in the sense that changes to the children
|
||||
* of the Node object that it was created from will be immediately
|
||||
* reflected in the nodes returned by the iterator; it is not a
|
||||
* static snapshot of the content of the Node. Similarly, changes
|
||||
* made to the nodes returned by the iterator will be immediately
|
||||
* reflected in the tree, including the set of children of the Node
|
||||
* that the NodeIterator was created from.
|
||||
*
|
||||
* @param aIterator [out] An iterator through the children of the node.
|
||||
* @return <b>NS_OK</b> iff the function succeeds, otherwise an error code
|
||||
*/
|
||||
NS_IMETHOD GetChildNodes(nsIDOMNodeIterator **aIterator) = 0;
|
||||
|
||||
/**
|
||||
* Returns true if the node has any children, false if the node has
|
||||
* no children at all.
|
||||
*
|
||||
* @return <b>NS_OK</b> iff the function succeeds, otherwise an error code
|
||||
*/
|
||||
NS_IMETHOD HasChildNodes() = 0;
|
||||
NS_IMETHOD GetChildNodes(nsIDOMNodeIterator** aReturn)=0;
|
||||
|
||||
/**
|
||||
* Returns the first child of a node. If there is no such node,
|
||||
* null is returned.
|
||||
*
|
||||
* @param aNode [out] The first child of the node, or null.
|
||||
* @return <b>NS_OK</b> iff the function succeeds, otherwise an error code
|
||||
*/
|
||||
NS_IMETHOD GetFirstChild(nsIDOMNode **aNode) = 0;
|
||||
|
||||
/**
|
||||
* Returns the node immediately preceding the current node in a
|
||||
* breadth-first traversal of the tree. If there is no such node,
|
||||
* null is returned.
|
||||
*
|
||||
* @param aNode [out] The the node immediately preceeding, or null.
|
||||
* @return <b>NS_OK</b> iff the function succeeds, otherwise an error code
|
||||
*/
|
||||
NS_IMETHOD GetPreviousSibling(nsIDOMNode **aNode) = 0;
|
||||
NS_IMETHOD HasChildNodes(PRBool* aReturn)=0;
|
||||
|
||||
/**
|
||||
* Returns the node immediately following the current node in a
|
||||
* breadth-first traversal of the tree. If there is no such node,
|
||||
* null is returned.
|
||||
*
|
||||
* @param aNode [out] The node immediately following, or null.
|
||||
* @return <b>NS_OK</b> iff the function succeeds, otherwise an error code
|
||||
*/
|
||||
NS_IMETHOD GetNextSibling(nsIDOMNode **aNode) = 0;
|
||||
|
||||
/**
|
||||
* Inserts a child node (newChildbefore the existing child node refChild.
|
||||
* If refChild is null, insert newChild at the end of the list of children.
|
||||
*
|
||||
* @param newChild [in] The node to be inserted
|
||||
* @param refChild [in] The node before which the new node will be inserted
|
||||
* @return <b>NS_OK</b> iff the function succeeds, otherwise an error code
|
||||
*/
|
||||
NS_IMETHOD InsertBefore(nsIDOMNode *newChild, nsIDOMNode *refChild) = 0;
|
||||
|
||||
/**
|
||||
* Replaces the child node oldChild with newChild in the set of
|
||||
* children of the given node, and return the oldChild node.
|
||||
*
|
||||
* @param newChild [in] The node to be inserted
|
||||
* @param oldChild [in] The node to be replaced
|
||||
* @return <b>NS_OK</b> iff the function succeeds, otherwise an error code
|
||||
*/
|
||||
NS_IMETHOD ReplaceChild(nsIDOMNode *newChild, nsIDOMNode *oldChild) = 0;
|
||||
NS_IMETHOD GetFirstChild(nsIDOMNode** aReturn)=0;
|
||||
|
||||
/**
|
||||
* Removes the child node indicated by oldChild from the list of
|
||||
* children and returns it.
|
||||
*
|
||||
* @param oldChild [in] The node to be deleted
|
||||
* @return <b>NS_OK</b> iff the function succeeds, otherwise an error code
|
||||
*/
|
||||
NS_IMETHOD RemoveChild(nsIDOMNode *oldChild) = 0;
|
||||
NS_IMETHOD GetPreviousSibling(nsIDOMNode** aReturn)=0;
|
||||
|
||||
NS_IMETHOD GetNextSibling(nsIDOMNode** aReturn)=0;
|
||||
|
||||
NS_IMETHOD InsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild)=0;
|
||||
|
||||
NS_IMETHOD ReplaceChild(nsIDOMNode* aNewChild, nsIDOMNode* aOldChild)=0;
|
||||
|
||||
NS_IMETHOD RemoveChild(nsIDOMNode* aOldChild)=0;
|
||||
};
|
||||
|
||||
#endif // nsIDOMNode_h__
|
||||
extern nsresult NS_InitNodeClass(nsIScriptContext *aContext, void **aPrototype);
|
||||
|
||||
extern "C" NS_DOM NS_NewScriptNode(nsIScriptContext *aContext, nsIDOMNode *aSupports, nsISupports *aParent, void **aReturn);
|
||||
|
||||
#endif // nsIDOMNode_h__
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
/* -*- 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!!! */
|
||||
|
||||
#ifndef nsIDOMNodeIterator_h__
|
||||
#define nsIDOMNodeIterator_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIScriptContext.h"
|
||||
|
||||
class nsIDOMNodeIterator;
|
||||
class nsIDOMNode;
|
||||
|
||||
#define NS_IDOMNODEITERATOR_IID \
|
||||
{ 0x6f7652e9, 0xee43, 0x11d1, \
|
||||
{ 0x9b, 0xc3, 0x00, 0x60, 0x08, 0x8c, 0xa6, 0xb3 } }
|
||||
|
||||
class nsIDOMNodeIterator : public nsISupports {
|
||||
public:
|
||||
|
||||
NS_IMETHOD GetLength(PRUint32* aReturn)=0;
|
||||
|
||||
NS_IMETHOD GetCurrentNode(nsIDOMNode** aReturn)=0;
|
||||
|
||||
NS_IMETHOD GetNextNode(nsIDOMNode** aReturn)=0;
|
||||
|
||||
NS_IMETHOD GetPreviousNode(nsIDOMNode** aReturn)=0;
|
||||
|
||||
NS_IMETHOD ToFirst(nsIDOMNode** aReturn)=0;
|
||||
|
||||
NS_IMETHOD ToLast(nsIDOMNode** aReturn)=0;
|
||||
|
||||
NS_IMETHOD MoveTo(PRInt32 aN, nsIDOMNode** aReturn)=0;
|
||||
};
|
||||
|
||||
extern nsresult NS_InitNodeIteratorClass(nsIScriptContext *aContext, void **aPrototype);
|
||||
|
||||
extern "C" NS_DOM NS_NewScriptNodeIterator(nsIScriptContext *aContext, nsIDOMNodeIterator *aSupports, nsISupports *aParent, void **aReturn);
|
||||
|
||||
#endif // nsIDOMNodeIterator_h__
|
|
@ -15,23 +15,34 @@
|
|||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
/* AUTO-GENERATED. DO NOT EDIT!!! */
|
||||
|
||||
#ifndef nsIDOMPI_h__
|
||||
#define nsIDOMPI_h__
|
||||
|
||||
#include "nsDOM.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsIDOMNode.h"
|
||||
|
||||
class nsIDOMPI;
|
||||
|
||||
#define NS_IDOMPI_IID \
|
||||
{ 0x6f7652ea, 0xee43, 0x11d1, \
|
||||
{ 0x9b, 0xc3, 0x00, 0x60, 0x08, 0x8c, 0xa6, 0xb3 } }
|
||||
|
||||
class nsIDOMPI : public nsIDOMNode {
|
||||
public:
|
||||
//attribute UniString name;
|
||||
virtual UniString GetName() = 0;
|
||||
virtual void SetName(UniString name) = 0;
|
||||
//attribute UniString data;
|
||||
virtual UniString GetData() = 0;
|
||||
virtual void SetData(UniString data) = 0;
|
||||
|
||||
NS_IMETHOD GetName(nsString& aName)=0;
|
||||
NS_IMETHOD SetName(nsString& aName)=0;
|
||||
|
||||
NS_IMETHOD GetData(nsString& aData)=0;
|
||||
NS_IMETHOD SetData(nsString& aData)=0;
|
||||
};
|
||||
|
||||
#endif // nsIDOMPI_h__
|
||||
extern nsresult NS_InitPIClass(nsIScriptContext *aContext, void **aPrototype);
|
||||
|
||||
extern "C" NS_DOM NS_NewScriptPI(nsIScriptContext *aContext, nsIDOMPI *aSupports, nsISupports *aParent, void **aReturn);
|
||||
|
||||
#endif // nsIDOMPI_h__
|
||||
|
|
|
@ -15,106 +15,42 @@
|
|||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
/* AUTO-GENERATED. DO NOT EDIT!!! */
|
||||
|
||||
#ifndef nsIDOMText_h__
|
||||
#define nsIDOMText_h__
|
||||
|
||||
#include "nsDOM.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsIDOMNode.h"
|
||||
|
||||
// forward declaration
|
||||
class nsIDOMElement;
|
||||
class nsIDOMText;
|
||||
|
||||
/* 8f6bca7b-ce42-11d1-b724-00600891d8c9 */
|
||||
#define NS_IDOMTEXT_IID \
|
||||
{ 0x8f6bca7b, 0xce42, 0x11d1, {0xb7, 0x24, 0x00, 0x60, 0x08, 0x91, 0xd8, 0xc9}}
|
||||
{ 0x6f7652eb, 0xee43, 0x11d1, \
|
||||
{ 0x9b, 0xc3, 0x00, 0x60, 0x08, 0x8c, 0xa6, 0xb3 } }
|
||||
|
||||
/**
|
||||
* The Text object contains the non-markup content of an Element. If
|
||||
* there is no markup inside an Element's content, the text will be
|
||||
* contained in a single Text object that is the child of the
|
||||
* Element. Any markup will parse into child elements that are
|
||||
* siblings of the Text nodes on either side of it, and whose content
|
||||
* will be represented as Text node children of the markup element.
|
||||
*/
|
||||
class nsIDOMText : public nsIDOMNode {
|
||||
public:
|
||||
/**
|
||||
* Return the actual content of the text node. Text nodes contain
|
||||
* just plain text, without markup and without entities, both of
|
||||
* which are represented as separate objects in the DOM.
|
||||
*
|
||||
* @param aString [out] The text data
|
||||
* @return <b>NS_OK</b> iff the function succeeds, otherwise an error code
|
||||
*/
|
||||
NS_IMETHOD GetData(nsString& aString) = 0;
|
||||
|
||||
/**
|
||||
* Set the actual content of the text node. Text nodes contain just
|
||||
* plain text, without markup and without entities, both of which
|
||||
* are represented as separate objects in the DOM.
|
||||
*
|
||||
* @param aString [in] The text data
|
||||
* @return <b>NS_OK</b> iff the function succeeds, otherwise an error code
|
||||
*/
|
||||
NS_IMETHOD SetData(const nsString& aString) = 0;
|
||||
NS_IMETHOD GetData(nsString& aData)=0;
|
||||
NS_IMETHOD SetData(nsString& aData)=0;
|
||||
|
||||
/**
|
||||
* Append the string to the end of the character data in this Text node
|
||||
*
|
||||
* @param aData [in] The data to append
|
||||
* @return <b>NS_OK</b> iff the function succeeds, otherwise an error code
|
||||
*/
|
||||
NS_IMETHOD Append(const nsString& aData) = 0;
|
||||
NS_IMETHOD Append(nsString& aData)=0;
|
||||
|
||||
/**
|
||||
* Insert the string at the specified character offset.
|
||||
*
|
||||
* @param offset [in] The offset
|
||||
* @param aData [in] The data to insert
|
||||
* @return <b>NS_OK</b> iff the function succeeds, otherwise an error code
|
||||
*/
|
||||
NS_IMETHOD Insert(PRInt32 offset, const nsString& aData) = 0;
|
||||
NS_IMETHOD Insert(PRInt32 aOffset, nsString& aData)=0;
|
||||
|
||||
/**
|
||||
* Delete the specified characters range
|
||||
*
|
||||
* @param offset [in] The offset where deletion starts
|
||||
* @param count [out] The number of chracters to delete
|
||||
* @return <b>NS_OK</b> iff the function succeeds, otherwise an error code
|
||||
*/
|
||||
NS_IMETHOD Delete(PRInt32 offset, PRInt32 count) = 0;
|
||||
NS_IMETHOD Delete(PRInt32 aOffset, PRInt32 aCount)=0;
|
||||
|
||||
/**
|
||||
* Replace the characters starting at the specified character offset with
|
||||
* the specified string.
|
||||
*
|
||||
* @param offset [in] Offset at which to start replacing
|
||||
* @param count [in] Number of characters to replace
|
||||
* @param aData [in] String to replace previous content with.
|
||||
* @return <b>NS_OK</b> iff the function succeeds, otherwise an error code
|
||||
*/
|
||||
NS_IMETHOD Replace(PRInt32 offset, PRInt32 count,
|
||||
const nsString& aData) = 0;
|
||||
NS_IMETHOD Replace(PRInt32 aOffset, PRInt32 aCount, nsString& aData)=0;
|
||||
|
||||
/**
|
||||
* Insert the specified element in the tree as a sibling of the
|
||||
* Text node. The result of this operation may be the creation of
|
||||
* up to 2 new Text nodes: the character data specified by the
|
||||
* offset and count will form one Text node that will become the
|
||||
* child of the inserted element and the remainder of the character
|
||||
* data (after the offset and count) will form another Text node
|
||||
* become a sibling of the original Text node.
|
||||
*
|
||||
* @param element [in] Element to insert into the tree.
|
||||
* @param offset [in] Offset at which to insert.
|
||||
* @param count [in] Number of characters to copy to child Text
|
||||
* node of element.
|
||||
* @return <b>NS_OK</b> iff the function succeeds, otherwise an error code
|
||||
*/
|
||||
NS_IMETHOD Splice(nsIDOMElement* element, PRInt32 offset,
|
||||
PRInt32 count) = 0;
|
||||
NS_IMETHOD Splice(nsIDOMElement* aElement, PRInt32 aOffset, PRInt32 aCount)=0;
|
||||
};
|
||||
|
||||
#endif // nsIDOMText_h__
|
||||
extern nsresult NS_InitTextClass(nsIScriptContext *aContext, void **aPrototype);
|
||||
|
||||
extern "C" NS_DOM NS_NewScriptText(nsIScriptContext *aContext, nsIDOMText *aSupports, nsISupports *aParent, void **aReturn);
|
||||
|
||||
#endif // nsIDOMText_h__
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
/* -*- 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!!! */
|
||||
|
||||
#ifndef nsIDOMTreeIterator_h__
|
||||
#define nsIDOMTreeIterator_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsIDOMNodeIterator.h"
|
||||
|
||||
class nsIDOMTreeIterator;
|
||||
class nsIDOMNode;
|
||||
|
||||
#define NS_IDOMTREEITERATOR_IID \
|
||||
{ 0x6f7652ec, 0xee43, 0x11d1, \
|
||||
{ 0x9b, 0xc3, 0x00, 0x60, 0x08, 0x8c, 0xa6, 0xb3 } }
|
||||
|
||||
class nsIDOMTreeIterator : public nsIDOMNodeIterator {
|
||||
public:
|
||||
|
||||
NS_IMETHOD NumChildren(PRUint32* aReturn)=0;
|
||||
|
||||
NS_IMETHOD NumPreviousSiblings(PRUint32* aReturn)=0;
|
||||
|
||||
NS_IMETHOD NumNextSiblings(PRUint32* aReturn)=0;
|
||||
|
||||
NS_IMETHOD ToParent(nsIDOMNode** aReturn)=0;
|
||||
|
||||
NS_IMETHOD ToPreviousSibling(nsIDOMNode** aReturn)=0;
|
||||
|
||||
NS_IMETHOD ToNextSibling(nsIDOMNode** aReturn)=0;
|
||||
|
||||
NS_IMETHOD ToFirstChild(nsIDOMNode** aReturn)=0;
|
||||
|
||||
NS_IMETHOD ToLastChild(nsIDOMNode** aReturn)=0;
|
||||
|
||||
NS_IMETHOD ToNthChild(PRInt32 aN, nsIDOMNode** aReturn)=0;
|
||||
};
|
||||
|
||||
extern nsresult NS_InitTreeIteratorClass(nsIScriptContext *aContext, void **aPrototype);
|
||||
|
||||
extern "C" NS_DOM NS_NewScriptTreeIterator(nsIScriptContext *aContext, nsIDOMTreeIterator *aSupports, nsISupports *aParent, void **aReturn);
|
||||
|
||||
#endif // nsIDOMTreeIterator_h__
|
|
@ -1,6 +0,0 @@
|
|||
interface Attribute {
|
||||
wstring getName();
|
||||
wstring getValue();
|
||||
attribute boolean specified;
|
||||
wstring toString();
|
||||
};
|
|
@ -1,9 +0,0 @@
|
|||
interface AttributeList {
|
||||
Attribute getAttribute(in wstring attrName);
|
||||
Attribute setAttribute(in Attribute attr);
|
||||
Attribute remove(in wstring attrName) interface NoSuchAttributeException {};
|
||||
|
||||
Attribute item(in unsigned long index) interface NoSuchAttributeException {};
|
||||
|
||||
unsigned long getLength();
|
||||
};
|
|
@ -1,17 +0,0 @@
|
|||
interface Document : DocumentFragment {
|
||||
attribute Node documentType;
|
||||
attribute Element documentElement;
|
||||
attribute DocumentContext contextInfo;
|
||||
DocumentContext createDocumentContext();
|
||||
Element createElement(in wstring tagName,
|
||||
in AttributeList attributes);
|
||||
Text createTextNode(in wstring data);
|
||||
Comment createComment(in wstring data);
|
||||
PI createPI(in wstring name,
|
||||
in wstring data);
|
||||
Attribute createAttribute(in wstring name,
|
||||
in Node value);
|
||||
AttributeList createAttributeList();
|
||||
TreeIterator createTreeIterator(in Node node);
|
||||
NodeIterator getElementsByTagName(in wstring tagname);
|
||||
};
|
|
@ -1,14 +0,0 @@
|
|||
interface Element : Node {
|
||||
wstring getTagName();
|
||||
NodeIterator getAttributes();
|
||||
wstring getAttribute(in wstring name);
|
||||
void setAttribute(in string name,
|
||||
in string value);
|
||||
void removeAttribute(in wstring name);
|
||||
Attribute getAttributeNode(in wstring name);
|
||||
void setAttributeNode(in Attribute newAttr);
|
||||
void removeAttributeNode(in Attribute oldAttr);
|
||||
void getElementsByTagName(in wstring tagname);
|
||||
void normalize();
|
||||
};
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
interface Node {
|
||||
// NodeType
|
||||
const int DOCUMENT = 1;
|
||||
const int ELEMENT = 2;
|
||||
const int ATTRIBUTE = 3;
|
||||
const int PI = 4;
|
||||
const int COMMENT = 5;
|
||||
const int TEXT = 6;
|
||||
|
||||
int getNodeType();
|
||||
Node getParentNode();
|
||||
NodeIterator getChildNodes();
|
||||
boolean hasChildNodes();
|
||||
Node getFirstChild();
|
||||
Node getPreviousSibling();
|
||||
Node getNextSibling();
|
||||
Node insertBefore(in Node newChild,
|
||||
in Node refChild) interface NotMyChildException {};
|
||||
|
||||
Node replaceChild(in Node newChild,
|
||||
in Node oldChild) interface NotMyChildException {};
|
||||
|
||||
Node removeChild(in Node oldChild) interface NotMyChildException {};
|
||||
|
||||
};
|
|
@ -1,11 +0,0 @@
|
|||
interface NodeIterator {
|
||||
unsigned long getLength();
|
||||
unsigned long getCurrentPos();
|
||||
boolean atFirst();
|
||||
boolean atLast();
|
||||
Node toNextNode();
|
||||
Node toPrevNode();
|
||||
Node toFirstNode();
|
||||
Node toLastNode();
|
||||
Node moveTo(in int n);
|
||||
};
|
|
@ -0,0 +1,4 @@
|
|||
interface Window {
|
||||
readonly attribute Document document;
|
||||
void dump(in wstring str);
|
||||
};
|
|
@ -35,8 +35,8 @@ IDLSRCS = \
|
|||
Text.idl \
|
||||
TreeIterator.idl
|
||||
|
||||
XPCOM_DESTDIR=$(DEPTH)\dom\test
|
||||
JSSTUB_DESTDIR=$(DEPTH)\dom\test
|
||||
XPCOM_DESTDIR=$(DEPTH)\dom\public\coreDom
|
||||
JSSTUB_DESTDIR=$(DEPTH)\dom\src
|
||||
|
||||
GENXDIR=genx
|
||||
GENJSDIR=genjs
|
||||
|
@ -56,7 +56,7 @@ export:: $(GENXDIR) $(GENJSDIR) $(IDLSRCS)
|
|||
@echo +++ make: generating xpcom headers
|
||||
$(IDLC) -d $(GENXDIR) -x $(IDLSRCS)
|
||||
@echo +++ make: generating interface ids
|
||||
$(MOZ_TOOLS)\perl5\perl.exe $(GENIID) $(GENXDIR)
|
||||
$(PERL) $(GENIID) $(GENXDIR)
|
||||
@echo +++ make: generating JavaScript stubs
|
||||
$(IDLC) -d $(GENJSDIR) -j $(IDLSRCS)
|
||||
|
||||
|
|
|
@ -20,7 +20,8 @@ IGNORE_MANIFEST=1
|
|||
|
||||
DIRS=coreDom coreEvents events
|
||||
DEFINES=-D_IMPL_NS_DOM
|
||||
EXPORTS=nsIScriptContext.h nsIScriptObject.h nsIScriptObjectOwner.h
|
||||
EXPORTS=nsIScriptContext.h nsIJSScriptObject.h nsIScriptObjectOwner.h \
|
||||
nsIScriptGlobalObject.h nsIDOMWindow.h
|
||||
|
||||
MODULE=dom
|
||||
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
/* -*- 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.
|
||||
*/
|
||||
|
||||
#ifndef nsIDOMWindow_h__
|
||||
#define nsIDOMWindow_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsString.h"
|
||||
|
||||
class nsIDOMDocument;
|
||||
class nsIDOMWindow;
|
||||
|
||||
#define NS_IDOMWINDOW_IID \
|
||||
{ 0x6f7652ed, 0xee43, 0x11d1, \
|
||||
{ 0x9b, 0xc3, 0x00, 0x60, 0x08, 0x8c, 0xa6, 0xb3 } }
|
||||
|
||||
class nsIDOMWindow : public nsISupports {
|
||||
public:
|
||||
|
||||
NS_IMETHOD GetDocument(nsIDOMDocument** aDocument)=0;
|
||||
|
||||
NS_IMETHOD Dump(nsString& aStr)=0;
|
||||
};
|
||||
|
||||
extern nsresult NS_InitWindowClass(nsIScriptContext *aContext, nsIScriptGlobalObject *aGlobalObject);
|
||||
|
||||
extern "C" NS_DOM NS_NewScriptWindow(nsIScriptContext *aContext, nsIDOMWindow *aSupports, nsISupports *aParent, void **aReturn);
|
||||
|
||||
#endif // nsIDOMWindow_h__
|
|
@ -0,0 +1,50 @@
|
|||
/* -*- 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.
|
||||
*/
|
||||
|
||||
#ifndef nsIJSScriptObject_h__
|
||||
#define nsIJSScriptObject_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "jsapi.h"
|
||||
|
||||
#define NS_IJSSCRIPTOBJECT_IID \
|
||||
{ /* 8f6bca7c-ce42-11d1-b724-00600891d8c9 */ \
|
||||
0x8f6bca7c, 0xce42, 0x11d1, \
|
||||
{0xb7, 0x24, 0x00, 0x60, 0x08, 0x91, 0xd8, 0xc9} }
|
||||
|
||||
/**
|
||||
* A java script specific interface.
|
||||
* <P>
|
||||
* It's implemented by an object that has to execute specific java script
|
||||
* behavior like the array semantic.
|
||||
* <P>
|
||||
* It is used by the script runtime to collect information about an object
|
||||
*/
|
||||
class nsIJSScriptObject : public nsISupports {
|
||||
public:
|
||||
virtual PRBool AddProperty(JSContext *aContext, jsval aID, jsval *aVp) = 0;
|
||||
virtual PRBool DeleteProperty(JSContext *aContext, jsval aID, jsval *aVp) = 0;
|
||||
virtual PRBool GetProperty(JSContext *aContext, jsval aID, jsval *aVp) = 0;
|
||||
virtual PRBool SetProperty(JSContext *aContext, jsval aID, jsval *aVp) = 0;
|
||||
virtual PRBool EnumerateProperty(JSContext *aContext) = 0;
|
||||
virtual PRBool Resolve(JSContext *aContext, jsval aID) = 0;
|
||||
virtual PRBool Convert(JSContext *aContext, jsval aID) = 0;
|
||||
virtual void Finalize(JSContext *aContext) = 0;
|
||||
};
|
||||
|
||||
#endif // nsIJSScriptObject_h__
|
|
@ -23,7 +23,7 @@
|
|||
#include "nsISupports.h"
|
||||
#include "jsapi.h"
|
||||
|
||||
class nsIWebWidget;
|
||||
class nsIScriptGlobalObject;
|
||||
|
||||
#define NS_ISCRIPTCONTEXT_IID \
|
||||
{ /* 8f6bca7d-ce42-11d1-b724-00600891d8c9 */ \
|
||||
|
@ -50,46 +50,43 @@ public:
|
|||
*
|
||||
**/
|
||||
virtual PRBool EvaluateString(const char *aScript,
|
||||
PRUint32 aScriptSize,
|
||||
jsval *aRetValue) = 0;
|
||||
PRUint32 aScriptSize,
|
||||
jsval *aRetValue) = 0;
|
||||
|
||||
/**
|
||||
* Return the global object.
|
||||
*
|
||||
**/
|
||||
virtual JSObject* GetGlobalObject() = 0;
|
||||
virtual nsIScriptGlobalObject* GetGlobalObject() = 0;
|
||||
|
||||
/**
|
||||
* Return the JSContext
|
||||
* Return the native script context
|
||||
*
|
||||
**/
|
||||
virtual JSContext* GetContext() = 0;
|
||||
virtual void* GetNativeContext() = 0;
|
||||
|
||||
/**
|
||||
* Init all DOM classes.
|
||||
*
|
||||
**/
|
||||
virtual nsresult InitAllClasses() = 0;
|
||||
virtual nsresult InitClasses() = 0;
|
||||
|
||||
/**
|
||||
* Init this context.
|
||||
* <P>
|
||||
* <I> The dependency with nsIWebWidget will disappear soon. A more general "global object"
|
||||
* interface should be defined. nsIWebWidget is too specific.</I>
|
||||
*
|
||||
* @param aGlobalObject the gobal object
|
||||
*
|
||||
* @return NS_OK if context initialization was successful
|
||||
*
|
||||
**/
|
||||
virtual nsresult InitContext(nsIWebWidget *aGlobalObject) = 0;
|
||||
virtual nsresult InitContext(nsIScriptGlobalObject *aGlobalObject) = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return a new Context
|
||||
*
|
||||
*/
|
||||
extern "C" NS_DOM NS_CreateContext(nsIWebWidget *aGlobal, nsIScriptContext **aContext);
|
||||
extern "C" NS_DOM NS_CreateContext(nsIScriptGlobalObject *aGlobal, nsIScriptContext **aContext);
|
||||
|
||||
#endif // nsIScriptContext_h__
|
||||
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
/* -*- 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.
|
||||
*/
|
||||
|
||||
#ifndef nsIScriptGlobalObject_h__
|
||||
#define nsIScriptGlobalObject_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsIScriptContext.h"
|
||||
|
||||
class nsIScriptContext;
|
||||
class nsIDOMDocument;
|
||||
|
||||
#define NS_ISCRIPTGLOBALOBJECT_IID \
|
||||
{ 0x2b16fc80, 0xfa41, 0x11d1, \
|
||||
{ 0x9b, 0xc3, 0x00, 0x60, 0x08, 0x8c, 0xa6, 0xb3} }
|
||||
|
||||
/**
|
||||
* The JavaScript specific global object. This often used to store
|
||||
* per-window global state.
|
||||
*/
|
||||
|
||||
class nsIScriptGlobalObject : public nsISupports {
|
||||
public:
|
||||
NS_IMETHOD_(void) SetContext(nsIScriptContext *aContext)=0;
|
||||
NS_IMETHOD_(void) SetNewDocument(nsIDOMDocument *aDocument)=0;
|
||||
};
|
||||
|
||||
extern "C" NS_DOM NS_NewScriptGlobalObject(nsIScriptGlobalObject **aGlobal);
|
||||
|
||||
#endif
|
|
@ -21,9 +21,7 @@
|
|||
|
||||
#include "nscore.h"
|
||||
#include "nsISupports.h"
|
||||
|
||||
typedef struct JSContext JSContext;
|
||||
typedef struct JSObject JSObject;
|
||||
#include "nsIScriptContext.h"
|
||||
|
||||
class nsIScriptContext;
|
||||
|
||||
|
@ -54,7 +52,7 @@ public:
|
|||
* @return nsresult NS_OK if the script object is successfully returned
|
||||
*
|
||||
**/
|
||||
NS_IMETHOD GetScriptObject(JSContext *aContext, void** aScriptObject) = 0;
|
||||
NS_IMETHOD GetScriptObject(nsIScriptContext *aContext, void** aScriptObject) = 0;
|
||||
|
||||
/**
|
||||
* Nuke the current script object.
|
||||
|
@ -64,34 +62,4 @@ public:
|
|||
NS_IMETHOD ResetScriptObject() = 0;
|
||||
};
|
||||
|
||||
class nsIDOMDocument;
|
||||
extern "C" NS_DOM nsresult NS_NewScriptDocument(JSContext *aContext,
|
||||
nsIDOMDocument *aDocument,
|
||||
JSObject *aParent,
|
||||
JSObject **aJSObject);
|
||||
class nsIDOMElement;
|
||||
extern "C" NS_DOM nsresult NS_NewScriptElement(JSContext *aContext,
|
||||
nsIDOMElement *aElement,
|
||||
JSObject *aParent,
|
||||
JSObject **aJSObject);
|
||||
class nsIDOMText;
|
||||
extern "C" NS_DOM nsresult NS_NewScriptText(JSContext *aContext,
|
||||
nsIDOMText *aText,
|
||||
JSObject *aParent,
|
||||
JSObject **aJSObject);
|
||||
class nsIDOMNodeIterator;
|
||||
extern "C" NS_DOM nsresult NS_NewScriptNodeIterator(JSContext *aContext,
|
||||
nsIDOMNodeIterator *aNodeIterator,
|
||||
JSObject *aParent,
|
||||
JSObject **aJSObject);
|
||||
class nsIDOMAttribute;
|
||||
extern "C" NS_DOM nsresult NS_NewScriptAttribute(JSContext *aContext,
|
||||
nsIDOMAttribute *aAttribute,
|
||||
JSObject *aParent,
|
||||
JSObject **aJSObject);
|
||||
class nsIDOMAttributeList;
|
||||
extern "C" NS_DOM nsresult NS_NewScriptAttributeList(JSContext *aContext,
|
||||
nsIDOMAttributeList *aAttributeList,
|
||||
JSObject *aParent,
|
||||
JSObject **aJSObject);
|
||||
#endif // nsIScriptObjectOwner_h__
|
||||
|
|
|
@ -25,12 +25,14 @@ CPPSRCS = \
|
|||
nsJSEnvironment.cpp \
|
||||
nsJSNode.cpp \
|
||||
nsJSDocument.cpp \
|
||||
nsJSDocumentFragment.cpp\
|
||||
nsJSElement.cpp \
|
||||
nsJSText.cpp \
|
||||
nsJSNodeIterator.cpp\
|
||||
nsJSAttribute.cpp \
|
||||
nsJSAttributeList.cpp\
|
||||
nsJSWindow.cpp\
|
||||
nsGlobalWindow.cpp \
|
||||
$(NULL)
|
||||
|
||||
MODULE = raptor
|
||||
|
|
|
@ -27,12 +27,14 @@ CPPSRCS = \
|
|||
nsJSEnvironment.cpp \
|
||||
nsJSNode.cpp \
|
||||
nsJSDocument.cpp \
|
||||
nsJSDocumentFragment.cpp\
|
||||
nsJSElement.cpp \
|
||||
nsJSText.cpp \
|
||||
nsJSNodeIterator.cpp\
|
||||
nsJSNodeIterator.cpp \
|
||||
nsJSAttribute.cpp \
|
||||
nsJSAttributeList.cpp\
|
||||
nsJSWindow.cpp\
|
||||
nsJSAttributeList.cpp \
|
||||
nsJSWindow.cpp \
|
||||
nsGlobalWindow.cpp \
|
||||
$(NULL)
|
||||
|
||||
MODULE=raptor
|
||||
|
@ -42,7 +44,8 @@ REQUIRES=xpcom raptor js
|
|||
CPP_OBJS= .\$(OBJDIR)\nsJSEnvironment.obj .\$(OBJDIR)\nsJSNode.obj .\$(OBJDIR)\nsJSDocument.obj \
|
||||
.\$(OBJDIR)\nsJSElement.obj .\$(OBJDIR)\nsJSText.obj \
|
||||
.\$(OBJDIR)\nsJSNodeIterator.obj .\$(OBJDIR)\nsJSAttribute.obj \
|
||||
.\$(OBJDIR)\nsJSAttributeList.obj .\$(OBJDIR)\nsJSWindow.obj
|
||||
.\$(OBJDIR)\nsJSAttributeList.obj .\$(OBJDIR)\nsJSWindow.obj \
|
||||
.\$(OBJDIR)\nsGlobalWindow.obj .\$(OBJDIR)\nsJSDocumentFragment.obj
|
||||
|
||||
LINCS=-I$(XPDIST)\public\xpcom -I$(XPDIST)\public\raptor -I$(XPDIST)\public\dom -I$(XPDIST)\public\js
|
||||
|
||||
|
|
|
@ -0,0 +1,213 @@
|
|||
/* -*- 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.
|
||||
*/
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsIFactory.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsHashtable.h"
|
||||
|
||||
#include "jsapi.h"
|
||||
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kIScriptGlobalObjectIID, NS_ISCRIPTGLOBALOBJECT_IID);
|
||||
static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID);
|
||||
static NS_DEFINE_IID(kIDOMWindowIID, NS_IDOMWINDOW_IID);
|
||||
|
||||
// Global object for scripting
|
||||
class GlobalWindowImpl : public nsIScriptObjectOwner, public nsIScriptGlobalObject, public nsIDOMWindow
|
||||
{
|
||||
public:
|
||||
GlobalWindowImpl();
|
||||
~GlobalWindowImpl();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD GetScriptObject(nsIScriptContext *aContext, void** aScriptObject);
|
||||
NS_IMETHOD ResetScriptObject();
|
||||
|
||||
NS_IMETHOD_(void) SetContext(nsIScriptContext *aContext);
|
||||
NS_IMETHOD_(void) SetNewDocument(nsIDOMDocument *aDocument);
|
||||
|
||||
NS_IMETHOD GetDocument(nsIDOMDocument** aDocument);
|
||||
NS_IMETHOD Dump(nsString& aStr);
|
||||
|
||||
protected:
|
||||
nsIScriptContext *mContext;
|
||||
void *mScriptObject;
|
||||
nsIDOMDocument *mDocument;
|
||||
};
|
||||
|
||||
GlobalWindowImpl::GlobalWindowImpl()
|
||||
{
|
||||
mContext = nsnull;
|
||||
mScriptObject = nsnull;
|
||||
mDocument = nsnull;
|
||||
}
|
||||
|
||||
GlobalWindowImpl::~GlobalWindowImpl()
|
||||
{
|
||||
if (nsnull != mScriptObject) {
|
||||
JS_RemoveRoot((JSContext *)mContext->GetNativeContext(), &mScriptObject);
|
||||
mScriptObject = nsnull;
|
||||
}
|
||||
|
||||
if (nsnull != mContext) {
|
||||
NS_RELEASE(mContext);
|
||||
}
|
||||
|
||||
if (nsnull != mDocument) {
|
||||
NS_RELEASE(mDocument);
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(GlobalWindowImpl)
|
||||
NS_IMPL_RELEASE(GlobalWindowImpl)
|
||||
|
||||
nsresult
|
||||
GlobalWindowImpl::QueryInterface(const nsIID& aIID,
|
||||
void** aInstancePtrResult)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aInstancePtrResult, "null pointer");
|
||||
if (nsnull == aInstancePtrResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
if (aIID.Equals(kIScriptObjectOwnerIID)) {
|
||||
*aInstancePtrResult = (void*) ((nsIScriptObjectOwner*)this);
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kIScriptGlobalObjectIID)) {
|
||||
*aInstancePtrResult = (void*) ((nsIScriptGlobalObject*)this);
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kIDOMWindowIID)) {
|
||||
*aInstancePtrResult = (void*) ((nsIDOMWindow*)this);
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kISupportsIID)) {
|
||||
*aInstancePtrResult = (void*)(nsISupports*)(nsIScriptGlobalObject*)this;
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
nsresult
|
||||
GlobalWindowImpl::ResetScriptObject()
|
||||
{
|
||||
mScriptObject = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
GlobalWindowImpl::GetScriptObject(nsIScriptContext *aContext, void** aScriptObject)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aScriptObject, "null arg");
|
||||
nsresult res = NS_OK;
|
||||
if (nsnull == mScriptObject) {
|
||||
res = NS_NewScriptWindow(aContext, this, nsnull, &mScriptObject);
|
||||
JS_AddNamedRoot((JSContext *)aContext->GetNativeContext(),
|
||||
&mScriptObject, "window_object");
|
||||
}
|
||||
|
||||
*aScriptObject = mScriptObject;
|
||||
return res;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(void)
|
||||
GlobalWindowImpl::SetContext(nsIScriptContext *aContext)
|
||||
{
|
||||
if (mContext) {
|
||||
NS_RELEASE(mContext);
|
||||
}
|
||||
|
||||
mContext = aContext;
|
||||
NS_ADDREF(mContext);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(void)
|
||||
GlobalWindowImpl::SetNewDocument(nsIDOMDocument *aDocument)
|
||||
{
|
||||
if (nsnull != mDocument) {
|
||||
if (nsnull != mScriptObject) {
|
||||
JS_ClearScope((JSContext *)mContext->GetNativeContext(),
|
||||
(JSObject *)mScriptObject);
|
||||
}
|
||||
|
||||
NS_RELEASE(mDocument);
|
||||
}
|
||||
|
||||
mDocument = aDocument;
|
||||
|
||||
if (nsnull != mDocument) {
|
||||
NS_ADDREF(mDocument);
|
||||
|
||||
if (nsnull != mContext) {
|
||||
mContext->InitContext(this);
|
||||
}
|
||||
}
|
||||
else {
|
||||
JS_GC((JSContext *)mContext->GetNativeContext());
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
GlobalWindowImpl::GetDocument(nsIDOMDocument** aDocument)
|
||||
{
|
||||
*aDocument = mDocument;
|
||||
NS_ADDREF(mDocument);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
GlobalWindowImpl::Dump(nsString& aStr)
|
||||
{
|
||||
char *cstr = aStr.ToNewCString();
|
||||
|
||||
if (nsnull != cstr) {
|
||||
printf("%s", cstr);
|
||||
delete [] cstr;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
extern "C" NS_DOM
|
||||
NS_NewScriptGlobalObject(nsIScriptGlobalObject **aResult)
|
||||
{
|
||||
if (nsnull == aResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
*aResult = NULL;
|
||||
|
||||
GlobalWindowImpl *global = new GlobalWindowImpl();
|
||||
if (nsnull == global) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return global->QueryInterface(kIScriptGlobalObjectIID, (void **)aResult);
|
||||
}
|
|
@ -15,194 +15,324 @@
|
|||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
/* AUTO-GENERATED. DO NOT EDIT!!! */
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "nscore.h"
|
||||
#include "nsIScriptObject.h"
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsIJSScriptObject.h"
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
#include "nsIDOMAttribute.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIPtr.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIDOMAttribute.h"
|
||||
|
||||
|
||||
static NS_DEFINE_IID(kIScriptObjectIID, NS_ISCRIPTOBJECT_IID);
|
||||
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_slot {
|
||||
ATTRIBUTE_VALUE = -1,
|
||||
ATTRIBUTE_SPECIFIED = -2
|
||||
enum Attribute_slots {
|
||||
ATTRIBUTE_VALUE = -11,
|
||||
ATTRIBUTE_SPECIFIED = -12
|
||||
};
|
||||
|
||||
/***********************************************************************/
|
||||
|
||||
//
|
||||
// Attribute properties getter
|
||||
// Attribute Properties Getter
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
GetAttributeProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
{
|
||||
nsIDOMAttribute *attribute = (nsIDOMAttribute*)JS_GetPrivate(cx, obj);
|
||||
// NS_ASSERTION(nsnull != attribute, "null pointer");
|
||||
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_VALUE:
|
||||
{
|
||||
nsAutoString string;
|
||||
if (NS_OK == attribute->GetValue(string)) {
|
||||
JSString *jsstring = JS_NewUCStringCopyN(cx, string.GetUnicode(), string.Length());
|
||||
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;
|
||||
}
|
||||
case ATTRIBUTE_SPECIFIED:
|
||||
{
|
||||
if (NS_OK == attribute->GetSpecified()) {
|
||||
*vp = JSVAL_TRUE;
|
||||
PRBool prop;
|
||||
if (NS_OK == a->GetSpecified(&prop)) {
|
||||
*vp = BOOLEAN_TO_JSVAL(prop);
|
||||
}
|
||||
else {
|
||||
*vp = JSVAL_FALSE;
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
nsIScriptObject *object;
|
||||
if (NS_OK == attribute->QueryInterface(kIScriptObjectIID, (void**)&object)) {
|
||||
return object->GetProperty(cx, id, vp);
|
||||
{
|
||||
nsIJSScriptObject *object;
|
||||
if (NS_OK == a->QueryInterface(kIJSScriptObjectIID, (void**)&object)) {
|
||||
PRBool rval;
|
||||
rval = object->GetProperty(cx, id, vp);
|
||||
NS_RELEASE(object);
|
||||
return rval;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
/***********************************************************************/
|
||||
//
|
||||
// Attribute properties setter
|
||||
// Attribute Properties Setter
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
SetAttributeProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
{
|
||||
nsIDOMAttribute *attribute = (nsIDOMAttribute*)JS_GetPrivate(cx, obj);
|
||||
NS_ASSERTION(nsnull != attribute, "null pointer");
|
||||
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_VALUE:
|
||||
{
|
||||
if (JSVAL_IS_STRING(*vp)) {
|
||||
JSString *jsstring = JSVAL_TO_STRING(*vp);
|
||||
nsAutoString string = JS_GetStringChars(jsstring);
|
||||
attribute->SetValue(string);
|
||||
nsAutoString prop;
|
||||
JSString *jsstring;
|
||||
if ((jsstring = JS_ValueToString(cx, *vp)) != nsnull) {
|
||||
prop.SetString(JS_GetStringChars(jsstring));
|
||||
}
|
||||
else {
|
||||
prop.SetString((const char *)nsnull);
|
||||
}
|
||||
|
||||
a->SetValue(prop);
|
||||
|
||||
break;
|
||||
}
|
||||
case ATTRIBUTE_SPECIFIED:
|
||||
{
|
||||
if (JSVAL_IS_BOOLEAN(*vp)) {
|
||||
attribute->SetSpecified(JSVAL_TO_BOOLEAN(*vp));
|
||||
PRBool prop;
|
||||
JSBool temp;
|
||||
if (JSVAL_IS_BOOLEAN(*vp) && JS_ValueToBoolean(cx, *vp, &temp)) {
|
||||
prop = (PRBool)temp;
|
||||
}
|
||||
else {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
a->SetSpecified(prop);
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
nsIScriptObject *object;
|
||||
if (NS_OK == attribute->QueryInterface(kIScriptObjectIID, (void**)&object)) {
|
||||
return object->GetProperty(cx, id, vp);
|
||||
{
|
||||
nsIJSScriptObject *object;
|
||||
if (NS_OK == a->QueryInterface(kIJSScriptObjectIID, (void**)&object)) {
|
||||
PRBool rval;
|
||||
rval = object->SetProperty(cx, id, vp);
|
||||
NS_RELEASE(object);
|
||||
return rval;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Attribute finalizer
|
||||
//
|
||||
PR_STATIC_CALLBACK(void)
|
||||
FinalizeAttribute(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
nsIDOMAttribute *attribute = (nsIDOMAttribute*)JS_GetPrivate(cx, obj);
|
||||
nsIDOMAttribute *a = (nsIDOMAttribute*)JS_GetPrivate(cx, obj);
|
||||
|
||||
if (nsnull != attribute) {
|
||||
if (nsnull != a) {
|
||||
// get the js object
|
||||
nsIScriptObjectOwner *owner = nsnull;
|
||||
if (NS_OK == attribute->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) {
|
||||
if (NS_OK == a->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) {
|
||||
owner->ResetScriptObject();
|
||||
NS_RELEASE(owner);
|
||||
}
|
||||
|
||||
attribute->Release();
|
||||
NS_RELEASE(a);
|
||||
}
|
||||
}
|
||||
|
||||
/***********************************************************************/
|
||||
|
||||
//
|
||||
// JS->Native functions
|
||||
// Attribute enumerate
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
GetName(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
EnumerateAttribute(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
nsIDOMAttribute *attribute = (nsIDOMAttribute*)JS_GetPrivate(cx, obj);
|
||||
NS_ASSERTION(nsnull != attribute, "null pointer");
|
||||
nsAutoString string;
|
||||
if (NS_OK == attribute->GetName(string)) {
|
||||
JSString *jsstring = JS_NewUCStringCopyN(cx, string.GetUnicode(), string.Length());
|
||||
*rval = STRING_TO_JSVAL(jsstring);
|
||||
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)
|
||||
ToString(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
ResolveAttribute(JSContext *cx, JSObject *obj, jsval id)
|
||||
{
|
||||
nsIDOMAttribute *attribute = (nsIDOMAttribute*)JS_GetPrivate(cx, obj);
|
||||
NS_ASSERTION(nsnull != attribute, "null pointer");
|
||||
nsAutoString string;
|
||||
if (NS_OK == attribute->ToString(string)) {
|
||||
JSString *jsstring = JS_NewUCStringCopyN(cx, string.GetUnicode(), string.Length());
|
||||
*rval = STRING_TO_JSVAL(jsstring);
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method GetName
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
AttributeGetName(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMAttribute *nativeThis = (nsIDOMAttribute*)JS_GetPrivate(cx, obj);
|
||||
JSBool rBool = JS_FALSE;
|
||||
nsAutoString 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->GetName(nativeRet)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
JSString *jsstring = JS_NewUCStringCopyN(cx, nativeRet, nativeRet.Length());
|
||||
// set the return value
|
||||
*rval = STRING_TO_JSVAL(jsstring);
|
||||
}
|
||||
else {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method ToString
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
AttributeToString(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMAttribute *nativeThis = (nsIDOMAttribute*)JS_GetPrivate(cx, obj);
|
||||
JSBool rBool = JS_FALSE;
|
||||
nsAutoString 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->ToString(nativeRet)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
JSString *jsstring = JS_NewUCStringCopyN(cx, nativeRet, nativeRet.Length());
|
||||
// set the return value
|
||||
*rval = STRING_TO_JSVAL(jsstring);
|
||||
}
|
||||
else {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************/
|
||||
//
|
||||
// the jscript class for a DOM Attribute
|
||||
// class for Attribute
|
||||
//
|
||||
JSClass attribute = {
|
||||
JSClass AttributeClass = {
|
||||
"Attribute",
|
||||
JSCLASS_HAS_PRIVATE,
|
||||
JS_PropertyStub,
|
||||
JS_PropertyStub,
|
||||
GetAttributeProperty,
|
||||
JS_PropertyStub,
|
||||
JS_PropertyStub,
|
||||
GetAttributeProperty,
|
||||
SetAttributeProperty,
|
||||
JS_EnumerateStub,
|
||||
JS_ResolveStub,
|
||||
JS_ConvertStub,
|
||||
EnumerateAttribute,
|
||||
ResolveAttribute,
|
||||
JS_ConvertStub,
|
||||
FinalizeAttribute
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// Attribute class properties
|
||||
//
|
||||
static JSPropertySpec attributeProperties[] =
|
||||
static JSPropertySpec AttributeProperties[] =
|
||||
{
|
||||
{"value", ATTRIBUTE_VALUE, JSPROP_ENUMERATE},
|
||||
{"specified", ATTRIBUTE_SPECIFIED, JSPROP_ENUMERATE},
|
||||
{"value", ATTRIBUTE_VALUE, JSPROP_ENUMERATE},
|
||||
{"specified", ATTRIBUTE_SPECIFIED, JSPROP_ENUMERATE},
|
||||
{0}
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// Attribute class methods
|
||||
//
|
||||
static JSFunctionSpec attributeMethods[] = {
|
||||
{"getName", GetName, 0},
|
||||
{"toString", ToString, 0},
|
||||
static JSFunctionSpec AttributeMethods[] =
|
||||
{
|
||||
{"getName", AttributeGetName, 0},
|
||||
{"toString", AttributeToString, 0},
|
||||
{0}
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// Attribute constructor
|
||||
//
|
||||
|
@ -212,79 +342,93 @@ Attribute(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
|||
return JS_TRUE;
|
||||
}
|
||||
|
||||
//
|
||||
// Attribute static property ids
|
||||
//
|
||||
|
||||
//
|
||||
// Attribute static properties
|
||||
// Attribute class initialization
|
||||
//
|
||||
|
||||
//
|
||||
// Attribute static methods
|
||||
//
|
||||
|
||||
/***********************************************************************/
|
||||
|
||||
//
|
||||
// Init this object class
|
||||
//
|
||||
nsresult NS_InitAttributeClass(JSContext *aContext, JSObject **aPrototype)
|
||||
nsresult NS_InitAttributeClass(nsIScriptContext *aContext, void **aPrototype)
|
||||
{
|
||||
// look in the global object for this class prototype
|
||||
static JSObject *proto = nsnull;
|
||||
JSContext *jscontext = (JSContext *)aContext->GetNativeContext();
|
||||
JSObject *proto = nsnull;
|
||||
JSObject *constructor = nsnull;
|
||||
JSObject *parent_proto = nsnull;
|
||||
JSObject *global = JS_GetGlobalObject(jscontext);
|
||||
jsval vp;
|
||||
|
||||
if (nsnull == proto) {
|
||||
proto = JS_InitClass(aContext, // context
|
||||
JS_GetGlobalObject(aContext), // global object
|
||||
NULL, // parent proto
|
||||
&attribute, // JSClass
|
||||
Attribute, // JSNative ctor
|
||||
0, // ctor args
|
||||
attributeProperties, // proto props
|
||||
attributeMethods, // proto funcs
|
||||
NULL, // ctor props (static)
|
||||
NULL); // ctor funcs (static)
|
||||
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)) {
|
||||
|
||||
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 (nsnull != aPrototype) {
|
||||
if (aPrototype) {
|
||||
*aPrototype = proto;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//
|
||||
// Attribute instance property ids
|
||||
//
|
||||
|
||||
//
|
||||
// Attribute instance properties
|
||||
// Method for creating a new Attribute JavaScript object
|
||||
//
|
||||
|
||||
//
|
||||
// New a attribute object in js, connect the native and js worlds
|
||||
//
|
||||
extern "C" NS_DOM nsresult NS_NewScriptAttribute(JSContext *aContext, nsIDOMAttribute *aAttribute, JSObject *aParent, JSObject **aJSObject)
|
||||
extern "C" NS_DOM NS_NewScriptAttribute(nsIScriptContext *aContext, nsIDOMAttribute *aSupports, nsISupports *aParent, void **aReturn)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aContext && nsnull != aAttribute && nsnull != aJSObject, "null arg");
|
||||
NS_PRECONDITION(nsnull != aContext && nsnull != aSupports && nsnull != aReturn, "null argument to NS_NewScriptAttribute");
|
||||
JSObject *proto;
|
||||
NS_InitAttributeClass(aContext, &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
|
||||
*aJSObject = JS_NewObject(aContext, &attribute, proto, aParent);
|
||||
if (nsnull != *aJSObject) {
|
||||
// define the instance specific properties
|
||||
|
||||
*aReturn = JS_NewObject(jscontext, &AttributeClass, proto, parent);
|
||||
if (nsnull != *aReturn) {
|
||||
// connect the native object to the js object
|
||||
JS_SetPrivate(aContext, *aJSObject, aAttribute);
|
||||
aAttribute->AddRef();
|
||||
JS_SetPrivate(jscontext, (JSObject *)*aReturn, aSupports);
|
||||
NS_ADDREF(aSupports);
|
||||
}
|
||||
else {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
else return NS_ERROR_FAILURE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,279 +15,448 @@
|
|||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
/* AUTO-GENERATED. DO NOT EDIT!!! */
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "nscore.h"
|
||||
#include "nsIScriptObject.h"
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsIJSScriptObject.h"
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
#include "nsIDOMAttribute.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIPtr.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIDOMAttributeList.h"
|
||||
#include "nsIDOMAttribute.h"
|
||||
|
||||
|
||||
static NS_DEFINE_IID(kIScriptObjectIID, NS_ISCRIPTOBJECT_IID);
|
||||
static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID);
|
||||
static NS_DEFINE_IID(kIDOMAttributeIID, NS_IDOMATTRIBUTE_IID);
|
||||
static NS_DEFINE_IID(kIJSScriptObjectIID, NS_IJSSCRIPTOBJECT_IID);
|
||||
static NS_DEFINE_IID(kIScriptGlobalObjectIID, NS_ISCRIPTGLOBALOBJECT_IID);
|
||||
static NS_DEFINE_IID(kIAttributeListIID, NS_IDOMATTRIBUTELIST_IID);
|
||||
static NS_DEFINE_IID(kIAttributeIID, NS_IDOMATTRIBUTE_IID);
|
||||
|
||||
NS_DEF_PTR(nsIDOMAttributeList);
|
||||
NS_DEF_PTR(nsIDOMAttribute);
|
||||
|
||||
|
||||
/***********************************************************************/
|
||||
|
||||
//
|
||||
// AttributeList properties getter
|
||||
// AttributeList Properties Getter
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
GetAttributeListProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
{
|
||||
nsIDOMAttributeList *attributeList = (nsIDOMAttributeList*)JS_GetPrivate(cx, obj);
|
||||
// NS_ASSERTION(nsnull != attributeList, "null pointer");
|
||||
nsIDOMAttributeList *a = (nsIDOMAttributeList*)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: //this is just to keep the compiler from issuing a warning
|
||||
//that there is a switch with only a default case. MMP
|
||||
default:
|
||||
nsIScriptObject *object;
|
||||
if (NS_OK == attributeList->QueryInterface(kIScriptObjectIID, (void**)&object)) {
|
||||
return object->GetProperty(cx, id, vp);
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
/***********************************************************************/
|
||||
//
|
||||
// AttributeList properties setter
|
||||
// AttributeList Properties Setter
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
SetAttributeListProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
{
|
||||
nsIDOMAttributeList *attributeList = (nsIDOMAttributeList*)JS_GetPrivate(cx, obj);
|
||||
NS_ASSERTION(nsnull != attributeList, "null pointer");
|
||||
nsIDOMAttributeList *a = (nsIDOMAttributeList*)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: //this is just to keep the compiler from issuing a warning
|
||||
//that there is a switch with only a default case. MMP
|
||||
default:
|
||||
nsIScriptObject *object;
|
||||
if (NS_OK == attributeList->QueryInterface(kIScriptObjectIID, (void**)&object)) {
|
||||
return object->SetProperty(cx, id, vp);
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Document finalizer
|
||||
// AttributeList finalizer
|
||||
//
|
||||
PR_STATIC_CALLBACK(void)
|
||||
FinalizeAttributeList(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
nsIDOMAttributeList *attributeList = (nsIDOMAttributeList*)JS_GetPrivate(cx, obj);
|
||||
|
||||
if (nsnull != attributeList) {
|
||||
nsIDOMAttributeList *a = (nsIDOMAttributeList*)JS_GetPrivate(cx, obj);
|
||||
|
||||
if (nsnull != a) {
|
||||
// get the js object
|
||||
nsIScriptObjectOwner *owner = nsnull;
|
||||
if (NS_OK == attributeList->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) {
|
||||
if (NS_OK == a->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) {
|
||||
owner->ResetScriptObject();
|
||||
NS_RELEASE(owner);
|
||||
}
|
||||
|
||||
attributeList->Release();
|
||||
NS_RELEASE(a);
|
||||
}
|
||||
}
|
||||
|
||||
/***********************************************************************/
|
||||
|
||||
//
|
||||
// JS->Native functions
|
||||
// AttributeList enumerate
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
GetAttribute(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
EnumerateAttributeList(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
nsIDOMAttributeList *attributeList = (nsIDOMAttributeList*)JS_GetPrivate(cx, obj);
|
||||
NS_ASSERTION(nsnull != attributeList, "null pointer");
|
||||
NS_ASSERTION(1 == argc, "wrong number of arguments");
|
||||
*rval = JSVAL_NULL;
|
||||
if (1 == argc) {
|
||||
// get the arguments
|
||||
if (JSVAL_IS_STRING(argv[0])) {
|
||||
JSString *jsstring1 = JSVAL_TO_STRING(argv[0]);
|
||||
nsAutoString string1 = JS_GetStringChars(jsstring1);
|
||||
|
||||
// call the function
|
||||
nsIDOMAttribute *attribute;
|
||||
if (NS_OK == attributeList->GetAttribute(string1, &attribute)) {
|
||||
|
||||
// get the js object
|
||||
nsIScriptObjectOwner *owner = nsnull;
|
||||
if (NS_OK == attribute->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) {
|
||||
JSObject *object = nsnull;
|
||||
if (NS_OK == owner->GetScriptObject(cx, (void**)&object)) {
|
||||
// set the return value
|
||||
*rval = OBJECT_TO_JSVAL(object);
|
||||
}
|
||||
NS_RELEASE(owner);
|
||||
}
|
||||
NS_RELEASE(attribute);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
SetAttribute(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMAttributeList *attributeList = (nsIDOMAttributeList*)JS_GetPrivate(cx, obj);
|
||||
NS_ASSERTION(nsnull != attributeList, "null pointer");
|
||||
NS_ASSERTION(1 == argc, "wrong number of arguments");
|
||||
*rval = JSVAL_NULL;
|
||||
if (1 == argc) {
|
||||
// get the arguments
|
||||
if (JSVAL_IS_OBJECT(argv[0])) {
|
||||
JSObject *obj1 = JSVAL_TO_OBJECT(argv[0]);
|
||||
//XXX should check if that's a good class (do not just GetPrivate)
|
||||
nsISupports *support1 = (nsISupports*)JS_GetPrivate(cx, obj1);
|
||||
NS_ASSERTION(nsnull != support1, "null pointer");
|
||||
|
||||
nsIDOMAttribute *attribute1 = nsnull;
|
||||
if (NS_OK == support1->QueryInterface(kIDOMAttributeIID, (void**)&attribute1)) {
|
||||
if (NS_OK == attributeList->SetAttribute(attribute1)) {
|
||||
// set the return value
|
||||
*rval = argv[0];
|
||||
}
|
||||
NS_RELEASE(attribute1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
Remove(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMAttributeList *attributeList = (nsIDOMAttributeList*)JS_GetPrivate(cx, obj);
|
||||
NS_ASSERTION(nsnull != attributeList, "null pointer");
|
||||
NS_ASSERTION(1 == argc, "wrong number of arguments");
|
||||
*rval = JSVAL_NULL;
|
||||
if (1 == argc) {
|
||||
// get the arguments
|
||||
if (JSVAL_IS_STRING(argv[0])) {
|
||||
JSString *jsstring1 = JSVAL_TO_STRING(argv[0]);
|
||||
nsAutoString string1 = JS_GetStringChars(jsstring1);
|
||||
|
||||
// call the function
|
||||
nsIDOMAttribute *attribute1 = nsnull;
|
||||
if (NS_OK == attributeList->Remove(string1, &attribute1)) {
|
||||
|
||||
// get the js object
|
||||
nsIScriptObjectOwner *owner = nsnull;
|
||||
if (NS_OK == attribute1->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) {
|
||||
JSObject *object = nsnull;
|
||||
if (NS_OK == owner->GetScriptObject(cx, (void**)&object)) {
|
||||
// set the return value
|
||||
*rval = OBJECT_TO_JSVAL(object);
|
||||
}
|
||||
NS_RELEASE(owner);
|
||||
}
|
||||
NS_RELEASE(attribute1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
Item(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMAttributeList *attributeList = (nsIDOMAttributeList*)JS_GetPrivate(cx, obj);
|
||||
NS_ASSERTION(nsnull != attributeList, "null pointer");
|
||||
NS_ASSERTION(1 == argc, "wrong number of arguments");
|
||||
*rval = JSVAL_NULL;
|
||||
if (1 == argc) {
|
||||
// get the arguments
|
||||
if (JSVAL_IS_INT(argv[0])) {
|
||||
PRInt32 pos = JSVAL_TO_INT(argv[0]);
|
||||
|
||||
// call the function
|
||||
nsIDOMAttribute *attribute1 = nsnull;
|
||||
if (NS_OK == attributeList->Item(pos, &attribute1)) {
|
||||
|
||||
// get the js object
|
||||
nsIScriptObjectOwner *owner = nsnull;
|
||||
if (NS_OK == attribute1->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) {
|
||||
JSObject *object = nsnull;
|
||||
if (NS_OK == owner->GetScriptObject(cx, (void**)&object)) {
|
||||
// set the return value
|
||||
*rval = OBJECT_TO_JSVAL(object);
|
||||
}
|
||||
NS_RELEASE(owner);
|
||||
}
|
||||
NS_RELEASE(attribute1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
GetLength(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMAttributeList *attributeList = (nsIDOMAttributeList*)JS_GetPrivate(cx, obj);
|
||||
NS_ASSERTION(nsnull != attributeList, "null pointer");
|
||||
nsIDOMAttributeList *a = (nsIDOMAttributeList*)JS_GetPrivate(cx, obj);
|
||||
|
||||
PRUint32 length;
|
||||
|
||||
// call the function
|
||||
if (NS_OK == attributeList->GetLength(&length)) {
|
||||
|
||||
// set the return value
|
||||
*rval = INT_TO_JSVAL((PRInt32)length);
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// AttributeList resolve
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
ResolveAttributeList(JSContext *cx, JSObject *obj, jsval id)
|
||||
{
|
||||
nsIDOMAttributeList *a = (nsIDOMAttributeList*)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 GetAttribute
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
AttributeListGetAttribute(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMAttributeList *nativeThis = (nsIDOMAttributeList*)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->GetAttribute(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 {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method SetAttribute
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
AttributeListSetAttribute(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMAttributeList *nativeThis = (nsIDOMAttributeList*)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_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())))) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
}
|
||||
else if (JSVAL_IS_NULL(argv[0])){
|
||||
b0 = nsnull;
|
||||
}
|
||||
else {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (NS_OK != nativeThis->SetAttribute(b0)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
*rval = JSVAL_VOID;
|
||||
}
|
||||
else {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method Remove
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
AttributeListRemove(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMAttributeList *nativeThis = (nsIDOMAttributeList*)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->Remove(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 {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method Item
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
AttributeListItem(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMAttributeList *nativeThis = (nsIDOMAttributeList*)JS_GetPrivate(cx, obj);
|
||||
JSBool rBool = JS_FALSE;
|
||||
nsIDOMAttribute* 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)) {
|
||||
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 {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method GetLength
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
AttributeListGetLength(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMAttributeList *nativeThis = (nsIDOMAttributeList*)JS_GetPrivate(cx, obj);
|
||||
JSBool rBool = JS_FALSE;
|
||||
PRUint32 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->GetLength(&nativeRet)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
*rval = INT_TO_JSVAL(nativeRet);
|
||||
}
|
||||
else {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************/
|
||||
//
|
||||
// the jscript class for a DOM AttributeList
|
||||
// class for AttributeList
|
||||
//
|
||||
JSClass attributeList = {
|
||||
JSClass AttributeListClass = {
|
||||
"AttributeList",
|
||||
JSCLASS_HAS_PRIVATE,
|
||||
JS_PropertyStub,
|
||||
JS_PropertyStub,
|
||||
GetAttributeListProperty,
|
||||
JS_PropertyStub,
|
||||
JS_PropertyStub,
|
||||
GetAttributeListProperty,
|
||||
SetAttributeListProperty,
|
||||
JS_EnumerateStub,
|
||||
JS_ResolveStub,
|
||||
JS_ConvertStub,
|
||||
EnumerateAttributeList,
|
||||
ResolveAttributeList,
|
||||
JS_ConvertStub,
|
||||
FinalizeAttributeList
|
||||
};
|
||||
|
||||
//
|
||||
// AttributeList property ids
|
||||
//
|
||||
|
||||
//
|
||||
// AttributeList class properties
|
||||
//
|
||||
static JSPropertySpec AttributeListProperties[] =
|
||||
{
|
||||
{0}
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// AttributeList class methods
|
||||
//
|
||||
static JSFunctionSpec attributeListMethods[] = {
|
||||
{"getAttribute", GetAttribute, 1},
|
||||
{"setAttribute", SetAttribute, 1},
|
||||
{"remove", Remove, 1},
|
||||
{"item", Item, 1},
|
||||
{"getLength", GetLength, 0},
|
||||
static JSFunctionSpec AttributeListMethods[] =
|
||||
{
|
||||
{"getAttribute", AttributeListGetAttribute, 1},
|
||||
{"setAttribute", AttributeListSetAttribute, 1},
|
||||
{"remove", AttributeListRemove, 1},
|
||||
{"item", AttributeListItem, 1},
|
||||
{"getLength", AttributeListGetLength, 0},
|
||||
{0}
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// AttributeList constructor
|
||||
//
|
||||
|
@ -297,79 +466,93 @@ AttributeList(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval
|
|||
return JS_TRUE;
|
||||
}
|
||||
|
||||
//
|
||||
// AttributeList static property ids
|
||||
//
|
||||
|
||||
//
|
||||
// AttributeList static properties
|
||||
// AttributeList class initialization
|
||||
//
|
||||
|
||||
//
|
||||
// AttributeList static methods
|
||||
//
|
||||
|
||||
/***********************************************************************/
|
||||
|
||||
//
|
||||
// Init this object class
|
||||
//
|
||||
nsresult NS_InitAttributeListClass(JSContext *aContext, JSObject **aPrototype)
|
||||
nsresult NS_InitAttributeListClass(nsIScriptContext *aContext, void **aPrototype)
|
||||
{
|
||||
// look in the global object for this class prototype
|
||||
static JSObject *proto = nsnull;
|
||||
JSContext *jscontext = (JSContext *)aContext->GetNativeContext();
|
||||
JSObject *proto = nsnull;
|
||||
JSObject *constructor = nsnull;
|
||||
JSObject *parent_proto = nsnull;
|
||||
JSObject *global = JS_GetGlobalObject(jscontext);
|
||||
jsval vp;
|
||||
|
||||
if (nsnull == proto) {
|
||||
proto = JS_InitClass(aContext, // context
|
||||
JS_GetGlobalObject(aContext), // global object
|
||||
NULL, // parent proto
|
||||
&attributeList, // JSClass
|
||||
AttributeList, // JSNative ctor
|
||||
0, // ctor args
|
||||
NULL, // proto props
|
||||
attributeListMethods, // proto funcs
|
||||
NULL, // ctor props (static)
|
||||
NULL); // ctor funcs (static)
|
||||
if ((PR_TRUE != JS_LookupProperty(jscontext, global, "AttributeList", &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
|
||||
&AttributeListClass, // JSClass
|
||||
AttributeList, // JSNative ctor
|
||||
0, // ctor args
|
||||
AttributeListProperties, // proto props
|
||||
AttributeListMethods, // 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 (nsnull != aPrototype) {
|
||||
if (aPrototype) {
|
||||
*aPrototype = proto;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//
|
||||
// AttributeList instance property ids
|
||||
//
|
||||
|
||||
//
|
||||
// AttributeList instance properties
|
||||
// Method for creating a new AttributeList JavaScript object
|
||||
//
|
||||
|
||||
//
|
||||
// New a AttributeList object in js, connect the native and js worlds
|
||||
//
|
||||
extern "C" NS_DOM nsresult NS_NewScriptAttributeList(JSContext *aContext, nsIDOMAttributeList *aAttributeList, JSObject *aParent, JSObject **aJSObject)
|
||||
extern "C" NS_DOM NS_NewScriptAttributeList(nsIScriptContext *aContext, nsIDOMAttributeList *aSupports, nsISupports *aParent, void **aReturn)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aContext && nsnull != aAttributeList && nsnull != aJSObject, "null arg");
|
||||
NS_PRECONDITION(nsnull != aContext && nsnull != aSupports && nsnull != aReturn, "null argument to NS_NewScriptAttributeList");
|
||||
JSObject *proto;
|
||||
NS_InitAttributeListClass(aContext, &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_InitAttributeListClass(aContext, (void **)&proto)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// create a js object for this class
|
||||
*aJSObject = JS_NewObject(aContext, &attributeList, proto, aParent);
|
||||
if (nsnull != *aJSObject) {
|
||||
// define the instance specific properties
|
||||
|
||||
*aReturn = JS_NewObject(jscontext, &AttributeListClass, proto, parent);
|
||||
if (nsnull != *aReturn) {
|
||||
// connect the native object to the js object
|
||||
JS_SetPrivate(aContext, *aJSObject, aAttributeList);
|
||||
aAttributeList->AddRef();
|
||||
JS_SetPrivate(jscontext, (JSObject *)*aReturn, aSupports);
|
||||
NS_ADDREF(aSupports);
|
||||
}
|
||||
else {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
else return NS_ERROR_FAILURE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,337 @@
|
|||
/* -*- 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 property ids
|
||||
//
|
||||
enum Comment_slots {
|
||||
COMMENT_DATA = -11
|
||||
};
|
||||
|
||||
/***********************************************************************/
|
||||
//
|
||||
// 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 COMMENT_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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 COMMENT_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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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[] =
|
||||
{
|
||||
{"data", COMMENT_DATA, JSPROP_ENUMERATE},
|
||||
{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_InitNodeClass(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 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;
|
||||
}
|
|
@ -0,0 +1,405 @@
|
|||
/* -*- 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 {
|
||||
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 {
|
||||
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 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;
|
||||
}
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,357 @@
|
|||
/* -*- 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 "nsIDOMDocumentContext.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(kIDocumentContextIID, NS_IDOMDOCUMENTCONTEXT_IID);
|
||||
|
||||
NS_DEF_PTR(nsIDOMDocument);
|
||||
NS_DEF_PTR(nsIDOMDocumentContext);
|
||||
|
||||
//
|
||||
// DocumentContext property ids
|
||||
//
|
||||
enum DocumentContext_slots {
|
||||
DOCUMENTCONTEXT_DOCUMENT = -11
|
||||
};
|
||||
|
||||
/***********************************************************************/
|
||||
//
|
||||
// DocumentContext Properties Getter
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
GetDocumentContextProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
{
|
||||
nsIDOMDocumentContext *a = (nsIDOMDocumentContext*)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 DOCUMENTCONTEXT_DOCUMENT:
|
||||
{
|
||||
nsIDOMDocument* prop;
|
||||
if (NS_OK == a->GetDocument(&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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
/***********************************************************************/
|
||||
//
|
||||
// DocumentContext Properties Setter
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
SetDocumentContextProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
{
|
||||
nsIDOMDocumentContext *a = (nsIDOMDocumentContext*)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 DOCUMENTCONTEXT_DOCUMENT:
|
||||
{
|
||||
nsIDOMDocument* prop;
|
||||
if (JSVAL_IS_OBJECT(*vp)) {
|
||||
JSObject *jsobj = JSVAL_TO_OBJECT(*vp);
|
||||
nsISupports *supports = (nsISupports *)JS_GetPrivate(cx, jsobj);
|
||||
if (NS_OK != supports->QueryInterface(kIDocumentIID, (void **)&prop)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
}
|
||||
else if (JSVAL_IS_NULL(*vp)) {
|
||||
prop = nsnull;
|
||||
}
|
||||
else {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
a->SetDocument(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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// DocumentContext finalizer
|
||||
//
|
||||
PR_STATIC_CALLBACK(void)
|
||||
FinalizeDocumentContext(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
nsIDOMDocumentContext *a = (nsIDOMDocumentContext*)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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// DocumentContext enumerate
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
EnumerateDocumentContext(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
nsIDOMDocumentContext *a = (nsIDOMDocumentContext*)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;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// DocumentContext resolve
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
ResolveDocumentContext(JSContext *cx, JSObject *obj, jsval id)
|
||||
{
|
||||
nsIDOMDocumentContext *a = (nsIDOMDocumentContext*)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 DocumentContext
|
||||
//
|
||||
JSClass DocumentContextClass = {
|
||||
"DocumentContext",
|
||||
JSCLASS_HAS_PRIVATE,
|
||||
JS_PropertyStub,
|
||||
JS_PropertyStub,
|
||||
GetDocumentContextProperty,
|
||||
SetDocumentContextProperty,
|
||||
EnumerateDocumentContext,
|
||||
ResolveDocumentContext,
|
||||
JS_ConvertStub,
|
||||
FinalizeDocumentContext
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// DocumentContext class properties
|
||||
//
|
||||
static JSPropertySpec DocumentContextProperties[] =
|
||||
{
|
||||
{"document", DOCUMENTCONTEXT_DOCUMENT, JSPROP_ENUMERATE},
|
||||
{0}
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// DocumentContext class methods
|
||||
//
|
||||
static JSFunctionSpec DocumentContextMethods[] =
|
||||
{
|
||||
{0}
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// DocumentContext constructor
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
DocumentContext(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// DocumentContext class initialization
|
||||
//
|
||||
nsresult NS_InitDocumentContextClass(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, "DocumentContext", &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
|
||||
&DocumentContextClass, // JSClass
|
||||
DocumentContext, // JSNative ctor
|
||||
0, // ctor args
|
||||
DocumentContextProperties, // proto props
|
||||
DocumentContextMethods, // 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 DocumentContext JavaScript object
|
||||
//
|
||||
extern "C" NS_DOM NS_NewScriptDocumentContext(nsIScriptContext *aContext, nsIDOMDocumentContext *aSupports, nsISupports *aParent, void **aReturn)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aContext && nsnull != aSupports && nsnull != aReturn, "null argument to NS_NewScriptDocumentContext");
|
||||
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_InitDocumentContextClass(aContext, (void **)&proto)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// create a js object for this class
|
||||
*aReturn = JS_NewObject(jscontext, &DocumentContextClass, 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;
|
||||
}
|
|
@ -0,0 +1,360 @@
|
|||
/* -*- 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 DOCUMENTFRAGMENT_MASTERDOC:
|
||||
{
|
||||
nsIDOMDocument* prop;
|
||||
if (JSVAL_IS_OBJECT(*vp)) {
|
||||
JSObject *jsobj = JSVAL_TO_OBJECT(*vp);
|
||||
nsISupports *supports = (nsISupports *)JS_GetPrivate(cx, jsobj);
|
||||
if (NS_OK != supports->QueryInterface(kIDocumentIID, (void **)&prop)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
}
|
||||
else if (JSVAL_IS_NULL(*vp)) {
|
||||
prop = nsnull;
|
||||
}
|
||||
else {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
a->SetMasterDoc(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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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},
|
||||
{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 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;
|
||||
}
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -18,16 +18,27 @@
|
|||
|
||||
#include "nsJSEnvironment.h"
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMText.h"
|
||||
#include "nsIDOMAttribute.h"
|
||||
#include "nsIDOMAttributeList.h"
|
||||
#include "nsIDOMNodeIterator.h"
|
||||
|
||||
const uint32 gGCSize = 4L * 1024L * 1024L;
|
||||
const size_t gStackSize = 8192;
|
||||
|
||||
static NS_DEFINE_IID(kIScriptContextIID, NS_ISCRIPTCONTEXT_IID);
|
||||
static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID);
|
||||
|
||||
nsJSContext::nsJSContext(JSRuntime *aRuntime)
|
||||
{
|
||||
mRefCnt = 1;
|
||||
mRefCnt = 0;
|
||||
mContext = JS_NewContext(aRuntime, gStackSize);
|
||||
JS_SetContextPrivate(mContext, (void *)this);
|
||||
}
|
||||
|
||||
nsJSContext::~nsJSContext()
|
||||
|
@ -50,81 +61,105 @@ PRBool nsJSContext::EvaluateString(const char *aScript,
|
|||
aRetValue);
|
||||
}
|
||||
|
||||
JSObject* nsJSContext::GetGlobalObject()
|
||||
nsIScriptGlobalObject* nsJSContext::GetGlobalObject()
|
||||
{
|
||||
return JS_GetGlobalObject(mContext);
|
||||
JSObject *global = JS_GetGlobalObject(mContext);
|
||||
nsIScriptGlobalObject *script_global;
|
||||
|
||||
if (nsnull != global) {
|
||||
script_global = (nsIScriptGlobalObject *)JS_GetPrivate(mContext, global);
|
||||
NS_ADDREF(script_global);
|
||||
return script_global;
|
||||
}
|
||||
else {
|
||||
return nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
JSContext* nsJSContext::GetContext()
|
||||
void* nsJSContext::GetNativeContext()
|
||||
{
|
||||
return mContext;
|
||||
return (void *)mContext;
|
||||
}
|
||||
|
||||
#define GLOBAL_OBJECT_NAME "window_object"
|
||||
nsresult NS_NewGlobalWindow(JSContext *aContext, nsIWebWidget *aWindow, void **aJSObject);
|
||||
|
||||
nsresult nsJSContext::InitContext(nsIWebWidget *aGlobalObject)
|
||||
nsresult nsJSContext::InitContext(nsIScriptGlobalObject *aGlobalObject)
|
||||
{
|
||||
nsresult result = NS_ERROR_FAILURE;
|
||||
|
||||
nsIScriptObjectOwner *owner;
|
||||
JSObject *global;
|
||||
nsresult res = NS_NewGlobalWindow(mContext, aGlobalObject, (void**)&global);
|
||||
nsresult res = aGlobalObject->QueryInterface(kIScriptObjectOwnerIID, (void **)&owner);
|
||||
|
||||
if (NS_OK == res) {
|
||||
res = owner->GetScriptObject(this, (void **)&global);
|
||||
|
||||
// init standard classes
|
||||
if (::JS_InitStandardClasses(mContext, global)) {
|
||||
res = InitAllClasses(); // this will complete the global object initialization
|
||||
if ((NS_OK == res) && ::JS_InitStandardClasses(mContext, global)) {
|
||||
JS_SetGlobalObject(mContext, global);
|
||||
res = InitClasses(); // this will complete the global object initialization
|
||||
}
|
||||
|
||||
NS_RELEASE(owner);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
nsresult NS_InitWindowClass(JSContext *aContext, JSObject *aGlobal);
|
||||
nsresult NS_InitNodeClass(JSContext *aContext, JSObject **aPrototype);
|
||||
nsresult NS_InitElementClass(JSContext *aContext, JSObject **aPrototype);
|
||||
nsresult NS_InitDocumentClass(JSContext *aContext, JSObject **aPrototype);
|
||||
nsresult NS_InitTextClass(JSContext *aContext, JSObject **aPrototype);
|
||||
nsresult NS_InitAttributeClass(JSContext *aContext, JSObject **aPrototype);
|
||||
nsresult NS_InitAttributeListClass(JSContext *aContext, JSObject **aPrototype);
|
||||
nsresult NS_InitNodeIteratorClass(JSContext *aContext, JSObject **aPrototype);
|
||||
|
||||
nsresult nsJSContext::InitAllClasses()
|
||||
nsresult nsJSContext::InitClasses()
|
||||
{
|
||||
if (NS_OK == NS_InitWindowClass(mContext, GetGlobalObject()) &&
|
||||
NS_OK == NS_InitNodeClass(mContext, nsnull) &&
|
||||
NS_OK == NS_InitElementClass(mContext, nsnull) &&
|
||||
NS_OK == NS_InitDocumentClass(mContext, nsnull) &&
|
||||
NS_OK == NS_InitTextClass(mContext, nsnull) &&
|
||||
NS_OK == NS_InitAttributeClass(mContext, nsnull) &&
|
||||
NS_OK == NS_InitAttributeListClass(mContext, nsnull) &&
|
||||
NS_OK == NS_InitNodeIteratorClass(mContext, nsnull))
|
||||
return NS_OK;
|
||||
nsresult res = NS_ERROR_FAILURE;
|
||||
nsIScriptGlobalObject *global = GetGlobalObject();
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
if (NS_OK == NS_InitWindowClass(this, global) &&
|
||||
NS_OK == NS_InitNodeClass(this, nsnull) &&
|
||||
NS_OK == NS_InitElementClass(this, nsnull) &&
|
||||
NS_OK == NS_InitDocumentClass(this, nsnull) &&
|
||||
NS_OK == NS_InitTextClass(this, nsnull) &&
|
||||
NS_OK == NS_InitAttributeClass(this, nsnull) &&
|
||||
NS_OK == NS_InitAttributeListClass(this, nsnull) &&
|
||||
NS_OK == NS_InitNodeIteratorClass(this, nsnull)) {
|
||||
res = NS_OK;
|
||||
}
|
||||
|
||||
NS_RELEASE(global);
|
||||
return res;
|
||||
}
|
||||
|
||||
nsJSEnvironment *nsJSEnvironment::sTheEnvironment = nsnull;
|
||||
|
||||
nsJSEnvironment *
|
||||
nsJSEnvironment::GetScriptingEnvironment()
|
||||
{
|
||||
if (nsnull == sTheEnvironment) {
|
||||
sTheEnvironment = new nsJSEnvironment();
|
||||
}
|
||||
return sTheEnvironment;
|
||||
}
|
||||
|
||||
nsJSEnvironment::nsJSEnvironment()
|
||||
{
|
||||
mRuntime = JS_Init(gGCSize);
|
||||
mScriptContext = new nsJSContext(mRuntime);
|
||||
}
|
||||
|
||||
nsJSEnvironment::~nsJSEnvironment()
|
||||
{
|
||||
NS_RELEASE(mScriptContext);
|
||||
JS_Finish(mRuntime);
|
||||
}
|
||||
|
||||
nsIScriptContext* nsJSEnvironment::GetContext()
|
||||
nsIScriptContext* nsJSEnvironment::GetNewContext()
|
||||
{
|
||||
return mScriptContext;
|
||||
nsIScriptContext *context;
|
||||
context = new nsJSContext(mRuntime);
|
||||
NS_ADDREF(context);
|
||||
return context;
|
||||
}
|
||||
|
||||
extern "C" NS_DOM NS_CreateContext(nsIWebWidget *aGlobal, nsIScriptContext **aContext)
|
||||
|
||||
extern "C" NS_DOM NS_CreateContext(nsIScriptGlobalObject *aGlobal, nsIScriptContext **aContext)
|
||||
{
|
||||
nsJSEnvironment *environment = new nsJSEnvironment();
|
||||
*aContext = environment->GetContext();
|
||||
nsJSEnvironment *environment = nsJSEnvironment::GetScriptingEnvironment();
|
||||
*aContext = environment->GetNewContext();
|
||||
(*aContext)->InitContext(aGlobal);
|
||||
aGlobal->SetContext(*aContext);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,54 +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.
|
||||
*/
|
||||
#ifndef nsJSEnvironment_h___
|
||||
#define nsJSEnvironment_h___
|
||||
|
||||
#include "nsIScriptContext.h"
|
||||
|
||||
class nsJSContext : public nsIScriptContext {
|
||||
private:
|
||||
JSContext *mContext;
|
||||
|
||||
public:
|
||||
nsJSContext(JSRuntime *aRuntime);
|
||||
~nsJSContext();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
virtual PRBool EvaluateString(const char *aScript,
|
||||
PRUint32 aScriptSize,
|
||||
jsval *aRetValue);
|
||||
virtual JSObject* GetGlobalObject();
|
||||
virtual JSContext* GetContext();
|
||||
virtual nsresult InitAllClasses();
|
||||
virtual nsresult InitContext(nsIWebWidget *aGlobalObject);
|
||||
};
|
||||
|
||||
class nsJSEnvironment {
|
||||
private:
|
||||
nsIScriptContext *mScriptContext;
|
||||
JSRuntime *mRuntime;
|
||||
|
||||
public:
|
||||
nsJSEnvironment();
|
||||
~nsJSEnvironment();
|
||||
|
||||
nsIScriptContext* GetContext();
|
||||
};
|
||||
|
||||
#endif /* nsJSEnvironment_h___ */
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -15,322 +15,527 @@
|
|||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
/* AUTO-GENERATED. DO NOT EDIT!!! */
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "nscore.h"
|
||||
#include "nsIScriptObject.h"
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsIJSScriptObject.h"
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
#include "nsIDOMIterators.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIPtr.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIDOMNodeIterator.h"
|
||||
#include "nsIDOMNode.h"
|
||||
|
||||
static NS_DEFINE_IID(kIScriptObjectIID, NS_ISCRIPTOBJECT_IID);
|
||||
|
||||
static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID);
|
||||
static NS_DEFINE_IID(kIDOMNodeIID, NS_IDOMNODE_IID);
|
||||
static NS_DEFINE_IID(kIJSScriptObjectIID, NS_IJSSCRIPTOBJECT_IID);
|
||||
static NS_DEFINE_IID(kIScriptGlobalObjectIID, NS_ISCRIPTGLOBALOBJECT_IID);
|
||||
static NS_DEFINE_IID(kINodeIteratorIID, NS_IDOMNODEITERATOR_IID);
|
||||
static NS_DEFINE_IID(kINodeIID, NS_IDOMNODE_IID);
|
||||
|
||||
NS_DEF_PTR(nsIDOMNodeIterator);
|
||||
NS_DEF_PTR(nsIDOMNode);
|
||||
|
||||
|
||||
/***********************************************************************/
|
||||
|
||||
//
|
||||
// NodeIterator properties getter
|
||||
// NodeIterator Properties Getter
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
GetNodeIteratorProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
{
|
||||
nsIDOMNodeIterator *nodeIterator = (nsIDOMNodeIterator*)JS_GetPrivate(cx, obj);
|
||||
// NS_ASSERTION(nsnull != nodeIterator, "null pointer");
|
||||
nsIDOMNodeIterator *a = (nsIDOMNodeIterator*)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: //this is just to keep the compiler from issuing a warning
|
||||
//that there is a switch with only a default case. MMP
|
||||
default:
|
||||
nsIScriptObject *object;
|
||||
if (NS_OK == nodeIterator->QueryInterface(kIScriptObjectIID, (void**)&object)) {
|
||||
return object->GetProperty(cx, id, vp);
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
/***********************************************************************/
|
||||
//
|
||||
// NodeIterator properties setter
|
||||
// NodeIterator Properties Setter
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
SetNodeIteratorProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
{
|
||||
nsIDOMNodeIterator *nodeIterator = (nsIDOMNodeIterator*)JS_GetPrivate(cx, obj);
|
||||
NS_ASSERTION(nsnull != nodeIterator, "null pointer");
|
||||
nsIDOMNodeIterator *a = (nsIDOMNodeIterator*)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: //this is just to keep the compiler from issuing a warning
|
||||
//that there is a switch with only a default case. MMP
|
||||
default:
|
||||
nsIScriptObject *object;
|
||||
if (NS_OK == nodeIterator->QueryInterface(kIScriptObjectIID, (void**)&object)) {
|
||||
return object->SetProperty(cx, id, vp);
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// NodeIterator finalizer
|
||||
//
|
||||
PR_STATIC_CALLBACK(void)
|
||||
FinalizeNodeIterator(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
nsIDOMNodeIterator *nodeIterator = (nsIDOMNodeIterator*)JS_GetPrivate(cx, obj);
|
||||
nsIDOMNodeIterator *a = (nsIDOMNodeIterator*)JS_GetPrivate(cx, obj);
|
||||
|
||||
if (nsnull != nodeIterator) {
|
||||
if (nsnull != a) {
|
||||
// get the js object
|
||||
nsIScriptObjectOwner *owner = nsnull;
|
||||
if (NS_OK == nodeIterator->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) {
|
||||
if (NS_OK == a->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) {
|
||||
owner->ResetScriptObject();
|
||||
NS_RELEASE(owner);
|
||||
}
|
||||
|
||||
nodeIterator->Release();
|
||||
NS_RELEASE(a);
|
||||
}
|
||||
}
|
||||
|
||||
/***********************************************************************/
|
||||
|
||||
//
|
||||
// JS->Native functions
|
||||
// NodeIterator enumerate
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
SetFilter(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
EnumerateNodeIterator(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
GetLength(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMNodeIterator *nodeIterator = (nsIDOMNodeIterator*)JS_GetPrivate(cx, obj);
|
||||
NS_ASSERTION(nsnull != nodeIterator, "null pointer");
|
||||
|
||||
PRUint32 length = 0;
|
||||
// call the function
|
||||
if (NS_OK == nodeIterator->GetLength(&length)) {
|
||||
// set the return value
|
||||
*rval = INT_TO_JSVAL(length);
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
GetCurrentNode(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMNodeIterator *nodeIterator = (nsIDOMNodeIterator*)JS_GetPrivate(cx, obj);
|
||||
NS_ASSERTION(nsnull != nodeIterator, "null pointer");
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIDOMNode *aNode1 = nsnull;
|
||||
// call the function
|
||||
if (NS_OK == nodeIterator->GetCurrentNode(&aNode1)) {
|
||||
|
||||
nsIDOMNodeIterator *a = (nsIDOMNodeIterator*)JS_GetPrivate(cx, obj);
|
||||
|
||||
if (nsnull != a) {
|
||||
// get the js object
|
||||
nsIScriptObjectOwner *owner = nsnull;
|
||||
if (NS_OK == aNode1->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) {
|
||||
JSObject *object = nsnull;
|
||||
if (NS_OK == owner->GetScriptObject(cx, (void**)&object)) {
|
||||
// set the return value
|
||||
*rval = OBJECT_TO_JSVAL(object);
|
||||
}
|
||||
NS_RELEASE(owner);
|
||||
nsIJSScriptObject *object;
|
||||
if (NS_OK == a->QueryInterface(kIJSScriptObjectIID, (void**)&object)) {
|
||||
object->EnumerateProperty(cx);
|
||||
NS_RELEASE(object);
|
||||
}
|
||||
NS_RELEASE(aNode1);
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// NodeIterator resolve
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
GetNextNode(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
ResolveNodeIterator(JSContext *cx, JSObject *obj, jsval id)
|
||||
{
|
||||
nsIDOMNodeIterator *nodeIterator = (nsIDOMNodeIterator*)JS_GetPrivate(cx, obj);
|
||||
NS_ASSERTION(nsnull != nodeIterator, "null pointer");
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIDOMNode *aNode1 = nsnull;
|
||||
// call the function
|
||||
if (NS_OK == nodeIterator->GetNextNode(&aNode1)) {
|
||||
|
||||
nsIDOMNodeIterator *a = (nsIDOMNodeIterator*)JS_GetPrivate(cx, obj);
|
||||
|
||||
if (nsnull != a) {
|
||||
// get the js object
|
||||
nsIScriptObjectOwner *owner = nsnull;
|
||||
if (NS_OK == aNode1->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) {
|
||||
JSObject *object = nsnull;
|
||||
if (NS_OK == owner->GetScriptObject(cx, (void**)&object)) {
|
||||
// set the return value
|
||||
*rval = OBJECT_TO_JSVAL(object);
|
||||
}
|
||||
NS_RELEASE(owner);
|
||||
nsIJSScriptObject *object;
|
||||
if (NS_OK == a->QueryInterface(kIJSScriptObjectIID, (void**)&object)) {
|
||||
object->Resolve(cx, id);
|
||||
NS_RELEASE(object);
|
||||
}
|
||||
NS_RELEASE(aNode1);
|
||||
}
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method GetLength
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
NodeIteratorGetLength(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMNodeIterator *nativeThis = (nsIDOMNodeIterator*)JS_GetPrivate(cx, obj);
|
||||
JSBool rBool = JS_FALSE;
|
||||
PRUint32 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->GetLength(&nativeRet)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
*rval = INT_TO_JSVAL(nativeRet);
|
||||
}
|
||||
else {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method GetCurrentNode
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
GetPreviousNode(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
NodeIteratorGetCurrentNode(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMNodeIterator *nodeIterator = (nsIDOMNodeIterator*)JS_GetPrivate(cx, obj);
|
||||
NS_ASSERTION(nsnull != nodeIterator, "null pointer");
|
||||
nsIDOMNodeIterator *nativeThis = (nsIDOMNodeIterator*)JS_GetPrivate(cx, obj);
|
||||
JSBool rBool = JS_FALSE;
|
||||
nsIDOMNode* nativeRet;
|
||||
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIDOMNode *aNode1 = nsnull;
|
||||
// call the function
|
||||
if (NS_OK == nodeIterator->GetPreviousNode(&aNode1)) {
|
||||
|
||||
// get the js object
|
||||
nsIScriptObjectOwner *owner = nsnull;
|
||||
if (NS_OK == aNode1->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) {
|
||||
JSObject *object = nsnull;
|
||||
if (NS_OK == owner->GetScriptObject(cx, (void**)&object)) {
|
||||
// set the return value
|
||||
*rval = OBJECT_TO_JSVAL(object);
|
||||
}
|
||||
NS_RELEASE(owner);
|
||||
}
|
||||
NS_RELEASE(aNode1);
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == nativeThis) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
if (argc >= 0) {
|
||||
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
ToFirst(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMNodeIterator *nodeIterator = (nsIDOMNodeIterator*)JS_GetPrivate(cx, obj);
|
||||
NS_ASSERTION(nsnull != nodeIterator, "null pointer");
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIDOMNode *aNode1 = nsnull;
|
||||
// call the function
|
||||
if (NS_OK == nodeIterator->ToFirst(&aNode1)) {
|
||||
|
||||
// get the js object
|
||||
nsIScriptObjectOwner *owner = nsnull;
|
||||
if (NS_OK == aNode1->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) {
|
||||
JSObject *object = nsnull;
|
||||
if (NS_OK == owner->GetScriptObject(cx, (void**)&object)) {
|
||||
// set the return value
|
||||
*rval = OBJECT_TO_JSVAL(object);
|
||||
}
|
||||
NS_RELEASE(owner);
|
||||
if (NS_OK != nativeThis->GetCurrentNode(&nativeRet)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(aNode1);
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
ToLast(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMNodeIterator *nodeIterator = (nsIDOMNodeIterator*)JS_GetPrivate(cx, obj);
|
||||
NS_ASSERTION(nsnull != nodeIterator, "null pointer");
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIDOMNode *aNode1 = nsnull;
|
||||
// call the function
|
||||
if (NS_OK == nodeIterator->ToLast(&aNode1)) {
|
||||
|
||||
// get the js object
|
||||
nsIScriptObjectOwner *owner = nsnull;
|
||||
if (NS_OK == aNode1->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) {
|
||||
JSObject *object = nsnull;
|
||||
if (NS_OK == owner->GetScriptObject(cx, (void**)&object)) {
|
||||
// set the return value
|
||||
*rval = OBJECT_TO_JSVAL(object);
|
||||
}
|
||||
NS_RELEASE(owner);
|
||||
}
|
||||
NS_RELEASE(aNode1);
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
MoveTo(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMNodeIterator *nodeIterator = (nsIDOMNodeIterator*)JS_GetPrivate(cx, obj);
|
||||
NS_ASSERTION(nsnull != nodeIterator, "null pointer");
|
||||
NS_ASSERTION(1 == argc, "wrong number of arguments");
|
||||
*rval = JSVAL_NULL;
|
||||
if (1 == argc) {
|
||||
// get the arguments
|
||||
if (JSVAL_IS_INT(argv[0])) {
|
||||
|
||||
nsIDOMNode *aNode1 = nsnull;
|
||||
// call the function
|
||||
if (NS_OK == nodeIterator->MoveTo(JSVAL_TO_INT(argv[0]), &aNode1)) {
|
||||
|
||||
// get the js object
|
||||
nsIScriptObjectOwner *owner = nsnull;
|
||||
if (NS_OK == aNode1->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) {
|
||||
JSObject *object = nsnull;
|
||||
if (NS_OK == owner->GetScriptObject(cx, (void**)&object)) {
|
||||
// set the return value
|
||||
*rval = OBJECT_TO_JSVAL(object);
|
||||
}
|
||||
NS_RELEASE(owner);
|
||||
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(aNode1);
|
||||
NS_RELEASE(owner);
|
||||
}
|
||||
NS_RELEASE(nativeRet);
|
||||
}
|
||||
else {
|
||||
*rval = JSVAL_NULL;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method GetNextNode
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
NodeIteratorGetNextNode(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMNodeIterator *nativeThis = (nsIDOMNodeIterator*)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->GetNextNode(&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 {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method GetPreviousNode
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
NodeIteratorGetPreviousNode(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMNodeIterator *nativeThis = (nsIDOMNodeIterator*)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->GetPreviousNode(&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 {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method ToFirst
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
NodeIteratorToFirst(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMNodeIterator *nativeThis = (nsIDOMNodeIterator*)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->ToFirst(&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 {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method ToLast
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
NodeIteratorToLast(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMNodeIterator *nativeThis = (nsIDOMNodeIterator*)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->ToLast(&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 {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method MoveTo
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
NodeIteratorMoveTo(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMNodeIterator *nativeThis = (nsIDOMNodeIterator*)JS_GetPrivate(cx, obj);
|
||||
JSBool rBool = JS_FALSE;
|
||||
nsIDOMNode* nativeRet;
|
||||
PRInt32 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)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (NS_OK != nativeThis->MoveTo(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 {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************/
|
||||
//
|
||||
// the jscript class for a DOM NodeIterator
|
||||
// class for NodeIterator
|
||||
//
|
||||
JSClass nodeIterator = {
|
||||
JSClass NodeIteratorClass = {
|
||||
"NodeIterator",
|
||||
JSCLASS_HAS_PRIVATE,
|
||||
JS_PropertyStub,
|
||||
JS_PropertyStub,
|
||||
GetNodeIteratorProperty,
|
||||
JS_PropertyStub,
|
||||
JS_PropertyStub,
|
||||
GetNodeIteratorProperty,
|
||||
SetNodeIteratorProperty,
|
||||
JS_EnumerateStub,
|
||||
JS_ResolveStub,
|
||||
JS_ConvertStub,
|
||||
EnumerateNodeIterator,
|
||||
ResolveNodeIterator,
|
||||
JS_ConvertStub,
|
||||
FinalizeNodeIterator
|
||||
};
|
||||
|
||||
//
|
||||
// NodeIterator property ids
|
||||
//
|
||||
|
||||
//
|
||||
// NodeIterator class properties
|
||||
//
|
||||
static JSPropertySpec NodeIteratorProperties[] =
|
||||
{
|
||||
{0}
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// NodeIterator class methods
|
||||
//
|
||||
static JSFunctionSpec nodeIteratorMethods[] = {
|
||||
{"setFilter", SetFilter, 2},
|
||||
{"getLength", GetLength, 0},
|
||||
{"getCurrentNode", GetCurrentNode, 0},
|
||||
{"getNextNode", GetNextNode, 0},
|
||||
{"getPreviousNode", GetPreviousNode, 0},
|
||||
{"toFirst", ToFirst, 0},
|
||||
{"toLast", ToLast, 0},
|
||||
{"moveTo", MoveTo, 1},
|
||||
static JSFunctionSpec NodeIteratorMethods[] =
|
||||
{
|
||||
{"getLength", NodeIteratorGetLength, 0},
|
||||
{"getCurrentNode", NodeIteratorGetCurrentNode, 0},
|
||||
{"getNextNode", NodeIteratorGetNextNode, 0},
|
||||
{"getPreviousNode", NodeIteratorGetPreviousNode, 0},
|
||||
{"toFirst", NodeIteratorToFirst, 0},
|
||||
{"toLast", NodeIteratorToLast, 0},
|
||||
{"moveTo", NodeIteratorMoveTo, 1},
|
||||
{0}
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// NodeIterator constructor
|
||||
//
|
||||
|
@ -340,79 +545,93 @@ NodeIterator(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
|||
return JS_TRUE;
|
||||
}
|
||||
|
||||
//
|
||||
// NodeIterator static property ids
|
||||
//
|
||||
|
||||
//
|
||||
// NodeIterator static properties
|
||||
// NodeIterator class initialization
|
||||
//
|
||||
|
||||
//
|
||||
// NodeIterator static methods
|
||||
//
|
||||
|
||||
/***********************************************************************/
|
||||
|
||||
//
|
||||
// Init this object class
|
||||
//
|
||||
nsresult NS_InitNodeIteratorClass(JSContext *aContext, JSObject **aPrototype)
|
||||
nsresult NS_InitNodeIteratorClass(nsIScriptContext *aContext, void **aPrototype)
|
||||
{
|
||||
// look in the global object for this class prototype
|
||||
static JSObject *proto = nsnull;
|
||||
JSContext *jscontext = (JSContext *)aContext->GetNativeContext();
|
||||
JSObject *proto = nsnull;
|
||||
JSObject *constructor = nsnull;
|
||||
JSObject *parent_proto = nsnull;
|
||||
JSObject *global = JS_GetGlobalObject(jscontext);
|
||||
jsval vp;
|
||||
|
||||
if (nsnull == proto) {
|
||||
proto = JS_InitClass(aContext, // context
|
||||
JS_GetGlobalObject(aContext), // global object
|
||||
NULL, // parent proto
|
||||
&nodeIterator, // JSClass
|
||||
NodeIterator, // JSNative ctor
|
||||
0, // ctor args
|
||||
NULL, // proto props
|
||||
nodeIteratorMethods, // proto funcs
|
||||
NULL, // ctor props (static)
|
||||
NULL); // ctor funcs (static)
|
||||
if ((PR_TRUE != JS_LookupProperty(jscontext, global, "NodeIterator", &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
|
||||
&NodeIteratorClass, // JSClass
|
||||
NodeIterator, // JSNative ctor
|
||||
0, // ctor args
|
||||
NodeIteratorProperties, // proto props
|
||||
NodeIteratorMethods, // 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 (nsnull != aPrototype) {
|
||||
if (aPrototype) {
|
||||
*aPrototype = proto;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//
|
||||
// NodeIterator instance property ids
|
||||
//
|
||||
|
||||
//
|
||||
// NodeIterator instance properties
|
||||
// Method for creating a new NodeIterator JavaScript object
|
||||
//
|
||||
|
||||
//
|
||||
// New a nodeIterator object in js, connect the native and js worlds
|
||||
//
|
||||
extern "C" NS_DOM nsresult NS_NewScriptNodeIterator(JSContext *aContext, nsIDOMNodeIterator *aNodeIterator, JSObject *aParent, JSObject **aJSObject)
|
||||
extern "C" NS_DOM NS_NewScriptNodeIterator(nsIScriptContext *aContext, nsIDOMNodeIterator *aSupports, nsISupports *aParent, void **aReturn)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aContext && nsnull != aNodeIterator && nsnull != aJSObject, "null arg");
|
||||
NS_PRECONDITION(nsnull != aContext && nsnull != aSupports && nsnull != aReturn, "null argument to NS_NewScriptNodeIterator");
|
||||
JSObject *proto;
|
||||
NS_InitNodeIteratorClass(aContext, &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_InitNodeIteratorClass(aContext, (void **)&proto)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// create a js object for this class
|
||||
*aJSObject = JS_NewObject(aContext, &nodeIterator, proto, aParent);
|
||||
if (nsnull != *aJSObject) {
|
||||
// define the instance specific properties
|
||||
|
||||
*aReturn = JS_NewObject(jscontext, &NodeIteratorClass, proto, parent);
|
||||
if (nsnull != *aReturn) {
|
||||
// connect the native object to the js object
|
||||
JS_SetPrivate(aContext, *aJSObject, aNodeIterator);
|
||||
aNodeIterator->AddRef();
|
||||
JS_SetPrivate(jscontext, (JSObject *)*aReturn, aSupports);
|
||||
NS_ADDREF(aSupports);
|
||||
}
|
||||
else {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
else return NS_ERROR_FAILURE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,238 +15,471 @@
|
|||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
/* AUTO-GENERATED. DO NOT EDIT!!! */
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "nscore.h"
|
||||
#include "nsIScriptObject.h"
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsIJSScriptObject.h"
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
#include "nsIDOMText.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIPtr.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMText.h"
|
||||
|
||||
|
||||
static NS_DEFINE_IID(kIScriptObjectIID, NS_ISCRIPTOBJECT_IID);
|
||||
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(kITextIID, NS_IDOMTEXT_IID);
|
||||
|
||||
NS_DEF_PTR(nsIDOMElement);
|
||||
NS_DEF_PTR(nsIDOMText);
|
||||
|
||||
//
|
||||
// Text property ids
|
||||
//
|
||||
enum text_slot {
|
||||
TEXT_DATA = -1
|
||||
enum Text_slots {
|
||||
TEXT_DATA = -11
|
||||
};
|
||||
|
||||
/***********************************************************************/
|
||||
|
||||
//
|
||||
// Text properties getter
|
||||
// Text Properties Getter
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
GetTextProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
{
|
||||
nsIDOMText *text = (nsIDOMText*)JS_GetPrivate(cx, obj);
|
||||
// NS_ASSERTION(nsnull != text, "null pointer");
|
||||
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 TEXT_DATA:
|
||||
{
|
||||
nsAutoString string;
|
||||
if (NS_OK == text->GetData(string)) {
|
||||
JSString *jsstring = JS_NewUCStringCopyN(cx, string, string.Length());
|
||||
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);
|
||||
}
|
||||
}
|
||||
default:
|
||||
{
|
||||
nsIScriptObject *object;
|
||||
if (NS_OK == text->QueryInterface(kIScriptObjectIID, (void**)&object)) {
|
||||
return object->GetProperty(cx, id, vp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
//
|
||||
// Text properties setter
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
SetTextProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
{
|
||||
nsIDOMText *text = (nsIDOMText*)JS_GetPrivate(cx, obj);
|
||||
NS_ASSERTION(nsnull != text, "null pointer");
|
||||
|
||||
if (JSVAL_IS_INT(id)) {
|
||||
switch(JSVAL_TO_INT(id)) {
|
||||
case TEXT_DATA:
|
||||
{
|
||||
if (JSVAL_IS_STRING(*vp)) {
|
||||
JSString *jsstring = JSVAL_TO_STRING(*vp);
|
||||
nsAutoString string = JS_GetStringChars(jsstring);
|
||||
text->SetData(string);
|
||||
else {
|
||||
return JS_FALSE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
nsIScriptObject *object;
|
||||
if (NS_OK == text->QueryInterface(kIScriptObjectIID, (void**)&object)) {
|
||||
return object->SetProperty(cx, id, vp);
|
||||
nsIJSScriptObject *object;
|
||||
if (NS_OK == a->QueryInterface(kIJSScriptObjectIID, (void**)&object)) {
|
||||
PRBool rval;
|
||||
rval = object->GetProperty(cx, id, vp);
|
||||
NS_RELEASE(object);
|
||||
return rval;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
/***********************************************************************/
|
||||
//
|
||||
// Finalize Text
|
||||
// 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 TEXT_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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Text finalizer
|
||||
//
|
||||
PR_STATIC_CALLBACK(void)
|
||||
FinalizeText(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
nsIDOMText *text = (nsIDOMText*)JS_GetPrivate(cx, obj);
|
||||
nsIDOMText *a = (nsIDOMText*)JS_GetPrivate(cx, obj);
|
||||
|
||||
if (nsnull != text) {
|
||||
if (nsnull != a) {
|
||||
// get the js object
|
||||
nsIScriptObjectOwner *owner = nsnull;
|
||||
if (NS_OK == text->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) {
|
||||
if (NS_OK == a->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) {
|
||||
owner->ResetScriptObject();
|
||||
NS_RELEASE(owner);
|
||||
}
|
||||
|
||||
text->Release();
|
||||
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 Append
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
TextAppend(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMText *nativeThis = (nsIDOMText*)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 {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method Insert
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
TextInsert(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMText *nativeThis = (nsIDOMText*)JS_GetPrivate(cx, obj);
|
||||
JSBool rBool = JS_FALSE;
|
||||
PRInt32 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)) {
|
||||
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 {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method Delete
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
TextDelete(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMText *nativeThis = (nsIDOMText*)JS_GetPrivate(cx, obj);
|
||||
JSBool rBool = JS_FALSE;
|
||||
PRInt32 b0;
|
||||
PRInt32 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)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (!JS_ValueToInt32(cx, argv[1], (int32 *)&b1)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (NS_OK != nativeThis->Delete(b0, b1)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
*rval = JSVAL_VOID;
|
||||
}
|
||||
else {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method Replace
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
TextReplace(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMText *nativeThis = (nsIDOMText*)JS_GetPrivate(cx, obj);
|
||||
JSBool rBool = JS_FALSE;
|
||||
PRInt32 b0;
|
||||
PRInt32 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)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (!JS_ValueToInt32(cx, argv[1], (int32 *)&b1)) {
|
||||
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 {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method Splice
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
TextSplice(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMText *nativeThis = (nsIDOMText*)JS_GetPrivate(cx, obj);
|
||||
JSBool rBool = JS_FALSE;
|
||||
nsIDOMElementPtr b0;
|
||||
PRInt32 b1;
|
||||
PRInt32 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 (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(kIElementIID, (void **)(b0.Query())))) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
}
|
||||
else if (JSVAL_IS_NULL(argv[0])){
|
||||
b0 = nsnull;
|
||||
}
|
||||
else {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (!JS_ValueToInt32(cx, argv[1], (int32 *)&b1)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (!JS_ValueToInt32(cx, argv[2], (int32 *)&b2)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (NS_OK != nativeThis->Splice(b0, b1, b2)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
*rval = JSVAL_VOID;
|
||||
}
|
||||
else {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************/
|
||||
//
|
||||
// JS->Native functions
|
||||
// class for Text
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
Append(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMText *text = (nsIDOMText*)JS_GetPrivate(cx, obj);
|
||||
NS_ASSERTION(nsnull != text, "null pointer");
|
||||
NS_ASSERTION(1 == argc, "wrong number of arguments");
|
||||
if (1 == argc) {
|
||||
// get the arguments
|
||||
if (JSVAL_IS_STRING(argv[0])) {
|
||||
JSString *jsstring1 = JSVAL_TO_STRING(argv[0]);
|
||||
nsAutoString string1 = JS_GetStringChars(jsstring1);
|
||||
|
||||
// call the function
|
||||
text->Append(string1);
|
||||
}
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
Insert(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMText *text = (nsIDOMText*)JS_GetPrivate(cx, obj);
|
||||
NS_ASSERTION(nsnull != text, "null pointer");
|
||||
NS_ASSERTION(2 == argc, "wrong number of arguments");
|
||||
if (2 == argc) {
|
||||
// get the arguments
|
||||
if (JSVAL_IS_INT(argv[0]) &&
|
||||
JSVAL_IS_STRING(argv[1])) {
|
||||
JSString *jsstring2 = JSVAL_TO_STRING(argv[1]);
|
||||
nsAutoString string2 = JS_GetStringChars(jsstring2);
|
||||
|
||||
// call the function
|
||||
text->Insert(JSVAL_TO_INT(argv[0]), string2);
|
||||
}
|
||||
}
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
Delete(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMText *text = (nsIDOMText*)JS_GetPrivate(cx, obj);
|
||||
NS_ASSERTION(nsnull != text, "null pointer");
|
||||
NS_ASSERTION(2 == argc, "wrong number of arguments");
|
||||
if (2 == argc) {
|
||||
// get the arguments
|
||||
if (JSVAL_IS_INT(argv[0]) && JSVAL_IS_INT(argv[1])) {
|
||||
// call the function
|
||||
text->Delete(JSVAL_TO_INT(argv[0]), JSVAL_TO_INT(argv[1]));
|
||||
}
|
||||
}
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
Replace(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMText *text = (nsIDOMText*)JS_GetPrivate(cx, obj);
|
||||
NS_ASSERTION(nsnull != text, "null pointer");
|
||||
NS_ASSERTION(3 == argc, "wrong number of arguments");
|
||||
if (3 == argc) {
|
||||
// get the arguments
|
||||
if (JSVAL_IS_INT(argv[0]) &&
|
||||
JSVAL_IS_INT(argv[1]) &&
|
||||
JSVAL_IS_STRING(argv[2])) {
|
||||
JSString *jsstring3 = JSVAL_TO_STRING(argv[2]);
|
||||
nsAutoString string3 = JS_GetStringChars(jsstring3);
|
||||
|
||||
// call the function
|
||||
text->Replace(JSVAL_TO_INT(argv[0]), JSVAL_TO_INT(argv[1]), string3);
|
||||
}
|
||||
}
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
Splice(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
//XXX TBI
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
/***********************************************************************/
|
||||
//
|
||||
// the jscript class for a DOM Text
|
||||
//
|
||||
JSClass text = {
|
||||
JSClass TextClass = {
|
||||
"Text",
|
||||
JSCLASS_HAS_PRIVATE,
|
||||
JS_PropertyStub,
|
||||
JS_PropertyStub,
|
||||
GetTextProperty,
|
||||
JS_PropertyStub,
|
||||
JS_PropertyStub,
|
||||
GetTextProperty,
|
||||
SetTextProperty,
|
||||
JS_EnumerateStub,
|
||||
JS_ResolveStub,
|
||||
JS_ConvertStub,
|
||||
EnumerateText,
|
||||
ResolveText,
|
||||
JS_ConvertStub,
|
||||
FinalizeText
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// Text class properties
|
||||
//
|
||||
static JSPropertySpec textProperties[] =
|
||||
static JSPropertySpec TextProperties[] =
|
||||
{
|
||||
{"data", TEXT_DATA, JSPROP_ENUMERATE},
|
||||
{"data", TEXT_DATA, JSPROP_ENUMERATE},
|
||||
{0}
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// Text class methods
|
||||
//
|
||||
static JSFunctionSpec textMethods[] = {
|
||||
{"append", Append, 1},
|
||||
{"insert", Insert, 2},
|
||||
{"remove", Delete, 2},
|
||||
{"replace", Replace, 3},
|
||||
{"splice", Splice, 3},
|
||||
static JSFunctionSpec TextMethods[] =
|
||||
{
|
||||
{"append", TextAppend, 1},
|
||||
{"insert", TextInsert, 2},
|
||||
{"delete", TextDelete, 2},
|
||||
{"replace", TextReplace, 3},
|
||||
{"splice", TextSplice, 3},
|
||||
{0}
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// Text constructor
|
||||
//
|
||||
|
@ -256,83 +489,96 @@ Text(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
|||
return JS_TRUE;
|
||||
}
|
||||
|
||||
//
|
||||
// Text static property ids
|
||||
//
|
||||
|
||||
//
|
||||
// Text static properties
|
||||
// Text class initialization
|
||||
//
|
||||
|
||||
//
|
||||
// Text static methods
|
||||
//
|
||||
|
||||
/***********************************************************************/
|
||||
|
||||
//
|
||||
// Init this object class
|
||||
//
|
||||
nsresult NS_InitNodeClass(JSContext *aContext, JSObject **aPrototype);
|
||||
nsresult NS_InitTextClass(JSContext *aContext, JSObject **aPrototype)
|
||||
nsresult NS_InitTextClass(nsIScriptContext *aContext, void **aPrototype)
|
||||
{
|
||||
// look in the global object for this class prototype
|
||||
static JSObject *proto = nsnull;
|
||||
JSContext *jscontext = (JSContext *)aContext->GetNativeContext();
|
||||
JSObject *proto = nsnull;
|
||||
JSObject *constructor = nsnull;
|
||||
JSObject *parent_proto = nsnull;
|
||||
JSObject *global = JS_GetGlobalObject(jscontext);
|
||||
jsval vp;
|
||||
|
||||
if (nsnull == proto) {
|
||||
JSObject *parentProto;
|
||||
NS_InitNodeClass(aContext, &parentProto);
|
||||
JSObject *proto;
|
||||
proto = JS_InitClass(aContext, // context
|
||||
JS_GetGlobalObject(aContext), // global object
|
||||
parentProto, // parent proto
|
||||
&text, // JSClass
|
||||
Text, // JSNative ctor
|
||||
0, // ctor args
|
||||
textProperties, // proto props
|
||||
textMethods, // proto funcs
|
||||
NULL, // ctor props (static)
|
||||
NULL); // ctor funcs (static)
|
||||
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_InitNodeClass(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 (nsnull != aPrototype) {
|
||||
if (aPrototype) {
|
||||
*aPrototype = proto;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//
|
||||
// Text instance property ids
|
||||
//
|
||||
|
||||
//
|
||||
// Text instance properties
|
||||
//
|
||||
|
||||
//
|
||||
// New a text object in js, connect the native and js worlds
|
||||
//
|
||||
extern "C" NS_DOM nsresult NS_NewScriptText(JSContext *aContext, nsIDOMText *aText, JSObject *aParent, JSObject **aJSObject)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aContext && nsnull != aText && nsnull != aJSObject, "null arg");
|
||||
JSObject *proto;
|
||||
NS_InitTextClass(aContext, &proto);
|
||||
|
||||
// create a js object for this class
|
||||
*aJSObject = JS_NewObject(aContext, &text, proto, aParent);
|
||||
if (nsnull != *aJSObject) {
|
||||
// define the instance specific properties
|
||||
|
||||
// connect the native object to the js object
|
||||
JS_SetPrivate(aContext, *aJSObject, aText);
|
||||
aText->AddRef();
|
||||
}
|
||||
else return NS_ERROR_FAILURE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Method for creating a new Text JavaScript object
|
||||
//
|
||||
extern "C" NS_DOM 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;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,708 @@
|
|||
/* -*- 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 "nsIDOMTreeIterator.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(kITreeIteratorIID, NS_IDOMTREEITERATOR_IID);
|
||||
static NS_DEFINE_IID(kINodeIID, NS_IDOMNODE_IID);
|
||||
|
||||
NS_DEF_PTR(nsIDOMTreeIterator);
|
||||
NS_DEF_PTR(nsIDOMNode);
|
||||
|
||||
|
||||
/***********************************************************************/
|
||||
//
|
||||
// TreeIterator Properties Getter
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
GetTreeIteratorProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
{
|
||||
nsIDOMTreeIterator *a = (nsIDOMTreeIterator*)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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
/***********************************************************************/
|
||||
//
|
||||
// TreeIterator Properties Setter
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
SetTreeIteratorProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
{
|
||||
nsIDOMTreeIterator *a = (nsIDOMTreeIterator*)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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// TreeIterator finalizer
|
||||
//
|
||||
PR_STATIC_CALLBACK(void)
|
||||
FinalizeTreeIterator(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
nsIDOMTreeIterator *a = (nsIDOMTreeIterator*)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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// TreeIterator enumerate
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
EnumerateTreeIterator(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
nsIDOMTreeIterator *a = (nsIDOMTreeIterator*)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;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// TreeIterator resolve
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
ResolveTreeIterator(JSContext *cx, JSObject *obj, jsval id)
|
||||
{
|
||||
nsIDOMTreeIterator *a = (nsIDOMTreeIterator*)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 NumChildren
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
TreeIteratorNumChildren(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMTreeIterator *nativeThis = (nsIDOMTreeIterator*)JS_GetPrivate(cx, obj);
|
||||
JSBool rBool = JS_FALSE;
|
||||
PRUint32 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->NumChildren(&nativeRet)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
*rval = INT_TO_JSVAL(nativeRet);
|
||||
}
|
||||
else {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method NumPreviousSiblings
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
TreeIteratorNumPreviousSiblings(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMTreeIterator *nativeThis = (nsIDOMTreeIterator*)JS_GetPrivate(cx, obj);
|
||||
JSBool rBool = JS_FALSE;
|
||||
PRUint32 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->NumPreviousSiblings(&nativeRet)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
*rval = INT_TO_JSVAL(nativeRet);
|
||||
}
|
||||
else {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method NumNextSiblings
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
TreeIteratorNumNextSiblings(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMTreeIterator *nativeThis = (nsIDOMTreeIterator*)JS_GetPrivate(cx, obj);
|
||||
JSBool rBool = JS_FALSE;
|
||||
PRUint32 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->NumNextSiblings(&nativeRet)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
*rval = INT_TO_JSVAL(nativeRet);
|
||||
}
|
||||
else {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method ToParent
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
TreeIteratorToParent(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMTreeIterator *nativeThis = (nsIDOMTreeIterator*)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->ToParent(&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 {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method ToPreviousSibling
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
TreeIteratorToPreviousSibling(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMTreeIterator *nativeThis = (nsIDOMTreeIterator*)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->ToPreviousSibling(&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 {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method ToNextSibling
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
TreeIteratorToNextSibling(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMTreeIterator *nativeThis = (nsIDOMTreeIterator*)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->ToNextSibling(&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 {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method ToFirstChild
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
TreeIteratorToFirstChild(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMTreeIterator *nativeThis = (nsIDOMTreeIterator*)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->ToFirstChild(&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 {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method ToLastChild
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
TreeIteratorToLastChild(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMTreeIterator *nativeThis = (nsIDOMTreeIterator*)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->ToLastChild(&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 {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method ToNthChild
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
TreeIteratorToNthChild(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMTreeIterator *nativeThis = (nsIDOMTreeIterator*)JS_GetPrivate(cx, obj);
|
||||
JSBool rBool = JS_FALSE;
|
||||
nsIDOMNode* nativeRet;
|
||||
PRInt32 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)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (NS_OK != nativeThis->ToNthChild(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 {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************/
|
||||
//
|
||||
// class for TreeIterator
|
||||
//
|
||||
JSClass TreeIteratorClass = {
|
||||
"TreeIterator",
|
||||
JSCLASS_HAS_PRIVATE,
|
||||
JS_PropertyStub,
|
||||
JS_PropertyStub,
|
||||
GetTreeIteratorProperty,
|
||||
SetTreeIteratorProperty,
|
||||
EnumerateTreeIterator,
|
||||
ResolveTreeIterator,
|
||||
JS_ConvertStub,
|
||||
FinalizeTreeIterator
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// TreeIterator class properties
|
||||
//
|
||||
static JSPropertySpec TreeIteratorProperties[] =
|
||||
{
|
||||
{0}
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// TreeIterator class methods
|
||||
//
|
||||
static JSFunctionSpec TreeIteratorMethods[] =
|
||||
{
|
||||
{"numChildren", TreeIteratorNumChildren, 0},
|
||||
{"numPreviousSiblings", TreeIteratorNumPreviousSiblings, 0},
|
||||
{"numNextSiblings", TreeIteratorNumNextSiblings, 0},
|
||||
{"toParent", TreeIteratorToParent, 0},
|
||||
{"toPreviousSibling", TreeIteratorToPreviousSibling, 0},
|
||||
{"toNextSibling", TreeIteratorToNextSibling, 0},
|
||||
{"toFirstChild", TreeIteratorToFirstChild, 0},
|
||||
{"toLastChild", TreeIteratorToLastChild, 0},
|
||||
{"toNthChild", TreeIteratorToNthChild, 1},
|
||||
{0}
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// TreeIterator constructor
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
TreeIterator(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// TreeIterator class initialization
|
||||
//
|
||||
nsresult NS_InitTreeIteratorClass(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, "TreeIterator", &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_InitNodeIteratorClass(aContext, (void **)&parent_proto)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
proto = JS_InitClass(jscontext, // context
|
||||
global, // global object
|
||||
parent_proto, // parent proto
|
||||
&TreeIteratorClass, // JSClass
|
||||
TreeIterator, // JSNative ctor
|
||||
0, // ctor args
|
||||
TreeIteratorProperties, // proto props
|
||||
TreeIteratorMethods, // 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 TreeIterator JavaScript object
|
||||
//
|
||||
extern "C" NS_DOM NS_NewScriptTreeIterator(nsIScriptContext *aContext, nsIDOMTreeIterator *aSupports, nsISupports *aParent, void **aReturn)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aContext && nsnull != aSupports && nsnull != aReturn, "null argument to NS_NewScriptTreeIterator");
|
||||
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_InitTreeIteratorClass(aContext, (void **)&proto)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// create a js object for this class
|
||||
*aReturn = JS_NewObject(jscontext, &TreeIteratorClass, 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;
|
||||
}
|
|
@ -19,62 +19,78 @@
|
|||
#include "jsapi.h"
|
||||
#include "nscore.h"
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsIScriptObject.h"
|
||||
#include "nsIJSScriptObject.h"
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
#include "nsIWebWidget.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIPtr.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
|
||||
|
||||
static NS_DEFINE_IID(kIScriptObjectIID, NS_ISCRIPTOBJECT_IID);
|
||||
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(kIWindowIID, NS_IDOMWINDOW_IID);
|
||||
|
||||
NS_DEF_PTR(nsIDOMDocument);
|
||||
NS_DEF_PTR(nsIDOMWindow);
|
||||
|
||||
//
|
||||
// Window property ids
|
||||
//
|
||||
enum window_slot {
|
||||
WINDOW_DOCUMENT = -1,
|
||||
enum Window_slots {
|
||||
WINDOW_DOCUMENT = -11
|
||||
};
|
||||
|
||||
/***********************************************************************/
|
||||
|
||||
//
|
||||
// Window properties getter
|
||||
// Window Properties Getter
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
GetWindowProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
{
|
||||
nsIWebWidget *window = (nsIWebWidget*)JS_GetPrivate(cx, obj);
|
||||
NS_ASSERTION(nsnull != window, "null pointer");
|
||||
nsIDOMWindow *a = (nsIDOMWindow*)JS_GetPrivate(cx, obj);
|
||||
NS_ASSERTION(nsnull != a, "null pointer");
|
||||
|
||||
if (JSVAL_IS_INT(id)) {
|
||||
switch(JSVAL_TO_INT(id)) {
|
||||
case WINDOW_DOCUMENT:
|
||||
{
|
||||
nsIDocument *document = window->GetDocument();
|
||||
// call the function
|
||||
if (nsnull != document) {
|
||||
|
||||
nsIDOMDocument* prop;
|
||||
if (NS_OK == a->GetDocument(&prop)) {
|
||||
// get the js object
|
||||
nsIScriptObjectOwner *owner = nsnull;
|
||||
if (NS_OK == document->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) {
|
||||
JSObject *object = nsnull;
|
||||
if (NS_OK == owner->GetScriptObject(cx, (void**)&object)) {
|
||||
// set the return value
|
||||
*vp = OBJECT_TO_JSVAL(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(owner);
|
||||
NS_RELEASE(prop);
|
||||
}
|
||||
NS_RELEASE(document);
|
||||
else {
|
||||
*vp = JSVAL_NULL;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return JS_FALSE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
nsIScriptObject *object;
|
||||
if (NS_OK == window->QueryInterface(kIScriptObjectIID, (void**)&object)) {
|
||||
PRBool ret = object->GetProperty(cx, id, vp);
|
||||
nsIJSScriptObject *object;
|
||||
if (NS_OK == a->QueryInterface(kIJSScriptObjectIID, (void**)&object)) {
|
||||
PRBool rval;
|
||||
rval = object->GetProperty(cx, id, vp);
|
||||
NS_RELEASE(object);
|
||||
return ret;
|
||||
return rval;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -83,28 +99,27 @@ GetWindowProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
|||
return PR_TRUE;
|
||||
}
|
||||
|
||||
/***********************************************************************/
|
||||
//
|
||||
// Window properties setter
|
||||
// Window Properties Setter
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
SetWindowProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
{
|
||||
nsIWebWidget *window = (nsIWebWidget*)JS_GetPrivate(cx, obj);
|
||||
NS_ASSERTION(nsnull != window, "null pointer");
|
||||
nsIDOMWindow *a = (nsIDOMWindow*)JS_GetPrivate(cx, obj);
|
||||
NS_ASSERTION(nsnull != a, "null pointer");
|
||||
|
||||
if (JSVAL_IS_INT(id)) {
|
||||
switch(JSVAL_TO_INT(id)) {
|
||||
case WINDOW_DOCUMENT:
|
||||
{
|
||||
break;
|
||||
}
|
||||
case 0:
|
||||
default:
|
||||
{
|
||||
nsIScriptObject *object;
|
||||
if (NS_OK == window->QueryInterface(kIScriptObjectIID, (void**)&object)) {
|
||||
PRBool ret = object->SetProperty(cx, id, vp);
|
||||
nsIJSScriptObject *object;
|
||||
if (NS_OK == a->QueryInterface(kIJSScriptObjectIID, (void**)&object)) {
|
||||
PRBool rval;
|
||||
rval = object->SetProperty(cx, id, vp);
|
||||
NS_RELEASE(object);
|
||||
return ret;
|
||||
return rval;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -113,81 +128,130 @@ SetWindowProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
|||
return PR_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Window finalizer
|
||||
//
|
||||
PR_STATIC_CALLBACK(void)
|
||||
FinalizeWindow(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
/*
|
||||
nsIWebWidget *window = (nsIWebWidget*)JS_GetPrivate(cx, obj);
|
||||
|
||||
if (nsnull != window) {
|
||||
// get the js object
|
||||
nsIScriptObjectOwner *owner = nsnull;
|
||||
if (NS_OK == window->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) {
|
||||
owner->ResetScriptObject();
|
||||
NS_RELEASE(owner);
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
/***********************************************************************/
|
||||
|
||||
//
|
||||
// JS->Native functions
|
||||
// Window enumerate
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
Dump(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
EnumerateWindow(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
NS_ASSERTION(1 == argc, "wrong number of arguments");
|
||||
if (1 == argc) {
|
||||
// get the arguments
|
||||
if (JSVAL_IS_STRING(argv[0])) {
|
||||
JSString *jsstring1 = JSVAL_TO_STRING(argv[0]);
|
||||
char *print = JS_GetStringBytes(jsstring1);
|
||||
printf("%s", print);
|
||||
//delete print;
|
||||
nsIDOMWindow *a = (nsIDOMWindow*)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;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Window resolve
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
ResolveWindow(JSContext *cx, JSObject *obj, jsval id)
|
||||
{
|
||||
nsIDOMWindow *a = (nsIDOMWindow*)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 Dump
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
WindowDump(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMWindow *nativeThis = (nsIDOMWindow*)JS_GetPrivate(cx, obj);
|
||||
NS_ASSERTION(nsnull != nativeThis, "null pointer");
|
||||
JSBool rBool = JS_FALSE;
|
||||
nsAutoString b0;
|
||||
|
||||
*rval = JSVAL_NULL;
|
||||
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->Dump(b0)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
*rval = JSVAL_VOID;
|
||||
}
|
||||
else {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************/
|
||||
//
|
||||
// the jscript class for a DOM Window
|
||||
// class for Window
|
||||
//
|
||||
JSClass window = {
|
||||
JSClass WindowClass = {
|
||||
"Window",
|
||||
JSCLASS_HAS_PRIVATE,
|
||||
JS_PropertyStub,
|
||||
JS_PropertyStub,
|
||||
GetWindowProperty,
|
||||
JS_PropertyStub,
|
||||
JS_PropertyStub,
|
||||
GetWindowProperty,
|
||||
SetWindowProperty,
|
||||
JS_EnumerateStub,
|
||||
JS_ResolveStub,
|
||||
JS_ConvertStub,
|
||||
EnumerateWindow,
|
||||
ResolveWindow,
|
||||
JS_ConvertStub,
|
||||
FinalizeWindow
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// Window class properties
|
||||
//
|
||||
static JSPropertySpec windowProperties[] =
|
||||
static JSPropertySpec WindowProperties[] =
|
||||
{
|
||||
{"document", WINDOW_DOCUMENT, JSPROP_ENUMERATE},
|
||||
{"document", WINDOW_DOCUMENT, JSPROP_ENUMERATE | JSPROP_READONLY},
|
||||
{0}
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// Window class methods
|
||||
//
|
||||
static JSFunctionSpec windowMethods[] = {
|
||||
{"dump", Dump, 1},
|
||||
static JSFunctionSpec WindowMethods[] =
|
||||
{
|
||||
{"dump", WindowDump, 1},
|
||||
{0}
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// Window constructor
|
||||
//
|
||||
|
@ -197,47 +261,32 @@ Window(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
|||
return JS_TRUE;
|
||||
}
|
||||
|
||||
//
|
||||
// Window static property ids
|
||||
//
|
||||
|
||||
//
|
||||
// Window static properties
|
||||
// Window class initialization
|
||||
//
|
||||
|
||||
//
|
||||
// Window static methods
|
||||
//
|
||||
|
||||
/***********************************************************************/
|
||||
|
||||
//
|
||||
// Init this object class
|
||||
//
|
||||
nsresult NS_InitWindowClass(JSContext *aContext, JSObject *aGlobalObject)
|
||||
nsresult NS_InitWindowClass(nsIScriptContext *aContext,
|
||||
nsIScriptGlobalObject *aGlobal)
|
||||
{
|
||||
// look in the global object for this class prototype
|
||||
JS_DefineProperties(aContext, aGlobalObject, windowProperties);
|
||||
JS_DefineFunctions(aContext, aGlobalObject, windowMethods);
|
||||
JSContext *jscontext = (JSContext *)aContext->GetNativeContext();
|
||||
JSObject *global = JS_GetGlobalObject(jscontext);
|
||||
|
||||
JS_DefineProperties(jscontext, global, WindowProperties);
|
||||
JS_DefineFunctions(jscontext, global, WindowMethods);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//
|
||||
// Window instance property ids
|
||||
//
|
||||
|
||||
//
|
||||
// Window instance properties
|
||||
// Method for creating a new Window JavaScript object
|
||||
//
|
||||
|
||||
//
|
||||
// New a Window object in js, connect the native and js worlds
|
||||
//
|
||||
nsresult NS_NewGlobalWindow(JSContext *aContext, nsIWebWidget *aWindow, void **aJSObject)
|
||||
extern "C" NS_DOM NS_NewScriptWindow(nsIScriptContext *aContext, nsIDOMWindow *aSupports, nsISupports *aParent, void **aReturn)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aContext && nsnull != aWindow && nsnull != aJSObject, "null arg");
|
||||
NS_PRECONDITION(nsnull != aContext && nsnull != aSupports && nsnull != aReturn, "null arg");
|
||||
JSContext *jscontext = (JSContext *)aContext->GetNativeContext();
|
||||
|
||||
JSObject *global = ::JS_NewObject(aContext, &window, NULL, NULL);
|
||||
JSObject *global = ::JS_NewObject(jscontext, &WindowClass, NULL, NULL);
|
||||
if (global) {
|
||||
// The global object has a to be defined in two step:
|
||||
// 1- create a generic object, with no prototype and no parent which
|
||||
|
@ -250,13 +299,11 @@ nsresult NS_NewGlobalWindow(JSContext *aContext, nsIWebWidget *aWindow, void **a
|
|||
// after JS_InitStandardClasses
|
||||
|
||||
// assign "this" to the js object, don't AddRef
|
||||
::JS_SetPrivate(aContext, global, aWindow);
|
||||
|
||||
*aJSObject = (void*)global;
|
||||
::JS_SetPrivate(jscontext, global, aSupports);
|
||||
|
||||
*aReturn = (void*)global;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
|
Двоичные данные
dom/tests/js/DumpHTML.js
Двоичные данные
dom/tests/js/DumpHTML.js
Двоичный файл не отображается.
|
@ -130,6 +130,11 @@ void IdlVariable::GetTypeAsString(char *aString, size_t aStringSize)
|
|||
strcpy(aString, mTypeName);
|
||||
}
|
||||
break;
|
||||
case TYPE_VOID:
|
||||
if (aStringSize > 4) {
|
||||
strcpy(aString, "void");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -75,11 +75,12 @@ JSStubGen::Generate(char *aFileName,
|
|||
static const char *kIncludeDefaultsStr = "\n"
|
||||
"#include \"jsapi.h\"\n"
|
||||
"#include \"nscore.h\"\n"
|
||||
"#include \"nsIScriptObject.h\"\n"
|
||||
"#include \"nsIScriptContext.h\"\n"
|
||||
"#include \"nsIJSScriptObject.h\"\n"
|
||||
"#include \"nsIScriptObjectOwner.h\"\n"
|
||||
"#include \"nsIScriptGlobalObject.h\"\n"
|
||||
"#include \"nsIPtr.h\"\n"
|
||||
"#include \"nsString.h\"\n"
|
||||
"#include \"nsIJSGlobalObject.h\"\n";
|
||||
"#include \"nsString.h\"\n";
|
||||
static const char *kIncludeStr = "#include \"nsIDOM%s.h\"\n";
|
||||
|
||||
static PRIntn
|
||||
|
@ -107,8 +108,8 @@ JSStubGen::GenerateIncludes(IdlSpecification &aSpec)
|
|||
|
||||
static const char *kIIDDefaultStr = "\n"
|
||||
"static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID);\n"
|
||||
"static NS_DEFINE_IID(kIScriptObjectIID, NS_ISCRIPTOBJECT_IID);\n"
|
||||
"static NS_DEFINE_IID(kIJSGlobalObjectIID, NS_IJSGLOBALOBJECT_IID);\n";
|
||||
"static NS_DEFINE_IID(kIJSScriptObjectIID, NS_IJSSCRIPTOBJECT_IID);\n"
|
||||
"static NS_DEFINE_IID(kIScriptGlobalObjectIID, NS_ISCRIPTGLOBALOBJECT_IID);\n";
|
||||
static const char *kIIDStr = "static NS_DEFINE_IID(kI%sIID, %s);\n";
|
||||
|
||||
PRIntn
|
||||
|
@ -218,7 +219,11 @@ static const char *kPropFuncBeginStr = "\n"
|
|||
"%s%sProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)\n"
|
||||
"{\n"
|
||||
" nsIDOM%s *a = (nsIDOM%s*)JS_GetPrivate(cx, obj);\n"
|
||||
" NS_ASSERTION(nsnull != a, \"null pointer\");\n"
|
||||
"\n"
|
||||
" // If there's no private data, this must be the prototype, so ignore\n"
|
||||
" if (nsnull == a) {\n"
|
||||
" return JS_TRUE;\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" if (JSVAL_IS_INT(id)) {\n"
|
||||
" switch(JSVAL_TO_INT(id)) {\n";
|
||||
|
@ -226,8 +231,8 @@ static const char *kPropFuncBeginStr = "\n"
|
|||
static const char *kPropFuncEndStr =
|
||||
" default:\n"
|
||||
" {\n"
|
||||
" nsIScriptObject *object;\n"
|
||||
" if (NS_OK == a->QueryInterface(kIScriptObjectIID, (void**)&object)) {\n"
|
||||
" nsIJSScriptObject *object;\n"
|
||||
" if (NS_OK == a->QueryInterface(kIJSScriptObjectIID, (void**)&object)) {\n"
|
||||
" PRBool rval;\n"
|
||||
" rval = object->%sProperty(cx, id, vp);\n"
|
||||
" NS_RELEASE(object);\n"
|
||||
|
@ -254,7 +259,7 @@ static const char *kPropCaseEndStr =
|
|||
" break;\n"
|
||||
" }\n";
|
||||
|
||||
static const char *kNoAttrStr = " case 0:";
|
||||
static const char *kNoAttrStr = " case 0:\n";
|
||||
|
||||
|
||||
void
|
||||
|
@ -346,7 +351,8 @@ static const char *kObjectGetCaseStr =
|
|||
" nsIScriptObjectOwner *owner = nsnull;\n"
|
||||
" if (NS_OK == prop->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) {\n"
|
||||
" JSObject *object = nsnull;\n"
|
||||
" if (NS_OK == owner->GetScriptObject(cx, (void**)&object)) {\n"
|
||||
" nsIScriptContext *script_cx = (nsIScriptContext *)JS_GetContextPrivate(cx);\n"
|
||||
" if (NS_OK == owner->GetScriptObject(script_cx, (void**)&object)) {\n"
|
||||
" // set the return value\n"
|
||||
" *vp = OBJECT_TO_JSVAL(object);\n"
|
||||
" }\n"
|
||||
|
@ -588,8 +594,8 @@ static const char *kEnumerateStr =
|
|||
" \n"
|
||||
" if (nsnull != a) {\n"
|
||||
" // get the js object\n"
|
||||
" nsIScriptObject *object;\n"
|
||||
" if (NS_OK == a->QueryInterface(kIScriptObjectIID, (void**)&object)) {\n"
|
||||
" nsIJSScriptObject *object;\n"
|
||||
" if (NS_OK == a->QueryInterface(kIJSScriptObjectIID, (void**)&object)) {\n"
|
||||
" object->EnumerateProperty(cx);\n"
|
||||
" NS_RELEASE(object);\n"
|
||||
" }\n"
|
||||
|
@ -624,8 +630,8 @@ static const char *kResolveStr =
|
|||
" \n"
|
||||
" if (nsnull != a) {\n"
|
||||
" // get the js object\n"
|
||||
" nsIScriptObject *object;\n"
|
||||
" if (NS_OK == a->QueryInterface(kIScriptObjectIID, (void**)&object)) {\n"
|
||||
" nsIJSScriptObject *object;\n"
|
||||
" if (NS_OK == a->QueryInterface(kIJSScriptObjectIID, (void**)&object)) {\n"
|
||||
" object->Resolve(cx, id);\n"
|
||||
" NS_RELEASE(object);\n"
|
||||
" }\n"
|
||||
|
@ -656,7 +662,6 @@ static const char *kMethodBeginStr = "\n\n"
|
|||
"%s%s(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)\n"
|
||||
"{\n"
|
||||
" nsIDOM%s *nativeThis = (nsIDOM%s*)JS_GetPrivate(cx, obj);\n"
|
||||
" NS_ASSERTION(nsnull != nativeThis, \"null pointer\");\n"
|
||||
" JSBool rBool = JS_FALSE;\n";
|
||||
|
||||
static const char *kMethodReturnStr =
|
||||
|
@ -666,6 +671,12 @@ static const char *kMethodParamStr = " %s b%d;\n";
|
|||
|
||||
static const char *kMethodBodyBeginStr = "\n"
|
||||
" *rval = JSVAL_NULL;\n"
|
||||
"\n"
|
||||
" // If there's no private data, this must be the prototype, so ignore\n"
|
||||
" if (nsnull == nativeThis) {\n"
|
||||
" return JS_TRUE;\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" if (argc >= %d) {\n";
|
||||
|
||||
static const char *kMethodObjectParamStr = "\n"
|
||||
|
@ -742,7 +753,8 @@ static const char *kMethodObjectRetStr =
|
|||
" nsIScriptObjectOwner *owner = nsnull;\n"
|
||||
" if (NS_OK == nativeRet->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) {\n"
|
||||
" JSObject *object = nsnull;\n"
|
||||
" if (NS_OK == owner->GetScriptObject(cx, (void**)&object)) {\n"
|
||||
" nsIScriptContext *script_cx = (nsIScriptContext *)JS_GetContextPrivate(cx);\n"
|
||||
" if (NS_OK == owner->GetScriptObject(script_cx, (void**)&object)) {\n"
|
||||
" // set the return value\n"
|
||||
" *rval = OBJECT_TO_JSVAL(object);\n"
|
||||
" }\n"
|
||||
|
@ -859,7 +871,9 @@ JSStubGen::GenerateMethods(IdlSpecification &aSpec)
|
|||
}
|
||||
|
||||
if (rval->GetType() != TYPE_VOID) {
|
||||
strcpy(param_ptr, kMethodParamListDelimiterStr);
|
||||
if (pcount > 0) {
|
||||
strcpy(param_ptr, kMethodParamListDelimiterStr);
|
||||
}
|
||||
sprintf(buf, kMethodBodyMiddleStr, method_name, param_buf,
|
||||
rval->GetType() == TYPE_STRING ? "" : "&");
|
||||
}
|
||||
|
@ -1060,56 +1074,76 @@ static const char *kInitClassBeginStr =
|
|||
"\n\n//\n"
|
||||
"// %s class initialization\n"
|
||||
"//\n"
|
||||
"nsresult NS_Init%sClass(JSContext *aContext, JSObject **aPrototype)\n"
|
||||
"nsresult NS_Init%sClass(nsIScriptContext *aContext, void **aPrototype)\n"
|
||||
"{\n"
|
||||
" JSContext *jscontext = (JSContext *)aContext->GetNativeContext();\n"
|
||||
" JSObject *proto = nsnull;\n"
|
||||
" JSObject *constructor = nsnull;\n"
|
||||
" JSObject *parent_proto = nsnull;\n"
|
||||
" JSObject *obj = JS_GetGlobalObject(aContext);\n"
|
||||
" nsISupports *supports = (nsISupports *)JS_GetPrivate(aContext, obj);\n"
|
||||
" nsIJSGlobalObject *global;\n"
|
||||
" JSObject *global = JS_GetGlobalObject(jscontext);\n"
|
||||
" jsval vp;\n"
|
||||
"\n"
|
||||
" if (NS_OK == supports->QueryInterface(kIJSGlobalObjectIID, (void **)&global)) {\n"
|
||||
" *aPrototype = global->GetClassPrototype(aContext, \"%s\");\n"
|
||||
" if (nsnull == *aPrototype) {\n";
|
||||
" if ((PR_TRUE != JS_LookupProperty(jscontext, global, \"%s\", &vp)) ||\n"
|
||||
" !JSVAL_IS_OBJECT(vp) ||\n"
|
||||
" ((constructor = JSVAL_TO_OBJECT(vp)) == nsnull) ||\n"
|
||||
" (PR_TRUE != JS_LookupProperty(jscontext, JSVAL_TO_OBJECT(vp), \"prototype\", &vp)) || \n"
|
||||
" !JSVAL_IS_OBJECT(vp)) {\n\n";
|
||||
|
||||
#define JSGEN_GENERATE_INITCLASSBEGIN(buffer, className) \
|
||||
sprintf(buffer, kInitClassBeginStr, className, className, className)
|
||||
|
||||
static const char *kGetParentProtoStr =
|
||||
" if (NS_OK != NS_Init%sClass(aContext, &parent_proto)) {\n"
|
||||
" return NS_ERROR_FAILURE;\n"
|
||||
" }\n";
|
||||
" if (NS_OK != NS_Init%sClass(aContext, (void **)&parent_proto)) {\n"
|
||||
" return NS_ERROR_FAILURE;\n"
|
||||
" }\n";
|
||||
|
||||
static const char *kInitClassBodyStr =
|
||||
" *aPrototype = JS_InitClass(aContext, // context\n"
|
||||
" obj, // global object\n"
|
||||
" parent_proto, // parent proto \n"
|
||||
" &%sClass, // JSClass\n"
|
||||
" %s, // JSNative ctor\n"
|
||||
" 0, // ctor args\n"
|
||||
" %sProperties, // proto props\n"
|
||||
" %sMethods, // proto funcs\n"
|
||||
" nsnull, // ctor props (static)\n"
|
||||
" nsnull); // ctor funcs (static)\n"
|
||||
" if (nsnull == *aPrototype) {\n"
|
||||
" NS_RELEASE(global);\n"
|
||||
" return NS_ERROR_FAILURE;\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" global->SetClassPrototype(aContext, \"%s\", *aPrototype);\n"
|
||||
" proto = JS_InitClass(jscontext, // context\n"
|
||||
" global, // global object\n"
|
||||
" parent_proto, // parent proto \n"
|
||||
" &%sClass, // JSClass\n"
|
||||
" %s, // JSNative ctor\n"
|
||||
" 0, // ctor args\n"
|
||||
" %sProperties, // proto props\n"
|
||||
" %sMethods, // proto funcs\n"
|
||||
" nsnull, // ctor props (static)\n"
|
||||
" nsnull); // ctor funcs (static)\n"
|
||||
" if (nsnull == proto) {\n"
|
||||
" return NS_ERROR_FAILURE;\n"
|
||||
" }\n"
|
||||
"\n";
|
||||
|
||||
#define JSGEN_GENERATE_INITCLASSBODY(buffer, className) \
|
||||
sprintf(buffer, kInitClassBodyStr, className, className, \
|
||||
className, className, className)
|
||||
className, className)
|
||||
|
||||
static const char *kInitStaticBeginStr =
|
||||
" if ((PR_TRUE == JS_LookupProperty(jscontext, global, \"%s\", &vp)) &&\n"
|
||||
" JSVAL_IS_OBJECT(vp) &&\n"
|
||||
" ((constructor = JSVAL_TO_OBJECT(vp)) != nsnull)) {\n";
|
||||
|
||||
static const char *kInitStaticEntryStr =
|
||||
" vp = INT_TO_JSVAL(nsIDOM%s::%s);\n"
|
||||
" JS_SetProperty(jscontext, constructor, \"%s\", &vp);\n"
|
||||
"\n";
|
||||
|
||||
static const char *kInitStaticEndStr =
|
||||
" }\n"
|
||||
"\n";
|
||||
|
||||
static const char *kInitClassEndStr =
|
||||
" return NS_OK;\n"
|
||||
" }\n"
|
||||
" else if ((nsnull != constructor) && JSVAL_IS_OBJECT(vp)) {\n"
|
||||
" proto = JSVAL_TO_OBJECT(vp);\n"
|
||||
" }\n"
|
||||
" else {\n"
|
||||
" return NS_ERROR_FAILURE;\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" if (aPrototype) {\n"
|
||||
" *aPrototype = proto;\n"
|
||||
" }\n"
|
||||
" return NS_OK;\n"
|
||||
"}\n";
|
||||
|
||||
void
|
||||
|
@ -1133,6 +1167,25 @@ JSStubGen::GenerateInitClass(IdlSpecification &aSpec)
|
|||
JSGEN_GENERATE_INITCLASSBODY(buf, primary_class);
|
||||
*file << buf;
|
||||
|
||||
int c, ccount = primary_iface->ConstCount();
|
||||
|
||||
if (ccount > 0) {
|
||||
sprintf(buf, kInitStaticBeginStr, primary_iface->GetName());
|
||||
*file << buf;
|
||||
|
||||
for (c = 0; c < ccount; c++) {
|
||||
IdlVariable *var = primary_iface->GetConstAt(c);
|
||||
|
||||
if (NULL != var) {
|
||||
sprintf(buf, kInitStaticEntryStr, primary_iface->GetName(),
|
||||
var->GetName(), var->GetName());
|
||||
*file << buf;
|
||||
}
|
||||
}
|
||||
|
||||
*file << kInitStaticEndStr;
|
||||
}
|
||||
|
||||
*file << kInitClassEndStr;
|
||||
}
|
||||
|
||||
|
@ -1141,19 +1194,37 @@ static const char *kNewJSObjectStr =
|
|||
"\n\n//\n"
|
||||
"// Method for creating a new %s JavaScript object\n"
|
||||
"//\n"
|
||||
"nsresult NS_NewScript%s(JSContext *aContext, nsIDOM%s *aSupports, JSObject *aParent, JSObject **aReturn)\n"
|
||||
"extern \"C\" NS_DOM NS_NewScript%s(nsIScriptContext *aContext, nsIDOM%s *aSupports, nsISupports *aParent, void **aReturn)\n"
|
||||
"{\n"
|
||||
" NS_PRECONDITION(nsnull != aContext && nsnull != aSupports && nsnull != aReturn, \"null argument to NS_NewScript%s\");\n"
|
||||
" JSObject *proto;\n"
|
||||
" if (NS_OK != NS_Init%sClass(aContext, &proto)) {\n"
|
||||
" JSObject *parent;\n"
|
||||
" nsIScriptObjectOwner *owner;\n"
|
||||
" JSContext *jscontext = (JSContext *)aContext->GetNativeContext();\n"
|
||||
"\n"
|
||||
" if (nsnull == aParent) {\n"
|
||||
" parent = nsnull;\n"
|
||||
" }\n"
|
||||
" else if (NS_OK == aParent->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) {\n"
|
||||
" if (NS_OK != owner->GetScriptObject(aContext, (void **)&parent)) {\n"
|
||||
" NS_RELEASE(owner);\n"
|
||||
" return NS_ERROR_FAILURE;\n"
|
||||
" }\n"
|
||||
" NS_RELEASE(owner);\n"
|
||||
" }\n"
|
||||
" else {\n"
|
||||
" return NS_ERROR_FAILURE;\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" if (NS_OK != NS_Init%sClass(aContext, (void **)&proto)) {\n"
|
||||
" return NS_ERROR_FAILURE;\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" // create a js object for this class\n"
|
||||
" *aReturn = JS_NewObject(aContext, &%sClass, proto, aParent);\n"
|
||||
" *aReturn = JS_NewObject(jscontext, &%sClass, proto, parent);\n"
|
||||
" if (nsnull != *aReturn) {\n"
|
||||
" // connect the native object to the js object\n"
|
||||
" JS_SetPrivate(aContext, *aReturn, aSupports);\n"
|
||||
" JS_SetPrivate(jscontext, (JSObject *)*aReturn, aSupports);\n"
|
||||
" NS_ADDREF(aSupports);\n"
|
||||
" }\n"
|
||||
" else {\n"
|
||||
|
|
|
@ -57,6 +57,7 @@ include <$(DEPTH)\config\rules.mak>
|
|||
install:: $(PROGRAM)
|
||||
echo $(OS_CFLAGS)
|
||||
$(MAKE_INSTALL) $(PROGRAM) $(DIST)\bin
|
||||
$(MAKE_INSTALL) geniid.pl $(DIST)\bin
|
||||
|
||||
clobber::
|
||||
rm -f $(DIST)\bin\idlc.exe
|
||||
|
|
|
@ -36,7 +36,10 @@ static const char *kFileSuffix = "h";
|
|||
static const char *kIfdefStr = "\n"
|
||||
"#ifndef nsIDOM%s_h__\n"
|
||||
"#define nsIDOM%s_h__\n\n";
|
||||
static const char *kIncludeISupportsStr = "#include \"nsISupports.h\"\n";
|
||||
static const char *kIncludeDefaultsStr =
|
||||
"#include \"nsISupports.h\"\n"
|
||||
"#include \"nsString.h\"\n"
|
||||
"#include \"nsIScriptContext.h\"\n";
|
||||
static const char *kIncludeStr = "#include \"nsIDOM%s.h\"\n";
|
||||
static const char *kForwardClassStr = "class nsIDOM%s;\n";
|
||||
static const char *kUuidStr =
|
||||
|
@ -46,7 +49,9 @@ static const char *kClassDeclStr = "class nsIDOM%s : ";
|
|||
static const char *kBaseClassStr = "public nsIDOM%s";
|
||||
static const char *kNoBaseClassStr = "public nsISupports";
|
||||
static const char *kClassPrologStr = " {\npublic:\n";
|
||||
static const char *kConstDeclStr = " const %s %s = %l;\n";
|
||||
static const char *kEnumDeclBeginStr = " enum {\n";
|
||||
static const char *kEnumEntryStr = " %s = %d%s\n";
|
||||
static const char *kEnumDeclEndStr = " };\n";
|
||||
static const char *kGetterMethodDeclStr = "\n NS_IMETHOD Get%s(%s%s a%s)=0;\n";
|
||||
static const char *kSetterMethodDeclStr = " NS_IMETHOD Set%s(%s a%s)=0;\n";
|
||||
static const char *kMethodDeclStr = "\n NS_IMETHOD %s(%s)=0;\n";
|
||||
|
@ -54,8 +59,8 @@ static const char *kParamStr = "%s a%s";
|
|||
static const char *kDelimiterStr = ", ";
|
||||
static const char *kReturnStr = "%s%s aReturn";
|
||||
static const char *kClassEpilogStr = "};\n\n";
|
||||
static const char *kInitClassStr = "extern nsresult NS_Init%sClass(JSContext *aContext, JSObject **aPrototype);\n\n";
|
||||
static const char *kNewObjStr = "extern nsresult NS_NewScript%s(JSContext *aContext, nsIDOM%s *aSupports, JSObject *aParent, JSObject **aReturn);\n\n";
|
||||
static const char *kInitClassStr = "extern nsresult NS_Init%sClass(nsIScriptContext *aContext, void **aPrototype);\n\n";
|
||||
static const char *kNewObjStr = "extern \"C\" NS_DOM NS_NewScript%s(nsIScriptContext *aContext, nsIDOM%s *aSupports, nsISupports *aParent, void **aReturn);\n\n";
|
||||
static const char *kEndifStr = "#endif // nsIDOM%s_h__\n";
|
||||
|
||||
|
||||
|
@ -88,6 +93,7 @@ XPCOMGen::Generate(char *aFileName,
|
|||
if (iface) {
|
||||
GenerateGuid(*iface);
|
||||
GenerateClassDecl(*iface);
|
||||
GenerateEnums(*iface);
|
||||
GenerateMethods(*iface);
|
||||
GenerateEndClassDecl();
|
||||
}
|
||||
|
@ -117,7 +123,7 @@ XPCOMGen::GenerateIncludes(IdlSpecification &aSpec)
|
|||
char buf[512];
|
||||
ofstream *file = GetFile();
|
||||
|
||||
*file << kIncludeISupportsStr;
|
||||
*file << kIncludeDefaultsStr;
|
||||
int i, icount = aSpec.InterfaceCount();
|
||||
for (i = 0; i < icount; i++) {
|
||||
IdlInterface *iface = aSpec.GetInterfaceAt(i);
|
||||
|
@ -194,6 +200,31 @@ XPCOMGen::GenerateClassDecl(IdlInterface &aInterface)
|
|||
*file << kClassPrologStr;
|
||||
}
|
||||
|
||||
void
|
||||
XPCOMGen::GenerateEnums(IdlInterface &aInterface)
|
||||
{
|
||||
char buf[512];
|
||||
ofstream *file = GetFile();
|
||||
|
||||
if (aInterface.ConstCount() > 0) {
|
||||
int c, ccount = aInterface.ConstCount();
|
||||
|
||||
*file << kEnumDeclBeginStr;
|
||||
|
||||
for (c = 0; c < ccount; c++) {
|
||||
IdlVariable *var = aInterface.GetConstAt(c);
|
||||
|
||||
if (NULL != var) {
|
||||
sprintf(buf, kEnumEntryStr, var->GetName(), var->GetLongValue(),
|
||||
((c < ccount-1) ? "," : ""));
|
||||
*file << buf;
|
||||
}
|
||||
}
|
||||
|
||||
*file << kEnumDeclEndStr;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
XPCOMGen::GenerateMethods(IdlInterface &aInterface)
|
||||
{
|
||||
|
@ -242,7 +273,7 @@ XPCOMGen::GenerateMethods(IdlInterface &aInterface)
|
|||
|
||||
IdlVariable *rval = func->GetReturnValue();
|
||||
if (rval->GetType() != TYPE_VOID) {
|
||||
if (p > 0) {
|
||||
if (pcount > 0) {
|
||||
strcpy(cur_param, kDelimiterStr);
|
||||
cur_param += strlen(kDelimiterStr);
|
||||
}
|
||||
|
@ -250,6 +281,9 @@ XPCOMGen::GenerateMethods(IdlInterface &aInterface)
|
|||
sprintf(cur_param, kReturnStr, type_buf,
|
||||
rval->GetType() == TYPE_STRING ? "" : "*");
|
||||
}
|
||||
else {
|
||||
*cur_param++ = '\0';
|
||||
}
|
||||
|
||||
GetCapitalizedName(name_buf, *func);
|
||||
sprintf(buf, kMethodDeclStr, name_buf, param_buf);
|
||||
|
|
|
@ -40,6 +40,7 @@ protected:
|
|||
void GenerateForwardDecls(IdlSpecification &aSpec);
|
||||
void GenerateGuid(IdlInterface &aInterface);
|
||||
void GenerateClassDecl(IdlInterface &aInterface);
|
||||
void GenerateEnums(IdlInterface &aInterface);
|
||||
void GenerateMethods(IdlInterface &aInterface);
|
||||
void GenerateEndClassDecl();
|
||||
void GenerateEpilog(IdlSpecification &aSpec);
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
require "find.pl";
|
||||
|
||||
$uuid = 0x6f7652e0;
|
||||
$format = "{ 0x%x, 0xee43, 0x11d1, \\ \
|
||||
$format = "{ 0x%x, 0xee43, 0x11d1, \\\
|
||||
{ 0x9b, 0xc3, 0x00, 0x60, 0x08, 0x8c, 0xa6, 0xb3 } }";
|
||||
$pattern = "--- IID GOES HERE ---";
|
||||
|
||||
|
@ -37,7 +37,6 @@ sub replaceText {
|
|||
while (<SEARCHFILE>) {
|
||||
if (/$pattern/) {
|
||||
$replacement = sprintf($format, $uuid++);
|
||||
warn "$name: Changing '$pattern' to '$replacement'\n";
|
||||
s/$pattern/$replacement /g;
|
||||
}
|
||||
print REPLACEFILE;
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "nsIPresShell.h"
|
||||
#include "nsIDocumentObserver.h"
|
||||
#include "nsEventListenerManager.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
|
||||
#include "nsSelection.h"
|
||||
#include "nsIDOMText.h"
|
||||
|
@ -436,15 +437,17 @@ void nsDocument::ContentHasBeenRemoved(nsIContent* aContainer,
|
|||
}
|
||||
}
|
||||
|
||||
nsresult nsDocument::GetScriptObject(JSContext *aContext, void** aScriptObject)
|
||||
nsresult nsDocument::GetScriptObject(nsIScriptContext *aContext, void** aScriptObject)
|
||||
{
|
||||
nsresult res = NS_OK;
|
||||
nsIScriptGlobalObject *global = aContext->GetGlobalObject();
|
||||
|
||||
if (nsnull == mScriptObject) {
|
||||
res = NS_NewScriptDocument(aContext, this, nsnull, (JSObject**)&mScriptObject);
|
||||
res = NS_NewScriptDocument(aContext, this, global, (void**)&mScriptObject);
|
||||
}
|
||||
*aScriptObject = mScriptObject;
|
||||
|
||||
NS_RELEASE(global);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -474,14 +477,15 @@ nsresult nsDocument::GetChildNodes(nsIDOMNodeIterator **aIterator)
|
|||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
nsresult nsDocument::HasChildNodes()
|
||||
nsresult nsDocument::HasChildNodes(PRBool *aReturn)
|
||||
{
|
||||
if (nsnull != mRootContent) {
|
||||
return NS_OK;
|
||||
*aReturn = PR_TRUE;
|
||||
}
|
||||
else {
|
||||
return NS_ERROR_FAILURE;
|
||||
*aReturn = PR_FALSE;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsDocument::GetFirstChild(nsIDOMNode **aNode)
|
||||
|
@ -664,7 +668,7 @@ nsresult nsDocument::CreateAttributeList(nsIDOMAttributeList **aAttributesList)
|
|||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
nsresult nsDocument::CreateTreeIterator(nsIDOMNode **aNode, nsIDOMTreeIterator **aTreeIterator)
|
||||
nsresult nsDocument::CreateTreeIterator(nsIDOMNode *aNode, nsIDOMTreeIterator **aTreeIterator)
|
||||
{
|
||||
//XXX TBI
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include "nsVoidArray.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsIDOMEventCapturer.h"
|
||||
|
||||
class nsISelection;
|
||||
|
@ -161,14 +162,14 @@ public:
|
|||
|
||||
public:
|
||||
|
||||
NS_IMETHOD GetScriptObject(JSContext *aContext, void** aScriptObject);
|
||||
NS_IMETHOD GetScriptObject(nsIScriptContext *aContext, void** aScriptObject);
|
||||
NS_IMETHOD ResetScriptObject();
|
||||
|
||||
// nsIDOMDocument interface
|
||||
NS_IMETHOD GetNodeType(PRInt32 *aType);
|
||||
NS_IMETHOD GetParentNode(nsIDOMNode **aNode);
|
||||
NS_IMETHOD GetChildNodes(nsIDOMNodeIterator **aIterator);
|
||||
NS_IMETHOD HasChildNodes();
|
||||
NS_IMETHOD HasChildNodes(PRBool *aReturn);
|
||||
NS_IMETHOD GetFirstChild(nsIDOMNode **aNode);
|
||||
NS_IMETHOD GetPreviousSibling(nsIDOMNode **aNode);
|
||||
NS_IMETHOD GetNextSibling(nsIDOMNode **aNode);
|
||||
|
@ -194,7 +195,7 @@ public:
|
|||
nsIDOMNode *value,
|
||||
nsIDOMAttribute **aAttribute);
|
||||
NS_IMETHOD CreateAttributeList(nsIDOMAttributeList **aAttributesList);
|
||||
NS_IMETHOD CreateTreeIterator(nsIDOMNode **aNode, nsIDOMTreeIterator **aTreeIterator);
|
||||
NS_IMETHOD CreateTreeIterator(nsIDOMNode *aNode, nsIDOMTreeIterator **aTreeIterator);
|
||||
NS_IMETHOD GetElementsByTagName(nsString &aTagname, nsIDOMNodeIterator **aIterator);
|
||||
|
||||
// nsIDOMEventCapturer interface
|
||||
|
|
|
@ -60,7 +60,7 @@ EXPORTS = \
|
|||
|
||||
MODULE = raptor
|
||||
|
||||
REQUIRES = xpcom raptor dom netlib
|
||||
REQUIRES = xpcom raptor dom netlib js
|
||||
|
||||
include $(DEPTH)/config/config.mk
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ DEPTH=..\..\..\..
|
|||
|
||||
LIBRARY_NAME=raptorhtmlbase_s
|
||||
MODULE=raptor
|
||||
REQUIRES=xpcom raptor
|
||||
REQUIRES=xpcom raptor js
|
||||
DEFINES=-D_IMPL_NS_HTML -DWIN32_LEAN_AND_MEAN
|
||||
|
||||
CPPSRCS= \
|
||||
|
@ -93,7 +93,7 @@ CPP_OBJS= \
|
|||
|
||||
EXPORTS=nsGlobalVariables.h
|
||||
|
||||
LINCS=-I$(PUBLIC)\xpcom -I$(PUBLIC)\raptor \
|
||||
LINCS=-I$(PUBLIC)\xpcom -I$(PUBLIC)\raptor -I$(PUBLIC)\js \
|
||||
-I..\..\style\src -I$(PUBLIC)\dom -I$(PUBLIC)\netlib \
|
||||
-I..\..\..\base\src
|
||||
|
||||
|
|
|
@ -69,11 +69,11 @@ NS_IMPL_ADDREF(nsDOMAttribute)
|
|||
NS_IMPL_RELEASE(nsDOMAttribute)
|
||||
|
||||
|
||||
nsresult nsDOMAttribute::GetScriptObject(JSContext *aContext, void** aScriptObject)
|
||||
nsresult nsDOMAttribute::GetScriptObject(nsIScriptContext *aContext, void** aScriptObject)
|
||||
{
|
||||
nsresult res = NS_OK;
|
||||
if (nsnull == mScriptObject) {
|
||||
res = NS_NewScriptAttribute(aContext, this, nsnull, (JSObject**)&mScriptObject);
|
||||
res = NS_NewScriptAttribute(aContext, this, nsnull, (void **)&mScriptObject);
|
||||
}
|
||||
*aScriptObject = mScriptObject;
|
||||
return res;
|
||||
|
@ -107,7 +107,7 @@ nsresult nsDOMAttribute::SetValue(nsString &aValue)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsDOMAttribute::GetSpecified()
|
||||
nsresult nsDOMAttribute::GetSpecified(PRBool *aSpecified)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
@ -173,11 +173,11 @@ NS_IMPL_ADDREF(nsDOMAttributeList)
|
|||
|
||||
NS_IMPL_RELEASE(nsDOMAttributeList)
|
||||
|
||||
nsresult nsDOMAttributeList::GetScriptObject(JSContext *aContext, void** aScriptObject)
|
||||
nsresult nsDOMAttributeList::GetScriptObject(nsIScriptContext *aContext, void** aScriptObject)
|
||||
{
|
||||
nsresult res = NS_OK;
|
||||
if (nsnull == mScriptObject) {
|
||||
res = NS_NewScriptAttributeList(aContext, this, nsnull, (JSObject**)&mScriptObject);
|
||||
res = NS_NewScriptAttributeList(aContext, this, nsnull, (void**)&mScriptObject);
|
||||
}
|
||||
*aScriptObject = mScriptObject;
|
||||
return res;
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#define nsDOMAttributes_h__
|
||||
|
||||
#include "nsIDOMAttribute.h"
|
||||
#include "nsIDOMAttributeList.h"
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
|
||||
class nsIContent;
|
||||
|
@ -32,14 +33,14 @@ public:
|
|||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD GetScriptObject(JSContext *aContext, void** aScriptObject);
|
||||
NS_IMETHOD GetScriptObject(nsIScriptContext *aContext, void** aScriptObject);
|
||||
NS_IMETHOD ResetScriptObject();
|
||||
|
||||
// nsIDOMAttribute interface
|
||||
NS_IMETHOD GetName(nsString &aName);
|
||||
NS_IMETHOD GetValue(nsString &aValue);
|
||||
NS_IMETHOD SetValue(nsString &aValue);
|
||||
NS_IMETHOD GetSpecified();
|
||||
NS_IMETHOD GetSpecified(PRBool *aSpecified);
|
||||
NS_IMETHOD SetSpecified(PRBool specified);
|
||||
NS_IMETHOD ToString(nsString &aString);
|
||||
|
||||
|
@ -57,7 +58,7 @@ public:
|
|||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD GetScriptObject(JSContext *aContext, void** aScriptObject);
|
||||
NS_IMETHOD GetScriptObject(nsIScriptContext *aContext, void** aScriptObject);
|
||||
NS_IMETHOD ResetScriptObject();
|
||||
|
||||
// nsIDOMAttributeList interface
|
||||
|
|
|
@ -69,11 +69,11 @@ NS_IMPL_ADDREF(nsDOMIterator)
|
|||
NS_IMPL_RELEASE(nsDOMIterator)
|
||||
|
||||
|
||||
nsresult nsDOMIterator::GetScriptObject(JSContext *aContext, void** aScriptObject)
|
||||
nsresult nsDOMIterator::GetScriptObject(nsIScriptContext *aContext, void** aScriptObject)
|
||||
{
|
||||
nsresult res = NS_OK;
|
||||
if (nsnull == mScriptObject) {
|
||||
res = NS_NewScriptNodeIterator(aContext, this, nsnull, (JSObject**)&mScriptObject);
|
||||
res = NS_NewScriptNodeIterator(aContext, this, nsnull, (void**)&mScriptObject);
|
||||
}
|
||||
*aScriptObject = mScriptObject;
|
||||
return res;
|
||||
|
@ -100,12 +100,15 @@ nsresult nsDOMIterator::GetLength(PRUint32 *aLength)
|
|||
nsresult nsDOMIterator::GetCurrentNode(nsIDOMNode **aNode)
|
||||
{
|
||||
nsIContent *content = nsnull;
|
||||
nsresult res = NS_ERROR_FAILURE;
|
||||
nsresult res = NS_OK;
|
||||
content = mContent.ChildAt(mPosition);
|
||||
if (nsnull != content) {
|
||||
res = content->QueryInterface(kIDOMNodeIID, (void**)aNode);
|
||||
NS_RELEASE(content);
|
||||
}
|
||||
else {
|
||||
*aNode = nsnull;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
@ -113,13 +116,16 @@ nsresult nsDOMIterator::GetCurrentNode(nsIDOMNode **aNode)
|
|||
nsresult nsDOMIterator::GetNextNode(nsIDOMNode **aNode)
|
||||
{
|
||||
nsIContent *content = nsnull;
|
||||
nsresult res = NS_ERROR_FAILURE;
|
||||
nsresult res = NS_OK;
|
||||
content = mContent.ChildAt(++mPosition);
|
||||
if (nsnull != content) {
|
||||
res = content->QueryInterface(kIDOMNodeIID, (void**)aNode);
|
||||
NS_RELEASE(content);
|
||||
}
|
||||
else mPosition = mContent.ChildCount();
|
||||
else {
|
||||
mPosition = mContent.ChildCount();
|
||||
*aNode = nsnull;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
@ -127,13 +133,16 @@ nsresult nsDOMIterator::GetNextNode(nsIDOMNode **aNode)
|
|||
nsresult nsDOMIterator::GetPreviousNode(nsIDOMNode **aNode)
|
||||
{
|
||||
nsIContent *content = nsnull;
|
||||
nsresult res = NS_ERROR_FAILURE;
|
||||
nsresult res = NS_OK;
|
||||
content = mContent.ChildAt(--mPosition);
|
||||
if (nsnull != content) {
|
||||
res = content->QueryInterface(kIDOMNodeIID, (void**)aNode);
|
||||
NS_RELEASE(content);
|
||||
}
|
||||
else mPosition = -1;
|
||||
else {
|
||||
mPosition = -1;
|
||||
*aNode = nsnull;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
@ -141,13 +150,16 @@ nsresult nsDOMIterator::GetPreviousNode(nsIDOMNode **aNode)
|
|||
nsresult nsDOMIterator::ToFirst(nsIDOMNode **aNode)
|
||||
{
|
||||
nsIContent *content = nsnull;
|
||||
nsresult res = NS_ERROR_FAILURE;
|
||||
nsresult res = NS_OK;
|
||||
mPosition = 0;
|
||||
content = mContent.ChildAt(mPosition);
|
||||
if (nsnull != content) {
|
||||
res = content->QueryInterface(kIDOMNodeIID, (void**)aNode);
|
||||
NS_RELEASE(content);
|
||||
}
|
||||
else {
|
||||
*aNode = nsnull;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
@ -155,13 +167,16 @@ nsresult nsDOMIterator::ToFirst(nsIDOMNode **aNode)
|
|||
nsresult nsDOMIterator::ToLast(nsIDOMNode **aNode)
|
||||
{
|
||||
nsIContent *content = nsnull;
|
||||
nsresult res = NS_ERROR_FAILURE;
|
||||
nsresult res = NS_OK;
|
||||
mPosition = mPosition = mContent.ChildCount();
|
||||
content = mContent.ChildAt(mPosition);
|
||||
if (nsnull != content) {
|
||||
res = content->QueryInterface(kIDOMNodeIID, (void**)aNode);
|
||||
NS_RELEASE(content);
|
||||
}
|
||||
else {
|
||||
*aNode = nsnull;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#ifndef nsDOMIterator_h__
|
||||
#define nsDOMIterator_h__
|
||||
|
||||
#include "nsIDOMIterators.h"
|
||||
#include "nsIDOMNodeIterator.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
|
||||
|
@ -30,7 +30,7 @@ public:
|
|||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD GetScriptObject(JSContext *aContext, void** aScriptObject);
|
||||
NS_IMETHOD GetScriptObject(nsIScriptContext *aContext, void** aScriptObject);
|
||||
NS_IMETHOD ResetScriptObject();
|
||||
|
||||
// nsIDOMIterator interface
|
||||
|
|
|
@ -817,14 +817,15 @@ nsresult nsHTMLContainer::GetChildNodes(nsIDOMNodeIterator **aIterator)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsHTMLContainer::HasChildNodes()
|
||||
nsresult nsHTMLContainer::HasChildNodes(PRBool *aReturn)
|
||||
{
|
||||
if (0 != mChildren.Count()) {
|
||||
return NS_OK;
|
||||
*aReturn = PR_TRUE;
|
||||
}
|
||||
else {
|
||||
return NS_ERROR_FAILURE;
|
||||
*aReturn = PR_FALSE;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsHTMLContainer::GetFirstChild(nsIDOMNode **aNode)
|
||||
|
@ -836,8 +837,10 @@ nsresult nsHTMLContainer::GetFirstChild(nsIDOMNode **aNode)
|
|||
|
||||
return res;
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
else {
|
||||
aNode = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
|
|
@ -50,7 +50,7 @@ public:
|
|||
nsIPresContext* aPresContext);
|
||||
|
||||
NS_IMETHOD GetChildNodes(nsIDOMNodeIterator **aIterator);
|
||||
NS_IMETHOD HasChildNodes();
|
||||
NS_IMETHOD HasChildNodes(PRBool *aReturn);
|
||||
NS_IMETHOD GetFirstChild(nsIDOMNode **aNode);
|
||||
NS_IMETHOD InsertBefore(nsIDOMNode *newChild, nsIDOMNode *refChild);
|
||||
NS_IMETHOD ReplaceChild(nsIDOMNode *newChild,
|
||||
|
|
|
@ -470,23 +470,29 @@ nsresult nsHTMLContent::GetParentNode(nsIDOMNode **aNode)
|
|||
NS_ASSERTION(NS_OK == res, "Must be a DOM Node");
|
||||
return res;
|
||||
}
|
||||
else {
|
||||
*aNode = nsnull;
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsHTMLContent::GetChildNodes(nsIDOMNodeIterator **aIterator)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
*aIterator = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsHTMLContent::HasChildNodes()
|
||||
nsresult nsHTMLContent::HasChildNodes(PRBool *aReturn)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
*aReturn = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsHTMLContent::GetFirstChild(nsIDOMNode **aNode)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
*aNode = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsHTMLContent::GetPreviousSibling(nsIDOMNode **aNode)
|
||||
|
|
|
@ -121,7 +121,7 @@ public:
|
|||
// nsIDOMNode interface
|
||||
NS_IMETHOD GetParentNode(nsIDOMNode **aNode);
|
||||
NS_IMETHOD GetChildNodes(nsIDOMNodeIterator **aIterator);
|
||||
NS_IMETHOD HasChildNodes();
|
||||
NS_IMETHOD HasChildNodes(PRBool *aReturn);
|
||||
NS_IMETHOD GetFirstChild(nsIDOMNode **aNode);
|
||||
NS_IMETHOD GetPreviousSibling(nsIDOMNode **aNode);
|
||||
NS_IMETHOD GetNextSibling(nsIDOMNode **aNode);
|
||||
|
|
|
@ -369,19 +369,11 @@ nsIStyleRule* nsHTMLTagContent::GetStyleRule(void)
|
|||
return result;
|
||||
}
|
||||
|
||||
nsresult nsHTMLTagContent::GetScriptObject(JSContext *aContext, void** aScriptObject)
|
||||
nsresult nsHTMLTagContent::GetScriptObject(nsIScriptContext *aContext, void** aScriptObject)
|
||||
{
|
||||
nsresult res = NS_OK;
|
||||
if (nsnull == mScriptObject) {
|
||||
*aScriptObject = nsnull;
|
||||
if (nsnull != mParent) {
|
||||
nsIScriptObjectOwner *parent;
|
||||
if (NS_OK == mParent->QueryInterface(kIScriptObjectOwner, (void**)&parent)) {
|
||||
parent->GetScriptObject(aContext, aScriptObject);
|
||||
NS_RELEASE(parent);
|
||||
}
|
||||
}
|
||||
res = NS_NewScriptElement(aContext, this, (JSObject*)*aScriptObject, (JSObject**)&mScriptObject);
|
||||
res = NS_NewScriptElement(aContext, this, mParent, (void**)&mScriptObject);
|
||||
}
|
||||
*aScriptObject = mScriptObject;
|
||||
return res;
|
||||
|
@ -403,9 +395,9 @@ nsresult nsHTMLTagContent::GetChildNodes(nsIDOMNodeIterator **aIterator)
|
|||
return nsHTMLContent::GetChildNodes(aIterator);
|
||||
}
|
||||
|
||||
nsresult nsHTMLTagContent::HasChildNodes()
|
||||
nsresult nsHTMLTagContent::HasChildNodes(PRBool *aReturn)
|
||||
{
|
||||
return nsHTMLContent::HasChildNodes();
|
||||
return nsHTMLContent::HasChildNodes(aReturn);
|
||||
}
|
||||
|
||||
nsresult nsHTMLTagContent::GetFirstChild(nsIDOMNode **aNode)
|
||||
|
@ -440,8 +432,9 @@ nsresult nsHTMLTagContent::RemoveChild(nsIDOMNode *oldChild)
|
|||
|
||||
nsresult nsHTMLTagContent::GetTagName(nsString &aName)
|
||||
{
|
||||
NS_ASSERTION(nsnull != mTag, "no tag");
|
||||
mTag->ToString(aName);
|
||||
if (nsnull != mTag) {
|
||||
mTag->ToString(aName);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -450,10 +443,11 @@ nsresult nsHTMLTagContent::GetAttributes(nsIDOMAttributeList **aAttributeList)
|
|||
NS_PRECONDITION(nsnull != aAttributeList, "null pointer argument");
|
||||
if (nsnull != mAttributes) {
|
||||
*aAttributeList = new nsDOMAttributeList(*this);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
else {
|
||||
*aAttributeList = nsnull;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsHTMLTagContent::GetDOMAttribute(nsString &aName, nsString &aValue)
|
||||
|
|
|
@ -87,7 +87,7 @@ public:
|
|||
virtual nsIStyleRule* GetStyleRule(void);
|
||||
|
||||
// nsIScriptObjectOwner interface
|
||||
NS_IMETHOD GetScriptObject(JSContext *aContext, void** aScriptObject);
|
||||
NS_IMETHOD GetScriptObject(nsIScriptContext *aContext, void** aScriptObject);
|
||||
|
||||
// nsIDOMElement interface
|
||||
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr);
|
||||
|
@ -96,7 +96,7 @@ public:
|
|||
NS_IMETHOD GetNodeType(PRInt32 *aType);
|
||||
NS_IMETHOD GetParentNode(nsIDOMNode **aNode);
|
||||
NS_IMETHOD GetChildNodes(nsIDOMNodeIterator **aIterator);
|
||||
NS_IMETHOD HasChildNodes();
|
||||
NS_IMETHOD HasChildNodes(PRBool *aReturn);
|
||||
NS_IMETHOD GetFirstChild(nsIDOMNode **aNode);
|
||||
NS_IMETHOD GetPreviousSibling(nsIDOMNode **aNode);
|
||||
NS_IMETHOD GetNextSibling(nsIDOMNode **aNode);
|
||||
|
|
|
@ -472,6 +472,8 @@ public:
|
|||
nsGUIEvent* aEvent,
|
||||
nsEventStatus& aEventStatus);
|
||||
|
||||
NS_IMETHOD GetScriptObject(nsIScriptContext *aContext, void** aScriptObject);
|
||||
|
||||
protected:
|
||||
virtual ~RootPart();
|
||||
};
|
||||
|
@ -510,6 +512,18 @@ RootPart::HandleDOMEvent(nsIPresContext& aPresContext,
|
|||
return mDocument->HandleDOMEvent(aPresContext, aEvent, aEventStatus);
|
||||
}
|
||||
|
||||
nsresult
|
||||
RootPart::GetScriptObject(nsIScriptContext *aContext,
|
||||
void** aScriptObject)
|
||||
{
|
||||
nsresult res = NS_OK;
|
||||
if (nsnull == mScriptObject) {
|
||||
res = NS_NewScriptElement(aContext, this, mDocument, (void**)&mScriptObject);
|
||||
}
|
||||
*aScriptObject = mScriptObject;
|
||||
return res;
|
||||
}
|
||||
|
||||
nsresult
|
||||
NS_NewRootPart(nsIHTMLContent** aInstancePtrResult,
|
||||
nsIDocument* aDocument)
|
||||
|
|
|
@ -259,13 +259,13 @@ public:
|
|||
nsIFrame*& aResult);
|
||||
|
||||
// nsIScriptObjectOwner interface
|
||||
NS_IMETHOD GetScriptObject(JSContext *aContext, void** aScriptObject);
|
||||
NS_IMETHOD GetScriptObject(nsIScriptContext *aContext, void** aScriptObject);
|
||||
|
||||
// nsIDOMText interface
|
||||
NS_IMETHOD GetNodeType(PRInt32 *aType);
|
||||
NS_IMETHOD GetParentNode(nsIDOMNode **aNode);
|
||||
NS_IMETHOD GetChildNodes(nsIDOMNodeIterator **aIterator);
|
||||
NS_IMETHOD HasChildNodes();
|
||||
NS_IMETHOD HasChildNodes(PRBool *aReturn);
|
||||
NS_IMETHOD GetFirstChild(nsIDOMNode **aNode);
|
||||
NS_IMETHOD GetPreviousSibling(nsIDOMNode **aNode);
|
||||
NS_IMETHOD GetNextSibling(nsIDOMNode **aNode);
|
||||
|
@ -274,11 +274,11 @@ public:
|
|||
nsIDOMNode *oldChild);
|
||||
NS_IMETHOD RemoveChild(nsIDOMNode *oldChild);
|
||||
NS_IMETHOD GetData(nsString& aString);
|
||||
NS_IMETHOD SetData(const nsString& aString);
|
||||
NS_IMETHOD Append(const nsString& aData);
|
||||
NS_IMETHOD Insert(PRInt32 offset, const nsString& aData);
|
||||
NS_IMETHOD SetData(nsString& aString);
|
||||
NS_IMETHOD Append(nsString& aData);
|
||||
NS_IMETHOD Insert(PRInt32 offset, nsString& aData);
|
||||
NS_IMETHOD Delete(PRInt32 offset, PRInt32 count);
|
||||
NS_IMETHOD Replace(PRInt32 offset, PRInt32 count, const nsString& aData);
|
||||
NS_IMETHOD Replace(PRInt32 offset, PRInt32 count, nsString& aData);
|
||||
NS_IMETHOD Splice(nsIDOMElement *element, PRInt32 offset, PRInt32 count);
|
||||
|
||||
void ToCString(nsString& aBuf, PRInt32 aOffset, PRInt32 aLen) const;
|
||||
|
@ -1753,19 +1753,11 @@ Text::CreateFrame(nsIPresContext* aPresContext,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult Text::GetScriptObject(JSContext *aContext, void** aScriptObject)
|
||||
nsresult Text::GetScriptObject(nsIScriptContext *aContext, void** aScriptObject)
|
||||
{
|
||||
nsresult res = NS_OK;
|
||||
if (nsnull == mScriptObject) {
|
||||
*aScriptObject = nsnull;
|
||||
if (nsnull != mParent) {
|
||||
nsIScriptObjectOwner *parent;
|
||||
if (NS_OK == mParent->QueryInterface(kIScriptObjectOwner, (void**)&parent)) {
|
||||
parent->GetScriptObject(aContext, aScriptObject);
|
||||
NS_RELEASE(parent);
|
||||
}
|
||||
}
|
||||
res = NS_NewScriptText(aContext, this, (JSObject*)*aScriptObject, (JSObject**)&mScriptObject);
|
||||
res = NS_NewScriptText(aContext, this, mParent, (void**)&mScriptObject);
|
||||
}
|
||||
*aScriptObject = mScriptObject;
|
||||
return res;
|
||||
|
@ -1790,9 +1782,9 @@ nsresult Text::GetChildNodes(nsIDOMNodeIterator **aIterator)
|
|||
return nsHTMLContent::GetChildNodes(aIterator);
|
||||
}
|
||||
|
||||
nsresult Text::HasChildNodes()
|
||||
nsresult Text::HasChildNodes(PRBool *aReturn)
|
||||
{
|
||||
return nsHTMLContent::HasChildNodes();
|
||||
return nsHTMLContent::HasChildNodes(aReturn);
|
||||
}
|
||||
|
||||
nsresult Text::GetFirstChild(nsIDOMNode **aNode)
|
||||
|
@ -1835,7 +1827,7 @@ Text::GetData(nsString& aString)
|
|||
}
|
||||
|
||||
nsresult
|
||||
Text::SetData(const nsString& aString)
|
||||
Text::SetData(nsString& aString)
|
||||
{
|
||||
if (mText) {
|
||||
delete[] mText;
|
||||
|
@ -1853,13 +1845,13 @@ Text::SetData(const nsString& aString)
|
|||
}
|
||||
|
||||
nsresult
|
||||
Text::Append(const nsString& aData)
|
||||
Text::Append(nsString& aData)
|
||||
{
|
||||
return Replace(mLength, 0, aData);
|
||||
}
|
||||
|
||||
nsresult
|
||||
Text::Insert(PRInt32 offset, const nsString& aData)
|
||||
Text::Insert(PRInt32 offset, nsString& aData)
|
||||
{
|
||||
return Replace(offset, 0, aData);
|
||||
}
|
||||
|
@ -1872,7 +1864,7 @@ Text::Delete(PRInt32 offset, PRInt32 count)
|
|||
}
|
||||
|
||||
nsresult
|
||||
Text::Replace(PRInt32 offset, PRInt32 count, const nsString& aData)
|
||||
Text::Replace(PRInt32 offset, PRInt32 count, nsString& aData)
|
||||
{
|
||||
// sanitize arguments
|
||||
if (offset < 0) {
|
||||
|
|
|
@ -49,7 +49,7 @@ INCLUDES += \
|
|||
|
||||
MODULE = raptor
|
||||
|
||||
REQUIRES = xpcom raptor dom netlib
|
||||
REQUIRES = xpcom raptor dom netlib js
|
||||
|
||||
include $(DEPTH)/config/rules.mk
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ EXPORTS = \
|
|||
nsIHTMLDocument.h \
|
||||
$(NULL)
|
||||
|
||||
LINCS=-I$(PUBLIC)\xpcom -I$(PUBLIC)\raptor \
|
||||
LINCS=-I$(PUBLIC)\xpcom -I$(PUBLIC)\raptor -I$(PUBLIC)\js \
|
||||
-I..\..\base\src -I..\..\forms\src \
|
||||
-I..\..\style\src -I..\..\table\src -I$(PUBLIC)\dom \
|
||||
-I$(PUBLIC)\netlib -I..\..\..\base\src
|
||||
|
|
|
@ -40,7 +40,7 @@ MODULE = raptor
|
|||
|
||||
INCLUDES += -I../../../base/src -I../../base/src -I../../style/src
|
||||
|
||||
REQUIRES = xpcom raptor dom netlib
|
||||
REQUIRES = xpcom raptor dom netlib js
|
||||
|
||||
include $(DEPTH)/config/rules.mk
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ LIBRARY_NAME=raptorhtmlforms_s
|
|||
|
||||
DEFINES=-D_IMPL_NS_HTML -DWIN32_LEAN_AND_MEAN
|
||||
MODULE=raptor
|
||||
REQUIRES=xpcom raptor
|
||||
REQUIRES=xpcom raptor js
|
||||
|
||||
CPPSRCS=nsForm.cpp nsInput.cpp nsInputButton.cpp nsInputCheckbox.cpp \
|
||||
nsInputFile.cpp nsInputFrame.cpp \
|
||||
|
@ -33,7 +33,7 @@ CPP_OBJS=.\$(OBJDIR)\nsForm.obj .\$(OBJDIR)\nsInput.obj \
|
|||
.\$(OBJDIR)\nsInputRadio.obj \
|
||||
.\$(OBJDIR)\nsInputText.obj .\$(OBJDIR)\nsSelect.obj
|
||||
|
||||
LINCS=-I$(PUBLIC)\xpcom -I$(PUBLIC)\raptor \
|
||||
LINCS=-I$(PUBLIC)\xpcom -I$(PUBLIC)\raptor -I$(PUBLIC)\js \
|
||||
-I..\..\base\src -I..\..\style\src \
|
||||
-I..\..\..\base\src \
|
||||
-I$(PUBLIC)\dom -I$(PUBLIC)\netlib
|
||||
|
|
|
@ -44,7 +44,7 @@ MODULE = raptor
|
|||
|
||||
INCLUDES += -I../../base/src -I../../../base/src -I.
|
||||
|
||||
REQUIRES = xpcom raptor dom netlib
|
||||
REQUIRES = xpcom raptor dom netlib js
|
||||
|
||||
include $(DEPTH)/config/rules.mk
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ DEPTH=..\..\..\..
|
|||
|
||||
LIBRARY_NAME=raptorhtmlstyle_s
|
||||
MODULE=raptor
|
||||
REQUIRES=xpcom raptor
|
||||
REQUIRES=xpcom raptor js
|
||||
|
||||
DEFINES=-D_IMPL_NS_HTML -DWIN32_LEAN_AND_MEAN
|
||||
|
||||
|
@ -38,7 +38,7 @@ CPP_OBJS=.\$(OBJDIR)\nsCSSKeywords.obj .\$(OBJDIR)\nsCSSLayout.obj \
|
|||
|
||||
LINCS=-I$(PUBLIC)\xpcom -I$(PUBLIC)\raptor -I$(PUBLIC)\netlib \
|
||||
-I..\..\..\base\src \
|
||||
-I..\..\base\src
|
||||
-I..\..\base\src -I$(PUBLIC)\js
|
||||
|
||||
LCFLAGS = \
|
||||
$(LCFLAGS) \
|
||||
|
|
|
@ -45,7 +45,7 @@ CPPSRCS = \
|
|||
|
||||
MODULE = raptor
|
||||
|
||||
REQUIRES = xpcom raptor dom
|
||||
REQUIRES = xpcom raptor dom js
|
||||
|
||||
INCLUDES += -I../../base/src -I../../style/src -I../../../base/src
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ DEPTH=..\..\..\..
|
|||
|
||||
LIBRARY_NAME=raptorhtmltable_s
|
||||
MODULE=raptor
|
||||
REQUIRES=xpcom raptor
|
||||
REQUIRES=xpcom raptor js
|
||||
|
||||
DEFINES=-D_IMPL_NS_HTML -DWIN32_LEAN_AND_MEAN
|
||||
|
||||
|
@ -45,7 +45,7 @@ CPP_OBJS=.\$(OBJDIR)\nsCellLayoutData.obj .\$(OBJDIR)\nsCellMap.obj \
|
|||
LINCS=-I$(XPDIST)\public\xpcom -I$(XPDIST)\public\raptor \
|
||||
-I..\..\base\src -I..\..\style\src \
|
||||
-I..\..\..\base\src \
|
||||
-I$(PUBLIC)\dom
|
||||
-I$(PUBLIC)\dom -I$(PUBLIC)\js
|
||||
|
||||
LCFLAGS = \
|
||||
$(LCFLAGS) \
|
||||
|
|
|
@ -26,7 +26,8 @@ CPPSRCS = \
|
|||
TestHTMLTagLookup.cpp \
|
||||
$(NULL)
|
||||
|
||||
INCLUDES+=-I../src -I$(PUBLIC)/xpcom -I$(PUBLIC)/raptor -I$(PUBLIC)/netlib
|
||||
INCLUDES+=-I../src -I$(PUBLIC)/xpcom -I$(PUBLIC)/raptor -I$(PUBLIC)/netlib \
|
||||
-I$(PUBLIC)\js
|
||||
|
||||
DIRS =
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ LCFLAGS = \
|
|||
|
||||
LINCS=-I$(PUBLIC)\xpcom -I$(PUBLIC)\raptor -I$(PUBLIC)\dom \
|
||||
-I$(PUBLIC)\netlib -I..\base\src -I..\style\src \
|
||||
-I..\..\base\src
|
||||
-I..\..\base\src -I$(PUBLIC)\js
|
||||
|
||||
LLIBS= \
|
||||
$(DIST)\lib\raptorhtmlbase_s.lib \
|
||||
|
|
Загрузка…
Ссылка в новой задаче