зеркало из https://github.com/mozilla/gecko-dev.git
Added setTimeout/setInterval to Window. Added ellipsis special-case to IDL generation code. Slightly better error reporting in generated JavaScript stub classes
This commit is contained in:
Родитель
b362b02627
Коммит
82106d30a3
|
@ -28,7 +28,7 @@ class nsIDOMNodeIterator;
|
|||
class nsIDOMNode;
|
||||
|
||||
#define NS_IDOMNODE_IID \
|
||||
{ 0x6f7652e9, 0xee43, 0x11d1, \
|
||||
{ 0x6f7652e8, 0xee43, 0x11d1, \
|
||||
{ 0x9b, 0xc3, 0x00, 0x60, 0x08, 0x8c, 0xa6, 0xb3 } }
|
||||
|
||||
class nsIDOMNode : public nsISupports {
|
||||
|
|
|
@ -28,7 +28,7 @@ class nsIDOMNodeIterator;
|
|||
class nsIDOMNode;
|
||||
|
||||
#define NS_IDOMNODEITERATOR_IID \
|
||||
{ 0x6f7652ea, 0xee43, 0x11d1, \
|
||||
{ 0x6f7652e9, 0xee43, 0x11d1, \
|
||||
{ 0x9b, 0xc3, 0x00, 0x60, 0x08, 0x8c, 0xa6, 0xb3 } }
|
||||
|
||||
class nsIDOMNodeIterator : public nsISupports {
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
class nsIDOMPI;
|
||||
|
||||
#define NS_IDOMPI_IID \
|
||||
{ 0x6f7652eb, 0xee43, 0x11d1, \
|
||||
{ 0x6f7652ea, 0xee43, 0x11d1, \
|
||||
{ 0x9b, 0xc3, 0x00, 0x60, 0x08, 0x8c, 0xa6, 0xb3 } }
|
||||
|
||||
class nsIDOMPI : public nsIDOMNode {
|
||||
|
|
|
@ -29,7 +29,7 @@ class nsIDOMElement;
|
|||
class nsIDOMText;
|
||||
|
||||
#define NS_IDOMTEXT_IID \
|
||||
{ 0x6f7652ec, 0xee43, 0x11d1, \
|
||||
{ 0x6f7652eb, 0xee43, 0x11d1, \
|
||||
{ 0x9b, 0xc3, 0x00, 0x60, 0x08, 0x8c, 0xa6, 0xb3 } }
|
||||
|
||||
class nsIDOMText : public nsIDOMNode {
|
||||
|
|
|
@ -29,7 +29,7 @@ class nsIDOMTreeIterator;
|
|||
class nsIDOMNode;
|
||||
|
||||
#define NS_IDOMTREEITERATOR_IID \
|
||||
{ 0x6f7652ed, 0xee43, 0x11d1, \
|
||||
{ 0x6f7652ec, 0xee43, 0x11d1, \
|
||||
{ 0x9b, 0xc3, 0x00, 0x60, 0x08, 0x8c, 0xa6, 0xb3 } }
|
||||
|
||||
class nsIDOMTreeIterator : public nsIDOMNodeIterator {
|
||||
|
|
|
@ -1,7 +1,14 @@
|
|||
interface Window {
|
||||
readonly attribute Window window;
|
||||
readonly attribute Window self;
|
||||
readonly attribute Document document;
|
||||
readonly attribute Navigator navigator;
|
||||
void dump(in wstring str);
|
||||
void alert(in wstring str);
|
||||
|
||||
void clearTimeout(in long timerID);
|
||||
void clearInterval(in long timerID);
|
||||
long setTimeout(/* ... */);
|
||||
long setInterval(/* ... */);
|
||||
};
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
class nsIDOMNavigator;
|
||||
|
||||
#define NS_IDOMNAVIGATOR_IID \
|
||||
{ 0x6f7652e8, 0xee43, 0x11d1, \
|
||||
{ 0x6f7652ed, 0xee43, 0x11d1, \
|
||||
{ 0x9b, 0xc3, 0x00, 0x60, 0x08, 0x8c, 0xa6, 0xb3 } }
|
||||
|
||||
class nsIDOMNavigator : public nsISupports {
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
/* AUTO-GENERATED. DO NOT EDIT!!! */
|
||||
|
||||
#ifndef nsIDOMWindow_h__
|
||||
#define nsIDOMWindow_h__
|
||||
|
@ -22,13 +23,14 @@
|
|||
#include "nsISupports.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIScriptContext.h"
|
||||
#include "jsapi.h"
|
||||
|
||||
class nsIDOMNavigator;
|
||||
class nsIDOMDocument;
|
||||
class nsIDOMWindow;
|
||||
|
||||
#define NS_IDOMWINDOW_IID \
|
||||
{ 0x6f7652ed, 0xee43, 0x11d1, \
|
||||
{ 0x6f7652ee, 0xee43, 0x11d1, \
|
||||
{ 0x9b, 0xc3, 0x00, 0x60, 0x08, 0x8c, 0xa6, 0xb3 } }
|
||||
|
||||
class nsIDOMWindow : public nsISupports {
|
||||
|
@ -36,6 +38,8 @@ public:
|
|||
|
||||
NS_IMETHOD GetWindow(nsIDOMWindow** aWindow)=0;
|
||||
|
||||
NS_IMETHOD GetSelf(nsIDOMWindow** aSelf)=0;
|
||||
|
||||
NS_IMETHOD GetDocument(nsIDOMDocument** aDocument)=0;
|
||||
|
||||
NS_IMETHOD GetNavigator(nsIDOMNavigator** aNavigator)=0;
|
||||
|
@ -43,9 +47,17 @@ public:
|
|||
NS_IMETHOD Dump(nsString& aStr)=0;
|
||||
|
||||
NS_IMETHOD Alert(nsString& aStr)=0;
|
||||
|
||||
NS_IMETHOD ClearTimeout(PRInt32 aTimerID)=0;
|
||||
|
||||
NS_IMETHOD ClearInterval(PRInt32 aTimerID)=0;
|
||||
|
||||
NS_IMETHOD SetTimeout(JSContext *cx, jsval *argv, PRUint32 argc, PRInt32* aReturn)=0;
|
||||
|
||||
NS_IMETHOD SetInterval(JSContext *cx, jsval *argv, PRUint32 argc, PRInt32* aReturn)=0;
|
||||
};
|
||||
|
||||
extern nsresult NS_InitWindowClass(nsIScriptContext *aContext, nsIScriptGlobalObject *aGlobalObject);
|
||||
extern nsresult NS_InitWindowClass(nsIScriptContext *aContext, nsIScriptGlobalObject *aGlobal);
|
||||
|
||||
extern "C" NS_DOM NS_NewScriptWindow(nsIScriptContext *aContext, nsIDOMWindow *aSupports, nsISupports *aParent, void **aReturn);
|
||||
|
||||
|
|
|
@ -57,6 +57,7 @@ LCFLAGS = \
|
|||
$(NULL)
|
||||
|
||||
LLIBS= \
|
||||
$(DIST)\lib\libplc21.lib \
|
||||
$(DIST)\lib\xpcom32.lib \
|
||||
$(DIST)\lib\raptorbase.lib \
|
||||
$(DIST)\lib\netlib.lib \
|
||||
|
|
|
@ -17,6 +17,10 @@
|
|||
*/
|
||||
|
||||
#include "nscore.h"
|
||||
#include "prmem.h"
|
||||
#include "prtime.h"
|
||||
#include "plstr.h"
|
||||
#include "prinrval.h"
|
||||
#include "nsIFactory.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsIScriptContext.h"
|
||||
|
@ -27,6 +31,7 @@
|
|||
#include "nsIDOMNavigator.h"
|
||||
#include "nsINetService.h"
|
||||
#include "nsINetContainerApplication.h"
|
||||
#include "nsITimer.h"
|
||||
|
||||
#include "jsapi.h"
|
||||
|
||||
|
@ -36,6 +41,8 @@ static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID);
|
|||
static NS_DEFINE_IID(kIDOMWindowIID, NS_IDOMWINDOW_IID);
|
||||
static NS_DEFINE_IID(kIDOMNavigatorIID, NS_IDOMNAVIGATOR_IID);
|
||||
|
||||
typedef struct nsTimeoutImpl nsTimeoutImpl;
|
||||
|
||||
// Global object for scripting
|
||||
class GlobalWindowImpl : public nsIScriptObjectOwner, public nsIScriptGlobalObject, public nsIDOMWindow
|
||||
{
|
||||
|
@ -52,18 +59,67 @@ public:
|
|||
NS_IMETHOD_(void) SetNewDocument(nsIDOMDocument *aDocument);
|
||||
|
||||
NS_IMETHOD GetWindow(nsIDOMWindow** aWindow);
|
||||
NS_IMETHOD GetSelf(nsIDOMWindow** aSelf);
|
||||
NS_IMETHOD GetDocument(nsIDOMDocument** aDocument);
|
||||
NS_IMETHOD GetNavigator(nsIDOMNavigator** aNavigator);
|
||||
NS_IMETHOD Dump(nsString& aStr);
|
||||
NS_IMETHOD Alert(nsString& aStr);
|
||||
NS_IMETHOD ClearTimeout(PRInt32 aTimerID);
|
||||
NS_IMETHOD ClearInterval(PRInt32 aTimerID);
|
||||
NS_IMETHOD SetTimeout(JSContext *cx, jsval *argv, PRUint32 argc,
|
||||
PRInt32* aReturn);
|
||||
NS_IMETHOD SetInterval(JSContext *cx, jsval *argv, PRUint32 argc,
|
||||
PRInt32* aReturn);
|
||||
|
||||
friend void nsGlobalWindow_RunTimeout(nsITimer *aTimer, void *aClosure);
|
||||
|
||||
protected:
|
||||
void RunTimeout(nsTimeoutImpl *aTimeout);
|
||||
nsresult ClearTimeoutOrInterval(PRInt32 aTimerID);
|
||||
nsresult SetTimeoutOrInterval(JSContext *cx, jsval *argv,
|
||||
PRUint32 argc, PRInt32* aReturn,
|
||||
PRBool aIsInterval);
|
||||
void InsertTimeoutIntoList(nsTimeoutImpl **aInsertionPoint,
|
||||
nsTimeoutImpl *aTimeout);
|
||||
void ClearAllTimeouts();
|
||||
void DropTimeout(nsTimeoutImpl *aTimeout);
|
||||
void HoldTimeout(nsTimeoutImpl *aTimeout);
|
||||
|
||||
nsIScriptContext *mContext;
|
||||
void *mScriptObject;
|
||||
nsIDOMDocument *mDocument;
|
||||
nsIDOMNavigator *mNavigator;
|
||||
|
||||
nsTimeoutImpl *mTimeouts;
|
||||
nsTimeoutImpl **mTimeoutInsertionPoint;
|
||||
nsTimeoutImpl *mRunningTimeout;
|
||||
PRUint32 mTimeoutPublicIdCounter;
|
||||
};
|
||||
|
||||
/*
|
||||
* Timeout struct that holds information about each JavaScript
|
||||
* timeout.
|
||||
*/
|
||||
struct nsTimeoutImpl {
|
||||
PRInt32 ref_count; /* reference count to shared usage */
|
||||
GlobalWindowImpl *window; /* window for which this timeout fires */
|
||||
char *expr; /* the JS expression to evaluate */
|
||||
JSObject *funobj; /* or function to call, if !expr */
|
||||
nsITimer *timer; /* The actual timer object */
|
||||
jsval *argv; /* function actual arguments */
|
||||
PRUint16 argc; /* and argument count */
|
||||
PRUint16 spare; /* alignment padding */
|
||||
PRUint32 public_id; /* Returned as value of setTimeout() */
|
||||
PRInt32 interval; /* Non-zero if repetitive timeout */
|
||||
PRInt64 when; /* nominal time to run this timeout */
|
||||
JSVersion version; /* Version of JavaScript to execute */
|
||||
JSPrincipals *principals; /* principals with which to execute */
|
||||
char *filename; /* filename of setTimeout call */
|
||||
PRUint32 lineno; /* line number of setTimeout call */
|
||||
nsTimeoutImpl *next;
|
||||
};
|
||||
|
||||
|
||||
// Script "navigator" object
|
||||
class NavigatorImpl : public nsIScriptObjectOwner, public nsIDOMNavigator {
|
||||
public:
|
||||
|
@ -102,6 +158,11 @@ GlobalWindowImpl::GlobalWindowImpl()
|
|||
mScriptObject = nsnull;
|
||||
mDocument = nsnull;
|
||||
mNavigator = nsnull;
|
||||
|
||||
mTimeouts = nsnull;
|
||||
mTimeoutInsertionPoint = nsnull;
|
||||
mRunningTimeout = nsnull;
|
||||
mTimeoutPublicIdCounter = 1;
|
||||
}
|
||||
|
||||
GlobalWindowImpl::~GlobalWindowImpl()
|
||||
|
@ -127,7 +188,7 @@ NS_IMPL_RELEASE(GlobalWindowImpl)
|
|||
|
||||
nsresult
|
||||
GlobalWindowImpl::QueryInterface(const nsIID& aIID,
|
||||
void** aInstancePtrResult)
|
||||
void** aInstancePtrResult)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aInstancePtrResult, "null pointer");
|
||||
if (nsnull == aInstancePtrResult) {
|
||||
|
@ -171,7 +232,7 @@ GlobalWindowImpl::GetScriptObject(nsIScriptContext *aContext, void** aScriptObje
|
|||
if (nsnull == mScriptObject) {
|
||||
res = NS_NewScriptWindow(aContext, this, nsnull, &mScriptObject);
|
||||
JS_AddNamedRoot((JSContext *)aContext->GetNativeContext(),
|
||||
&mScriptObject, "window_object");
|
||||
&mScriptObject, "window_object");
|
||||
}
|
||||
|
||||
*aScriptObject = mScriptObject;
|
||||
|
@ -193,9 +254,11 @@ NS_IMETHODIMP_(void)
|
|||
GlobalWindowImpl::SetNewDocument(nsIDOMDocument *aDocument)
|
||||
{
|
||||
if (nsnull != mDocument) {
|
||||
ClearAllTimeouts();
|
||||
|
||||
if (nsnull != mScriptObject) {
|
||||
JS_ClearScope((JSContext *)mContext->GetNativeContext(),
|
||||
(JSObject *)mScriptObject);
|
||||
(JSObject *)mScriptObject);
|
||||
}
|
||||
|
||||
NS_RELEASE(mDocument);
|
||||
|
@ -210,9 +273,8 @@ GlobalWindowImpl::SetNewDocument(nsIDOMDocument *aDocument)
|
|||
mContext->InitContext(this);
|
||||
}
|
||||
}
|
||||
else {
|
||||
JS_GC((JSContext *)mContext->GetNativeContext());
|
||||
}
|
||||
|
||||
JS_GC((JSContext *)mContext->GetNativeContext());
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -224,6 +286,15 @@ GlobalWindowImpl::GetWindow(nsIDOMWindow** aWindow)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
GlobalWindowImpl::GetSelf(nsIDOMWindow** aWindow)
|
||||
{
|
||||
*aWindow = this;
|
||||
NS_ADDREF(this);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
GlobalWindowImpl::GetDocument(nsIDOMDocument** aDocument)
|
||||
{
|
||||
|
@ -263,9 +334,432 @@ GlobalWindowImpl::Dump(nsString& aStr)
|
|||
NS_IMETHODIMP
|
||||
GlobalWindowImpl::Alert(nsString& aStr)
|
||||
{
|
||||
// XXX Temporary
|
||||
return Dump(aStr);
|
||||
}
|
||||
|
||||
nsresult
|
||||
GlobalWindowImpl::ClearTimeoutOrInterval(PRInt32 aTimerID)
|
||||
{
|
||||
PRUint32 public_id;
|
||||
nsTimeoutImpl **top, *timeout;
|
||||
|
||||
public_id = (PRUint32)aTimerID;
|
||||
if (!public_id) /* id of zero is reserved for internal use */
|
||||
return NS_ERROR_FAILURE;
|
||||
for (top = &mTimeouts; ((timeout = *top) != NULL); top = &timeout->next) {
|
||||
if (timeout->public_id == public_id) {
|
||||
if (mRunningTimeout == timeout) {
|
||||
/* We're running from inside the timeout. Mark this
|
||||
timeout for deferred deletion by the code in
|
||||
win_run_timeout() */
|
||||
timeout->interval = 0;
|
||||
}
|
||||
else {
|
||||
/* Delete the timeout from the pending timeout list */
|
||||
*top = timeout->next;
|
||||
if (timeout->timer) {
|
||||
timeout->timer->Cancel();
|
||||
NS_RELEASE(timeout->timer);
|
||||
DropTimeout(timeout);
|
||||
}
|
||||
DropTimeout(timeout);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
GlobalWindowImpl::ClearTimeout(PRInt32 aTimerID)
|
||||
{
|
||||
return ClearTimeoutOrInterval(aTimerID);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
GlobalWindowImpl::ClearInterval(PRInt32 aTimerID)
|
||||
{
|
||||
return ClearTimeoutOrInterval(aTimerID);
|
||||
}
|
||||
|
||||
void
|
||||
GlobalWindowImpl::ClearAllTimeouts()
|
||||
{
|
||||
nsTimeoutImpl *timeout, *next;
|
||||
|
||||
for (timeout = mTimeouts; timeout; timeout = next) {
|
||||
/* If RunTimeout() is higher up on the stack for this
|
||||
window, e.g. as a result of document.write from a timeout,
|
||||
then we need to reset the list insertion point for
|
||||
newly-created timeouts in case the user adds a timeout,
|
||||
before we pop the stack back to RunTimeout. */
|
||||
if (mRunningTimeout == timeout)
|
||||
mTimeoutInsertionPoint = nsnull;
|
||||
|
||||
next = timeout->next;
|
||||
if (timeout->timer) {
|
||||
timeout->timer->Cancel();
|
||||
NS_RELEASE(timeout->timer);
|
||||
// Drop the count since the timer isn't going to hold on
|
||||
// anymore.
|
||||
DropTimeout(timeout);
|
||||
}
|
||||
// Drop the count since we're removing it from the list.
|
||||
DropTimeout(timeout);
|
||||
}
|
||||
|
||||
mTimeouts = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
GlobalWindowImpl::HoldTimeout(nsTimeoutImpl *aTimeout)
|
||||
{
|
||||
aTimeout->ref_count++;
|
||||
}
|
||||
|
||||
void
|
||||
GlobalWindowImpl::DropTimeout(nsTimeoutImpl *aTimeout)
|
||||
{
|
||||
JSContext *cx;
|
||||
|
||||
if (--aTimeout->ref_count > 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
cx = (JSContext *)mContext->GetNativeContext();
|
||||
|
||||
if (aTimeout->expr) {
|
||||
PR_FREEIF(aTimeout->expr);
|
||||
}
|
||||
else if (aTimeout->funobj) {
|
||||
JS_RemoveRoot(cx, &aTimeout->funobj);
|
||||
if (aTimeout->argv) {
|
||||
int i;
|
||||
for (i = 0; i < aTimeout->argc; i++)
|
||||
JS_RemoveRoot(cx, &aTimeout->argv[i]);
|
||||
PR_FREEIF(aTimeout->argv);
|
||||
}
|
||||
}
|
||||
NS_IF_RELEASE(aTimeout->timer);
|
||||
PR_FREEIF(aTimeout->filename);
|
||||
NS_IF_RELEASE(aTimeout->window);
|
||||
PR_DELETE(aTimeout);
|
||||
}
|
||||
|
||||
void
|
||||
GlobalWindowImpl::InsertTimeoutIntoList(nsTimeoutImpl **aList,
|
||||
nsTimeoutImpl *aTimeout)
|
||||
{
|
||||
nsTimeoutImpl *to;
|
||||
|
||||
while ((to = *aList) != nsnull) {
|
||||
if (LL_CMP(to->when, >, aTimeout->when))
|
||||
break;
|
||||
aList = &to->next;
|
||||
}
|
||||
aTimeout->next = to;
|
||||
*aList = aTimeout;
|
||||
// Increment the ref_count since we're in the list
|
||||
HoldTimeout(aTimeout);
|
||||
}
|
||||
|
||||
void
|
||||
nsGlobalWindow_RunTimeout(nsITimer *aTimer, void *aClosure)
|
||||
{
|
||||
nsTimeoutImpl *timeout = (nsTimeoutImpl *)aClosure;
|
||||
|
||||
timeout->window->RunTimeout(timeout);
|
||||
// Drop the ref_count since the timer won't be holding on to the
|
||||
// timeout struct anymore
|
||||
timeout->window->DropTimeout(timeout);
|
||||
}
|
||||
|
||||
void
|
||||
GlobalWindowImpl::RunTimeout(nsTimeoutImpl *aTimeout)
|
||||
{
|
||||
nsTimeoutImpl *next, *timeout;
|
||||
nsTimeoutImpl *last_expired_timeout;
|
||||
nsTimeoutImpl dummy_timeout;
|
||||
JSContext *cx;
|
||||
PRInt64 now;
|
||||
jsval result;
|
||||
nsITimer *timer;
|
||||
|
||||
timer = aTimeout->timer;
|
||||
cx = (JSContext *)mContext->GetNativeContext();
|
||||
|
||||
/*
|
||||
* A native timer has gone off. See which of our timeouts need
|
||||
* servicing
|
||||
*/
|
||||
LL_I2L(now, PR_IntervalNow());
|
||||
|
||||
/* The timeout list is kept in deadline order. Discover the
|
||||
latest timeout whose deadline has expired. On some platforms,
|
||||
native timeout events fire "early", so we need to test the
|
||||
timer as well as the deadline. */
|
||||
last_expired_timeout = nsnull;
|
||||
for (timeout = mTimeouts; timeout; timeout = timeout->next) {
|
||||
if ((timeout == aTimeout) || !LL_CMP(timeout->when, >, now))
|
||||
last_expired_timeout = timeout;
|
||||
}
|
||||
|
||||
/* Maybe the timeout that the event was fired for has been deleted
|
||||
and there are no others timeouts with deadlines that make them
|
||||
eligible for execution yet. Go away. */
|
||||
if (!last_expired_timeout)
|
||||
return;
|
||||
|
||||
/* Insert a dummy timeout into the list of timeouts between the portion
|
||||
of the list that we are about to process now and those timeouts that
|
||||
will be processed in a future call to win_run_timeout(). This dummy
|
||||
timeout serves as the head of the list for any timeouts inserted as
|
||||
a result of running a timeout. */
|
||||
dummy_timeout.timer = NULL;
|
||||
dummy_timeout.public_id = 0;
|
||||
dummy_timeout.next = last_expired_timeout->next;
|
||||
last_expired_timeout->next = &dummy_timeout;
|
||||
|
||||
/* Don't let ClearWindowTimeouts throw away our stack-allocated
|
||||
dummy timeout. */
|
||||
dummy_timeout.ref_count = 2;
|
||||
|
||||
mTimeoutInsertionPoint = &dummy_timeout.next;
|
||||
|
||||
for (timeout = mTimeouts; timeout != &dummy_timeout; timeout = next) {
|
||||
next = timeout->next;
|
||||
|
||||
/* Hold the timeout in case expr or funobj releases its doc. */
|
||||
mRunningTimeout = timeout;
|
||||
|
||||
if (timeout->expr) {
|
||||
/* Evaluate the timeout expression. */
|
||||
JS_EvaluateScript(cx, (JSObject *)mScriptObject,
|
||||
timeout->expr,
|
||||
PL_strlen(timeout->expr),
|
||||
timeout->filename, timeout->lineno,
|
||||
&result);
|
||||
}
|
||||
else {
|
||||
PRInt64 lateness64;
|
||||
PRInt32 lateness;
|
||||
|
||||
/* Add "secret" final argument that indicates timeout
|
||||
lateness in milliseconds */
|
||||
LL_SUB(lateness64, now, timeout->when);
|
||||
LL_L2I(lateness, lateness64);
|
||||
lateness = PR_IntervalToMilliseconds(lateness);
|
||||
timeout->argv[timeout->argc] = INT_TO_JSVAL((jsint)lateness);
|
||||
JS_CallFunctionValue(cx, (JSObject *)mScriptObject,
|
||||
OBJECT_TO_JSVAL(timeout->funobj),
|
||||
timeout->argc + 1, timeout->argv, &result);
|
||||
}
|
||||
|
||||
mRunningTimeout = nsnull;
|
||||
|
||||
/* If we have a regular interval timer, we re-fire the
|
||||
* timeout, accounting for clock drift.
|
||||
*/
|
||||
if (timeout->interval) {
|
||||
/* Compute time to next timeout for interval timer. */
|
||||
PRInt32 delay32;
|
||||
PRInt64 interval, delay;
|
||||
LL_I2L(interval, PR_MillisecondsToInterval(timeout->interval));
|
||||
LL_ADD(timeout->when, timeout->when, interval);
|
||||
LL_I2L(now, PR_IntervalNow());
|
||||
LL_SUB(delay, timeout->when, now);
|
||||
LL_L2I(delay32, delay);
|
||||
|
||||
/* If the next interval timeout is already supposed to
|
||||
* have happened then run the timeout immediately.
|
||||
*/
|
||||
if (delay32 < 0) {
|
||||
delay32 = 0;
|
||||
}
|
||||
delay32 = PR_IntervalToMilliseconds(delay32);
|
||||
|
||||
NS_IF_RELEASE(timeout->timer);
|
||||
|
||||
/* Reschedule timeout. Account for possible error return in
|
||||
code below that checks for zero toid. */
|
||||
nsresult err = NS_NewTimer(&timeout->timer);
|
||||
if (NS_OK != err) {
|
||||
return;
|
||||
}
|
||||
|
||||
err = timeout->timer->Init(nsGlobalWindow_RunTimeout, timeout,
|
||||
delay32);
|
||||
if (NS_OK != err) {
|
||||
return;
|
||||
}
|
||||
// Increment ref_count to indicate that this timer is holding
|
||||
// on to the timeout struct.
|
||||
HoldTimeout(timeout);
|
||||
}
|
||||
|
||||
/* Running a timeout can cause another timeout to be deleted,
|
||||
so we need to reset the pointer to the following timeout. */
|
||||
next = timeout->next;
|
||||
mTimeouts = next;
|
||||
// Drop timeout struct since it's out of the list
|
||||
DropTimeout(timeout);
|
||||
|
||||
/* Free the timeout if this is not a repeating interval
|
||||
* timeout (or if it was an interval timeout, but we were
|
||||
* unsuccessful at rescheduling it.)
|
||||
*/
|
||||
if (timeout->interval && timeout->timer) {
|
||||
/* Reschedule an interval timeout */
|
||||
/* Insert interval timeout onto list sorted in deadline order. */
|
||||
InsertTimeoutIntoList(mTimeoutInsertionPoint, timeout);
|
||||
}
|
||||
}
|
||||
|
||||
/* Take the dummy timeout off the head of the list */
|
||||
mTimeouts = dummy_timeout.next;
|
||||
mTimeoutInsertionPoint = nsnull;
|
||||
}
|
||||
|
||||
static const char *kSetIntervalStr = "setInterval";
|
||||
static const char *kSetTimeoutStr = "setTimeout";
|
||||
|
||||
nsresult
|
||||
GlobalWindowImpl::SetTimeoutOrInterval(JSContext *cx,
|
||||
jsval *argv,
|
||||
PRUint32 argc,
|
||||
PRInt32* aReturn,
|
||||
PRBool aIsInterval)
|
||||
{
|
||||
char *expr = nsnull;
|
||||
JSObject *funobj = nsnull;
|
||||
JSString *str;
|
||||
nsTimeoutImpl *timeout, **insertion_point;
|
||||
jsdouble interval;
|
||||
PRInt64 now, delta;
|
||||
|
||||
if (argc >= 2) {
|
||||
if (!JS_ValueToNumber(cx, argv[1], &interval)) {
|
||||
JS_ReportError(cx, "Second argument to %s must be a millisecond interval",
|
||||
aIsInterval ? kSetIntervalStr : kSetTimeoutStr);
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
|
||||
switch (JS_TypeOfValue(cx, argv[0])) {
|
||||
case JSTYPE_FUNCTION:
|
||||
funobj = JSVAL_TO_OBJECT(argv[0]);
|
||||
break;
|
||||
case JSTYPE_STRING:
|
||||
case JSTYPE_OBJECT:
|
||||
if (!(str = JS_ValueToString(cx, argv[0])))
|
||||
return NS_ERROR_FAILURE;
|
||||
expr = PL_strdup(JS_GetStringBytes(str));
|
||||
if (nsnull == expr)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
break;
|
||||
default:
|
||||
JS_ReportError(cx, "useless %s call (missing quotes around argument?)", aIsInterval ? kSetIntervalStr : kSetTimeoutStr);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
timeout = PR_NEWZAP(nsTimeoutImpl);
|
||||
if (nsnull == timeout) {
|
||||
PR_FREEIF(expr);
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
// Initial ref_count to indicate that this timeout struct will
|
||||
// be held as the closure of a timer.
|
||||
timeout->ref_count = 1;
|
||||
if (aIsInterval)
|
||||
timeout->interval = (PRInt32)interval;
|
||||
timeout->expr = expr;
|
||||
timeout->funobj = funobj;
|
||||
if (expr) {
|
||||
timeout->argv = 0;
|
||||
timeout->argc = 0;
|
||||
}
|
||||
else {
|
||||
int i;
|
||||
/* Leave an extra slot for a secret final argument that
|
||||
indicates to the called function how "late" the timeout is. */
|
||||
timeout->argv = (jsval *)PR_MALLOC((argc - 1) * sizeof(jsval));
|
||||
if (nsnull == timeout->argv) {
|
||||
DropTimeout(timeout);
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
if (!JS_AddNamedRoot(cx, &timeout->funobj, "timeout.funobj")) {
|
||||
DropTimeout(timeout);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
timeout->argc = 0;
|
||||
for (i = 2; (uint)i < argc; i++) {
|
||||
timeout->argv[i - 2] = argv[i];
|
||||
if (!JS_AddNamedRoot(cx, &timeout->argv[i - 2], "timeout.argv[i]")) {
|
||||
DropTimeout(timeout);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
timeout->argc++;
|
||||
}
|
||||
}
|
||||
|
||||
LL_I2L(now, PR_IntervalNow());
|
||||
LL_D2L(delta, PR_MillisecondsToInterval((PRUint32)interval));
|
||||
LL_ADD(timeout->when, now, delta);
|
||||
|
||||
nsresult err = NS_NewTimer(&timeout->timer);
|
||||
if (NS_OK != err) {
|
||||
DropTimeout(timeout);
|
||||
return err;
|
||||
}
|
||||
|
||||
err = timeout->timer->Init(nsGlobalWindow_RunTimeout, timeout,
|
||||
(PRInt32)interval);
|
||||
if (NS_OK != err) {
|
||||
DropTimeout(timeout);
|
||||
return err;
|
||||
}
|
||||
|
||||
timeout->window = this;
|
||||
NS_ADDREF(this);
|
||||
|
||||
if (mTimeoutInsertionPoint == NULL)
|
||||
insertion_point = &mTimeouts;
|
||||
else
|
||||
insertion_point = mTimeoutInsertionPoint;
|
||||
|
||||
InsertTimeoutIntoList(insertion_point, timeout);
|
||||
timeout->public_id = ++mTimeoutPublicIdCounter;
|
||||
*aReturn = timeout->public_id;
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function %s requires at least 2 parameters", aIsInterval ? kSetIntervalStr : kSetTimeoutStr);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
GlobalWindowImpl::SetTimeout(JSContext *cx,
|
||||
jsval *argv,
|
||||
PRUint32 argc,
|
||||
PRInt32* aReturn)
|
||||
{
|
||||
return SetTimeoutOrInterval(cx, argv, argc, aReturn, PR_FALSE);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
GlobalWindowImpl::SetInterval(JSContext *cx,
|
||||
jsval *argv,
|
||||
PRUint32 argc,
|
||||
PRInt32* aReturn)
|
||||
{
|
||||
return SetTimeoutOrInterval(cx, argv, argc, aReturn, PR_TRUE);
|
||||
}
|
||||
|
||||
extern "C" NS_DOM
|
||||
NS_NewScriptGlobalObject(nsIScriptGlobalObject **aResult)
|
||||
{
|
||||
|
@ -302,7 +796,7 @@ NS_IMPL_RELEASE(NavigatorImpl)
|
|||
|
||||
nsresult
|
||||
NavigatorImpl::QueryInterface(const nsIID& aIID,
|
||||
void** aInstancePtrResult)
|
||||
void** aInstancePtrResult)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aInstancePtrResult, "null pointer");
|
||||
if (nsnull == aInstancePtrResult) {
|
||||
|
|
|
@ -138,6 +138,7 @@ SetAttributeProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
|||
prop = (PRBool)temp;
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Parameter must be a boolean");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -251,6 +252,7 @@ AttributeGetName(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *r
|
|||
*rval = STRING_TO_JSVAL(jsstring);
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function getName requires 0 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -286,6 +288,7 @@ AttributeToString(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *
|
|||
*rval = STRING_TO_JSVAL(jsstring);
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function toString requires 0 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
|
|
@ -217,6 +217,7 @@ AttributeListGetAttribute(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
|||
}
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function getAttribute requires 1 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -252,10 +253,12 @@ AttributeListSetAttribute(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
|||
|
||||
if ((nsnull == supports0) ||
|
||||
(NS_OK != supports0->QueryInterface(kIAttributeIID, (void **)(b0.Query())))) {
|
||||
JS_ReportError(cx, "Parameter must be of type Attribute");
|
||||
return JS_FALSE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Parameter must be an object");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -266,6 +269,7 @@ AttributeListSetAttribute(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
|||
*rval = JSVAL_VOID;
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function setAttribute requires 1 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -323,6 +327,7 @@ AttributeListRemove(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval
|
|||
}
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function remove requires 1 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -351,6 +356,7 @@ AttributeListItem(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *
|
|||
if (argc >= 1) {
|
||||
|
||||
if (!JS_ValueToInt32(cx, argv[0], (int32 *)&b0)) {
|
||||
JS_ReportError(cx, "Parameter must be a number");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -376,6 +382,7 @@ AttributeListItem(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *
|
|||
}
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function item requires 1 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -409,6 +416,7 @@ AttributeListGetLength(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, js
|
|||
*rval = INT_TO_JSVAL(nativeRet);
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function getLength requires 0 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
|
|
@ -217,6 +217,7 @@ DOMCreateDocument(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *
|
|||
}
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function createDocument requires 1 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -259,6 +260,7 @@ DOMHasFeature(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval
|
|||
*rval = BOOLEAN_TO_JSVAL(nativeRet);
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function hasFeature requires 1 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
|
|
@ -213,10 +213,12 @@ SetDocumentProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
|||
JSObject *jsobj = JSVAL_TO_OBJECT(*vp);
|
||||
nsISupports *supports = (nsISupports *)JS_GetPrivate(cx, jsobj);
|
||||
if (NS_OK != supports->QueryInterface(kINodeIID, (void **)&prop)) {
|
||||
JS_ReportError(cx, "Parameter must be of type Node");
|
||||
return JS_FALSE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Parameter must be an object");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -234,10 +236,12 @@ SetDocumentProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
|||
JSObject *jsobj = JSVAL_TO_OBJECT(*vp);
|
||||
nsISupports *supports = (nsISupports *)JS_GetPrivate(cx, jsobj);
|
||||
if (NS_OK != supports->QueryInterface(kIElementIID, (void **)&prop)) {
|
||||
JS_ReportError(cx, "Parameter must be of type Element");
|
||||
return JS_FALSE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Parameter must be an object");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -255,10 +259,12 @@ SetDocumentProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
|||
JSObject *jsobj = JSVAL_TO_OBJECT(*vp);
|
||||
nsISupports *supports = (nsISupports *)JS_GetPrivate(cx, jsobj);
|
||||
if (NS_OK != supports->QueryInterface(kIDocumentContextIID, (void **)&prop)) {
|
||||
JS_ReportError(cx, "Parameter must be of type DocumentContext");
|
||||
return JS_FALSE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Parameter must be an object");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -385,6 +391,7 @@ DocumentCreateDocumentContext(JSContext *cx, JSObject *obj, uintN argc, jsval *a
|
|||
}
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function createDocumentContext requires 0 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -430,10 +437,12 @@ DocumentCreateElement(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsv
|
|||
|
||||
if ((nsnull == supports1) ||
|
||||
(NS_OK != supports1->QueryInterface(kIAttributeListIID, (void **)(b1.Query())))) {
|
||||
JS_ReportError(cx, "Parameter must be of type AttributeList");
|
||||
return JS_FALSE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Parameter must be an object");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -459,6 +468,7 @@ DocumentCreateElement(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsv
|
|||
}
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function createElement requires 2 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -516,6 +526,7 @@ DocumentCreateTextNode(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, js
|
|||
}
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function createTextNode requires 1 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -573,6 +584,7 @@ DocumentCreateComment(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsv
|
|||
}
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function createComment requires 1 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -639,6 +651,7 @@ DocumentCreatePI(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *r
|
|||
}
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function createPI requires 2 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -684,10 +697,12 @@ DocumentCreateAttribute(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, j
|
|||
|
||||
if ((nsnull == supports1) ||
|
||||
(NS_OK != supports1->QueryInterface(kINodeIID, (void **)(b1.Query())))) {
|
||||
JS_ReportError(cx, "Parameter must be of type Node");
|
||||
return JS_FALSE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Parameter must be an object");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -713,6 +728,7 @@ DocumentCreateAttribute(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, j
|
|||
}
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function createAttribute requires 2 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -761,6 +777,7 @@ DocumentCreateAttributeList(JSContext *cx, JSObject *obj, uintN argc, jsval *arg
|
|||
}
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function createAttributeList requires 0 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -797,10 +814,12 @@ DocumentCreateTreeIterator(JSContext *cx, JSObject *obj, uintN argc, jsval *argv
|
|||
|
||||
if ((nsnull == supports0) ||
|
||||
(NS_OK != supports0->QueryInterface(kINodeIID, (void **)(b0.Query())))) {
|
||||
JS_ReportError(cx, "Parameter must be of type Node");
|
||||
return JS_FALSE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Parameter must be an object");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -826,6 +845,7 @@ DocumentCreateTreeIterator(JSContext *cx, JSObject *obj, uintN argc, jsval *argv
|
|||
}
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function createTreeIterator requires 1 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -883,6 +903,7 @@ DocumentGetElementsByTagName(JSContext *cx, JSObject *obj, uintN argc, jsval *ar
|
|||
}
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function getElementsByTagName requires 1 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
|
|
@ -130,10 +130,12 @@ SetDocumentContextProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
|||
JSObject *jsobj = JSVAL_TO_OBJECT(*vp);
|
||||
nsISupports *supports = (nsISupports *)JS_GetPrivate(cx, jsobj);
|
||||
if (NS_OK != supports->QueryInterface(kIDocumentIID, (void **)&prop)) {
|
||||
JS_ReportError(cx, "Parameter must be of type Document");
|
||||
return JS_FALSE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Parameter must be an object");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
|
|
@ -130,10 +130,12 @@ SetDocumentFragmentProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
|||
JSObject *jsobj = JSVAL_TO_OBJECT(*vp);
|
||||
nsISupports *supports = (nsISupports *)JS_GetPrivate(cx, jsobj);
|
||||
if (NS_OK != supports->QueryInterface(kIDocumentIID, (void **)&prop)) {
|
||||
JS_ReportError(cx, "Parameter must be of type Document");
|
||||
return JS_FALSE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Parameter must be an object");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
|
|
@ -201,6 +201,7 @@ ElementGetTagName(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *
|
|||
*rval = STRING_TO_JSVAL(jsstring);
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function getTagName requires 0 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -249,6 +250,7 @@ ElementGetAttributes(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsva
|
|||
}
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function getAttributes requires 0 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -293,6 +295,7 @@ ElementGetDOMAttribute(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, js
|
|||
*rval = STRING_TO_JSVAL(jsstring);
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function getDOMAttribute requires 1 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -343,6 +346,7 @@ ElementSetDOMAttribute(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, js
|
|||
*rval = JSVAL_VOID;
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function setDOMAttribute requires 2 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -384,6 +388,7 @@ ElementRemoveAttribute(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, js
|
|||
*rval = JSVAL_VOID;
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function removeAttribute requires 1 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -441,6 +446,7 @@ ElementGetAttributeNode(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, j
|
|||
}
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function getAttributeNode requires 1 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -476,10 +482,12 @@ ElementSetAttributeNode(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, j
|
|||
|
||||
if ((nsnull == supports0) ||
|
||||
(NS_OK != supports0->QueryInterface(kIAttributeIID, (void **)(b0.Query())))) {
|
||||
JS_ReportError(cx, "Parameter must be of type Attribute");
|
||||
return JS_FALSE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Parameter must be an object");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -490,6 +498,7 @@ ElementSetAttributeNode(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, j
|
|||
*rval = JSVAL_VOID;
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function setAttributeNode requires 1 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -525,10 +534,12 @@ ElementRemoveAttributeNode(JSContext *cx, JSObject *obj, uintN argc, jsval *argv
|
|||
|
||||
if ((nsnull == supports0) ||
|
||||
(NS_OK != supports0->QueryInterface(kIAttributeIID, (void **)(b0.Query())))) {
|
||||
JS_ReportError(cx, "Parameter must be of type Attribute");
|
||||
return JS_FALSE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Parameter must be an object");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -539,6 +550,7 @@ ElementRemoveAttributeNode(JSContext *cx, JSObject *obj, uintN argc, jsval *argv
|
|||
*rval = JSVAL_VOID;
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function removeAttributeNode requires 1 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -596,6 +608,7 @@ ElementGetElementsByTagName(JSContext *cx, JSObject *obj, uintN argc, jsval *arg
|
|||
}
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function getElementsByTagName requires 1 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -628,6 +641,7 @@ ElementNormalize(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *r
|
|||
*rval = JSVAL_VOID;
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function normalize requires 0 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
|
|
@ -292,6 +292,7 @@ NavigatorJavaEnabled(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsva
|
|||
*rval = BOOLEAN_TO_JSVAL(nativeRet);
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function javaEnabled requires 0 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
|
|
@ -193,6 +193,7 @@ NodeGetNodeType(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rv
|
|||
*rval = INT_TO_JSVAL(nativeRet);
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function getNodeType requires 0 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -241,6 +242,7 @@ NodeGetParentNode(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *
|
|||
}
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function getParentNode requires 0 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -289,6 +291,7 @@ NodeGetChildNodes(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *
|
|||
}
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function getChildNodes requires 0 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -322,6 +325,7 @@ NodeHasChildNodes(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *
|
|||
*rval = BOOLEAN_TO_JSVAL(nativeRet);
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function hasChildNodes requires 0 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -370,6 +374,7 @@ NodeGetFirstChild(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *
|
|||
}
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function getFirstChild requires 0 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -418,6 +423,7 @@ NodeGetPreviousSibling(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, js
|
|||
}
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function getPreviousSibling requires 0 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -466,6 +472,7 @@ NodeGetNextSibling(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval
|
|||
}
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function getNextSibling requires 0 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -502,10 +509,12 @@ NodeInsertBefore(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *r
|
|||
|
||||
if ((nsnull == supports0) ||
|
||||
(NS_OK != supports0->QueryInterface(kINodeIID, (void **)(b0.Query())))) {
|
||||
JS_ReportError(cx, "Parameter must be of type Node");
|
||||
return JS_FALSE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Parameter must be an object");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -518,10 +527,12 @@ NodeInsertBefore(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *r
|
|||
|
||||
if ((nsnull == supports1) ||
|
||||
(NS_OK != supports1->QueryInterface(kINodeIID, (void **)(b1.Query())))) {
|
||||
JS_ReportError(cx, "Parameter must be of type Node");
|
||||
return JS_FALSE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Parameter must be an object");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -532,6 +543,7 @@ NodeInsertBefore(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *r
|
|||
*rval = JSVAL_VOID;
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function insertBefore requires 2 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -568,10 +580,12 @@ NodeReplaceChild(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *r
|
|||
|
||||
if ((nsnull == supports0) ||
|
||||
(NS_OK != supports0->QueryInterface(kINodeIID, (void **)(b0.Query())))) {
|
||||
JS_ReportError(cx, "Parameter must be of type Node");
|
||||
return JS_FALSE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Parameter must be an object");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -584,10 +598,12 @@ NodeReplaceChild(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *r
|
|||
|
||||
if ((nsnull == supports1) ||
|
||||
(NS_OK != supports1->QueryInterface(kINodeIID, (void **)(b1.Query())))) {
|
||||
JS_ReportError(cx, "Parameter must be of type Node");
|
||||
return JS_FALSE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Parameter must be an object");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -598,6 +614,7 @@ NodeReplaceChild(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *r
|
|||
*rval = JSVAL_VOID;
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function replaceChild requires 2 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -633,10 +650,12 @@ NodeRemoveChild(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rv
|
|||
|
||||
if ((nsnull == supports0) ||
|
||||
(NS_OK != supports0->QueryInterface(kINodeIID, (void **)(b0.Query())))) {
|
||||
JS_ReportError(cx, "Parameter must be of type Node");
|
||||
return JS_FALSE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Parameter must be an object");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -647,6 +666,7 @@ NodeRemoveChild(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rv
|
|||
*rval = JSVAL_VOID;
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function removeChild requires 1 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
|
|
@ -193,6 +193,7 @@ NodeIteratorGetLength(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsv
|
|||
*rval = INT_TO_JSVAL(nativeRet);
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function getLength requires 0 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -241,6 +242,7 @@ NodeIteratorGetCurrentNode(JSContext *cx, JSObject *obj, uintN argc, jsval *argv
|
|||
}
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function getCurrentNode requires 0 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -289,6 +291,7 @@ NodeIteratorGetNextNode(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, j
|
|||
}
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function getNextNode requires 0 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -337,6 +340,7 @@ NodeIteratorGetPreviousNode(JSContext *cx, JSObject *obj, uintN argc, jsval *arg
|
|||
}
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function getPreviousNode requires 0 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -385,6 +389,7 @@ NodeIteratorToFirst(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval
|
|||
}
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function toFirst requires 0 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -433,6 +438,7 @@ NodeIteratorToLast(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval
|
|||
}
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function toLast requires 0 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -461,6 +467,7 @@ NodeIteratorMoveTo(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval
|
|||
if (argc >= 1) {
|
||||
|
||||
if (!JS_ValueToInt32(cx, argv[0], (int32 *)&b0)) {
|
||||
JS_ReportError(cx, "Parameter must be a number");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -486,6 +493,7 @@ NodeIteratorMoveTo(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval
|
|||
}
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function moveTo requires 1 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
|
|
@ -233,6 +233,7 @@ TextAppend(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
|||
*rval = JSVAL_VOID;
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function append requires 1 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -261,6 +262,7 @@ TextInsert(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
|||
if (argc >= 2) {
|
||||
|
||||
if (!JS_ValueToInt32(cx, argv[0], (int32 *)&b0)) {
|
||||
JS_ReportError(cx, "Parameter must be a number");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -279,6 +281,7 @@ TextInsert(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
|||
*rval = JSVAL_VOID;
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function insert requires 2 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -307,10 +310,12 @@ TextDelete(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
|||
if (argc >= 2) {
|
||||
|
||||
if (!JS_ValueToInt32(cx, argv[0], (int32 *)&b0)) {
|
||||
JS_ReportError(cx, "Parameter must be a number");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (!JS_ValueToInt32(cx, argv[1], (int32 *)&b1)) {
|
||||
JS_ReportError(cx, "Parameter must be a number");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -321,6 +326,7 @@ TextDelete(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
|||
*rval = JSVAL_VOID;
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function delete requires 2 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -350,10 +356,12 @@ TextReplace(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
|||
if (argc >= 3) {
|
||||
|
||||
if (!JS_ValueToInt32(cx, argv[0], (int32 *)&b0)) {
|
||||
JS_ReportError(cx, "Parameter must be a number");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (!JS_ValueToInt32(cx, argv[1], (int32 *)&b1)) {
|
||||
JS_ReportError(cx, "Parameter must be a number");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -372,6 +380,7 @@ TextReplace(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
|||
*rval = JSVAL_VOID;
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function replace requires 3 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -409,18 +418,22 @@ TextSplice(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
|||
|
||||
if ((nsnull == supports0) ||
|
||||
(NS_OK != supports0->QueryInterface(kIElementIID, (void **)(b0.Query())))) {
|
||||
JS_ReportError(cx, "Parameter must be of type Element");
|
||||
return JS_FALSE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Parameter must be an object");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (!JS_ValueToInt32(cx, argv[1], (int32 *)&b1)) {
|
||||
JS_ReportError(cx, "Parameter must be a number");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (!JS_ValueToInt32(cx, argv[2], (int32 *)&b2)) {
|
||||
JS_ReportError(cx, "Parameter must be a number");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -431,6 +444,7 @@ TextSplice(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
|||
*rval = JSVAL_VOID;
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function splice requires 3 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
|
|
@ -193,6 +193,7 @@ TreeIteratorNumChildren(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, j
|
|||
*rval = INT_TO_JSVAL(nativeRet);
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function numChildren requires 0 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -226,6 +227,7 @@ TreeIteratorNumPreviousSiblings(JSContext *cx, JSObject *obj, uintN argc, jsval
|
|||
*rval = INT_TO_JSVAL(nativeRet);
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function numPreviousSiblings requires 0 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -259,6 +261,7 @@ TreeIteratorNumNextSiblings(JSContext *cx, JSObject *obj, uintN argc, jsval *arg
|
|||
*rval = INT_TO_JSVAL(nativeRet);
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function numNextSiblings requires 0 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -307,6 +310,7 @@ TreeIteratorToParent(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsva
|
|||
}
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function toParent requires 0 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -355,6 +359,7 @@ TreeIteratorToPreviousSibling(JSContext *cx, JSObject *obj, uintN argc, jsval *a
|
|||
}
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function toPreviousSibling requires 0 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -403,6 +408,7 @@ TreeIteratorToNextSibling(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
|||
}
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function toNextSibling requires 0 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -451,6 +457,7 @@ TreeIteratorToFirstChild(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
|||
}
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function toFirstChild requires 0 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -499,6 +506,7 @@ TreeIteratorToLastChild(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, j
|
|||
}
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function toLastChild requires 0 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -527,6 +535,7 @@ TreeIteratorToNthChild(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, js
|
|||
if (argc >= 1) {
|
||||
|
||||
if (!JS_ValueToInt32(cx, argv[0], (int32 *)&b0)) {
|
||||
JS_ReportError(cx, "Parameter must be a number");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -552,6 +561,7 @@ TreeIteratorToNthChild(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, js
|
|||
}
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function toNthChild requires 1 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
/* AUTO-GENERATED. DO NOT EDIT!!! */
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "nscore.h"
|
||||
|
@ -45,8 +46,9 @@ NS_DEF_PTR(nsIDOMWindow);
|
|||
//
|
||||
enum Window_slots {
|
||||
WINDOW_WINDOW = -11,
|
||||
WINDOW_DOCUMENT = -12,
|
||||
WINDOW_NAVIGATOR = -13
|
||||
WINDOW_SELF = -12,
|
||||
WINDOW_DOCUMENT = -13,
|
||||
WINDOW_NAVIGATOR = -14
|
||||
};
|
||||
|
||||
/***********************************************************************/
|
||||
|
@ -92,6 +94,33 @@ GetWindowProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
|||
}
|
||||
break;
|
||||
}
|
||||
case WINDOW_SELF:
|
||||
{
|
||||
nsIDOMWindow* prop;
|
||||
if (NS_OK == a->GetSelf(&prop)) {
|
||||
// get the js object
|
||||
if (prop != nsnull) {
|
||||
nsIScriptObjectOwner *owner = nsnull;
|
||||
if (NS_OK == prop->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) {
|
||||
JSObject *object = nsnull;
|
||||
nsIScriptContext *script_cx = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
if (NS_OK == owner->GetScriptObject(script_cx, (void**)&object)) {
|
||||
// set the return value
|
||||
*vp = OBJECT_TO_JSVAL(object);
|
||||
}
|
||||
NS_RELEASE(owner);
|
||||
}
|
||||
NS_RELEASE(prop);
|
||||
}
|
||||
else {
|
||||
*vp = JSVAL_NULL;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return JS_FALSE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case WINDOW_DOCUMENT:
|
||||
{
|
||||
nsIDOMDocument* prop;
|
||||
|
@ -252,11 +281,16 @@ 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 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]);
|
||||
|
@ -274,6 +308,7 @@ WindowDump(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
|||
*rval = JSVAL_VOID;
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function dump requires 1 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -315,12 +350,160 @@ WindowAlert(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
|||
*rval = JSVAL_VOID;
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function alert requires 1 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method ClearTimeout
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
WindowClearTimeout(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMWindow *nativeThis = (nsIDOMWindow*)JS_GetPrivate(cx, obj);
|
||||
JSBool rBool = JS_FALSE;
|
||||
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)) {
|
||||
JS_ReportError(cx, "Parameter must be a number");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (NS_OK != nativeThis->ClearTimeout(b0)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
*rval = JSVAL_VOID;
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function clearTimeout requires 1 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method ClearInterval
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
WindowClearInterval(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMWindow *nativeThis = (nsIDOMWindow*)JS_GetPrivate(cx, obj);
|
||||
JSBool rBool = JS_FALSE;
|
||||
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)) {
|
||||
JS_ReportError(cx, "Parameter must be a number");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (NS_OK != nativeThis->ClearInterval(b0)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
*rval = JSVAL_VOID;
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function clearInterval requires 1 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method SetTimeout
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
WindowSetTimeout(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMWindow *nativeThis = (nsIDOMWindow*)JS_GetPrivate(cx, obj);
|
||||
JSBool rBool = JS_FALSE;
|
||||
PRInt32 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->SetTimeout(cx, argv+0, argc-0, &nativeRet)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
*rval = INT_TO_JSVAL(nativeRet);
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function setTimeout requires 0 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method SetInterval
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
WindowSetInterval(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMWindow *nativeThis = (nsIDOMWindow*)JS_GetPrivate(cx, obj);
|
||||
JSBool rBool = JS_FALSE;
|
||||
PRInt32 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->SetInterval(cx, argv+0, argc-0, &nativeRet)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
*rval = INT_TO_JSVAL(nativeRet);
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function setInterval requires 0 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************/
|
||||
//
|
||||
// class for Window
|
||||
|
@ -345,6 +528,7 @@ JSClass WindowClass = {
|
|||
static JSPropertySpec WindowProperties[] =
|
||||
{
|
||||
{"window", WINDOW_WINDOW, JSPROP_ENUMERATE | JSPROP_READONLY},
|
||||
{"self", WINDOW_SELF, JSPROP_ENUMERATE | JSPROP_READONLY},
|
||||
{"document", WINDOW_DOCUMENT, JSPROP_ENUMERATE | JSPROP_READONLY},
|
||||
{"navigator", WINDOW_NAVIGATOR, JSPROP_ENUMERATE | JSPROP_READONLY},
|
||||
{0}
|
||||
|
@ -358,6 +542,10 @@ static JSFunctionSpec WindowMethods[] =
|
|||
{
|
||||
{"dump", WindowDump, 1},
|
||||
{"alert", WindowAlert, 1},
|
||||
{"clearTimeout", WindowClearTimeout, 1},
|
||||
{"clearInterval", WindowClearInterval, 1},
|
||||
{"setTimeout", WindowSetTimeout, 0},
|
||||
{"setInterval", WindowSetInterval, 0},
|
||||
{0}
|
||||
};
|
||||
|
||||
|
@ -376,7 +564,7 @@ Window(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
|||
// Window class initialization
|
||||
//
|
||||
nsresult NS_InitWindowClass(nsIScriptContext *aContext,
|
||||
nsIScriptGlobalObject *aGlobal)
|
||||
nsIScriptGlobalObject *aGlobal)
|
||||
{
|
||||
JSContext *jscontext = (JSContext *)aContext->GetNativeContext();
|
||||
JSObject *global = JS_GetGlobalObject(jscontext);
|
||||
|
|
|
@ -37,6 +37,9 @@ ostream& operator<<(ostream &s, IdlFunction &aFunction)
|
|||
}
|
||||
s << *(aFunction.GetParameterAt(count - 1));
|
||||
}
|
||||
if (aFunction.GetHasEllipsis()) {
|
||||
s << ",...";
|
||||
}
|
||||
s << ")";
|
||||
|
||||
count = aFunction.ExceptionCount();
|
||||
|
@ -56,6 +59,7 @@ IdlFunction::IdlFunction()
|
|||
mReturnValue = (IdlVariable*)0;
|
||||
mParameters = (nsVoidArray*)0;
|
||||
mExceptions = (nsVoidArray*)0;
|
||||
mHasEllipsis = 0;
|
||||
}
|
||||
|
||||
IdlFunction::~IdlFunction()
|
||||
|
@ -151,4 +155,15 @@ char* IdlFunction::GetExceptionAt(long aIndex)
|
|||
return excName;
|
||||
}
|
||||
|
||||
int
|
||||
IdlFunction::GetHasEllipsis()
|
||||
{
|
||||
return mHasEllipsis;
|
||||
}
|
||||
|
||||
void
|
||||
IdlFunction::SetHasEllipsis(int aHasEllipsis)
|
||||
{
|
||||
mHasEllipsis = aHasEllipsis;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@ private:
|
|||
IdlVariable *mReturnValue;
|
||||
nsVoidArray *mParameters;
|
||||
nsVoidArray *mExceptions;
|
||||
int mHasEllipsis;
|
||||
|
||||
public:
|
||||
IdlFunction();
|
||||
|
@ -46,6 +47,9 @@ public:
|
|||
void AddException(char *aException);
|
||||
long ExceptionCount();
|
||||
char* GetExceptionAt(long aIndex);
|
||||
|
||||
int GetHasEllipsis();
|
||||
void SetHasEllipsis(int aHasEllipsis);
|
||||
};
|
||||
|
||||
class ostream;
|
||||
|
|
|
@ -40,6 +40,7 @@ ostream& operator<<(ostream &s, IdlParameter &aParameter)
|
|||
IdlParameter::IdlParameter()
|
||||
{
|
||||
mAttribute = 0;
|
||||
mIsOptional = 0;
|
||||
}
|
||||
|
||||
IdlParameter::~IdlParameter()
|
||||
|
@ -56,3 +57,15 @@ int IdlParameter::GetAttribute()
|
|||
return mAttribute;
|
||||
}
|
||||
|
||||
void
|
||||
IdlParameter::SetIsOptional(int aIsOptional)
|
||||
{
|
||||
mIsOptional = aIsOptional;
|
||||
}
|
||||
|
||||
int
|
||||
IdlParameter::GetIsOptional()
|
||||
{
|
||||
return mIsOptional;
|
||||
}
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@ public:
|
|||
|
||||
private:
|
||||
int mAttribute;
|
||||
int mIsOptional;
|
||||
|
||||
public:
|
||||
IdlParameter();
|
||||
|
@ -40,6 +41,8 @@ public:
|
|||
void SetAttribute(CallAttribute aAttribute);
|
||||
int GetAttribute();
|
||||
|
||||
void SetIsOptional(int aIsOptional);
|
||||
int GetIsOptional();
|
||||
};
|
||||
|
||||
class ostream;
|
||||
|
|
|
@ -685,23 +685,38 @@ IdlFunction* IdlParser::ParseFunction(IdlSpecification &aSpecification, Token &a
|
|||
if (FUNC_PARAMS_SPEC_BEGIN_TOKEN == token->id) {
|
||||
|
||||
try {
|
||||
int anyOptional = 0;
|
||||
while (FUNC_PARAMS_SPEC_END_TOKEN != token->id &&
|
||||
ELLIPSIS_TOKEN != token->id &&
|
||||
(FUNC_PARAMS_SPEC_BEGIN_TOKEN == token->id ||
|
||||
SEPARATOR_TOKEN == token->id)
|
||||
) {
|
||||
) {
|
||||
mScanner->NextToken(); // eat the last peeked symbol
|
||||
TrimComments();
|
||||
|
||||
if (FUNC_PARAMS_SPEC_END_TOKEN == mScanner->PeekToken()->id) {
|
||||
if ((FUNC_PARAMS_SPEC_END_TOKEN == mScanner->PeekToken()->id) ||
|
||||
(ELLIPSIS_TOKEN == mScanner->PeekToken()->id)) {
|
||||
break;
|
||||
}
|
||||
|
||||
// parse all arguments
|
||||
funcObj->AddParameter(ParseFunctionParameter(aSpecification));
|
||||
IdlParameter *param = ParseFunctionParameter(aSpecification);
|
||||
if (param->GetIsOptional()) {
|
||||
anyOptional = 1;
|
||||
}
|
||||
else if (anyOptional) {
|
||||
throw ParameterParsingException("Non-optional parameter cannot follow optional parameters");
|
||||
}
|
||||
funcObj->AddParameter(param);
|
||||
|
||||
TrimComments();
|
||||
token = mScanner->PeekToken();
|
||||
}
|
||||
if (mScanner->PeekToken()->id == ELLIPSIS_TOKEN) {
|
||||
mScanner->NextToken();
|
||||
funcObj->SetHasEllipsis(1);
|
||||
TrimComments();
|
||||
}
|
||||
mScanner->NextToken(); // eat ')'
|
||||
}
|
||||
catch (ParameterParsingException &) {
|
||||
|
@ -790,7 +805,11 @@ IdlParameter* IdlParser::ParseFunctionParameter(IdlSpecification &aSpecification
|
|||
IdlParameter *argObj = new IdlParameter();
|
||||
|
||||
Token *token = mScanner->NextToken();
|
||||
|
||||
if (token->id == OPTIONAL_TOKEN) {
|
||||
argObj->SetIsOptional(1);
|
||||
mScanner->NextToken();
|
||||
}
|
||||
|
||||
// the paramenter attribute (in, out, inout)
|
||||
switch(token->id) {
|
||||
// base type
|
||||
|
@ -885,4 +904,3 @@ void IdlParser::TrimComments()
|
|||
mScanner->NextToken();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -61,6 +61,7 @@ protected:
|
|||
IdlParameter* ParseFunctionParameter(IdlSpecification &aSpecification);
|
||||
|
||||
void TrimComments();
|
||||
int TrimCommentsSpecial();
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -1162,6 +1162,8 @@ void IdlScanner::Char(int aStartChar, Token *aToken)
|
|||
}
|
||||
|
||||
#define DEFAULT_COMMENT_SIZE 512
|
||||
static char *kOptionalStr = "/* optional ";
|
||||
static char *kEllipsisStr = "/* ... ";
|
||||
|
||||
void IdlScanner::Comment(char *aCurrentPos, Token *aToken)
|
||||
{
|
||||
|
@ -1220,7 +1222,15 @@ void IdlScanner::Comment(char *aCurrentPos, Token *aToken)
|
|||
// go back one and terminate the string
|
||||
*--pos = '\0';
|
||||
|
||||
aToken->SetToken(COMMENT_TOKEN, aCommentBuffer);
|
||||
if (strcmp(aCommentBuffer, kOptionalStr) == 0) {
|
||||
aToken->SetToken(OPTIONAL_TOKEN, aCommentBuffer);
|
||||
}
|
||||
else if (strcmp(aCommentBuffer, kEllipsisStr) == 0) {
|
||||
aToken->SetToken(ELLIPSIS_TOKEN, aCommentBuffer);
|
||||
}
|
||||
else {
|
||||
aToken->SetToken(COMMENT_TOKEN, aCommentBuffer);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// don't deal with it for now. It will report an error
|
||||
|
|
|
@ -37,6 +37,8 @@ enum TokenType {
|
|||
CONST_TOKEN,
|
||||
EXCEPTION_TOKEN,
|
||||
READONLY_TOKEN,
|
||||
OPTIONAL_TOKEN,
|
||||
ELLIPSIS_TOKEN,
|
||||
ATTRIBUTE_TOKEN,
|
||||
IDENTIFIER_TOKEN,
|
||||
BOOLEAN_TOKEN,
|
||||
|
|
|
@ -345,6 +345,7 @@ static const char *kGetCaseNonPrimaryStr =
|
|||
" }\n"
|
||||
" }\n"
|
||||
" else {\n"
|
||||
" JS_ReportError(cx, \"Object must be of type %s\");\n"
|
||||
" return JS_FALSE;\n"
|
||||
" }\n";
|
||||
|
||||
|
@ -427,7 +428,7 @@ JSStubGen::GeneratePropGetter(ofstream *file,
|
|||
aInterface.GetName(), aInterface.GetName(),
|
||||
attr_name,
|
||||
aAttribute.GetType() == TYPE_STRING ? "" : "&",
|
||||
case_str);
|
||||
case_str, aInterface.GetName());
|
||||
}
|
||||
|
||||
*file << buf;
|
||||
|
@ -450,6 +451,7 @@ static const char *kSetCaseNonPrimaryStr =
|
|||
" }\n"
|
||||
" else {\n"
|
||||
" %s\n"
|
||||
" JS_ReportError(cx, \"Object must be of type %s\");\n"
|
||||
" return JS_FALSE;\n"
|
||||
" }\n"
|
||||
" %s\n";
|
||||
|
@ -463,10 +465,12 @@ static const char *kObjectSetCaseStr =
|
|||
" JSObject *jsobj = JSVAL_TO_OBJECT(*vp); \n"
|
||||
" nsISupports *supports = (nsISupports *)JS_GetPrivate(cx, jsobj);\n"
|
||||
" if (NS_OK != supports->QueryInterface(kI%sIID, (void **)&prop)) {\n"
|
||||
" JS_ReportError(cx, \"Parameter must be of type %s\");\n"
|
||||
" return JS_FALSE;\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
" else {\n"
|
||||
" JS_ReportError(cx, \"Parameter must be an object\");\n"
|
||||
" return JS_FALSE;\n"
|
||||
" }\n";
|
||||
|
||||
|
@ -487,6 +491,7 @@ static const char *kIntSetCaseStr =
|
|||
" prop = (%s)temp;\n"
|
||||
" }\n"
|
||||
" else {\n"
|
||||
" JS_ReportError(cx, \"Parameter must be a number\");\n"
|
||||
" return JS_FALSE;\n"
|
||||
" }\n";
|
||||
|
||||
|
@ -496,6 +501,7 @@ static const char *kBoolSetCaseStr =
|
|||
" prop = (%s)temp;\n"
|
||||
" }\n"
|
||||
" else {\n"
|
||||
" JS_ReportError(cx, \"Parameter must be a boolean\");\n"
|
||||
" return JS_FALSE;\n"
|
||||
" }\n";
|
||||
|
||||
|
@ -532,7 +538,7 @@ JSStubGen::GeneratePropSetter(ofstream *file,
|
|||
strcpy(case_buf, kStringSetCaseStr);
|
||||
break;
|
||||
case TYPE_OBJECT:
|
||||
sprintf(case_buf, kObjectSetCaseStr, aAttribute.GetTypeName());
|
||||
sprintf(case_buf, kObjectSetCaseStr, aAttribute.GetTypeName(), aAttribute.GetTypeName());
|
||||
break;
|
||||
default:
|
||||
// XXX Fail for other cases
|
||||
|
@ -546,7 +552,7 @@ JSStubGen::GeneratePropSetter(ofstream *file,
|
|||
else {
|
||||
sprintf(buf, kSetCaseNonPrimaryStr, attr_type, case_buf,
|
||||
aInterface.GetName(), aInterface.GetName(), attr_name,
|
||||
end_str, end_str);
|
||||
end_str, aInterface.GetName(), end_str);
|
||||
}
|
||||
|
||||
*file << buf;
|
||||
|
@ -706,10 +712,12 @@ static const char *kMethodObjectParamStr = "\n"
|
|||
"\n"
|
||||
" if ((nsnull == supports%d) ||\n"
|
||||
" (NS_OK != supports%d->QueryInterface(kI%sIID, (void **)(b%d.Query())))) {\n"
|
||||
" JS_ReportError(cx, \"Parameter must be of type %s\");\n"
|
||||
" return JS_FALSE;\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
" else {\n"
|
||||
" JS_ReportError(cx, \"Parameter must be an object\");\n"
|
||||
" return JS_FALSE;\n"
|
||||
" }\n";
|
||||
|
||||
|
@ -717,7 +725,7 @@ static const char *kMethodObjectParamStr = "\n"
|
|||
sprintf(buffer, kMethodObjectParamStr, paramNum, paramNum, \
|
||||
paramNum, paramNum, \
|
||||
paramNum, paramNum, paramNum, paramNum, paramType, \
|
||||
paramNum)
|
||||
paramNum, paramType)
|
||||
|
||||
|
||||
static const char *kMethodStringParamStr = "\n"
|
||||
|
@ -735,6 +743,7 @@ static const char *kMethodStringParamStr = "\n"
|
|||
|
||||
static const char *kMethodBoolParamStr = "\n"
|
||||
" if (!JS_ValueToBoolean(cx, argv[%d], &b%d)) {\n"
|
||||
" JS_ReportError(cx, \"Parameter must be a boolean\");\n"
|
||||
" return JS_FALSE;\n"
|
||||
" }\n";
|
||||
|
||||
|
@ -743,6 +752,7 @@ static const char *kMethodBoolParamStr = "\n"
|
|||
|
||||
static const char *kMethodIntParamStr = "\n"
|
||||
" if (!JS_ValueToInt32(cx, argv[%d], (int32 *)&b%d)) {\n"
|
||||
" JS_ReportError(cx, \"Parameter must be a number\");\n"
|
||||
" return JS_FALSE;\n"
|
||||
" }\n";
|
||||
|
||||
|
@ -751,6 +761,7 @@ static const char *kMethodIntParamStr = "\n"
|
|||
|
||||
static const char *kMethodParamListStr = "b%d";
|
||||
static const char *kMethodParamListDelimiterStr = ", ";
|
||||
static const char *kMethodParamEllipsisStr = "cx, argv+%d, argc-%d";
|
||||
|
||||
static const char *kMethodBodyMiddleStr =
|
||||
"\n"
|
||||
|
@ -801,6 +812,7 @@ static const char *kMethodVoidRetStr =
|
|||
static const char *kMethodEndStr =
|
||||
" }\n"
|
||||
" else {\n"
|
||||
" JS_ReportError(cx, \"Function %s requires %d parameters\");\n"
|
||||
" return JS_FALSE;\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
|
@ -888,9 +900,18 @@ JSStubGen::GenerateMethods(IdlSpecification &aSpec)
|
|||
param_ptr += strlen(param_ptr);
|
||||
}
|
||||
|
||||
if (rval->GetType() != TYPE_VOID) {
|
||||
if (func->GetHasEllipsis()) {
|
||||
if (pcount > 0) {
|
||||
strcpy(param_ptr, kMethodParamListDelimiterStr);
|
||||
param_ptr += strlen(param_ptr);
|
||||
}
|
||||
sprintf(param_ptr, kMethodParamEllipsisStr, pcount, pcount);
|
||||
param_ptr += strlen(param_ptr);
|
||||
}
|
||||
|
||||
if (rval->GetType() != TYPE_VOID) {
|
||||
if ((pcount > 0) || func->GetHasEllipsis()) {
|
||||
strcpy(param_ptr, kMethodParamListDelimiterStr);
|
||||
}
|
||||
sprintf(buf, kMethodBodyMiddleStr, method_name, param_buf,
|
||||
rval->GetType() == TYPE_STRING ? "" : "&");
|
||||
|
@ -927,7 +948,8 @@ JSStubGen::GenerateMethods(IdlSpecification &aSpec)
|
|||
break;
|
||||
}
|
||||
|
||||
*file << kMethodEndStr;
|
||||
sprintf(buf, kMethodEndStr, func->GetName(), func->ParameterCount());
|
||||
*file << buf;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ interface Test : Node {
|
|||
long createChildren(in wstring ids, in boolean new);
|
||||
boolean isNew();
|
||||
wstring rename(in wstring newName);
|
||||
wstring setTimeout(in wstring expr /* ... */);
|
||||
};
|
||||
|
||||
interface Test2 {
|
||||
|
|
|
@ -41,6 +41,7 @@ static const char *kIncludeDefaultsStr =
|
|||
"#include \"nsString.h\"\n"
|
||||
"#include \"nsIScriptContext.h\"\n";
|
||||
static const char *kIncludeStr = "#include \"nsIDOM%s.h\"\n";
|
||||
static const char *kIncludeJSStr = "#include \"jsapi.h\"\n";
|
||||
static const char *kForwardClassStr = "class nsIDOM%s;\n";
|
||||
static const char *kUuidStr =
|
||||
"#define %s \\\n"
|
||||
|
@ -57,6 +58,7 @@ static const char *kSetterMethodDeclStr = " NS_IMETHOD Set%s(%s a%s)=0;\n";
|
|||
static const char *kMethodDeclStr = "\n NS_IMETHOD %s(%s)=0;\n";
|
||||
static const char *kParamStr = "%s a%s";
|
||||
static const char *kDelimiterStr = ", ";
|
||||
static const char *kEllipsisParamStr = "JSContext *cx, jsval *argv, PRUint32 argc";
|
||||
static const char *kReturnStr = "%s%s aReturn";
|
||||
static const char *kClassEpilogStr = "};\n\n";
|
||||
static const char *kGlobalInitClassStr = "extern nsresult NS_Init%sClass(nsIScriptContext *aContext, nsIScriptGlobalObject *aGlobal);\n\n";
|
||||
|
@ -139,6 +141,16 @@ XPCOMGen::GenerateIncludes(IdlSpecification &aSpec)
|
|||
*file << buf;
|
||||
}
|
||||
}
|
||||
|
||||
int m, mcount = iface->FunctionCount();
|
||||
for (m = 0; m < mcount; m++) {
|
||||
IdlFunction *func = iface->GetFunctionAt(m);
|
||||
|
||||
if (func->GetHasEllipsis()) {
|
||||
*file << kIncludeJSStr;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*file << "\n";
|
||||
|
@ -275,9 +287,18 @@ XPCOMGen::GenerateMethods(IdlInterface &aInterface)
|
|||
cur_param += strlen(cur_param);
|
||||
}
|
||||
|
||||
if (func->GetHasEllipsis()) {
|
||||
if (pcount > 0) {
|
||||
strcpy(cur_param, kDelimiterStr);
|
||||
cur_param += strlen(kDelimiterStr);
|
||||
}
|
||||
sprintf(cur_param, kEllipsisParamStr);
|
||||
cur_param += strlen(cur_param);
|
||||
}
|
||||
|
||||
IdlVariable *rval = func->GetReturnValue();
|
||||
if (rval->GetType() != TYPE_VOID) {
|
||||
if (pcount > 0) {
|
||||
if ((pcount > 0) || func->GetHasEllipsis()) {
|
||||
strcpy(cur_param, kDelimiterStr);
|
||||
cur_param += strlen(kDelimiterStr);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче