зеркало из https://github.com/mozilla/gecko-dev.git
Added support and test for [shared]. Added nsrootidl.idl with some typedefs and annotated 'native' declarations used elsewhere - this will eventially migrate to a more public place. Fixed 'reciever' misspelling (oh boy!). Made constants work (with test) using new 'const' stuff in xpidl. Fixed failure to mark pointer 'out' params for later free'ing - was leaking!
This commit is contained in:
Родитель
c5e8747649
Коммит
472da673c5
|
@ -1,4 +1,5 @@
|
|||
|
||||
xpidl -w -m header -o ..\public\nsrootidl nsrootidl.idl
|
||||
xpidl -w -m header -o ..\public\xpccomponents xpccomponents.idl
|
||||
xpidl -w -m header -o ..\public\xpcjsid xpcjsid.idl
|
||||
xpidl -w -m header -o ..\tests\xpctest xpctest.idl
|
||||
|
|
|
@ -16,29 +16,17 @@
|
|||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsrootidl.idl"
|
||||
|
||||
%{C++
|
||||
#include "nsDebug.h"
|
||||
#include "nsTraceRefcnt.h"
|
||||
#include "nsIID.h"
|
||||
%}
|
||||
/* #include "nsID.idl" */
|
||||
%{C++
|
||||
#include "nsError.h"
|
||||
|
||||
#include "nsISupportsUtils.h"
|
||||
%}
|
||||
|
||||
native nsQIResult(void *);
|
||||
native voidStar(void*);
|
||||
native voidStarRef(void**);
|
||||
native nsIIDRef(REFNSIID);
|
||||
|
||||
typedef unsigned long nsrefcnt;
|
||||
|
||||
[
|
||||
object,
|
||||
uuid(00000000-0000-0000-c000-000000000046)
|
||||
]
|
||||
[object, uuid(00000000-0000-0000-c000-000000000046)]
|
||||
interface nsISupports {
|
||||
void QueryInterface(in nsIIDRef uuid, [iid_is(uuid),retval] out nsQIResult result);
|
||||
[notxpcom] nsrefcnt AddRef();
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/* Root idl declarations to be used by all. */
|
||||
|
||||
%{C++
|
||||
/*
|
||||
* Start commenting out the C++ versions of the below in the output header
|
||||
*/
|
||||
#if 0
|
||||
%}
|
||||
|
||||
typedef octet PRUint8 ;
|
||||
typedef unsigned short PRUint16 ;
|
||||
typedef unsigned long PRUint32 ;
|
||||
typedef unsigned long long PRUint64 ;
|
||||
typedef short PRInt16 ;
|
||||
typedef long PRInt32 ;
|
||||
typedef long long PRInt64 ;
|
||||
|
||||
typedef unsigned long nsrefcnt ;
|
||||
|
||||
[ptr] native voidStar(void);
|
||||
[ref] native voidRef(void);
|
||||
|
||||
[ref, nsid] native nsIDRef(nsID);
|
||||
[ref, nsid] native nsIIDRef(nsIID);
|
||||
[ref, nsid] native nsCIDRef(nsCID);
|
||||
|
||||
[ptr, nsid] native nsIDPtr(nsID);
|
||||
[ptr, nsid] native nsIIDPtr(nsIID);
|
||||
[ptr, nsid] native nsCIDPtr(nsCID);
|
||||
|
||||
[ptr] native nsQIResult(void);
|
||||
|
||||
%{C++
|
||||
/*
|
||||
* End commenting out the C++ versions of the above in the output header
|
||||
*/
|
||||
#endif
|
||||
%}
|
|
@ -0,0 +1,10 @@
|
|||
|
||||
#include "nsrootidl.idl"
|
||||
|
||||
[uuid(bbc57da0-e321-11d2-ba97-00805f8a5dd7)]
|
||||
interface test{
|
||||
void m1(in voidStar foo);
|
||||
void m2(in voidRef foo);
|
||||
void m3([const] in voidRef foo);
|
||||
void m4(in nsIIDRef id, out nsIDPtr idOut);
|
||||
};
|
|
@ -8,6 +8,10 @@ native nsID(nsID *);
|
|||
interface nsITestXPCFoo : nsISupports {
|
||||
long Test(in long p1, in long p2);
|
||||
void Test2();
|
||||
|
||||
const short one = 1;
|
||||
const short five = 5;
|
||||
const short six = 6;
|
||||
};
|
||||
|
||||
[uuid(5F9D20C0-9B6B-11d2-9FFE-000064657374)]
|
||||
|
@ -18,7 +22,7 @@ interface nsITestXPCFoo2 : nsITestXPCFoo {
|
|||
[uuid(CD2F2F40-C5D9-11d2-9838-006008962422)]
|
||||
interface nsIEcho : nsISupports {
|
||||
|
||||
void SetReciever(in nsIEcho aReciever);
|
||||
void SetReceiver(in nsIEcho aReceiver);
|
||||
void SendOneString(in string str);
|
||||
long In2OutOneInt(in long input);
|
||||
|
||||
|
@ -64,5 +68,6 @@ interface nsIEcho : nsISupports {
|
|||
void MethodWithNative(in long p1, in voidStar p2);
|
||||
void ReturnCode(in long code);
|
||||
void FailInJSTest(in long fail);
|
||||
void SharedString([retval, shared] out string str);
|
||||
};
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@ EXPORTS = \
|
|||
xpccomponents.h \
|
||||
xpcjsid.h \
|
||||
xpclog.h \
|
||||
nsrootidl.h \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
|
||||
|
|
|
@ -25,6 +25,7 @@ EXPORTS = \
|
|||
xpccomponents.h \
|
||||
xpcjsid.h \
|
||||
xpclog.h \
|
||||
nsrootidl.h \
|
||||
$(NULL)
|
||||
|
||||
MODULE = xpconnect
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* DO NOT EDIT. THIS FILE IS GENERATED FROM nsrootidl.idl
|
||||
*/
|
||||
|
||||
#ifndef __gen_nsrootidl_h__
|
||||
#define __gen_nsrootidl_h__
|
||||
|
||||
#ifdef XPIDL_JS_STUBS
|
||||
#include "jsapi.h"
|
||||
#endif
|
||||
/*
|
||||
* Start commenting out the C++ versions of the below in the output header
|
||||
*/
|
||||
#if 0
|
||||
|
||||
typedef PRUint8 PRUint8;
|
||||
typedef PRUint16 PRUint16;
|
||||
typedef PRUint32 PRUint32;
|
||||
typedef PRUint64 PRUint64;
|
||||
typedef PRInt16 PRInt16;
|
||||
typedef PRInt32 PRInt32;
|
||||
typedef PRInt64 PRInt64;
|
||||
typedef PRUint32 nsrefcnt;
|
||||
/*
|
||||
* End commenting out the C++ versions of the above in the output header
|
||||
*/
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* __gen_nsrootidl_h__ */
|
|
@ -6,12 +6,13 @@
|
|||
#define __gen_xpccomponents_h__
|
||||
|
||||
#include "nsISupports.h" /* interface nsISupports */
|
||||
#include "nsrootidl.h" /* interface nsrootidl */
|
||||
|
||||
#ifdef XPIDL_JS_STUBS
|
||||
#include "jsapi.h"
|
||||
#endif
|
||||
|
||||
/* starting interface nsIXPCInterfaces */
|
||||
/* starting interface: nsIXPCInterfaces */
|
||||
|
||||
/* {4b62a640-d26c-11d2-9842-006008962422} */
|
||||
#define NS_IXPCINTERFACES_IID_STR "4b62a640-d26c-11d2-9842-006008962422"
|
||||
|
@ -32,7 +33,7 @@ class nsIXPCInterfaces : public nsISupports {
|
|||
#endif
|
||||
};
|
||||
|
||||
/* starting interface nsIXPCClasses */
|
||||
/* starting interface: nsIXPCClasses */
|
||||
|
||||
/* {978ff520-d26c-11d2-9842-006008962422} */
|
||||
#define NS_IXPCCLASSES_IID_STR "978ff520-d26c-11d2-9842-006008962422"
|
||||
|
@ -53,7 +54,7 @@ class nsIXPCClasses : public nsISupports {
|
|||
#endif
|
||||
};
|
||||
|
||||
/* starting interface nsIXPCComponents */
|
||||
/* starting interface: nsIXPCComponents */
|
||||
|
||||
/* {42624f80-d26c-11d2-9842-006008962422} */
|
||||
#define NS_IXPCCOMPONENTS_IID_STR "42624f80-d26c-11d2-9842-006008962422"
|
||||
|
|
|
@ -6,12 +6,13 @@
|
|||
#define __gen_xpcjsid_h__
|
||||
|
||||
#include "nsISupports.h" /* interface nsISupports */
|
||||
#include "nsrootidl.h" /* interface nsrootidl */
|
||||
|
||||
#ifdef XPIDL_JS_STUBS
|
||||
#include "jsapi.h"
|
||||
#endif
|
||||
|
||||
/* starting interface nsIJSID */
|
||||
/* starting interface: nsIJSID */
|
||||
|
||||
/* {C86AE131-D101-11d2-9841-006008962422} */
|
||||
#define NS_IJSID_IID_STR "C86AE131-D101-11d2-9841-006008962422"
|
||||
|
@ -53,7 +54,7 @@ class nsIJSID : public nsISupports {
|
|||
#endif
|
||||
};
|
||||
|
||||
/* starting interface nsIJSIID */
|
||||
/* starting interface: nsIJSIID */
|
||||
|
||||
/* {e08dcda0-d651-11d2-9843-006008962422} */
|
||||
#define NS_IJSIID_IID_STR "e08dcda0-d651-11d2-9843-006008962422"
|
||||
|
@ -74,7 +75,7 @@ class nsIJSIID : public nsIJSID {
|
|||
#endif
|
||||
};
|
||||
|
||||
/* starting interface nsIJSCID */
|
||||
/* starting interface: nsIJSCID */
|
||||
|
||||
/* {e3a24a60-d651-11d2-9843-006008962422} */
|
||||
#define NS_IJSCID_IID_STR "e3a24a60-d651-11d2-9843-006008962422"
|
||||
|
|
|
@ -421,7 +421,7 @@ XPCConvert::JSData2Native(JSContext* cx, void* d, jsval s,
|
|||
return JS_FALSE;
|
||||
case nsXPTType::T_IID:
|
||||
{
|
||||
NS_ASSERTION(useAllocator,"trying to convert a JSID to nsID without allocator");
|
||||
NS_ASSERTION(useAllocator,"trying to convert a JSID to nsID without allocator : this would leak");
|
||||
|
||||
JSObject* obj;
|
||||
const nsID* pid=NULL;
|
||||
|
|
|
@ -486,7 +486,7 @@ pre_call_clean_up:
|
|||
!(conditional_iid = *((nsID**)params[arg_num].val.p)))
|
||||
break;
|
||||
}
|
||||
else if(type.IsPointer())
|
||||
else if(type.IsPointer() && !param.IsShared())
|
||||
useAllocator = JS_TRUE;
|
||||
|
||||
if(!XPCConvert::JSData2Native(cx, &pv->val, val, type,
|
||||
|
|
|
@ -457,15 +457,15 @@ nsXPCWrappedNativeClass::CallWrappedMethod(JSContext* cx,
|
|||
cx, desc, i);
|
||||
goto done;
|
||||
}
|
||||
if(!param.IsIn())
|
||||
continue;
|
||||
|
||||
// in the future there may be a param flag indicating 'shared'
|
||||
if(type.IsPointer())
|
||||
if(type.IsPointer() &&
|
||||
!type.IsInterfacePointer() &&
|
||||
!param.IsShared())
|
||||
{
|
||||
useAllocator = JS_TRUE;
|
||||
dp->flags |= nsXPTCVariant::VAL_IS_OWNED;
|
||||
}
|
||||
if(!param.IsIn())
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -166,7 +166,7 @@ class MyEcho : public nsIEcho
|
|||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_IMETHOD SetReciever(nsIEcho* aReciever);
|
||||
NS_IMETHOD SetReceiver(nsIEcho* aReceiver);
|
||||
NS_IMETHOD SendOneString(const char* str);
|
||||
NS_IMETHOD In2OutOneInt(int input, int* output);
|
||||
NS_IMETHOD In2OutAddTwoInts(int input1,
|
||||
|
@ -214,9 +214,12 @@ public:
|
|||
|
||||
NS_IMETHOD FailInJSTest(int fail);
|
||||
|
||||
/* void SharedTest ([shared, retval] out string str); */
|
||||
NS_IMETHOD SharedString(char **str);
|
||||
|
||||
MyEcho();
|
||||
private:
|
||||
nsIEcho* mReciever;
|
||||
nsIEcho* mReceiver;
|
||||
nsIAllocator* mAllocator;
|
||||
};
|
||||
|
||||
|
@ -224,7 +227,7 @@ static NS_DEFINE_IID(kMyEchoIID, NS_IECHO_IID);
|
|||
NS_IMPL_ISUPPORTS(MyEcho, kMyEchoIID);
|
||||
|
||||
MyEcho::MyEcho()
|
||||
: mReciever(NULL)
|
||||
: mReceiver(NULL)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
NS_ADDREF_THIS();
|
||||
|
@ -233,20 +236,20 @@ MyEcho::MyEcho()
|
|||
(nsISupports **)&mAllocator);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP MyEcho::SetReciever(nsIEcho* aReciever)
|
||||
NS_IMETHODIMP MyEcho::SetReceiver(nsIEcho* aReceiver)
|
||||
{
|
||||
if(mReciever)
|
||||
NS_RELEASE(mReciever);
|
||||
mReciever = aReciever;
|
||||
if(mReciever)
|
||||
NS_ADDREF(mReciever);
|
||||
if(mReceiver)
|
||||
NS_RELEASE(mReceiver);
|
||||
mReceiver = aReceiver;
|
||||
if(mReceiver)
|
||||
NS_ADDREF(mReceiver);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP MyEcho::SendOneString(const char* str)
|
||||
{
|
||||
if(mReciever)
|
||||
return mReciever->SendOneString(str);
|
||||
if(mReceiver)
|
||||
return mReceiver->SendOneString(str);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -307,8 +310,8 @@ MyEcho::SendManyTypes(PRUint8 p1,
|
|||
const char* p15,
|
||||
const PRUnichar* p16)
|
||||
{
|
||||
if(mReciever)
|
||||
return mReciever->SendManyTypes(p1, p2, p3, p4, p5, p6, p7, p8, p9,
|
||||
if(mReceiver)
|
||||
return mReceiver->SendManyTypes(p1, p2, p3, p4, p5, p6, p7, p8, p9,
|
||||
p10, p11, p12, p13, p14, p15, p16);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -331,8 +334,8 @@ MyEcho::SendInOutManyTypes(PRUint8* p1,
|
|||
char** p15,
|
||||
PRUint16** p16)
|
||||
{
|
||||
if(mReciever)
|
||||
return mReciever->SendInOutManyTypes(p1, p2, p3, p4, p5, p6, p7, p8, p9,
|
||||
if(mReceiver)
|
||||
return mReceiver->SendInOutManyTypes(p1, p2, p3, p4, p5, p6, p7, p8, p9,
|
||||
p10, p11, p12, p13, p14, p15, p16);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -352,8 +355,22 @@ MyEcho::ReturnCode(int code)
|
|||
NS_IMETHODIMP
|
||||
MyEcho::FailInJSTest(int fail)
|
||||
{
|
||||
if(mReciever)
|
||||
return mReciever->FailInJSTest(fail);
|
||||
if(mReceiver)
|
||||
return mReceiver->FailInJSTest(fail);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MyEcho::SharedString(char **str)
|
||||
{
|
||||
*str = "a static string";
|
||||
/*
|
||||
// to do non-shared we clone the string:
|
||||
char buf[] = "a static string";
|
||||
int len;
|
||||
*str = (char*)mAllocator->Alloc(len=strlen(buf)+1);
|
||||
memcpy(*str, buf, len);
|
||||
*/
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -642,7 +659,7 @@ int main()
|
|||
JS_DeleteProperty(jscontext, glob, "foo2");
|
||||
JS_DeleteProperty(jscontext, glob, "baz");
|
||||
JS_DeleteProperty(jscontext, glob, "baz2");
|
||||
JS_DeleteProperty(jscontext, glob, "reciever");
|
||||
JS_DeleteProperty(jscontext, glob, "receiver");
|
||||
JS_SetGlobalObject(jscontext, JS_NewObject(jscontext, &global_class, NULL, NULL));
|
||||
}
|
||||
NS_RELEASE(wrapper);
|
||||
|
|
|
@ -62,25 +62,25 @@ for(i in foo)
|
|||
print(".......................................");
|
||||
print("echo tests...");
|
||||
|
||||
var reciever = new Object();
|
||||
reciever.SetReciever = function() {};
|
||||
reciever.SendOneString = function(str) {reciever_results[0] = str;};
|
||||
reciever.SendManyTypes = function()
|
||||
var receiver = new Object();
|
||||
receiver.SetReceiver = function() {};
|
||||
receiver.SendOneString = function(str) {receiver_results[0] = str;};
|
||||
receiver.SendManyTypes = function()
|
||||
{
|
||||
for(var i = 0; i < arguments.length; i++)
|
||||
reciever_results[i] = arguments[i];
|
||||
receiver_results[i] = arguments[i];
|
||||
};
|
||||
|
||||
echo.SetReciever(reciever);
|
||||
echo.SetReceiver(receiver);
|
||||
|
||||
////////////////////
|
||||
// SendOneString
|
||||
|
||||
var test_string = "some string";
|
||||
var reciever_results = new Object();
|
||||
var receiver_results = new Object();
|
||||
echo.SendOneString(test_string);
|
||||
print("SendOneString - "+(
|
||||
reciever_results[0] == test_string
|
||||
receiver_results[0] == test_string
|
||||
? "passed" : "failed"));
|
||||
|
||||
////////////////////
|
||||
|
@ -113,7 +113,7 @@ print("In2OutOneString - "+(
|
|||
////////////////////
|
||||
// SendManyTypes
|
||||
|
||||
var reciever_results = new Object();
|
||||
var receiver_results = new Object();
|
||||
var send_params = [1,-2,-3,-102020,2,4,6,1023,1.5,2.000008,true,'a','b',NS_ITESTXPC_FOO_IID,"a string","another string"];
|
||||
echo.SendManyTypes(send_params[0],
|
||||
send_params[1],
|
||||
|
@ -134,12 +134,12 @@ echo.SendManyTypes(send_params[0],
|
|||
|
||||
var all_ok = true;
|
||||
for(i = 0; i < 16; i++) {
|
||||
if(((""+reciever_results[i]).toLowerCase()) !=
|
||||
if(((""+receiver_results[i]).toLowerCase()) !=
|
||||
((""+send_params[i]).toLowerCase())) {
|
||||
if(all_ok)
|
||||
print("SendManyTypes - failed...");
|
||||
all_ok = false;
|
||||
print(" param number "+i+" diff: "+send_params[i]+" -> "+reciever_results[i])
|
||||
print(" param number "+i+" diff: "+send_params[i]+" -> "+receiver_results[i])
|
||||
}
|
||||
}
|
||||
if(all_ok)
|
||||
|
@ -148,14 +148,14 @@ if(all_ok)
|
|||
////////////////////
|
||||
// SendInOutManyTypes
|
||||
|
||||
var reciever_results = new Object();
|
||||
var receiver_results = new Object();
|
||||
var send_params = [1,-2,-3,-102020,2,4,6,1023,1.5,2.000008,true,'a','b',NS_ITESTXPC_FOO_IID,"a string","another string"];
|
||||
var resend_params = [2,-3,-7,-10220,18,14,16,123,2.5,8.000008,false,'z','l',NS_ISUPPORTS_IID,"foo string","yet another string"];
|
||||
|
||||
reciever.SendInOutManyTypes = function()
|
||||
receiver.SendInOutManyTypes = function()
|
||||
{
|
||||
for(var i = 0; i < arguments.length; i++) {
|
||||
reciever_results[i] = arguments[i].value;
|
||||
receiver_results[i] = arguments[i].value;
|
||||
arguments[i].value = resend_params[i];
|
||||
}
|
||||
};
|
||||
|
@ -196,12 +196,12 @@ echo.SendInOutManyTypes(inout_params[0] ,
|
|||
|
||||
var all_ok = true;
|
||||
for(i = 0; i < 16; i++) {
|
||||
if(((""+reciever_results[i]).toLowerCase()) !=
|
||||
if(((""+receiver_results[i]).toLowerCase()) !=
|
||||
((""+send_params[i]).toLowerCase())) {
|
||||
if(all_ok)
|
||||
print("SendInOutManyTypes - failed...");
|
||||
all_ok = false;
|
||||
print(" sent param number "+i+" diff: "+send_params[i]+" -> "+reciever_results[i]);
|
||||
print(" sent param number "+i+" diff: "+send_params[i]+" -> "+receiver_results[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -256,7 +256,7 @@ catch(e) {
|
|||
// XXX this is bad test since null is now convertable.
|
||||
/*
|
||||
try {
|
||||
echo.SetReciever(null);
|
||||
echo.SetReceiver(null);
|
||||
// print("Can't convert arg to Native ("+out+")- failed");
|
||||
print("Can't convert arg to Native - failed");
|
||||
}
|
||||
|
@ -268,10 +268,10 @@ catch(e) {
|
|||
////////////////////
|
||||
// FailInJSTest
|
||||
|
||||
var reciever3 = new Object();
|
||||
reciever3.SetReciever = function() {};
|
||||
reciever3.FailInJSTest = function(fail) {if(fail)throw("");};
|
||||
echo.SetReciever(reciever3);
|
||||
var receiver3 = new Object();
|
||||
receiver3.SetReceiver = function() {};
|
||||
receiver3.FailInJSTest = function(fail) {if(fail)throw("");};
|
||||
echo.SetReceiver(receiver3);
|
||||
|
||||
var all_ok = true;
|
||||
|
||||
|
@ -371,6 +371,11 @@ all_ok = idTest("bogus", "{XXXXXXXX-C5D9-11d2-9838-006008962422}", true)
|
|||
|
||||
print("nsID tests - "+(all_ok ? "passed" : "failed"));
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
all_ok = echo.SharedString() == "a static string";
|
||||
print("[shared] test - "+(all_ok ? "passed" : "failed"));
|
||||
|
||||
/***************************************************************************/
|
||||
// Components object test...
|
||||
// print(".......................................");
|
||||
|
@ -397,12 +402,12 @@ print("simple speed tests...");
|
|||
|
||||
var iterations = 1000;
|
||||
|
||||
var reciever2 = new Object();
|
||||
reciever2.SetReciever = function() {};
|
||||
reciever2.SendOneString = function(str) {/*print(str);*/};
|
||||
var receiver2 = new Object();
|
||||
receiver2.SetReceiver = function() {};
|
||||
receiver2.SendOneString = function(str) {/*print(str);*/};
|
||||
|
||||
var echoJS = new Object();
|
||||
echoJS.SetReciever = function(r) {this.r = r;};
|
||||
echoJS.SetReceiver = function(r) {this.r = r;};
|
||||
echoJS.SendOneString = function(str) {if(this.r)this.r.SendOneString(str)};
|
||||
echoJS.SimpleCallNoEcho = function(){}
|
||||
|
||||
|
@ -411,7 +416,7 @@ echoJS.SimpleCallNoEcho = function(){}
|
|||
|
||||
print("\nEcho.SimpleCallNoEcho (just makes call with no params and no callback)");
|
||||
var start_time = new Date().getTime()/1000;
|
||||
echoJS.SetReciever(reciever2);
|
||||
echoJS.SetReceiver(receiver2);
|
||||
for(i = 0; i < iterations; i++)
|
||||
echoJS.SimpleCallNoEcho();
|
||||
var end_time = new Date().getTime()/1000;
|
||||
|
@ -419,7 +424,7 @@ var interval = parseInt(100*(end_time - start_time),10)/100;
|
|||
print("JS control did "+iterations+" iterations in "+interval+ " seconds.");
|
||||
|
||||
var start_time = new Date().getTime()/1000;
|
||||
echo.SetReciever(reciever2);
|
||||
echo.SetReceiver(receiver2);
|
||||
for(i = 0; i < iterations; i++)
|
||||
echo.SimpleCallNoEcho();
|
||||
var end_time = new Date().getTime()/1000;
|
||||
|
@ -430,7 +435,7 @@ print("XPConnect did "+iterations+" iterations in "+interval+ " seconds.");
|
|||
|
||||
print("\nEcho.SendOneString (calls a callback that does a call)");
|
||||
var start_time = new Date().getTime()/1000;
|
||||
echoJS.SetReciever(reciever2);
|
||||
echoJS.SetReceiver(receiver2);
|
||||
for(i = 0; i < iterations; i++)
|
||||
echoJS.SendOneString("foo");
|
||||
var end_time = new Date().getTime()/1000;
|
||||
|
@ -438,7 +443,7 @@ var interval = parseInt(100*(end_time - start_time),10)/100;
|
|||
print("JS control did "+iterations+" iterations in "+interval+ " seconds.");
|
||||
|
||||
var start_time = new Date().getTime()/1000;
|
||||
echo.SetReciever(reciever2);
|
||||
echo.SetReceiver(receiver2);
|
||||
for(i = 0; i < iterations; i++)
|
||||
echo.SendOneString("foo");
|
||||
var end_time = new Date().getTime()/1000;
|
||||
|
@ -447,5 +452,5 @@ print("XPConnect did "+iterations+" iterations in "+interval+ " seconds.");
|
|||
|
||||
print(".......................................");
|
||||
|
||||
echoJS.SetReciever(null);
|
||||
echo.SetReciever(null);
|
||||
echoJS.SetReceiver(null);
|
||||
echo.SetReceiver(null);
|
||||
|
|
|
@ -6,12 +6,13 @@
|
|||
#define __gen_xpctest_h__
|
||||
|
||||
#include "nsISupports.h" /* interface nsISupports */
|
||||
#include "nsrootidl.h" /* interface nsrootidl */
|
||||
|
||||
#ifdef XPIDL_JS_STUBS
|
||||
#include "jsapi.h"
|
||||
#endif
|
||||
|
||||
/* starting interface nsITestXPCFoo */
|
||||
/* starting interface: nsITestXPCFoo */
|
||||
|
||||
/* {159E36D0-991E-11d2-AC3F-00C09300144B} */
|
||||
#define NS_ITESTXPCFOO_IID_STR "159E36D0-991E-11d2-AC3F-00C09300144B"
|
||||
|
@ -31,6 +32,9 @@ class nsITestXPCFoo : public nsISupports {
|
|||
|
||||
/* void Test2 (); */
|
||||
NS_IMETHOD Test2() = 0;
|
||||
enum { one = 1 };
|
||||
enum { five = 5 };
|
||||
enum { six = 6 };
|
||||
|
||||
#ifdef XPIDL_JS_STUBS
|
||||
static NS_EXPORT_(JSObject *) InitJSClass(JSContext *cx);
|
||||
|
@ -38,7 +42,7 @@ class nsITestXPCFoo : public nsISupports {
|
|||
#endif
|
||||
};
|
||||
|
||||
/* starting interface nsITestXPCFoo2 */
|
||||
/* starting interface: nsITestXPCFoo2 */
|
||||
|
||||
/* {5F9D20C0-9B6B-11d2-9FFE-000064657374} */
|
||||
#define NS_ITESTXPCFOO2_IID_STR "5F9D20C0-9B6B-11d2-9FFE-000064657374"
|
||||
|
@ -59,7 +63,7 @@ class nsITestXPCFoo2 : public nsITestXPCFoo {
|
|||
#endif
|
||||
};
|
||||
|
||||
/* starting interface nsIEcho */
|
||||
/* starting interface: nsIEcho */
|
||||
|
||||
/* {CD2F2F40-C5D9-11d2-9838-006008962422} */
|
||||
#define NS_IECHO_IID_STR "CD2F2F40-C5D9-11d2-9838-006008962422"
|
||||
|
@ -74,8 +78,8 @@ class nsIEcho : public nsISupports {
|
|||
return iid;
|
||||
}
|
||||
|
||||
/* void SetReciever (in nsIEcho aReciever); */
|
||||
NS_IMETHOD SetReciever(nsIEcho *aReciever) = 0;
|
||||
/* void SetReceiver (in nsIEcho aReceiver); */
|
||||
NS_IMETHOD SetReceiver(nsIEcho *aReceiver) = 0;
|
||||
|
||||
/* void SendOneString (in string str); */
|
||||
NS_IMETHOD SendOneString(const char *str) = 0;
|
||||
|
@ -99,7 +103,7 @@ class nsIEcho : public nsISupports {
|
|||
NS_IMETHOD SendInOutManyTypes(PRUint8 *p1, PRInt16 *p2, PRInt32 *p3, PRInt64 *p4, PRUint8 *p5, PRUint16 *p6, PRUint32 *p7, PRUint64 *p8, float *p9, double *p10, PRBool *p11, char *p12, PRUint16 *p13, nsID * *p14, char **p15, PRUnichar **p16) = 0;
|
||||
|
||||
/* void MethodWithNative (in long p1, in voidStar p2); */
|
||||
NS_IMETHOD MethodWithNative(PRInt32 p1, void* p2) = 0;
|
||||
NS_IMETHOD MethodWithNative(PRInt32 p1, void * p2) = 0;
|
||||
|
||||
/* void ReturnCode (in long code); */
|
||||
NS_IMETHOD ReturnCode(PRInt32 code) = 0;
|
||||
|
@ -107,6 +111,9 @@ class nsIEcho : public nsISupports {
|
|||
/* void FailInJSTest (in long fail); */
|
||||
NS_IMETHOD FailInJSTest(PRInt32 fail) = 0;
|
||||
|
||||
/* void SharedString ([shared, retval] out string str); */
|
||||
NS_IMETHOD SharedString(char **str) = 0;
|
||||
|
||||
#ifdef XPIDL_JS_STUBS
|
||||
static NS_EXPORT_(JSObject *) InitJSClass(JSContext *cx);
|
||||
static NS_EXPORT_(JSObject *) GetJSObject(JSContext *cx, nsIEcho *priv);
|
||||
|
|
Двоичные данные
js/src/xpconnect/typelib/nsISupports.xpt
Двоичные данные
js/src/xpconnect/typelib/nsISupports.xpt
Двоичный файл не отображается.
Двоичные данные
js/src/xpconnect/typelib/xpccomponents.xpt
Двоичные данные
js/src/xpconnect/typelib/xpccomponents.xpt
Двоичный файл не отображается.
Двоичные данные
js/src/xpconnect/typelib/xpcjsid.xpt
Двоичные данные
js/src/xpconnect/typelib/xpcjsid.xpt
Двоичный файл не отображается.
Двоичные данные
js/src/xpconnect/typelib/xpctest.xpt
Двоичные данные
js/src/xpconnect/typelib/xpctest.xpt
Двоичный файл не отображается.
Загрузка…
Ссылка в новой задаче