зеркало из https://github.com/mozilla/pjs.git
'array' param support. Not part of build. a=mkaply1
This commit is contained in:
Родитель
726ce24c3f
Коммит
0914e04744
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -15,7 +15,7 @@
|
|||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* IBM Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2004
|
||||
* Portions created by the Initial Developer are Copyright (C) 2005
|
||||
* IBM Corporation. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -803,13 +803,13 @@ GetNewOrUsedXPCOMObject(JNIEnv* env, jobject aJavaObject, const nsIID& aIID,
|
|||
|
||||
nsresult
|
||||
GetIIDForMethodParam(nsIInterfaceInfo *iinfo, const nsXPTMethodInfo *methodInfo,
|
||||
const nsXPTParamInfo ¶mInfo, PRUint16 methodIndex,
|
||||
nsXPTCMiniVariant *dispatchParams,
|
||||
const nsXPTParamInfo ¶mInfo, PRUint8 paramType,
|
||||
PRUint16 methodIndex, nsXPTCMiniVariant *dispatchParams,
|
||||
PRBool isFullVariantArray, nsID &result)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
switch (paramInfo.GetType().TagPart())
|
||||
switch (paramType)
|
||||
{
|
||||
case nsXPTType::T_INTERFACE:
|
||||
rv = iinfo->GetIIDForParamNoAlloc(methodIndex, ¶mInfo, &result);
|
||||
|
@ -818,7 +818,8 @@ GetIIDForMethodParam(nsIInterfaceInfo *iinfo, const nsXPTMethodInfo *methodInfo,
|
|||
case nsXPTType::T_INTERFACE_IS:
|
||||
{
|
||||
PRUint8 argnum;
|
||||
rv = iinfo->GetInterfaceIsArgNumberForParam(methodIndex, ¶mInfo, &argnum);
|
||||
rv = iinfo->GetInterfaceIsArgNumberForParam(methodIndex, ¶mInfo,
|
||||
&argnum);
|
||||
if (NS_FAILED(rv))
|
||||
break;
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* IBM Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2004
|
||||
* Portions created by the Initial Developer are Copyright (C) 2005
|
||||
* IBM Corporation. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -295,7 +295,7 @@ nsresult GetNewOrUsedXPCOMObject(JNIEnv* env, jobject aJavaObject,
|
|||
nsresult GetIIDForMethodParam(nsIInterfaceInfo *iinfo,
|
||||
const nsXPTMethodInfo *methodInfo,
|
||||
const nsXPTParamInfo ¶mInfo,
|
||||
PRUint16 methodIndex,
|
||||
PRUint8 paramType, PRUint16 methodIndex,
|
||||
nsXPTCMiniVariant *dispatchParams,
|
||||
PRBool isFullVariantArray,
|
||||
nsID &result);
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* IBM Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2004
|
||||
* Portions created by the Initial Developer are Copyright (C) 2005
|
||||
* IBM Corporation. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -883,7 +883,8 @@ nsJavaXPTCStub::SetupJavaParams(const nsXPTParamInfo &aParamInfo,
|
|||
jobject java_stub = nsnull;
|
||||
if (xpcom_obj) {
|
||||
nsID iid;
|
||||
rv = GetIIDForMethodParam(mIInfo, aMethodInfo, aParamInfo, aMethodIndex,
|
||||
rv = GetIIDForMethodParam(mIInfo, aMethodInfo, aParamInfo,
|
||||
aParamInfo.GetType().TagPart(), aMethodIndex,
|
||||
aDispatchParams, PR_FALSE, iid);
|
||||
if (NS_FAILED(rv))
|
||||
break;
|
||||
|
@ -1413,8 +1414,8 @@ nsJavaXPTCStub::FinalizeJavaParams(const nsXPTParamInfo &aParamInfo,
|
|||
// Get IID for this param
|
||||
nsID iid;
|
||||
rv = GetIIDForMethodParam(mIInfo, aMethodInfo, aParamInfo,
|
||||
aMethodIndex, aDispatchParams,
|
||||
PR_FALSE, iid);
|
||||
aParamInfo.GetType().TagPart(), aMethodIndex,
|
||||
aDispatchParams, PR_FALSE, iid);
|
||||
if (NS_FAILED(rv))
|
||||
break;
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# IBM Corporation.
|
||||
# Portions created by the Initial Developer are Copyright (C) 2004
|
||||
# Portions created by the Initial Developer are Copyright (C) 2005
|
||||
# IBM Corporation. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
|
@ -44,9 +44,23 @@ include $(DEPTH)/config/autoconf.mk
|
|||
|
||||
XPIDL_MODULE = javaxpcomtest
|
||||
|
||||
# From our interface file, we need to create an XPT file, so Mozilla knows
|
||||
# about this interface.
|
||||
# In order for XPCOM to reference these interfaces, they need to be compiled
|
||||
# into XPT files.
|
||||
XPIDLSRCS = \
|
||||
IFoo.idl \
|
||||
ITestParams.idl \
|
||||
$(NULL)
|
||||
|
||||
# Since we are creating a component that implements the ITestParams interface
|
||||
# (in the 'dll' directory), we need to add the Java interface to the
|
||||
# org.mozilla.xpcom package.
|
||||
JAVA_XPIDLSRCS += \
|
||||
ITestParams.idl \
|
||||
$(NULL)
|
||||
|
||||
# The IFoo interface is not part of the org.mozilla.xpcom package, but we need
|
||||
# to create a Java version of it.
|
||||
LOCAL_JAVA_XPIDLSRCS = \
|
||||
IFoo.idl \
|
||||
$(NULL)
|
||||
|
||||
|
@ -55,8 +69,11 @@ JAVA_SRCS = \
|
|||
TestProps.java \
|
||||
TestQI.java \
|
||||
TestJavaProxy.java \
|
||||
TestParams.java \
|
||||
$(NULL)
|
||||
|
||||
DIRS += dll
|
||||
|
||||
ifeq ($(OS_ARCH),WINNT)
|
||||
SEP = \;
|
||||
else
|
||||
|
@ -71,7 +88,8 @@ include $(topsrcdir)/config/rules.mk
|
|||
|
||||
$(XPIDL_GEN_DIR)/%.java: %.idl $(XPIDL_COMPILE) $(XPIDL_GEN_DIR)/.done
|
||||
$(REPORT_BUILD)
|
||||
$(ELOG) $(JAVA_IDL_COMPILE) -m java -w -I$(srcdir) -I$(IDL_DIR) -o $(XPIDL_GEN_DIR)/$* $(_VPATH_SRCS)
|
||||
$(ELOG) $(JAVA_IDL_COMPILE) -m java -w -I$(srcdir) -I$(IDL_DIR) \
|
||||
-o $(XPIDL_GEN_DIR)/$* $(_VPATH_SRCS)
|
||||
|
||||
ifdef JAVA_CLASSPATH
|
||||
_JAVA_CLASSPATH = .$(SEP)$(srcdir)$(SEP)$(JAVA_CLASSPATH)
|
||||
|
@ -81,8 +99,9 @@ endif
|
|||
|
||||
%.class: %.java Makefile Makefile.in
|
||||
$(REPORT_BUILD)
|
||||
$(ELOG) $(CYGWIN_WRAPPER) $(JAVAC) -classpath $(_JAVA_CLASSPATH) -d . $(_VPATH_SRCS)
|
||||
$(ELOG) $(CYGWIN_WRAPPER) $(JAVAC) -classpath $(_JAVA_CLASSPATH) -d . \
|
||||
$(_VPATH_SRCS)
|
||||
|
||||
export:: $(XPIDL_GEN_DIR)/$(XPIDLSRCS:.idl=.java)
|
||||
export:: $(patsubst %.idl,$(XPIDL_GEN_DIR)/%.java, $(LOCAL_JAVA_XPIDLSRCS))
|
||||
|
||||
libs:: $(JAVA_SRCS:.java=.class)
|
||||
|
|
|
@ -0,0 +1,239 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Java XPCOM Bindings.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* IBM Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2005
|
||||
* IBM Corporation. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Javier Pedemonte (jhpedemonte@gmail.com)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
import org.mozilla.xpcom.*;
|
||||
import java.io.*;
|
||||
|
||||
|
||||
public class TestParams
|
||||
{
|
||||
public static final String TESTPARAMS_CID =
|
||||
"{3f64f1ad-bbbc-4c2f-88c8-e5b6b67bb0cc}";
|
||||
|
||||
public static void main(String [] args)
|
||||
{
|
||||
System.loadLibrary("javaxpcom");
|
||||
|
||||
String mozillaPath = System.getProperty("MOZILLA_FIVE_HOME");
|
||||
if (mozillaPath == null) {
|
||||
throw new RuntimeException("MOZILLA_FIVE_HOME system property not set.");
|
||||
}
|
||||
|
||||
File localFile = new File(mozillaPath);
|
||||
XPCOM.initXPCOM(localFile, null);
|
||||
|
||||
nsIComponentManager componentManager = XPCOM.getComponentManager();
|
||||
ITestParams p = (ITestParams)
|
||||
componentManager.createInstance(TESTPARAMS_CID, null,
|
||||
ITestParams.ITESTPARAMS_IID);
|
||||
if (p == null) {
|
||||
throw new RuntimeException("Failed to create ITestParams.");
|
||||
}
|
||||
|
||||
testArrayParams(p);
|
||||
|
||||
XPCOM.shutdownXPCOM(null);
|
||||
}
|
||||
|
||||
static void testArrayParams(ITestParams p)
|
||||
{
|
||||
testArrayParamsIn(p);
|
||||
testArrayParamsOut(p);
|
||||
testArrayParamsInOut(p);
|
||||
testArrayParamsRetval(p);
|
||||
}
|
||||
|
||||
static void testArrayParamsIn(ITestParams p)
|
||||
{
|
||||
int count = 4;
|
||||
byte[] byte_array = new byte[count];
|
||||
for (byte i = 0; i < count; i++) {
|
||||
byte_array[i] = i;
|
||||
}
|
||||
p.testSimpleTypeArrayIn(count, byte_array);
|
||||
|
||||
count = 3;
|
||||
String[] str_array = new String[count];
|
||||
str_array[0] = "three";
|
||||
str_array[1] = "two";
|
||||
str_array[2] = "one";
|
||||
p.testCharStrTypeArrayIn(count, str_array);
|
||||
|
||||
count = 4;
|
||||
str_array = new String[count];
|
||||
str_array[0] = "foúr";
|
||||
str_array[1] = "threë";
|
||||
str_array[2] = "twò";
|
||||
str_array[3] = "ône";
|
||||
p.testWCharStrTypeArrayIn(count, str_array);
|
||||
|
||||
count = 2;
|
||||
String[] iid_array = new String[count];
|
||||
iid_array[0] = nsISupports.NS_ISUPPORTS_IID;
|
||||
iid_array[1] = nsISupportsWeakReference.NS_ISUPPORTSWEAKREFERENCE_IID;
|
||||
p.testIIDTypeArrayIn(count, iid_array);
|
||||
|
||||
count = 3;
|
||||
nsILocalFile[] iface_array = new nsILocalFile[count];
|
||||
iface_array[0] = XPCOM.newLocalFile("/usr/bin", false);
|
||||
iface_array[1] = XPCOM.newLocalFile("/var/log", false);
|
||||
iface_array[2] = XPCOM.newLocalFile("/home", false);
|
||||
p.testIfaceTypeArrayIn(count, iface_array);
|
||||
}
|
||||
|
||||
static void testArrayParamsOut(ITestParams p)
|
||||
{
|
||||
int[] count = new int[1];
|
||||
char[][] char_array = new char[1][];
|
||||
p.testSimpleTypeArrayOut(count, char_array);
|
||||
for (int i = 0; i < count[0]; i++) {
|
||||
System.out.println("[" + i + "] " + char_array[0][i]);
|
||||
}
|
||||
|
||||
String[][] str_array = new String[1][];
|
||||
p.testCharStrTypeArrayOut(count, str_array);
|
||||
for (int i = 0; i < count[0]; i++) {
|
||||
System.out.println("[" + i + "] " + str_array[0][i]);
|
||||
}
|
||||
|
||||
str_array = new String[1][];
|
||||
p.testWCharStrTypeArrayOut(count, str_array);
|
||||
for (int i = 0; i < count[0]; i++) {
|
||||
System.out.println("[" + i + "] " + str_array[0][i]);
|
||||
}
|
||||
|
||||
str_array = new String[1][];
|
||||
p.testIIDTypeArrayOut(count, str_array);
|
||||
for (int i = 0; i < count[0]; i++) {
|
||||
System.out.println("[" + i + "] " + str_array[0][i]);
|
||||
}
|
||||
|
||||
nsILocalFile[][] file_array = new nsILocalFile[1][];
|
||||
p.testIfaceTypeArrayOut(count, file_array);
|
||||
for (int i = 0; i < count[0]; i++) {
|
||||
System.out.println("[" + i + "] " + file_array[0][i].getPath());
|
||||
}
|
||||
}
|
||||
|
||||
static void testArrayParamsInOut(ITestParams p)
|
||||
{
|
||||
int count = 5;
|
||||
short[][] short_array = new short[1][count];
|
||||
for (short i = 0; i < count; i++) {
|
||||
short_array[0][i] = i;
|
||||
}
|
||||
p.testSimpleTypeArrayInOut(count, short_array);
|
||||
System.out.println("out:");
|
||||
for (int i = 0; i < count; i++) {
|
||||
System.out.println("[" + i + "] " + short_array[0][i]);
|
||||
}
|
||||
|
||||
count = 3;
|
||||
String[][] str_array = new String[1][count];
|
||||
str_array[0][0] = "three";
|
||||
str_array[0][1] = "two";
|
||||
str_array[0][2] = "one";
|
||||
p.testCharStrTypeArrayInOut(count, str_array);
|
||||
System.out.println("out:");
|
||||
for (int i = 0; i < count; i++) {
|
||||
System.out.println("[" + i + "] " + str_array[0][i]);
|
||||
}
|
||||
|
||||
count = 4;
|
||||
str_array = new String[1][count];
|
||||
str_array[0][0] = "foúr";
|
||||
str_array[0][1] = "threë";
|
||||
str_array[0][2] = "twò";
|
||||
str_array[0][3] = "ône";
|
||||
p.testWCharStrTypeArrayInOut(count, str_array);
|
||||
System.out.println("out:");
|
||||
for (int i = 0; i < count; i++) {
|
||||
System.out.println("[" + i + "] " + str_array[0][i]);
|
||||
}
|
||||
|
||||
count = 2;
|
||||
String[][] iid_array = new String[1][count];
|
||||
iid_array[0][0] = nsISupports.NS_ISUPPORTS_IID;
|
||||
iid_array[0][1] = nsISupportsWeakReference.NS_ISUPPORTSWEAKREFERENCE_IID;
|
||||
p.testIIDTypeArrayInOut(count, iid_array);
|
||||
System.out.println("out:");
|
||||
for (int i = 0; i < count; i++) {
|
||||
System.out.println("[" + i + "] " + iid_array[0][i]);
|
||||
}
|
||||
|
||||
count = 3;
|
||||
nsILocalFile[][] iface_array = new nsILocalFile[1][count];
|
||||
iface_array[0][0] = XPCOM.newLocalFile("/usr/bin", false);
|
||||
iface_array[0][1] = XPCOM.newLocalFile("/var/log", false);
|
||||
iface_array[0][2] = XPCOM.newLocalFile("/home", false);
|
||||
p.testIfaceTypeArrayInOut(count, iface_array);
|
||||
System.out.println("out:");
|
||||
for (int i = 0; i < count; i++) {
|
||||
System.out.println("[" + i + "] " + iface_array[0][i].getPath());
|
||||
}
|
||||
}
|
||||
|
||||
static void testArrayParamsRetval(ITestParams p)
|
||||
{
|
||||
int[] count = new int[1];
|
||||
int[] int_array = p.returnSimpleTypeArray(count);
|
||||
for (int i = 0; i < count[0]; i++) {
|
||||
System.out.println("[" + i + "] " + int_array[i]);
|
||||
}
|
||||
|
||||
String[] str_array = p.returnCharStrTypeArray(count);
|
||||
for (int i = 0; i < count[0]; i++) {
|
||||
System.out.println("[" + i + "] " + str_array[i]);
|
||||
}
|
||||
|
||||
str_array = p.returnWCharStrTypeArray(count);
|
||||
for (int i = 0; i < count[0]; i++) {
|
||||
System.out.println("[" + i + "] " + str_array[i]);
|
||||
}
|
||||
|
||||
str_array = p.returnIIDTypeArray(count);
|
||||
for (int i = 0; i < count[0]; i++) {
|
||||
System.out.println("[" + i + "] " + str_array[i]);
|
||||
}
|
||||
|
||||
nsILocalFile[] file_array = (nsILocalFile[]) p.returnIfaceTypeArray(count);
|
||||
for (int i = 0; i < count[0]; i++) {
|
||||
System.out.println("[" + i + "] " + file_array[i].getPath());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* IBM Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2004
|
||||
* Portions created by the Initial Developer are Copyright (C) 2005
|
||||
* IBM Corporation. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -113,6 +113,12 @@ public class TestProps {
|
|||
// test the "getKeys" method
|
||||
int[] count = new int[1];
|
||||
String[] keys = props.getKeys(count);
|
||||
if (keys == null || keys.length != 3) {
|
||||
System.out.println("getKeys returned incorrect array.");
|
||||
}
|
||||
for (int i = 0; i < keys.length; i++) {
|
||||
System.out.println("key " + i + ": " + keys[i]);
|
||||
}
|
||||
|
||||
XPCOM.shutdownXPCOM(null);
|
||||
// GeckoEmbed.termEmbedding();
|
||||
|
|
|
@ -0,0 +1,444 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Java XPCOM Bindings.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* IBM Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2005
|
||||
* IBM Corporation. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Javier Pedemonte (jhpedemonte@gmail.com)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "TestParams.h"
|
||||
#include "nsIGenericFactory.h"
|
||||
#include "nsMemory.h"
|
||||
#include "prmem.h"
|
||||
#include "nsString.h"
|
||||
#include "nsWeakReference.h"
|
||||
#include "nsILocalFile.h"
|
||||
#include "stdio.h"
|
||||
|
||||
|
||||
/* TestParams */
|
||||
|
||||
NS_IMPL_ISUPPORTS1(TestParams, ITestParams)
|
||||
|
||||
TestParams::TestParams()
|
||||
{
|
||||
/* member initializers and constructor code */
|
||||
}
|
||||
|
||||
TestParams::~TestParams()
|
||||
{
|
||||
/* destructor code */
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
TestParams::TestSimpleTypeArrayIn(PRUint32 aCount, PRUint8* aArray)
|
||||
{
|
||||
printf("-> TestSimpleTypeArrayIn()\n");
|
||||
|
||||
for (PRUint32 i = 0; i < aCount; i++) {
|
||||
printf("[%d] %u\n", i, aArray[i]);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
TestParams::TestCharStrTypeArrayIn(PRUint32 aCount, const char** aArray)
|
||||
{
|
||||
printf("-> TestCharStrTypeArrayIn()\n");
|
||||
|
||||
for (PRUint32 i = 0; i < aCount; i++) {
|
||||
printf("[%d] %s\n", i, aArray[i]);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
TestParams::TestWCharStrTypeArrayIn(PRUint32 aCount, const PRUnichar** aArray)
|
||||
{
|
||||
printf("-> TestWCharStrTypeArrayIn()\n");
|
||||
|
||||
for (PRUint32 i = 0; i < aCount; i++) {
|
||||
nsAutoString tmp(aArray[i]);
|
||||
printf("[%d] %s\n", i, NS_LossyConvertUCS2toASCII(tmp).get());
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
TestParams::TestIIDTypeArrayIn(PRUint32 aCount, const nsIID** aArray)
|
||||
{
|
||||
printf("-> TestIIDTypeArrayIn()\n");
|
||||
|
||||
for (PRUint32 i = 0; i < aCount; i++) {
|
||||
char* iid = aArray[i]->ToString();
|
||||
printf("[%d] %s\n", i, iid);
|
||||
PR_Free(iid);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
TestParams::TestIfaceTypeArrayIn(PRUint32 aCount, nsILocalFile** aArray)
|
||||
{
|
||||
printf("-> TestIfaceTypeArrayIn()\n");
|
||||
|
||||
for (PRUint32 i = 0; i < aCount; i++) {
|
||||
nsAutoString path;
|
||||
aArray[i]->GetPath(path);
|
||||
printf("[%d] %s\n", i, NS_LossyConvertUCS2toASCII(path).get());
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
TestParams::TestSimpleTypeArrayOut(PRUint32* aCount, char** aResult)
|
||||
{
|
||||
printf("-> TestSimpleTypeArrayOut()\n");
|
||||
|
||||
PRUint32 count = 4;
|
||||
char* array = (char*) nsMemory::Alloc(count * sizeof(char));
|
||||
array[0] = 's';
|
||||
array[1] = 't';
|
||||
array[2] = 'u';
|
||||
array[3] = 'v';
|
||||
|
||||
*aCount = count;
|
||||
*aResult = array;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
TestParams::TestCharStrTypeArrayOut(PRUint32* aCount, char*** aResult)
|
||||
{
|
||||
printf("-> TestCharStrTypeArrayOut()\n");
|
||||
|
||||
PRUint32 count = 3;
|
||||
char** array = (char**) nsMemory::Alloc(count * sizeof(char*));
|
||||
|
||||
array[0] = (char*) nsMemory::Alloc(4 * sizeof(char));
|
||||
strcpy(array[0], "one");
|
||||
array[1] = (char*) nsMemory::Alloc(4 * sizeof(char));
|
||||
strcpy(array[1], "two");
|
||||
array[2] = (char*) nsMemory::Alloc(6 * sizeof(char));
|
||||
strcpy(array[2], "three");
|
||||
|
||||
*aCount = count;
|
||||
*aResult = array;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
TestParams::TestWCharStrTypeArrayOut(PRUint32* aCount, PRUnichar*** aResult)
|
||||
{
|
||||
printf("-> TestWCharStrTypeArrayOut()\n");
|
||||
|
||||
PRUint32 count = 3;
|
||||
PRUnichar** array = (PRUnichar**) nsMemory::Alloc(count * sizeof(PRUnichar*));
|
||||
|
||||
NS_NAMED_LITERAL_STRING(one, "ône");
|
||||
NS_NAMED_LITERAL_STRING(two, "twò");
|
||||
NS_NAMED_LITERAL_STRING(three, "threë");
|
||||
|
||||
array[0] = (PRUnichar*) nsMemory::Alloc(4 * sizeof(PRUnichar));
|
||||
memcpy(array[0], one.get(), 4 * sizeof(PRUnichar));
|
||||
array[1] = (PRUnichar*) nsMemory::Alloc(4 * sizeof(PRUnichar));
|
||||
memcpy(array[1], two.get(), 4 * sizeof(PRUnichar));
|
||||
array[2] = (PRUnichar*) nsMemory::Alloc(6 * sizeof(PRUnichar));
|
||||
memcpy(array[2], three.get(), 6 * sizeof(PRUnichar));
|
||||
|
||||
*aCount = count;
|
||||
*aResult = array;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
TestParams::TestIIDTypeArrayOut(PRUint32* aCount, nsIID*** aResult)
|
||||
{
|
||||
printf("-> TestIIDTypeArrayOut()\n");
|
||||
|
||||
PRUint32 count = 2;
|
||||
nsIID** array = (nsIID**) nsMemory::Alloc(count * sizeof(nsIID*));
|
||||
|
||||
const nsIID& iid = NS_GET_IID(nsISupports);
|
||||
array[0] = (nsIID*) nsMemory::Clone(&iid, sizeof(iid));
|
||||
const nsIID& iid2 = NS_GET_IID(nsISupportsWeakReference);
|
||||
array[1] = (nsIID*) nsMemory::Clone(&iid2, sizeof(iid2));
|
||||
|
||||
*aCount = count;
|
||||
*aResult = array;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
TestParams::TestIfaceTypeArrayOut(PRUint32* aCount, nsILocalFile*** aResult)
|
||||
{
|
||||
printf("-> TestIfaceTypeArrayOut()\n");
|
||||
|
||||
PRUint32 count = 3;
|
||||
nsILocalFile** array = (nsILocalFile**)
|
||||
nsMemory::Alloc(count * sizeof(nsILocalFile*));
|
||||
|
||||
nsILocalFile* dir1;
|
||||
NS_NewLocalFile(NS_LITERAL_STRING("/usr/local/share"), PR_FALSE, &dir1);
|
||||
array[0] = dir1;
|
||||
nsILocalFile* dir2;
|
||||
NS_NewLocalFile(NS_LITERAL_STRING("/home"), PR_FALSE, &dir2);
|
||||
array[1] = dir2;
|
||||
nsILocalFile* dir3;
|
||||
NS_NewLocalFile(NS_LITERAL_STRING("/var/log"), PR_FALSE, &dir3);
|
||||
array[2] = dir3;
|
||||
|
||||
*aCount = count;
|
||||
*aResult = array;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
TestParams::TestSimpleTypeArrayInOut(PRUint32 aCount, PRInt16** aArray)
|
||||
{
|
||||
printf("-> TestSimpleTypeArrayInOut()\n");
|
||||
|
||||
printf("in:\n");
|
||||
for (PRUint32 i = 0; i < aCount; i++) {
|
||||
printf("[%d] %d\n", i, aArray[0][i]);
|
||||
}
|
||||
|
||||
for (PRUint32 i = 0; i < aCount/2; i++) {
|
||||
PRUint32 index = aCount - 1 - i;
|
||||
PRUint16 temp = aArray[0][index];
|
||||
aArray[0][index] = aArray[0][i];
|
||||
aArray[0][i] = temp;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
TestParams::TestCharStrTypeArrayInOut(PRUint32 aCount, char*** aArray)
|
||||
{
|
||||
printf("-> TestCharStrTypeArrayInOut()\n");
|
||||
|
||||
printf("in:\n");
|
||||
for (PRUint32 i = 0; i < aCount; i++) {
|
||||
printf("[%d] %s\n", i, aArray[0][i]);
|
||||
}
|
||||
|
||||
for (PRUint32 i = 0; i < aCount/2; i++) {
|
||||
PRUint32 index = aCount - 1 - i;
|
||||
char* temp = aArray[0][index];
|
||||
aArray[0][index] = aArray[0][i];
|
||||
aArray[0][i] = temp;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
TestParams::TestWCharStrTypeArrayInOut(PRUint32 aCount, PRUnichar*** aArray)
|
||||
{
|
||||
printf("-> TestWCharStrTypeArrayInOut()\n");
|
||||
|
||||
printf("in:\n");
|
||||
for (PRUint32 i = 0; i < aCount; i++) {
|
||||
nsAutoString tmp(aArray[0][i]);
|
||||
printf("[%d] %s\n", i, NS_LossyConvertUCS2toASCII(tmp).get());
|
||||
}
|
||||
|
||||
for (PRUint32 i = 0; i < aCount/2; i++) {
|
||||
PRUint32 index = aCount - 1 - i;
|
||||
PRUnichar* temp = aArray[0][index];
|
||||
aArray[0][index] = aArray[0][i];
|
||||
aArray[0][i] = temp;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
TestParams::TestIIDTypeArrayInOut(PRUint32 aCount, nsIID*** aArray)
|
||||
{
|
||||
printf("-> TestIIDTypeArrayInOut()\n");
|
||||
|
||||
printf("in:\n");
|
||||
for (PRUint32 i = 0; i < aCount; i++) {
|
||||
char* iid = aArray[0][i]->ToString();
|
||||
printf("[%d] %s\n", i, iid);
|
||||
PR_Free(iid);
|
||||
}
|
||||
|
||||
for (PRUint32 i = 0; i < aCount/2; i++) {
|
||||
PRUint32 index = aCount - 1 - i;
|
||||
nsID* temp = aArray[0][index];
|
||||
aArray[0][index] = aArray[0][i];
|
||||
aArray[0][i] = temp;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
TestParams::TestIfaceTypeArrayInOut(PRUint32 aCount, nsILocalFile*** aArray)
|
||||
{
|
||||
printf("-> TestIfaceTypeArrayInOut()\n");
|
||||
|
||||
printf("in:\n");
|
||||
for (PRUint32 i = 0; i < aCount; i++) {
|
||||
nsAutoString path;
|
||||
aArray[0][i]->GetPath(path);
|
||||
printf("[%d] %s\n", i, NS_LossyConvertUCS2toASCII(path).get());
|
||||
}
|
||||
|
||||
for (PRUint32 i = 0; i < aCount/2; i++) {
|
||||
PRUint32 index = aCount - 1 - i;
|
||||
nsILocalFile* temp = aArray[0][index];
|
||||
aArray[0][index] = aArray[0][i];
|
||||
aArray[0][i] = temp;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
TestParams::ReturnSimpleTypeArray(PRUint32* aCount, PRUint32** aResult)
|
||||
{
|
||||
printf("-> ReturnSimpleArrayType()\n");
|
||||
|
||||
PRUint32 count = 5;
|
||||
PRUint32* array = (PRUint32*) nsMemory::Alloc(count * sizeof(PRUint32));
|
||||
for (PRUint32 i = 0, j = 1; i < count; i++ ) {
|
||||
array[i] = j;
|
||||
j *= 13;
|
||||
}
|
||||
|
||||
*aCount = count;
|
||||
*aResult = array;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
TestParams::ReturnCharStrTypeArray(PRUint32* aCount, char*** aResult)
|
||||
{
|
||||
printf("-> ReturnCharStrTypeArray()\n");
|
||||
|
||||
PRUint32 count = 3;
|
||||
char** array = (char**) nsMemory::Alloc(count * sizeof(char*));
|
||||
|
||||
array[0] = (char*) nsMemory::Alloc(4 * sizeof(char));
|
||||
strcpy(array[0], "one");
|
||||
array[1] = (char*) nsMemory::Alloc(4 * sizeof(char));
|
||||
strcpy(array[1], "two");
|
||||
array[2] = (char*) nsMemory::Alloc(6 * sizeof(char));
|
||||
strcpy(array[2], "three");
|
||||
|
||||
*aCount = count;
|
||||
*aResult = array;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
TestParams::ReturnWCharStrTypeArray(PRUint32* aCount, PRUnichar*** aResult)
|
||||
{
|
||||
printf("-> ReturnWCharStrTypeArray()\n");
|
||||
|
||||
PRUint32 count = 3;
|
||||
PRUnichar** array = (PRUnichar**) nsMemory::Alloc(count * sizeof(PRUnichar*));
|
||||
|
||||
NS_NAMED_LITERAL_STRING(one, "one");
|
||||
NS_NAMED_LITERAL_STRING(two, "two");
|
||||
NS_NAMED_LITERAL_STRING(three, "three");
|
||||
|
||||
array[0] = (PRUnichar*) nsMemory::Alloc(4 * sizeof(PRUnichar));
|
||||
memcpy(array[0], one.get(), 4 * sizeof(PRUnichar));
|
||||
array[1] = (PRUnichar*) nsMemory::Alloc(4 * sizeof(PRUnichar));
|
||||
memcpy(array[1], two.get(), 4 * sizeof(PRUnichar));
|
||||
array[2] = (PRUnichar*) nsMemory::Alloc(6 * sizeof(PRUnichar));
|
||||
memcpy(array[2], three.get(), 6 * sizeof(PRUnichar));
|
||||
|
||||
*aCount = count;
|
||||
*aResult = array;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
TestParams::ReturnIIDTypeArray(PRUint32* aCount, nsIID*** aResult)
|
||||
{
|
||||
printf("-> ReturnIIDTypeArray()\n");
|
||||
|
||||
PRUint32 count = 2;
|
||||
nsIID** array = (nsIID**) nsMemory::Alloc(count * sizeof(nsIID*));
|
||||
|
||||
const nsIID& iid = NS_GET_IID(nsISupports);
|
||||
array[0] = (nsIID*) nsMemory::Clone(&iid, sizeof(iid));
|
||||
const nsIID& iid2 = NS_GET_IID(nsISupportsWeakReference);
|
||||
array[1] = (nsIID*) nsMemory::Clone(&iid2, sizeof(iid2));
|
||||
|
||||
*aCount = count;
|
||||
*aResult = array;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
TestParams::ReturnIfaceTypeArray(PRUint32* aCount, nsILocalFile*** aResult)
|
||||
{
|
||||
printf("-> ReturnIfaceTypeArray()\n");
|
||||
|
||||
PRUint32 count = 3;
|
||||
nsILocalFile** array = (nsILocalFile**)
|
||||
nsMemory::Alloc(count * sizeof(nsILocalFile*));
|
||||
|
||||
nsILocalFile* dir1;
|
||||
NS_NewLocalFile(NS_LITERAL_STRING("/usr/local/share"), PR_FALSE, &dir1);
|
||||
array[0] = dir1;
|
||||
nsILocalFile* dir2;
|
||||
NS_NewLocalFile(NS_LITERAL_STRING("/home"), PR_FALSE, &dir2);
|
||||
array[1] = dir2;
|
||||
nsILocalFile* dir3;
|
||||
NS_NewLocalFile(NS_LITERAL_STRING("/var/log"), PR_FALSE, &dir3);
|
||||
array[2] = dir3;
|
||||
|
||||
*aCount = count;
|
||||
*aResult = array;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
/* TestParamsFactory */
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(TestParams)
|
||||
|
||||
static const nsModuleComponentInfo components[] = {
|
||||
{ "TestParams", TESTPARAMS_CID, nsnull, TestParamsConstructor }
|
||||
};
|
||||
|
||||
NS_IMPL_NSGETMODULE(TestParamsFactory, components)
|
||||
|
||||
|
Загрузка…
Ссылка в новой задаче