diff options
Diffstat (limited to '')
24 files changed, 4140 insertions, 0 deletions
diff --git a/src/libs/xpcom18a4/python/test/.cvsignore b/src/libs/xpcom18a4/python/test/.cvsignore new file mode 100644 index 00000000..52e4e611 --- /dev/null +++ b/src/libs/xpcom18a4/python/test/.cvsignore @@ -0,0 +1,2 @@ +*.pyc +*.pyo diff --git a/src/libs/xpcom18a4/python/test/output/test_com_exceptions b/src/libs/xpcom18a4/python/test/output/test_com_exceptions new file mode 100644 index 00000000..16e4bda1 --- /dev/null +++ b/src/libs/xpcom18a4/python/test/output/test_com_exceptions @@ -0,0 +1,8 @@ +test_com_exceptions +** Unhandled exception calling 'int8 do_short(in int16, inout int16, out int16, out retval int16);' +** Returning nsresult of NS_ERROR_FAILURE +** Unhandled exception calling 'int8 do_unsigned_short(in uint16, inout uint16, out uint16, out retval uint16);' +** Returning nsresult of NS_ERROR_FAILURE +** Unhandled exception calling 'int8 do_unsigned_long_long(in uint64, inout uint64, out uint64, out retval uint64);' +** Returning nsresult of NS_ERROR_FAILURE +The xpcom exception tests passed diff --git a/src/libs/xpcom18a4/python/test/output/test_comfile b/src/libs/xpcom18a4/python/test/output/test_comfile new file mode 100644 index 00000000..8de43add --- /dev/null +++ b/src/libs/xpcom18a4/python/test/output/test_comfile @@ -0,0 +1,7 @@ +test_comfile +Open as string test worked. +Open as URL test worked. +File test using buffers worked. +Local file read test worked. +Read the correct data. +Chunks read the correct data. diff --git a/src/libs/xpcom18a4/python/test/output/test_components b/src/libs/xpcom18a4/python/test/output/test_components new file mode 100644 index 00000000..4a6386e7 --- /dev/null +++ b/src/libs/xpcom18a4/python/test/output/test_components @@ -0,0 +1,4 @@ +test_components +The interfaces object appeared to work! +The classes object appeared to work! +The ID function appeared to work! diff --git a/src/libs/xpcom18a4/python/test/output/test_isupports_primitives b/src/libs/xpcom18a4/python/test/output/test_isupports_primitives new file mode 100644 index 00000000..7765ac21 --- /dev/null +++ b/src/libs/xpcom18a4/python/test/output/test_isupports_primitives @@ -0,0 +1,2 @@ +test_isupports_primitives +The nsISupports primitive interface tests appeared to work diff --git a/src/libs/xpcom18a4/python/test/output/test_streams b/src/libs/xpcom18a4/python/test/output/test_streams new file mode 100644 index 00000000..e81ef151 --- /dev/null +++ b/src/libs/xpcom18a4/python/test/output/test_streams @@ -0,0 +1 @@ +test_streams diff --git a/src/libs/xpcom18a4/python/test/output/test_test_component b/src/libs/xpcom18a4/python/test/output/test_test_component new file mode 100644 index 00000000..c57c1325 --- /dev/null +++ b/src/libs/xpcom18a4/python/test/output/test_test_component @@ -0,0 +1,4 @@ +test_test_component +Testing the Python.TestComponent component +The Python test component worked! +Javascript could successfully use the Python test component. diff --git a/src/libs/xpcom18a4/python/test/output/test_weakreferences b/src/libs/xpcom18a4/python/test/output/test_weakreferences new file mode 100644 index 00000000..b337d26a --- /dev/null +++ b/src/libs/xpcom18a4/python/test/output/test_weakreferences @@ -0,0 +1,2 @@ +test_weakreferences +Weak-reference tests appear to have worked! diff --git a/src/libs/xpcom18a4/python/test/pyxpcom_test_tools.py b/src/libs/xpcom18a4/python/test/pyxpcom_test_tools.py new file mode 100755 index 00000000..447c5446 --- /dev/null +++ b/src/libs/xpcom18a4/python/test/pyxpcom_test_tools.py @@ -0,0 +1,126 @@ +# test tools for the pyxpcom bindings +from xpcom import _xpcom +import unittest + +# export a "getmemusage()" function that returns a useful "bytes used" count +# for the current process. Growth in this when doing the same thing over and +# over implies a leak. + +try: + import win32api + import win32pdh + import win32pdhutil + have_pdh = 1 +except ImportError: + have_pdh = 0 + +# XXX - win32pdh is slow, particularly finding our current process. +# A better way would be good. + +# Our win32pdh specific functions - they can be at the top-level on all +# platforms, but will only actually be called if the modules are available. +def FindMyCounter(): + pid_me = win32api.GetCurrentProcessId() + + object = "Process" + items, instances = win32pdh.EnumObjectItems(None,None,object, -1) + for instance in instances: + # We use 2 counters - "ID Process" and "Working Set" + counter = "ID Process" + format = win32pdh.PDH_FMT_LONG + + hq = win32pdh.OpenQuery() + path = win32pdh.MakeCounterPath( (None,object,instance, None, -1,"ID Process") ) + hc1 = win32pdh.AddCounter(hq, path) + path = win32pdh.MakeCounterPath( (None,object,instance, None, -1,"Working Set") ) + hc2 = win32pdh.AddCounter(hq, path) + win32pdh.CollectQueryData(hq) + type, pid = win32pdh.GetFormattedCounterValue(hc1, format) + if pid==pid_me: + win32pdh.RemoveCounter(hc1) # not needed any more + return hq, hc2 + # Not mine - close the query and try again + win32pdh.RemoveCounter(hc1) + win32pdh.RemoveCounter(hc2) + win32pdh.CloseQuery(hq) + else: + raise RuntimeError, "Can't find myself!?" + +def CloseCounter(hq, hc): + win32pdh.RemoveCounter(hc) + win32pdh.CloseQuery(hq) + +def GetCounterValue(hq, hc): + win32pdh.CollectQueryData(hq) + format = win32pdh.PDH_FMT_LONG + type, val = win32pdh.GetFormattedCounterValue(hc, format) + return val + +g_pdh_data = None +# The pdh function that does the work +def pdh_getmemusage(): + global g_pdh_data + if g_pdh_data is None: + hq, hc = FindMyCounter() + g_pdh_data = hq, hc + hq, hc = g_pdh_data + return GetCounterValue(hq, hc) + +# The public bit +if have_pdh: + getmemusage = pdh_getmemusage +else: + def getmemusage(): + return 0 + +# Test runner utilities, including some support for builtin leak tests. +class TestLoader(unittest.TestLoader): + def loadTestsFromTestCase(self, testCaseClass): + """Return a suite of all tests cases contained in testCaseClass""" + leak_tests = [] + for name in self.getTestCaseNames(testCaseClass): + real_test = testCaseClass(name) + leak_test = self._getTestWrapper(real_test) + leak_tests.append(leak_test) + return self.suiteClass(leak_tests) + def _getTestWrapper(self, test): + # later! see pywin32's win32/test/util.py + return test + def loadTestsFromModule(self, mod): + if hasattr(mod, "suite"): + ret = mod.suite() + else: + ret = unittest.TestLoader.loadTestsFromModule(self, mod) + assert ret.countTestCases() > 0, "No tests in %r" % (mod,) + return ret + def loadTestsFromName(self, name, module=None): + test = unittest.TestLoader.loadTestsFromName(self, name, module) + if isinstance(test, unittest.TestSuite): + pass # hmmm? print "Don't wrap suites yet!", test._tests + elif isinstance(test, unittest.TestCase): + test = self._getTestWrapper(test) + else: + print "XXX - what is", test + return test + +# A base class our tests should derive from (well, one day it will be) +TestCase = unittest.TestCase + +def suite_from_functions(*funcs): + suite = unittest.TestSuite() + for func in funcs: + suite.addTest(unittest.FunctionTestCase(func)) + return suite + +def testmain(*args, **kw): + new_kw = kw.copy() + if not new_kw.has_key('testLoader'): + new_kw['testLoader'] = TestLoader() + try: + unittest.main(*args, **new_kw) + finally: + _xpcom.NS_ShutdownXPCOM() + ni = _xpcom._GetInterfaceCount() + ng = _xpcom._GetGatewayCount() + if ni or ng: + print "********* WARNING - Leaving with %d/%d objects alive" % (ni,ng) diff --git a/src/libs/xpcom18a4/python/test/regrtest.py b/src/libs/xpcom18a4/python/test/regrtest.py new file mode 100644 index 00000000..90d07948 --- /dev/null +++ b/src/libs/xpcom18a4/python/test/regrtest.py @@ -0,0 +1,91 @@ +# ***** 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 Python XPCOM language bindings. +# +# The Initial Developer of the Original Code is +# ActiveState Tool Corp. +# Portions created by the Initial Developer are Copyright (C) 2000 +# the Initial Developer. All Rights Reserved. +# +# Contributor(s): +# Mark Hammond <mhammond@skippinet.com.au> (original author) +# +# 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 ***** + +# regrtest.py +# +# The Regression Tests for the xpcom package. +import os +import sys + +import unittest + +# A little magic to create a single "test suite" from all test_ files +# in this dir. A single suite makes for prettier output test :) +def suite(): + # Loop over all test_*.py files here + try: + me = __file__ + except NameError: + me = sys.argv[0] + me = os.path.abspath(me) + files = os.listdir(os.path.dirname(me)) + suite = unittest.TestSuite() + # XXX - add the others here! + #suite.addTest(unittest.FunctionTestCase(import_all)) + for file in files: + base, ext = os.path.splitext(file) + if ext=='.py' and os.path.basename(base).startswith("test_"): + mod = __import__(base) + if hasattr(mod, "suite"): + test = mod.suite() + else: + test = unittest.defaultTestLoader.loadTestsFromModule(mod) + suite.addTest(test) + return suite + +class CustomLoader(unittest.TestLoader): + def loadTestsFromModule(self, module): + return suite() + +try: + unittest.TestProgram(testLoader=CustomLoader())(argv=sys.argv) +finally: + from xpcom import _xpcom + _xpcom.NS_ShutdownXPCOM() # To get leak stats and otherwise ensure life is good. + ni = _xpcom._GetInterfaceCount() + ng = _xpcom._GetGatewayCount() + if ni or ng: + # The old 'regrtest' that was not based purely on unittest did not + # do this check at the end - it relied on each module doing it itself. + # Thus, these leaks are not new, just newly noticed :) Likely to be + # something silly like module globals. + if ni == 6 and ng == 1: + print "Sadly, there are 6/1 leaks, but these appear normal and benign" + else: + print "********* WARNING - Leaving with %d/%d objects alive" % (ni,ng) + else: + print "yay! Our leaks have all vanished!" diff --git a/src/libs/xpcom18a4/python/test/test_com_exceptions.py b/src/libs/xpcom18a4/python/test/test_com_exceptions.py new file mode 100755 index 00000000..7813bf98 --- /dev/null +++ b/src/libs/xpcom18a4/python/test/test_com_exceptions.py @@ -0,0 +1,124 @@ +# ***** 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 the Python XPCOM language bindings. +# +# The Initial Developer of the Original Code is ActiveState Tool Corp. +# Portions created by ActiveState Tool Corp. are Copyright (C) 2000, 2001 +# ActiveState Tool Corp. All Rights Reserved. +# +# Contributor(s): +# Mark Hammond <MarkH@ActiveState.com> (original author) +# +# 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 ***** + +# Test pyxpcom exception. + +from xpcom import components, nsError, ServerException, COMException, logger +from xpcom.server import WrapObject +from pyxpcom_test_tools import testmain + +import unittest +import logging + +class PythonFailingComponent: + # Re-use the test interface for this test. + _com_interfaces_ = components.interfaces.nsIPythonTestInterfaceExtra + + def do_boolean(self, p1, p2): + # This should cause the caller to see a "silent" NS_ERROR_FAILURE exception. + raise ServerException() + + def do_octet(self, p1, p2): + # This should cause the caller to see a "silent" NS_ERROR_NOT_IMPLEMENTED exception. + raise ServerException(nsError.NS_ERROR_NOT_IMPLEMENTED) + + def do_short(self, p1, p2): + # This should cause the caller to see a "debug" NS_ERROR_FAILURE exception. + raise COMException(nsError.NS_ERROR_NOT_IMPLEMENTED) + + def do_unsigned_short(self, p1, p2): + # This should cause the caller to see a "debug" NS_ERROR_FAILURE exception. + raise "Foo" + + def do_long(self, p1, p2): + # This should cause the caller to see a "silent" NS_ERROR_FAILURE exception. + raise ServerException + + def do_unsigned_long(self, p1, p2): + # This should cause the caller to see a "silent" NS_ERROR_NOT_IMPLEMENTED exception. + raise ServerException, nsError.NS_ERROR_NOT_IMPLEMENTED + + def do_long_long(self, p1, p2): + # This should cause the caller to see a "silent" NS_ERROR_NOT_IMPLEMENTED exception. + raise ServerException, (nsError.NS_ERROR_NOT_IMPLEMENTED, "testing") + + def do_unsigned_long_long(self, p1, p2): + # Report of a crash in this case - test it! + raise ServerException, "A bad exception param" + +class TestHandler(logging.Handler): + def __init__(self, level=logging.ERROR): # only counting error records + logging.Handler.__init__(self, level) + self.records = [] + + def reset(self): + self.records = [] + + def handle(self, record): + self.records.append(record) + +class ExceptionTests(unittest.TestCase): + + def _testit(self, expected_errno, num_tracebacks, func, *args): + + # Screw with the logger + old_handlers = logger.handlers + test_handler = TestHandler() + logger.handlers = [test_handler] + + try: + try: + apply(func, args) + except COMException, what: + if what.errno != expected_errno: + raise + finally: + logger.handlers = old_handlers + self.failUnlessEqual(num_tracebacks, len(test_handler.records)) + + def testEmAll(self): + ob = WrapObject( PythonFailingComponent(), components.interfaces.nsIPythonTestInterfaceExtra) + self._testit(nsError.NS_ERROR_FAILURE, 0, ob.do_boolean, 0, 0) + self._testit(nsError.NS_ERROR_NOT_IMPLEMENTED, 0, ob.do_octet, 0, 0) + self._testit(nsError.NS_ERROR_FAILURE, 1, ob.do_short, 0, 0) + self._testit(nsError.NS_ERROR_FAILURE, 1, ob.do_unsigned_short, 0, 0) + self._testit(nsError.NS_ERROR_FAILURE, 0, ob.do_long, 0, 0) + self._testit(nsError.NS_ERROR_NOT_IMPLEMENTED, 0, ob.do_unsigned_long, 0, 0) + self._testit(nsError.NS_ERROR_NOT_IMPLEMENTED, 0, ob.do_long_long, 0, 0) + self._testit(nsError.NS_ERROR_FAILURE, 1, ob.do_unsigned_long_long, 0, 0) + +if __name__=='__main__': + testmain() diff --git a/src/libs/xpcom18a4/python/test/test_comfile.py b/src/libs/xpcom18a4/python/test/test_comfile.py new file mode 100755 index 00000000..9ffebe37 --- /dev/null +++ b/src/libs/xpcom18a4/python/test/test_comfile.py @@ -0,0 +1,49 @@ +# ***** 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 the Python XPCOM language bindings. +# +# The Initial Developer of the Original Code is +# ActiveState Tool Corp. +# Portions created by the Initial Developer are Copyright (C) 2000, 2001 +# the Initial Developer. All Rights Reserved. +# +# Contributor(s): +# Mark Hammond (markh@activestate.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 ***** + +"""Test the xpcom.file module.""" +from pyxpcom_test_tools import suite_from_functions, testmain + +import xpcom.file + +# Make this test run under our std test suite +def suite(): + return suite_from_functions(xpcom.file._TestAll) + +if __name__=='__main__': + testmain() + diff --git a/src/libs/xpcom18a4/python/test/test_component/_xpidlgen/.done b/src/libs/xpcom18a4/python/test/test_component/_xpidlgen/.done new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/src/libs/xpcom18a4/python/test/test_component/_xpidlgen/.done diff --git a/src/libs/xpcom18a4/python/test/test_component/_xpidlgen/py_test_component.h b/src/libs/xpcom18a4/python/test/test_component/_xpidlgen/py_test_component.h new file mode 100644 index 00000000..7d0cd8c9 --- /dev/null +++ b/src/libs/xpcom18a4/python/test/test_component/_xpidlgen/py_test_component.h @@ -0,0 +1,1411 @@ +/* + * DO NOT EDIT. THIS FILE IS GENERATED FROM py_test_component.idl + */ + +#ifndef __gen_py_test_component_h__ +#define __gen_py_test_component_h__ + + +#ifndef __gen_nsISupports_h__ +#include "nsISupports.h" +#endif + +#ifndef __gen_nsIVariant_h__ +#include "nsIVariant.h" +#endif + +/* For IDL files that don't want to include root IDL files. */ +#ifndef NS_NO_VTABLE +#define NS_NO_VTABLE +#endif + +/* starting interface: nsIPythonTestInterface */ +#define NS_IPYTHONTESTINTERFACE_IID_STR "1ecaed4f-e4d5-4ee7-abf0-7d72ae1441d7" + +#define NS_IPYTHONTESTINTERFACE_IID \ + {0x1ecaed4f, 0xe4d5, 0x4ee7, \ + { 0xab, 0xf0, 0x7d, 0x72, 0xae, 0x14, 0x41, 0xd7 }} + +class NS_NO_VTABLE nsIPythonTestInterface : public nsISupports { + public: + + NS_DEFINE_STATIC_IID_ACCESSOR(NS_IPYTHONTESTINTERFACE_IID) + + enum { One = 1 }; + + enum { Two = 2 }; + + enum { MinusOne = -1 }; + + enum { BigLong = 2147483647 }; + + enum { BiggerLong = 4294967295 }; + + enum { BigULong = 4294967295U }; + + /* attribute boolean boolean_value; */ + NS_IMETHOD GetBoolean_value(PRBool *aBoolean_value) = 0; + NS_IMETHOD SetBoolean_value(PRBool aBoolean_value) = 0; + + /* attribute octet octet_value; */ + NS_IMETHOD GetOctet_value(PRUint8 *aOctet_value) = 0; + NS_IMETHOD SetOctet_value(PRUint8 aOctet_value) = 0; + + /* attribute short short_value; */ + NS_IMETHOD GetShort_value(PRInt16 *aShort_value) = 0; + NS_IMETHOD SetShort_value(PRInt16 aShort_value) = 0; + + /* attribute unsigned short ushort_value; */ + NS_IMETHOD GetUshort_value(PRUint16 *aUshort_value) = 0; + NS_IMETHOD SetUshort_value(PRUint16 aUshort_value) = 0; + + /* attribute long long_value; */ + NS_IMETHOD GetLong_value(PRInt32 *aLong_value) = 0; + NS_IMETHOD SetLong_value(PRInt32 aLong_value) = 0; + + /* attribute unsigned long ulong_value; */ + NS_IMETHOD GetUlong_value(PRUint32 *aUlong_value) = 0; + NS_IMETHOD SetUlong_value(PRUint32 aUlong_value) = 0; + + /* attribute long long long_long_value; */ + NS_IMETHOD GetLong_long_value(PRInt64 *aLong_long_value) = 0; + NS_IMETHOD SetLong_long_value(PRInt64 aLong_long_value) = 0; + + /* attribute unsigned long long ulong_long_value; */ + NS_IMETHOD GetUlong_long_value(PRUint64 *aUlong_long_value) = 0; + NS_IMETHOD SetUlong_long_value(PRUint64 aUlong_long_value) = 0; + + /* attribute float float_value; */ + NS_IMETHOD GetFloat_value(float *aFloat_value) = 0; + NS_IMETHOD SetFloat_value(float aFloat_value) = 0; + + /* attribute double double_value; */ + NS_IMETHOD GetDouble_value(double *aDouble_value) = 0; + NS_IMETHOD SetDouble_value(double aDouble_value) = 0; + + /* attribute char char_value; */ + NS_IMETHOD GetChar_value(char *aChar_value) = 0; + NS_IMETHOD SetChar_value(char aChar_value) = 0; + + /* attribute wchar wchar_value; */ + NS_IMETHOD GetWchar_value(PRUnichar *aWchar_value) = 0; + NS_IMETHOD SetWchar_value(PRUnichar aWchar_value) = 0; + + /* attribute string string_value; */ + NS_IMETHOD GetString_value(char * *aString_value) = 0; + NS_IMETHOD SetString_value(const char * aString_value) = 0; + + /* attribute wstring wstring_value; */ + NS_IMETHOD GetWstring_value(PRUnichar * *aWstring_value) = 0; + NS_IMETHOD SetWstring_value(const PRUnichar * aWstring_value) = 0; + + /* attribute AString astring_value; */ + NS_IMETHOD GetAstring_value(nsAString & aAstring_value) = 0; + NS_IMETHOD SetAstring_value(const nsAString & aAstring_value) = 0; + + /* attribute ACString acstring_value; */ + NS_IMETHOD GetAcstring_value(nsACString & aAcstring_value) = 0; + NS_IMETHOD SetAcstring_value(const nsACString & aAcstring_value) = 0; + + /* attribute AUTF8String utf8string_value; */ + NS_IMETHOD GetUtf8string_value(nsACString & aUtf8string_value) = 0; + NS_IMETHOD SetUtf8string_value(const nsACString & aUtf8string_value) = 0; + + /* attribute nsIIDRef iid_value; */ + NS_IMETHOD GetIid_value(nsIID & *aIid_value) = 0; + NS_IMETHOD SetIid_value(const nsIID & aIid_value) = 0; + + /* attribute nsIPythonTestInterface interface_value; */ + NS_IMETHOD GetInterface_value(nsIPythonTestInterface * *aInterface_value) = 0; + NS_IMETHOD SetInterface_value(nsIPythonTestInterface * aInterface_value) = 0; + + /* attribute nsISupports isupports_value; */ + NS_IMETHOD GetIsupports_value(nsISupports * *aIsupports_value) = 0; + NS_IMETHOD SetIsupports_value(nsISupports * aIsupports_value) = 0; + + /* boolean do_boolean (in boolean p1, inout boolean p2, out boolean p3); */ + NS_IMETHOD Do_boolean(PRBool p1, PRBool *p2, PRBool *p3, PRBool *_retval) = 0; + + /* octet do_octet (in octet p1, inout octet p2, out octet p3); */ + NS_IMETHOD Do_octet(PRUint8 p1, PRUint8 *p2, PRUint8 *p3, PRUint8 *_retval) = 0; + + /* short do_short (in short p1, inout short p2, out short p3); */ + NS_IMETHOD Do_short(PRInt16 p1, PRInt16 *p2, PRInt16 *p3, PRInt16 *_retval) = 0; + + /* unsigned short do_unsigned_short (in unsigned short p1, inout unsigned short p2, out unsigned short p3); */ + NS_IMETHOD Do_unsigned_short(PRUint16 p1, PRUint16 *p2, PRUint16 *p3, PRUint16 *_retval) = 0; + + /* long do_long (in long p1, inout long p2, out long p3); */ + NS_IMETHOD Do_long(PRInt32 p1, PRInt32 *p2, PRInt32 *p3, PRInt32 *_retval) = 0; + + /* unsigned long do_unsigned_long (in unsigned long p1, inout unsigned long p2, out unsigned long p3); */ + NS_IMETHOD Do_unsigned_long(PRUint32 p1, PRUint32 *p2, PRUint32 *p3, PRUint32 *_retval) = 0; + + /* long long do_long_long (in long long p1, inout long long p2, out long long p3); */ + NS_IMETHOD Do_long_long(PRInt64 p1, PRInt64 *p2, PRInt64 *p3, PRInt64 *_retval) = 0; + + /* unsigned long long do_unsigned_long_long (in unsigned long long p1, inout unsigned long long p2, out unsigned long long p3); */ + NS_IMETHOD Do_unsigned_long_long(PRUint64 p1, PRUint64 *p2, PRUint64 *p3, PRUint64 *_retval) = 0; + + /* float do_float (in float p1, inout float p2, out float p3); */ + NS_IMETHOD Do_float(float p1, float *p2, float *p3, float *_retval) = 0; + + /* double do_double (in double p1, inout double p2, out double p3); */ + NS_IMETHOD Do_double(double p1, double *p2, double *p3, double *_retval) = 0; + + /* char do_char (in char p1, inout char p2, out char p3); */ + NS_IMETHOD Do_char(char p1, char *p2, char *p3, char *_retval) = 0; + + /* wchar do_wchar (in wchar p1, inout wchar p2, out wchar p3); */ + NS_IMETHOD Do_wchar(PRUnichar p1, PRUnichar *p2, PRUnichar *p3, PRUnichar *_retval) = 0; + + /* string do_string (in string p1, inout string p2, out string p3); */ + NS_IMETHOD Do_string(const char *p1, char **p2, char **p3, char **_retval) = 0; + + /* wstring do_wstring (in wstring p1, inout wstring p2, out wstring p3); */ + NS_IMETHOD Do_wstring(const PRUnichar *p1, PRUnichar **p2, PRUnichar **p3, PRUnichar **_retval) = 0; + + /* nsIIDRef do_nsIIDRef (in nsIIDRef p1, inout nsIIDRef p2, out nsIIDRef p3); */ + NS_IMETHOD Do_nsIIDRef(const nsIID & p1, nsIID & *p2, nsIID & *p3, nsIID & *_retval) = 0; + + /* nsIPythonTestInterface do_nsIPythonTestInterface (in nsIPythonTestInterface p1, inout nsIPythonTestInterface p2, out nsIPythonTestInterface p3); */ + NS_IMETHOD Do_nsIPythonTestInterface(nsIPythonTestInterface *p1, nsIPythonTestInterface **p2, nsIPythonTestInterface **p3, nsIPythonTestInterface **_retval) = 0; + + /* nsISupports do_nsISupports (in nsISupports p1, inout nsISupports p2, out nsISupports p3); */ + NS_IMETHOD Do_nsISupports(nsISupports *p1, nsISupports **p2, nsISupports **p3, nsISupports **_retval) = 0; + + /* void do_nsISupportsIs (in nsIIDRef iid, [iid_is (iid), retval] out nsQIResult result); */ + NS_IMETHOD Do_nsISupportsIs(const nsIID & iid, void * *result) = 0; + +}; + +/* Use this macro when declaring classes that implement this interface. */ +#define NS_DECL_NSIPYTHONTESTINTERFACE \ + NS_IMETHOD GetBoolean_value(PRBool *aBoolean_value); \ + NS_IMETHOD SetBoolean_value(PRBool aBoolean_value); \ + NS_IMETHOD GetOctet_value(PRUint8 *aOctet_value); \ + NS_IMETHOD SetOctet_value(PRUint8 aOctet_value); \ + NS_IMETHOD GetShort_value(PRInt16 *aShort_value); \ + NS_IMETHOD SetShort_value(PRInt16 aShort_value); \ + NS_IMETHOD GetUshort_value(PRUint16 *aUshort_value); \ + NS_IMETHOD SetUshort_value(PRUint16 aUshort_value); \ + NS_IMETHOD GetLong_value(PRInt32 *aLong_value); \ + NS_IMETHOD SetLong_value(PRInt32 aLong_value); \ + NS_IMETHOD GetUlong_value(PRUint32 *aUlong_value); \ + NS_IMETHOD SetUlong_value(PRUint32 aUlong_value); \ + NS_IMETHOD GetLong_long_value(PRInt64 *aLong_long_value); \ + NS_IMETHOD SetLong_long_value(PRInt64 aLong_long_value); \ + NS_IMETHOD GetUlong_long_value(PRUint64 *aUlong_long_value); \ + NS_IMETHOD SetUlong_long_value(PRUint64 aUlong_long_value); \ + NS_IMETHOD GetFloat_value(float *aFloat_value); \ + NS_IMETHOD SetFloat_value(float aFloat_value); \ + NS_IMETHOD GetDouble_value(double *aDouble_value); \ + NS_IMETHOD SetDouble_value(double aDouble_value); \ + NS_IMETHOD GetChar_value(char *aChar_value); \ + NS_IMETHOD SetChar_value(char aChar_value); \ + NS_IMETHOD GetWchar_value(PRUnichar *aWchar_value); \ + NS_IMETHOD SetWchar_value(PRUnichar aWchar_value); \ + NS_IMETHOD GetString_value(char * *aString_value); \ + NS_IMETHOD SetString_value(const char * aString_value); \ + NS_IMETHOD GetWstring_value(PRUnichar * *aWstring_value); \ + NS_IMETHOD SetWstring_value(const PRUnichar * aWstring_value); \ + NS_IMETHOD GetAstring_value(nsAString & aAstring_value); \ + NS_IMETHOD SetAstring_value(const nsAString & aAstring_value); \ + NS_IMETHOD GetAcstring_value(nsACString & aAcstring_value); \ + NS_IMETHOD SetAcstring_value(const nsACString & aAcstring_value); \ + NS_IMETHOD GetUtf8string_value(nsACString & aUtf8string_value); \ + NS_IMETHOD SetUtf8string_value(const nsACString & aUtf8string_value); \ + NS_IMETHOD GetIid_value(nsIID & *aIid_value); \ + NS_IMETHOD SetIid_value(const nsIID & aIid_value); \ + NS_IMETHOD GetInterface_value(nsIPythonTestInterface * *aInterface_value); \ + NS_IMETHOD SetInterface_value(nsIPythonTestInterface * aInterface_value); \ + NS_IMETHOD GetIsupports_value(nsISupports * *aIsupports_value); \ + NS_IMETHOD SetIsupports_value(nsISupports * aIsupports_value); \ + NS_IMETHOD Do_boolean(PRBool p1, PRBool *p2, PRBool *p3, PRBool *_retval); \ + NS_IMETHOD Do_octet(PRUint8 p1, PRUint8 *p2, PRUint8 *p3, PRUint8 *_retval); \ + NS_IMETHOD Do_short(PRInt16 p1, PRInt16 *p2, PRInt16 *p3, PRInt16 *_retval); \ + NS_IMETHOD Do_unsigned_short(PRUint16 p1, PRUint16 *p2, PRUint16 *p3, PRUint16 *_retval); \ + NS_IMETHOD Do_long(PRInt32 p1, PRInt32 *p2, PRInt32 *p3, PRInt32 *_retval); \ + NS_IMETHOD Do_unsigned_long(PRUint32 p1, PRUint32 *p2, PRUint32 *p3, PRUint32 *_retval); \ + NS_IMETHOD Do_long_long(PRInt64 p1, PRInt64 *p2, PRInt64 *p3, PRInt64 *_retval); \ + NS_IMETHOD Do_unsigned_long_long(PRUint64 p1, PRUint64 *p2, PRUint64 *p3, PRUint64 *_retval); \ + NS_IMETHOD Do_float(float p1, float *p2, float *p3, float *_retval); \ + NS_IMETHOD Do_double(double p1, double *p2, double *p3, double *_retval); \ + NS_IMETHOD Do_char(char p1, char *p2, char *p3, char *_retval); \ + NS_IMETHOD Do_wchar(PRUnichar p1, PRUnichar *p2, PRUnichar *p3, PRUnichar *_retval); \ + NS_IMETHOD Do_string(const char *p1, char **p2, char **p3, char **_retval); \ + NS_IMETHOD Do_wstring(const PRUnichar *p1, PRUnichar **p2, PRUnichar **p3, PRUnichar **_retval); \ + NS_IMETHOD Do_nsIIDRef(const nsIID & p1, nsIID & *p2, nsIID & *p3, nsIID & *_retval); \ + NS_IMETHOD Do_nsIPythonTestInterface(nsIPythonTestInterface *p1, nsIPythonTestInterface **p2, nsIPythonTestInterface **p3, nsIPythonTestInterface **_retval); \ + NS_IMETHOD Do_nsISupports(nsISupports *p1, nsISupports **p2, nsISupports **p3, nsISupports **_retval); \ + NS_IMETHOD Do_nsISupportsIs(const nsIID & iid, void * *result); + +/* Use this macro to declare functions that forward the behavior of this interface to another object. */ +#define NS_FORWARD_NSIPYTHONTESTINTERFACE(_to) \ + NS_IMETHOD GetBoolean_value(PRBool *aBoolean_value) { return _to GetBoolean_value(aBoolean_value); } \ + NS_IMETHOD SetBoolean_value(PRBool aBoolean_value) { return _to SetBoolean_value(aBoolean_value); } \ + NS_IMETHOD GetOctet_value(PRUint8 *aOctet_value) { return _to GetOctet_value(aOctet_value); } \ + NS_IMETHOD SetOctet_value(PRUint8 aOctet_value) { return _to SetOctet_value(aOctet_value); } \ + NS_IMETHOD GetShort_value(PRInt16 *aShort_value) { return _to GetShort_value(aShort_value); } \ + NS_IMETHOD SetShort_value(PRInt16 aShort_value) { return _to SetShort_value(aShort_value); } \ + NS_IMETHOD GetUshort_value(PRUint16 *aUshort_value) { return _to GetUshort_value(aUshort_value); } \ + NS_IMETHOD SetUshort_value(PRUint16 aUshort_value) { return _to SetUshort_value(aUshort_value); } \ + NS_IMETHOD GetLong_value(PRInt32 *aLong_value) { return _to GetLong_value(aLong_value); } \ + NS_IMETHOD SetLong_value(PRInt32 aLong_value) { return _to SetLong_value(aLong_value); } \ + NS_IMETHOD GetUlong_value(PRUint32 *aUlong_value) { return _to GetUlong_value(aUlong_value); } \ + NS_IMETHOD SetUlong_value(PRUint32 aUlong_value) { return _to SetUlong_value(aUlong_value); } \ + NS_IMETHOD GetLong_long_value(PRInt64 *aLong_long_value) { return _to GetLong_long_value(aLong_long_value); } \ + NS_IMETHOD SetLong_long_value(PRInt64 aLong_long_value) { return _to SetLong_long_value(aLong_long_value); } \ + NS_IMETHOD GetUlong_long_value(PRUint64 *aUlong_long_value) { return _to GetUlong_long_value(aUlong_long_value); } \ + NS_IMETHOD SetUlong_long_value(PRUint64 aUlong_long_value) { return _to SetUlong_long_value(aUlong_long_value); } \ + NS_IMETHOD GetFloat_value(float *aFloat_value) { return _to GetFloat_value(aFloat_value); } \ + NS_IMETHOD SetFloat_value(float aFloat_value) { return _to SetFloat_value(aFloat_value); } \ + NS_IMETHOD GetDouble_value(double *aDouble_value) { return _to GetDouble_value(aDouble_value); } \ + NS_IMETHOD SetDouble_value(double aDouble_value) { return _to SetDouble_value(aDouble_value); } \ + NS_IMETHOD GetChar_value(char *aChar_value) { return _to GetChar_value(aChar_value); } \ + NS_IMETHOD SetChar_value(char aChar_value) { return _to SetChar_value(aChar_value); } \ + NS_IMETHOD GetWchar_value(PRUnichar *aWchar_value) { return _to GetWchar_value(aWchar_value); } \ + NS_IMETHOD SetWchar_value(PRUnichar aWchar_value) { return _to SetWchar_value(aWchar_value); } \ + NS_IMETHOD GetString_value(char * *aString_value) { return _to GetString_value(aString_value); } \ + NS_IMETHOD SetString_value(const char * aString_value) { return _to SetString_value(aString_value); } \ + NS_IMETHOD GetWstring_value(PRUnichar * *aWstring_value) { return _to GetWstring_value(aWstring_value); } \ + NS_IMETHOD SetWstring_value(const PRUnichar * aWstring_value) { return _to SetWstring_value(aWstring_value); } \ + NS_IMETHOD GetAstring_value(nsAString & aAstring_value) { return _to GetAstring_value(aAstring_value); } \ + NS_IMETHOD SetAstring_value(const nsAString & aAstring_value) { return _to SetAstring_value(aAstring_value); } \ + NS_IMETHOD GetAcstring_value(nsACString & aAcstring_value) { return _to GetAcstring_value(aAcstring_value); } \ + NS_IMETHOD SetAcstring_value(const nsACString & aAcstring_value) { return _to SetAcstring_value(aAcstring_value); } \ + NS_IMETHOD GetUtf8string_value(nsACString & aUtf8string_value) { return _to GetUtf8string_value(aUtf8string_value); } \ + NS_IMETHOD SetUtf8string_value(const nsACString & aUtf8string_value) { return _to SetUtf8string_value(aUtf8string_value); } \ + NS_IMETHOD GetIid_value(nsIID & *aIid_value) { return _to GetIid_value(aIid_value); } \ + NS_IMETHOD SetIid_value(const nsIID & aIid_value) { return _to SetIid_value(aIid_value); } \ + NS_IMETHOD GetInterface_value(nsIPythonTestInterface * *aInterface_value) { return _to GetInterface_value(aInterface_value); } \ + NS_IMETHOD SetInterface_value(nsIPythonTestInterface * aInterface_value) { return _to SetInterface_value(aInterface_value); } \ + NS_IMETHOD GetIsupports_value(nsISupports * *aIsupports_value) { return _to GetIsupports_value(aIsupports_value); } \ + NS_IMETHOD SetIsupports_value(nsISupports * aIsupports_value) { return _to SetIsupports_value(aIsupports_value); } \ + NS_IMETHOD Do_boolean(PRBool p1, PRBool *p2, PRBool *p3, PRBool *_retval) { return _to Do_boolean(p1, p2, p3, _retval); } \ + NS_IMETHOD Do_octet(PRUint8 p1, PRUint8 *p2, PRUint8 *p3, PRUint8 *_retval) { return _to Do_octet(p1, p2, p3, _retval); } \ + NS_IMETHOD Do_short(PRInt16 p1, PRInt16 *p2, PRInt16 *p3, PRInt16 *_retval) { return _to Do_short(p1, p2, p3, _retval); } \ + NS_IMETHOD Do_unsigned_short(PRUint16 p1, PRUint16 *p2, PRUint16 *p3, PRUint16 *_retval) { return _to Do_unsigned_short(p1, p2, p3, _retval); } \ + NS_IMETHOD Do_long(PRInt32 p1, PRInt32 *p2, PRInt32 *p3, PRInt32 *_retval) { return _to Do_long(p1, p2, p3, _retval); } \ + NS_IMETHOD Do_unsigned_long(PRUint32 p1, PRUint32 *p2, PRUint32 *p3, PRUint32 *_retval) { return _to Do_unsigned_long(p1, p2, p3, _retval); } \ + NS_IMETHOD Do_long_long(PRInt64 p1, PRInt64 *p2, PRInt64 *p3, PRInt64 *_retval) { return _to Do_long_long(p1, p2, p3, _retval); } \ + NS_IMETHOD Do_unsigned_long_long(PRUint64 p1, PRUint64 *p2, PRUint64 *p3, PRUint64 *_retval) { return _to Do_unsigned_long_long(p1, p2, p3, _retval); } \ + NS_IMETHOD Do_float(float p1, float *p2, float *p3, float *_retval) { return _to Do_float(p1, p2, p3, _retval); } \ + NS_IMETHOD Do_double(double p1, double *p2, double *p3, double *_retval) { return _to Do_double(p1, p2, p3, _retval); } \ + NS_IMETHOD Do_char(char p1, char *p2, char *p3, char *_retval) { return _to Do_char(p1, p2, p3, _retval); } \ + NS_IMETHOD Do_wchar(PRUnichar p1, PRUnichar *p2, PRUnichar *p3, PRUnichar *_retval) { return _to Do_wchar(p1, p2, p3, _retval); } \ + NS_IMETHOD Do_string(const char *p1, char **p2, char **p3, char **_retval) { return _to Do_string(p1, p2, p3, _retval); } \ + NS_IMETHOD Do_wstring(const PRUnichar *p1, PRUnichar **p2, PRUnichar **p3, PRUnichar **_retval) { return _to Do_wstring(p1, p2, p3, _retval); } \ + NS_IMETHOD Do_nsIIDRef(const nsIID & p1, nsIID & *p2, nsIID & *p3, nsIID & *_retval) { return _to Do_nsIIDRef(p1, p2, p3, _retval); } \ + NS_IMETHOD Do_nsIPythonTestInterface(nsIPythonTestInterface *p1, nsIPythonTestInterface **p2, nsIPythonTestInterface **p3, nsIPythonTestInterface **_retval) { return _to Do_nsIPythonTestInterface(p1, p2, p3, _retval); } \ + NS_IMETHOD Do_nsISupports(nsISupports *p1, nsISupports **p2, nsISupports **p3, nsISupports **_retval) { return _to Do_nsISupports(p1, p2, p3, _retval); } \ + NS_IMETHOD Do_nsISupportsIs(const nsIID & iid, void * *result) { return _to Do_nsISupportsIs(iid, result); } + +/* Use this macro to declare functions that forward the behavior of this interface to another object in a safe way. */ +#define NS_FORWARD_SAFE_NSIPYTHONTESTINTERFACE(_to) \ + NS_IMETHOD GetBoolean_value(PRBool *aBoolean_value) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetBoolean_value(aBoolean_value); } \ + NS_IMETHOD SetBoolean_value(PRBool aBoolean_value) { return !_to ? NS_ERROR_NULL_POINTER : _to->SetBoolean_value(aBoolean_value); } \ + NS_IMETHOD GetOctet_value(PRUint8 *aOctet_value) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetOctet_value(aOctet_value); } \ + NS_IMETHOD SetOctet_value(PRUint8 aOctet_value) { return !_to ? NS_ERROR_NULL_POINTER : _to->SetOctet_value(aOctet_value); } \ + NS_IMETHOD GetShort_value(PRInt16 *aShort_value) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetShort_value(aShort_value); } \ + NS_IMETHOD SetShort_value(PRInt16 aShort_value) { return !_to ? NS_ERROR_NULL_POINTER : _to->SetShort_value(aShort_value); } \ + NS_IMETHOD GetUshort_value(PRUint16 *aUshort_value) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetUshort_value(aUshort_value); } \ + NS_IMETHOD SetUshort_value(PRUint16 aUshort_value) { return !_to ? NS_ERROR_NULL_POINTER : _to->SetUshort_value(aUshort_value); } \ + NS_IMETHOD GetLong_value(PRInt32 *aLong_value) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetLong_value(aLong_value); } \ + NS_IMETHOD SetLong_value(PRInt32 aLong_value) { return !_to ? NS_ERROR_NULL_POINTER : _to->SetLong_value(aLong_value); } \ + NS_IMETHOD GetUlong_value(PRUint32 *aUlong_value) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetUlong_value(aUlong_value); } \ + NS_IMETHOD SetUlong_value(PRUint32 aUlong_value) { return !_to ? NS_ERROR_NULL_POINTER : _to->SetUlong_value(aUlong_value); } \ + NS_IMETHOD GetLong_long_value(PRInt64 *aLong_long_value) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetLong_long_value(aLong_long_value); } \ + NS_IMETHOD SetLong_long_value(PRInt64 aLong_long_value) { return !_to ? NS_ERROR_NULL_POINTER : _to->SetLong_long_value(aLong_long_value); } \ + NS_IMETHOD GetUlong_long_value(PRUint64 *aUlong_long_value) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetUlong_long_value(aUlong_long_value); } \ + NS_IMETHOD SetUlong_long_value(PRUint64 aUlong_long_value) { return !_to ? NS_ERROR_NULL_POINTER : _to->SetUlong_long_value(aUlong_long_value); } \ + NS_IMETHOD GetFloat_value(float *aFloat_value) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetFloat_value(aFloat_value); } \ + NS_IMETHOD SetFloat_value(float aFloat_value) { return !_to ? NS_ERROR_NULL_POINTER : _to->SetFloat_value(aFloat_value); } \ + NS_IMETHOD GetDouble_value(double *aDouble_value) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetDouble_value(aDouble_value); } \ + NS_IMETHOD SetDouble_value(double aDouble_value) { return !_to ? NS_ERROR_NULL_POINTER : _to->SetDouble_value(aDouble_value); } \ + NS_IMETHOD GetChar_value(char *aChar_value) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetChar_value(aChar_value); } \ + NS_IMETHOD SetChar_value(char aChar_value) { return !_to ? NS_ERROR_NULL_POINTER : _to->SetChar_value(aChar_value); } \ + NS_IMETHOD GetWchar_value(PRUnichar *aWchar_value) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetWchar_value(aWchar_value); } \ + NS_IMETHOD SetWchar_value(PRUnichar aWchar_value) { return !_to ? NS_ERROR_NULL_POINTER : _to->SetWchar_value(aWchar_value); } \ + NS_IMETHOD GetString_value(char * *aString_value) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetString_value(aString_value); } \ + NS_IMETHOD SetString_value(const char * aString_value) { return !_to ? NS_ERROR_NULL_POINTER : _to->SetString_value(aString_value); } \ + NS_IMETHOD GetWstring_value(PRUnichar * *aWstring_value) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetWstring_value(aWstring_value); } \ + NS_IMETHOD SetWstring_value(const PRUnichar * aWstring_value) { return !_to ? NS_ERROR_NULL_POINTER : _to->SetWstring_value(aWstring_value); } \ + NS_IMETHOD GetAstring_value(nsAString & aAstring_value) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetAstring_value(aAstring_value); } \ + NS_IMETHOD SetAstring_value(const nsAString & aAstring_value) { return !_to ? NS_ERROR_NULL_POINTER : _to->SetAstring_value(aAstring_value); } \ + NS_IMETHOD GetAcstring_value(nsACString & aAcstring_value) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetAcstring_value(aAcstring_value); } \ + NS_IMETHOD SetAcstring_value(const nsACString & aAcstring_value) { return !_to ? NS_ERROR_NULL_POINTER : _to->SetAcstring_value(aAcstring_value); } \ + NS_IMETHOD GetUtf8string_value(nsACString & aUtf8string_value) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetUtf8string_value(aUtf8string_value); } \ + NS_IMETHOD SetUtf8string_value(const nsACString & aUtf8string_value) { return !_to ? NS_ERROR_NULL_POINTER : _to->SetUtf8string_value(aUtf8string_value); } \ + NS_IMETHOD GetIid_value(nsIID & *aIid_value) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetIid_value(aIid_value); } \ + NS_IMETHOD SetIid_value(const nsIID & aIid_value) { return !_to ? NS_ERROR_NULL_POINTER : _to->SetIid_value(aIid_value); } \ + NS_IMETHOD GetInterface_value(nsIPythonTestInterface * *aInterface_value) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetInterface_value(aInterface_value); } \ + NS_IMETHOD SetInterface_value(nsIPythonTestInterface * aInterface_value) { return !_to ? NS_ERROR_NULL_POINTER : _to->SetInterface_value(aInterface_value); } \ + NS_IMETHOD GetIsupports_value(nsISupports * *aIsupports_value) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetIsupports_value(aIsupports_value); } \ + NS_IMETHOD SetIsupports_value(nsISupports * aIsupports_value) { return !_to ? NS_ERROR_NULL_POINTER : _to->SetIsupports_value(aIsupports_value); } \ + NS_IMETHOD Do_boolean(PRBool p1, PRBool *p2, PRBool *p3, PRBool *_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->Do_boolean(p1, p2, p3, _retval); } \ + NS_IMETHOD Do_octet(PRUint8 p1, PRUint8 *p2, PRUint8 *p3, PRUint8 *_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->Do_octet(p1, p2, p3, _retval); } \ + NS_IMETHOD Do_short(PRInt16 p1, PRInt16 *p2, PRInt16 *p3, PRInt16 *_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->Do_short(p1, p2, p3, _retval); } \ + NS_IMETHOD Do_unsigned_short(PRUint16 p1, PRUint16 *p2, PRUint16 *p3, PRUint16 *_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->Do_unsigned_short(p1, p2, p3, _retval); } \ + NS_IMETHOD Do_long(PRInt32 p1, PRInt32 *p2, PRInt32 *p3, PRInt32 *_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->Do_long(p1, p2, p3, _retval); } \ + NS_IMETHOD Do_unsigned_long(PRUint32 p1, PRUint32 *p2, PRUint32 *p3, PRUint32 *_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->Do_unsigned_long(p1, p2, p3, _retval); } \ + NS_IMETHOD Do_long_long(PRInt64 p1, PRInt64 *p2, PRInt64 *p3, PRInt64 *_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->Do_long_long(p1, p2, p3, _retval); } \ + NS_IMETHOD Do_unsigned_long_long(PRUint64 p1, PRUint64 *p2, PRUint64 *p3, PRUint64 *_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->Do_unsigned_long_long(p1, p2, p3, _retval); } \ + NS_IMETHOD Do_float(float p1, float *p2, float *p3, float *_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->Do_float(p1, p2, p3, _retval); } \ + NS_IMETHOD Do_double(double p1, double *p2, double *p3, double *_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->Do_double(p1, p2, p3, _retval); } \ + NS_IMETHOD Do_char(char p1, char *p2, char *p3, char *_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->Do_char(p1, p2, p3, _retval); } \ + NS_IMETHOD Do_wchar(PRUnichar p1, PRUnichar *p2, PRUnichar *p3, PRUnichar *_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->Do_wchar(p1, p2, p3, _retval); } \ + NS_IMETHOD Do_string(const char *p1, char **p2, char **p3, char **_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->Do_string(p1, p2, p3, _retval); } \ + NS_IMETHOD Do_wstring(const PRUnichar *p1, PRUnichar **p2, PRUnichar **p3, PRUnichar **_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->Do_wstring(p1, p2, p3, _retval); } \ + NS_IMETHOD Do_nsIIDRef(const nsIID & p1, nsIID & *p2, nsIID & *p3, nsIID & *_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->Do_nsIIDRef(p1, p2, p3, _retval); } \ + NS_IMETHOD Do_nsIPythonTestInterface(nsIPythonTestInterface *p1, nsIPythonTestInterface **p2, nsIPythonTestInterface **p3, nsIPythonTestInterface **_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->Do_nsIPythonTestInterface(p1, p2, p3, _retval); } \ + NS_IMETHOD Do_nsISupports(nsISupports *p1, nsISupports **p2, nsISupports **p3, nsISupports **_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->Do_nsISupports(p1, p2, p3, _retval); } \ + NS_IMETHOD Do_nsISupportsIs(const nsIID & iid, void * *result) { return !_to ? NS_ERROR_NULL_POINTER : _to->Do_nsISupportsIs(iid, result); } + +#if 0 +/* Use the code below as a template for the implementation class for this interface. */ + +/* Header file */ +class nsPythonTestInterface : public nsIPythonTestInterface +{ +public: + NS_DECL_ISUPPORTS + NS_DECL_NSIPYTHONTESTINTERFACE + + nsPythonTestInterface(); + +private: + ~nsPythonTestInterface(); + +protected: + /* additional members */ +}; + +/* Implementation file */ +NS_IMPL_ISUPPORTS1(nsPythonTestInterface, nsIPythonTestInterface) + +nsPythonTestInterface::nsPythonTestInterface() +{ + /* member initializers and constructor code */ +} + +nsPythonTestInterface::~nsPythonTestInterface() +{ + /* destructor code */ +} + +/* attribute boolean boolean_value; */ +NS_IMETHODIMP nsPythonTestInterface::GetBoolean_value(PRBool *aBoolean_value) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} +NS_IMETHODIMP nsPythonTestInterface::SetBoolean_value(PRBool aBoolean_value) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* attribute octet octet_value; */ +NS_IMETHODIMP nsPythonTestInterface::GetOctet_value(PRUint8 *aOctet_value) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} +NS_IMETHODIMP nsPythonTestInterface::SetOctet_value(PRUint8 aOctet_value) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* attribute short short_value; */ +NS_IMETHODIMP nsPythonTestInterface::GetShort_value(PRInt16 *aShort_value) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} +NS_IMETHODIMP nsPythonTestInterface::SetShort_value(PRInt16 aShort_value) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* attribute unsigned short ushort_value; */ +NS_IMETHODIMP nsPythonTestInterface::GetUshort_value(PRUint16 *aUshort_value) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} +NS_IMETHODIMP nsPythonTestInterface::SetUshort_value(PRUint16 aUshort_value) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* attribute long long_value; */ +NS_IMETHODIMP nsPythonTestInterface::GetLong_value(PRInt32 *aLong_value) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} +NS_IMETHODIMP nsPythonTestInterface::SetLong_value(PRInt32 aLong_value) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* attribute unsigned long ulong_value; */ +NS_IMETHODIMP nsPythonTestInterface::GetUlong_value(PRUint32 *aUlong_value) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} +NS_IMETHODIMP nsPythonTestInterface::SetUlong_value(PRUint32 aUlong_value) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* attribute long long long_long_value; */ +NS_IMETHODIMP nsPythonTestInterface::GetLong_long_value(PRInt64 *aLong_long_value) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} +NS_IMETHODIMP nsPythonTestInterface::SetLong_long_value(PRInt64 aLong_long_value) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* attribute unsigned long long ulong_long_value; */ +NS_IMETHODIMP nsPythonTestInterface::GetUlong_long_value(PRUint64 *aUlong_long_value) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} +NS_IMETHODIMP nsPythonTestInterface::SetUlong_long_value(PRUint64 aUlong_long_value) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* attribute float float_value; */ +NS_IMETHODIMP nsPythonTestInterface::GetFloat_value(float *aFloat_value) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} +NS_IMETHODIMP nsPythonTestInterface::SetFloat_value(float aFloat_value) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* attribute double double_value; */ +NS_IMETHODIMP nsPythonTestInterface::GetDouble_value(double *aDouble_value) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} +NS_IMETHODIMP nsPythonTestInterface::SetDouble_value(double aDouble_value) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* attribute char char_value; */ +NS_IMETHODIMP nsPythonTestInterface::GetChar_value(char *aChar_value) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} +NS_IMETHODIMP nsPythonTestInterface::SetChar_value(char aChar_value) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* attribute wchar wchar_value; */ +NS_IMETHODIMP nsPythonTestInterface::GetWchar_value(PRUnichar *aWchar_value) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} +NS_IMETHODIMP nsPythonTestInterface::SetWchar_value(PRUnichar aWchar_value) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* attribute string string_value; */ +NS_IMETHODIMP nsPythonTestInterface::GetString_value(char * *aString_value) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} +NS_IMETHODIMP nsPythonTestInterface::SetString_value(const char * aString_value) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* attribute wstring wstring_value; */ +NS_IMETHODIMP nsPythonTestInterface::GetWstring_value(PRUnichar * *aWstring_value) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} +NS_IMETHODIMP nsPythonTestInterface::SetWstring_value(const PRUnichar * aWstring_value) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* attribute AString astring_value; */ +NS_IMETHODIMP nsPythonTestInterface::GetAstring_value(nsAString & aAstring_value) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} +NS_IMETHODIMP nsPythonTestInterface::SetAstring_value(const nsAString & aAstring_value) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* attribute ACString acstring_value; */ +NS_IMETHODIMP nsPythonTestInterface::GetAcstring_value(nsACString & aAcstring_value) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} +NS_IMETHODIMP nsPythonTestInterface::SetAcstring_value(const nsACString & aAcstring_value) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* attribute AUTF8String utf8string_value; */ +NS_IMETHODIMP nsPythonTestInterface::GetUtf8string_value(nsACString & aUtf8string_value) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} +NS_IMETHODIMP nsPythonTestInterface::SetUtf8string_value(const nsACString & aUtf8string_value) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* attribute nsIIDRef iid_value; */ +NS_IMETHODIMP nsPythonTestInterface::GetIid_value(nsIID & *aIid_value) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} +NS_IMETHODIMP nsPythonTestInterface::SetIid_value(const nsIID & aIid_value) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* attribute nsIPythonTestInterface interface_value; */ +NS_IMETHODIMP nsPythonTestInterface::GetInterface_value(nsIPythonTestInterface * *aInterface_value) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} +NS_IMETHODIMP nsPythonTestInterface::SetInterface_value(nsIPythonTestInterface * aInterface_value) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* attribute nsISupports isupports_value; */ +NS_IMETHODIMP nsPythonTestInterface::GetIsupports_value(nsISupports * *aIsupports_value) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} +NS_IMETHODIMP nsPythonTestInterface::SetIsupports_value(nsISupports * aIsupports_value) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* boolean do_boolean (in boolean p1, inout boolean p2, out boolean p3); */ +NS_IMETHODIMP nsPythonTestInterface::Do_boolean(PRBool p1, PRBool *p2, PRBool *p3, PRBool *_retval) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* octet do_octet (in octet p1, inout octet p2, out octet p3); */ +NS_IMETHODIMP nsPythonTestInterface::Do_octet(PRUint8 p1, PRUint8 *p2, PRUint8 *p3, PRUint8 *_retval) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* short do_short (in short p1, inout short p2, out short p3); */ +NS_IMETHODIMP nsPythonTestInterface::Do_short(PRInt16 p1, PRInt16 *p2, PRInt16 *p3, PRInt16 *_retval) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* unsigned short do_unsigned_short (in unsigned short p1, inout unsigned short p2, out unsigned short p3); */ +NS_IMETHODIMP nsPythonTestInterface::Do_unsigned_short(PRUint16 p1, PRUint16 *p2, PRUint16 *p3, PRUint16 *_retval) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* long do_long (in long p1, inout long p2, out long p3); */ +NS_IMETHODIMP nsPythonTestInterface::Do_long(PRInt32 p1, PRInt32 *p2, PRInt32 *p3, PRInt32 *_retval) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* unsigned long do_unsigned_long (in unsigned long p1, inout unsigned long p2, out unsigned long p3); */ +NS_IMETHODIMP nsPythonTestInterface::Do_unsigned_long(PRUint32 p1, PRUint32 *p2, PRUint32 *p3, PRUint32 *_retval) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* long long do_long_long (in long long p1, inout long long p2, out long long p3); */ +NS_IMETHODIMP nsPythonTestInterface::Do_long_long(PRInt64 p1, PRInt64 *p2, PRInt64 *p3, PRInt64 *_retval) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* unsigned long long do_unsigned_long_long (in unsigned long long p1, inout unsigned long long p2, out unsigned long long p3); */ +NS_IMETHODIMP nsPythonTestInterface::Do_unsigned_long_long(PRUint64 p1, PRUint64 *p2, PRUint64 *p3, PRUint64 *_retval) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* float do_float (in float p1, inout float p2, out float p3); */ +NS_IMETHODIMP nsPythonTestInterface::Do_float(float p1, float *p2, float *p3, float *_retval) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* double do_double (in double p1, inout double p2, out double p3); */ +NS_IMETHODIMP nsPythonTestInterface::Do_double(double p1, double *p2, double *p3, double *_retval) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* char do_char (in char p1, inout char p2, out char p3); */ +NS_IMETHODIMP nsPythonTestInterface::Do_char(char p1, char *p2, char *p3, char *_retval) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* wchar do_wchar (in wchar p1, inout wchar p2, out wchar p3); */ +NS_IMETHODIMP nsPythonTestInterface::Do_wchar(PRUnichar p1, PRUnichar *p2, PRUnichar *p3, PRUnichar *_retval) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* string do_string (in string p1, inout string p2, out string p3); */ +NS_IMETHODIMP nsPythonTestInterface::Do_string(const char *p1, char **p2, char **p3, char **_retval) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* wstring do_wstring (in wstring p1, inout wstring p2, out wstring p3); */ +NS_IMETHODIMP nsPythonTestInterface::Do_wstring(const PRUnichar *p1, PRUnichar **p2, PRUnichar **p3, PRUnichar **_retval) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* nsIIDRef do_nsIIDRef (in nsIIDRef p1, inout nsIIDRef p2, out nsIIDRef p3); */ +NS_IMETHODIMP nsPythonTestInterface::Do_nsIIDRef(const nsIID & p1, nsIID & *p2, nsIID & *p3, nsIID & *_retval) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* nsIPythonTestInterface do_nsIPythonTestInterface (in nsIPythonTestInterface p1, inout nsIPythonTestInterface p2, out nsIPythonTestInterface p3); */ +NS_IMETHODIMP nsPythonTestInterface::Do_nsIPythonTestInterface(nsIPythonTestInterface *p1, nsIPythonTestInterface **p2, nsIPythonTestInterface **p3, nsIPythonTestInterface **_retval) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* nsISupports do_nsISupports (in nsISupports p1, inout nsISupports p2, out nsISupports p3); */ +NS_IMETHODIMP nsPythonTestInterface::Do_nsISupports(nsISupports *p1, nsISupports **p2, nsISupports **p3, nsISupports **_retval) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* void do_nsISupportsIs (in nsIIDRef iid, [iid_is (iid), retval] out nsQIResult result); */ +NS_IMETHODIMP nsPythonTestInterface::Do_nsISupportsIs(const nsIID & iid, void * *result) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* End of implementation class template. */ +#endif + + +/* starting interface: nsIPythonTestInterfaceExtra */ +#define NS_IPYTHONTESTINTERFACEEXTRA_IID_STR "b38d1538-fe92-42c3-831f-285242edeea4" + +#define NS_IPYTHONTESTINTERFACEEXTRA_IID \ + {0xb38d1538, 0xfe92, 0x42c3, \ + { 0x83, 0x1f, 0x28, 0x52, 0x42, 0xed, 0xee, 0xa4 }} + +class NS_NO_VTABLE nsIPythonTestInterfaceExtra : public nsIPythonTestInterface { + public: + + NS_DEFINE_STATIC_IID_ACCESSOR(NS_IPYTHONTESTINTERFACEEXTRA_IID) + + /* void MultiplyEachItemInIntegerArray (in PRInt32 val, in PRUint32 count, [array, size_is (count)] inout PRInt32 valueArray); */ + NS_IMETHOD MultiplyEachItemInIntegerArray(PRInt32 val, PRUint32 count, PRInt32 **valueArray) = 0; + + /* void MultiplyEachItemInIntegerArrayAndAppend (in PRInt32 val, inout PRUint32 count, [array, size_is (count)] inout PRInt32 valueArray); */ + NS_IMETHOD MultiplyEachItemInIntegerArrayAndAppend(PRInt32 val, PRUint32 *count, PRInt32 **valueArray) = 0; + + /* void CompareStringArrays ([array, size_is (count)] in string arr1, [array, size_is (count)] in string arr2, in unsigned long count, [retval] out short result); */ + NS_IMETHOD CompareStringArrays(const char **arr1, const char **arr2, PRUint32 count, PRInt16 *result) = 0; + + /* void DoubleStringArray (inout PRUint32 count, [array, size_is (count)] inout string valueArray); */ + NS_IMETHOD DoubleStringArray(PRUint32 *count, char ***valueArray) = 0; + + /* void ReverseStringArray (in PRUint32 count, [array, size_is (count)] inout string valueArray); */ + NS_IMETHOD ReverseStringArray(PRUint32 count, char ***valueArray) = 0; + + /* void DoubleString (inout PRUint32 count, [size_is (count)] inout string str); */ + NS_IMETHOD DoubleString(PRUint32 *count, char **str) = 0; + + /* void DoubleString2 (in PRUint32 in_count, [size_is (in_count)] in string in_str, out PRUint32 out_count, [size_is (out_count)] out string out_str); */ + NS_IMETHOD DoubleString2(PRUint32 in_count, const char *in_str, PRUint32 *out_count, char **out_str) = 0; + + /* void DoubleString3 (in PRUint32 in_count, [size_is (in_count)] in string in_str, out PRUint32 out_count, [size_is (out_count), retval] out string out_str); */ + NS_IMETHOD DoubleString3(PRUint32 in_count, const char *in_str, PRUint32 *out_count, char **out_str) = 0; + + /* void DoubleString4 ([size_is (count)] in string in_str, inout PRUint32 count, [size_is (count)] out string out_str); */ + NS_IMETHOD DoubleString4(const char *in_str, PRUint32 *count, char **out_str) = 0; + + /* void UpString (in PRUint32 count, [size_is (count)] inout string str); */ + NS_IMETHOD UpString(PRUint32 count, char **str) = 0; + + /* void UpString2 (in PRUint32 count, [size_is (count)] in string in_str, [size_is (count)] out string out_str); */ + NS_IMETHOD UpString2(PRUint32 count, const char *in_str, char **out_str) = 0; + + /* void CopyUTF8String (in AUTF8String in_str, out AUTF8String out_str); */ + NS_IMETHOD CopyUTF8String(const nsACString & in_str, nsACString & out_str) = 0; + + /* void CopyUTF8String2 (in AUTF8String in_str, out AUTF8String out_str); */ + NS_IMETHOD CopyUTF8String2(const nsACString & in_str, nsACString & out_str) = 0; + + /* void GetFixedString (in PRUint32 count, [size_is (count)] out string out_str); */ + NS_IMETHOD GetFixedString(PRUint32 count, char **out_str) = 0; + + /* void DoubleWideString (inout PRUint32 count, [size_is (count)] inout wstring str); */ + NS_IMETHOD DoubleWideString(PRUint32 *count, PRUnichar **str) = 0; + + /* void DoubleWideString2 (in PRUint32 in_count, [size_is (in_count)] in wstring in_str, out PRUint32 out_count, [size_is (out_count)] out wstring out_str); */ + NS_IMETHOD DoubleWideString2(PRUint32 in_count, const PRUnichar *in_str, PRUint32 *out_count, PRUnichar **out_str) = 0; + + /* void DoubleWideString3 (in PRUint32 in_count, [size_is (in_count)] in wstring in_str, out PRUint32 out_count, [size_is (out_count), retval] out wstring out_str); */ + NS_IMETHOD DoubleWideString3(PRUint32 in_count, const PRUnichar *in_str, PRUint32 *out_count, PRUnichar **out_str) = 0; + + /* void DoubleWideString4 ([size_is (count)] in wstring in_str, inout PRUint32 count, [size_is (count)] out wstring out_str); */ + NS_IMETHOD DoubleWideString4(const PRUnichar *in_str, PRUint32 *count, PRUnichar **out_str) = 0; + + /* void UpWideString (in PRUint32 count, [size_is (count)] inout wstring str); */ + NS_IMETHOD UpWideString(PRUint32 count, PRUnichar **str) = 0; + + /* void UpWideString2 (in PRUint32 count, [size_is (count)] in wstring in_str, [size_is (count)] out wstring out_str); */ + NS_IMETHOD UpWideString2(PRUint32 count, const PRUnichar *in_str, PRUnichar **out_str) = 0; + + /* void GetFixedWideString (in PRUint32 count, [size_is (count)] out string out_str); */ + NS_IMETHOD GetFixedWideString(PRUint32 count, char **out_str) = 0; + + /* void GetStrings (out PRUint32 count, [array, size_is (count), retval] out string str); */ + NS_IMETHOD GetStrings(PRUint32 *count, char ***str) = 0; + + /* void UpOctetArray (inout PRUint32 count, [array, size_is (count)] inout PRUint8 data); */ + NS_IMETHOD UpOctetArray(PRUint32 *count, PRUint8 **data) = 0; + + /* void UpOctetArray2 (inout PRUint32 count, [array, size_is (count)] inout PRUint8 data); */ + NS_IMETHOD UpOctetArray2(PRUint32 *count, PRUint8 **data) = 0; + + /* void CheckInterfaceArray (in PRUint32 count, [array, size_is (count)] in nsISupports data, [retval] out PRBool all_non_null); */ + NS_IMETHOD CheckInterfaceArray(PRUint32 count, nsISupports **data, PRBool *all_non_null) = 0; + + /* void CopyInterfaceArray (in PRUint32 count, [array, size_is (count)] in nsISupports data, [array, size_is (out_count)] out nsISupports out_data, out PRUint32 out_count); */ + NS_IMETHOD CopyInterfaceArray(PRUint32 count, nsISupports **data, nsISupports ***out_data, PRUint32 *out_count) = 0; + + /* void GetInterfaceArray (out PRUint32 count, [array, size_is (count)] out nsISupports data); */ + NS_IMETHOD GetInterfaceArray(PRUint32 *count, nsISupports ***data) = 0; + + /* void ExtendInterfaceArray (inout PRUint32 count, [array, size_is (count)] inout nsISupports data); */ + NS_IMETHOD ExtendInterfaceArray(PRUint32 *count, nsISupports ***data) = 0; + + /* void CheckIIDArray (in PRUint32 count, [array, size_is (count)] in nsIIDRef data, [retval] out PRBool all_mine); */ + NS_IMETHOD CheckIIDArray(PRUint32 count, const nsIID & *data, PRBool *all_mine) = 0; + + /* void GetIIDArray (out PRUint32 count, [array, size_is (count)] out nsIIDRef data); */ + NS_IMETHOD GetIIDArray(PRUint32 *count, nsIID & **data) = 0; + + /* void ExtendIIDArray (inout PRUint32 count, [array, size_is (count)] inout nsIIDRef data); */ + NS_IMETHOD ExtendIIDArray(PRUint32 *count, nsIID & **data) = 0; + + /* void SumArrays (in PRUint32 count, [array, size_is (count)] in PRInt32 array1, [array, size_is (count)] in PRInt32 array2, [retval] out PRInt32 result); */ + NS_IMETHOD SumArrays(PRUint32 count, PRInt32 *array1, PRInt32 *array2, PRInt32 *result) = 0; + + /* void GetArrays (out PRUint32 count, [array, size_is (count)] out PRInt32 array1, [array, size_is (count)] out PRInt32 array2); */ + NS_IMETHOD GetArrays(PRUint32 *count, PRInt32 **array1, PRInt32 **array2) = 0; + + /* void GetFixedArray (in PRUint32 count, [array, size_is (count)] out PRInt32 array1); */ + NS_IMETHOD GetFixedArray(PRUint32 count, PRInt32 **array1) = 0; + + /* void CopyArray (in PRUint32 count, [array, size_is (count)] in PRInt32 array1, [array, size_is (count)] out PRInt32 array2); */ + NS_IMETHOD CopyArray(PRUint32 count, PRInt32 *array1, PRInt32 **array2) = 0; + + /* void CopyAndDoubleArray (inout PRUint32 count, [array, size_is (count)] in PRInt32 array1, [array, size_is (count)] out PRInt32 array2); */ + NS_IMETHOD CopyAndDoubleArray(PRUint32 *count, PRInt32 *array1, PRInt32 **array2) = 0; + + /* void AppendArray (inout PRUint32 count, [array, size_is (count)] in PRInt32 array1, [array, size_is (count)] inout PRInt32 array2); */ + NS_IMETHOD AppendArray(PRUint32 *count, PRInt32 *array1, PRInt32 **array2) = 0; + + /* void AppendVariant (in nsIVariant variant, inout nsIVariant result); */ + NS_IMETHOD AppendVariant(nsIVariant *variant, nsIVariant **result) = 0; + + /* nsIVariant CopyVariant (in nsIVariant variant); */ + NS_IMETHOD CopyVariant(nsIVariant *variant, nsIVariant **_retval) = 0; + + /* nsIVariant SumVariants (in PRUint32 incount, [array, size_is (incount)] in nsIVariant variants); */ + NS_IMETHOD SumVariants(PRUint32 incount, nsIVariant **variants, nsIVariant **_retval) = 0; + +}; + +/* Use this macro when declaring classes that implement this interface. */ +#define NS_DECL_NSIPYTHONTESTINTERFACEEXTRA \ + NS_IMETHOD MultiplyEachItemInIntegerArray(PRInt32 val, PRUint32 count, PRInt32 **valueArray); \ + NS_IMETHOD MultiplyEachItemInIntegerArrayAndAppend(PRInt32 val, PRUint32 *count, PRInt32 **valueArray); \ + NS_IMETHOD CompareStringArrays(const char **arr1, const char **arr2, PRUint32 count, PRInt16 *result); \ + NS_IMETHOD DoubleStringArray(PRUint32 *count, char ***valueArray); \ + NS_IMETHOD ReverseStringArray(PRUint32 count, char ***valueArray); \ + NS_IMETHOD DoubleString(PRUint32 *count, char **str); \ + NS_IMETHOD DoubleString2(PRUint32 in_count, const char *in_str, PRUint32 *out_count, char **out_str); \ + NS_IMETHOD DoubleString3(PRUint32 in_count, const char *in_str, PRUint32 *out_count, char **out_str); \ + NS_IMETHOD DoubleString4(const char *in_str, PRUint32 *count, char **out_str); \ + NS_IMETHOD UpString(PRUint32 count, char **str); \ + NS_IMETHOD UpString2(PRUint32 count, const char *in_str, char **out_str); \ + NS_IMETHOD CopyUTF8String(const nsACString & in_str, nsACString & out_str); \ + NS_IMETHOD CopyUTF8String2(const nsACString & in_str, nsACString & out_str); \ + NS_IMETHOD GetFixedString(PRUint32 count, char **out_str); \ + NS_IMETHOD DoubleWideString(PRUint32 *count, PRUnichar **str); \ + NS_IMETHOD DoubleWideString2(PRUint32 in_count, const PRUnichar *in_str, PRUint32 *out_count, PRUnichar **out_str); \ + NS_IMETHOD DoubleWideString3(PRUint32 in_count, const PRUnichar *in_str, PRUint32 *out_count, PRUnichar **out_str); \ + NS_IMETHOD DoubleWideString4(const PRUnichar *in_str, PRUint32 *count, PRUnichar **out_str); \ + NS_IMETHOD UpWideString(PRUint32 count, PRUnichar **str); \ + NS_IMETHOD UpWideString2(PRUint32 count, const PRUnichar *in_str, PRUnichar **out_str); \ + NS_IMETHOD GetFixedWideString(PRUint32 count, char **out_str); \ + NS_IMETHOD GetStrings(PRUint32 *count, char ***str); \ + NS_IMETHOD UpOctetArray(PRUint32 *count, PRUint8 **data); \ + NS_IMETHOD UpOctetArray2(PRUint32 *count, PRUint8 **data); \ + NS_IMETHOD CheckInterfaceArray(PRUint32 count, nsISupports **data, PRBool *all_non_null); \ + NS_IMETHOD CopyInterfaceArray(PRUint32 count, nsISupports **data, nsISupports ***out_data, PRUint32 *out_count); \ + NS_IMETHOD GetInterfaceArray(PRUint32 *count, nsISupports ***data); \ + NS_IMETHOD ExtendInterfaceArray(PRUint32 *count, nsISupports ***data); \ + NS_IMETHOD CheckIIDArray(PRUint32 count, const nsIID & *data, PRBool *all_mine); \ + NS_IMETHOD GetIIDArray(PRUint32 *count, nsIID & **data); \ + NS_IMETHOD ExtendIIDArray(PRUint32 *count, nsIID & **data); \ + NS_IMETHOD SumArrays(PRUint32 count, PRInt32 *array1, PRInt32 *array2, PRInt32 *result); \ + NS_IMETHOD GetArrays(PRUint32 *count, PRInt32 **array1, PRInt32 **array2); \ + NS_IMETHOD GetFixedArray(PRUint32 count, PRInt32 **array1); \ + NS_IMETHOD CopyArray(PRUint32 count, PRInt32 *array1, PRInt32 **array2); \ + NS_IMETHOD CopyAndDoubleArray(PRUint32 *count, PRInt32 *array1, PRInt32 **array2); \ + NS_IMETHOD AppendArray(PRUint32 *count, PRInt32 *array1, PRInt32 **array2); \ + NS_IMETHOD AppendVariant(nsIVariant *variant, nsIVariant **result); \ + NS_IMETHOD CopyVariant(nsIVariant *variant, nsIVariant **_retval); \ + NS_IMETHOD SumVariants(PRUint32 incount, nsIVariant **variants, nsIVariant **_retval); + +/* Use this macro to declare functions that forward the behavior of this interface to another object. */ +#define NS_FORWARD_NSIPYTHONTESTINTERFACEEXTRA(_to) \ + NS_IMETHOD MultiplyEachItemInIntegerArray(PRInt32 val, PRUint32 count, PRInt32 **valueArray) { return _to MultiplyEachItemInIntegerArray(val, count, valueArray); } \ + NS_IMETHOD MultiplyEachItemInIntegerArrayAndAppend(PRInt32 val, PRUint32 *count, PRInt32 **valueArray) { return _to MultiplyEachItemInIntegerArrayAndAppend(val, count, valueArray); } \ + NS_IMETHOD CompareStringArrays(const char **arr1, const char **arr2, PRUint32 count, PRInt16 *result) { return _to CompareStringArrays(arr1, arr2, count, result); } \ + NS_IMETHOD DoubleStringArray(PRUint32 *count, char ***valueArray) { return _to DoubleStringArray(count, valueArray); } \ + NS_IMETHOD ReverseStringArray(PRUint32 count, char ***valueArray) { return _to ReverseStringArray(count, valueArray); } \ + NS_IMETHOD DoubleString(PRUint32 *count, char **str) { return _to DoubleString(count, str); } \ + NS_IMETHOD DoubleString2(PRUint32 in_count, const char *in_str, PRUint32 *out_count, char **out_str) { return _to DoubleString2(in_count, in_str, out_count, out_str); } \ + NS_IMETHOD DoubleString3(PRUint32 in_count, const char *in_str, PRUint32 *out_count, char **out_str) { return _to DoubleString3(in_count, in_str, out_count, out_str); } \ + NS_IMETHOD DoubleString4(const char *in_str, PRUint32 *count, char **out_str) { return _to DoubleString4(in_str, count, out_str); } \ + NS_IMETHOD UpString(PRUint32 count, char **str) { return _to UpString(count, str); } \ + NS_IMETHOD UpString2(PRUint32 count, const char *in_str, char **out_str) { return _to UpString2(count, in_str, out_str); } \ + NS_IMETHOD CopyUTF8String(const nsACString & in_str, nsACString & out_str) { return _to CopyUTF8String(in_str, out_str); } \ + NS_IMETHOD CopyUTF8String2(const nsACString & in_str, nsACString & out_str) { return _to CopyUTF8String2(in_str, out_str); } \ + NS_IMETHOD GetFixedString(PRUint32 count, char **out_str) { return _to GetFixedString(count, out_str); } \ + NS_IMETHOD DoubleWideString(PRUint32 *count, PRUnichar **str) { return _to DoubleWideString(count, str); } \ + NS_IMETHOD DoubleWideString2(PRUint32 in_count, const PRUnichar *in_str, PRUint32 *out_count, PRUnichar **out_str) { return _to DoubleWideString2(in_count, in_str, out_count, out_str); } \ + NS_IMETHOD DoubleWideString3(PRUint32 in_count, const PRUnichar *in_str, PRUint32 *out_count, PRUnichar **out_str) { return _to DoubleWideString3(in_count, in_str, out_count, out_str); } \ + NS_IMETHOD DoubleWideString4(const PRUnichar *in_str, PRUint32 *count, PRUnichar **out_str) { return _to DoubleWideString4(in_str, count, out_str); } \ + NS_IMETHOD UpWideString(PRUint32 count, PRUnichar **str) { return _to UpWideString(count, str); } \ + NS_IMETHOD UpWideString2(PRUint32 count, const PRUnichar *in_str, PRUnichar **out_str) { return _to UpWideString2(count, in_str, out_str); } \ + NS_IMETHOD GetFixedWideString(PRUint32 count, char **out_str) { return _to GetFixedWideString(count, out_str); } \ + NS_IMETHOD GetStrings(PRUint32 *count, char ***str) { return _to GetStrings(count, str); } \ + NS_IMETHOD UpOctetArray(PRUint32 *count, PRUint8 **data) { return _to UpOctetArray(count, data); } \ + NS_IMETHOD UpOctetArray2(PRUint32 *count, PRUint8 **data) { return _to UpOctetArray2(count, data); } \ + NS_IMETHOD CheckInterfaceArray(PRUint32 count, nsISupports **data, PRBool *all_non_null) { return _to CheckInterfaceArray(count, data, all_non_null); } \ + NS_IMETHOD CopyInterfaceArray(PRUint32 count, nsISupports **data, nsISupports ***out_data, PRUint32 *out_count) { return _to CopyInterfaceArray(count, data, out_data, out_count); } \ + NS_IMETHOD GetInterfaceArray(PRUint32 *count, nsISupports ***data) { return _to GetInterfaceArray(count, data); } \ + NS_IMETHOD ExtendInterfaceArray(PRUint32 *count, nsISupports ***data) { return _to ExtendInterfaceArray(count, data); } \ + NS_IMETHOD CheckIIDArray(PRUint32 count, const nsIID & *data, PRBool *all_mine) { return _to CheckIIDArray(count, data, all_mine); } \ + NS_IMETHOD GetIIDArray(PRUint32 *count, nsIID & **data) { return _to GetIIDArray(count, data); } \ + NS_IMETHOD ExtendIIDArray(PRUint32 *count, nsIID & **data) { return _to ExtendIIDArray(count, data); } \ + NS_IMETHOD SumArrays(PRUint32 count, PRInt32 *array1, PRInt32 *array2, PRInt32 *result) { return _to SumArrays(count, array1, array2, result); } \ + NS_IMETHOD GetArrays(PRUint32 *count, PRInt32 **array1, PRInt32 **array2) { return _to GetArrays(count, array1, array2); } \ + NS_IMETHOD GetFixedArray(PRUint32 count, PRInt32 **array1) { return _to GetFixedArray(count, array1); } \ + NS_IMETHOD CopyArray(PRUint32 count, PRInt32 *array1, PRInt32 **array2) { return _to CopyArray(count, array1, array2); } \ + NS_IMETHOD CopyAndDoubleArray(PRUint32 *count, PRInt32 *array1, PRInt32 **array2) { return _to CopyAndDoubleArray(count, array1, array2); } \ + NS_IMETHOD AppendArray(PRUint32 *count, PRInt32 *array1, PRInt32 **array2) { return _to AppendArray(count, array1, array2); } \ + NS_IMETHOD AppendVariant(nsIVariant *variant, nsIVariant **result) { return _to AppendVariant(variant, result); } \ + NS_IMETHOD CopyVariant(nsIVariant *variant, nsIVariant **_retval) { return _to CopyVariant(variant, _retval); } \ + NS_IMETHOD SumVariants(PRUint32 incount, nsIVariant **variants, nsIVariant **_retval) { return _to SumVariants(incount, variants, _retval); } + +/* Use this macro to declare functions that forward the behavior of this interface to another object in a safe way. */ +#define NS_FORWARD_SAFE_NSIPYTHONTESTINTERFACEEXTRA(_to) \ + NS_IMETHOD MultiplyEachItemInIntegerArray(PRInt32 val, PRUint32 count, PRInt32 **valueArray) { return !_to ? NS_ERROR_NULL_POINTER : _to->MultiplyEachItemInIntegerArray(val, count, valueArray); } \ + NS_IMETHOD MultiplyEachItemInIntegerArrayAndAppend(PRInt32 val, PRUint32 *count, PRInt32 **valueArray) { return !_to ? NS_ERROR_NULL_POINTER : _to->MultiplyEachItemInIntegerArrayAndAppend(val, count, valueArray); } \ + NS_IMETHOD CompareStringArrays(const char **arr1, const char **arr2, PRUint32 count, PRInt16 *result) { return !_to ? NS_ERROR_NULL_POINTER : _to->CompareStringArrays(arr1, arr2, count, result); } \ + NS_IMETHOD DoubleStringArray(PRUint32 *count, char ***valueArray) { return !_to ? NS_ERROR_NULL_POINTER : _to->DoubleStringArray(count, valueArray); } \ + NS_IMETHOD ReverseStringArray(PRUint32 count, char ***valueArray) { return !_to ? NS_ERROR_NULL_POINTER : _to->ReverseStringArray(count, valueArray); } \ + NS_IMETHOD DoubleString(PRUint32 *count, char **str) { return !_to ? NS_ERROR_NULL_POINTER : _to->DoubleString(count, str); } \ + NS_IMETHOD DoubleString2(PRUint32 in_count, const char *in_str, PRUint32 *out_count, char **out_str) { return !_to ? NS_ERROR_NULL_POINTER : _to->DoubleString2(in_count, in_str, out_count, out_str); } \ + NS_IMETHOD DoubleString3(PRUint32 in_count, const char *in_str, PRUint32 *out_count, char **out_str) { return !_to ? NS_ERROR_NULL_POINTER : _to->DoubleString3(in_count, in_str, out_count, out_str); } \ + NS_IMETHOD DoubleString4(const char *in_str, PRUint32 *count, char **out_str) { return !_to ? NS_ERROR_NULL_POINTER : _to->DoubleString4(in_str, count, out_str); } \ + NS_IMETHOD UpString(PRUint32 count, char **str) { return !_to ? NS_ERROR_NULL_POINTER : _to->UpString(count, str); } \ + NS_IMETHOD UpString2(PRUint32 count, const char *in_str, char **out_str) { return !_to ? NS_ERROR_NULL_POINTER : _to->UpString2(count, in_str, out_str); } \ + NS_IMETHOD CopyUTF8String(const nsACString & in_str, nsACString & out_str) { return !_to ? NS_ERROR_NULL_POINTER : _to->CopyUTF8String(in_str, out_str); } \ + NS_IMETHOD CopyUTF8String2(const nsACString & in_str, nsACString & out_str) { return !_to ? NS_ERROR_NULL_POINTER : _to->CopyUTF8String2(in_str, out_str); } \ + NS_IMETHOD GetFixedString(PRUint32 count, char **out_str) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetFixedString(count, out_str); } \ + NS_IMETHOD DoubleWideString(PRUint32 *count, PRUnichar **str) { return !_to ? NS_ERROR_NULL_POINTER : _to->DoubleWideString(count, str); } \ + NS_IMETHOD DoubleWideString2(PRUint32 in_count, const PRUnichar *in_str, PRUint32 *out_count, PRUnichar **out_str) { return !_to ? NS_ERROR_NULL_POINTER : _to->DoubleWideString2(in_count, in_str, out_count, out_str); } \ + NS_IMETHOD DoubleWideString3(PRUint32 in_count, const PRUnichar *in_str, PRUint32 *out_count, PRUnichar **out_str) { return !_to ? NS_ERROR_NULL_POINTER : _to->DoubleWideString3(in_count, in_str, out_count, out_str); } \ + NS_IMETHOD DoubleWideString4(const PRUnichar *in_str, PRUint32 *count, PRUnichar **out_str) { return !_to ? NS_ERROR_NULL_POINTER : _to->DoubleWideString4(in_str, count, out_str); } \ + NS_IMETHOD UpWideString(PRUint32 count, PRUnichar **str) { return !_to ? NS_ERROR_NULL_POINTER : _to->UpWideString(count, str); } \ + NS_IMETHOD UpWideString2(PRUint32 count, const PRUnichar *in_str, PRUnichar **out_str) { return !_to ? NS_ERROR_NULL_POINTER : _to->UpWideString2(count, in_str, out_str); } \ + NS_IMETHOD GetFixedWideString(PRUint32 count, char **out_str) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetFixedWideString(count, out_str); } \ + NS_IMETHOD GetStrings(PRUint32 *count, char ***str) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetStrings(count, str); } \ + NS_IMETHOD UpOctetArray(PRUint32 *count, PRUint8 **data) { return !_to ? NS_ERROR_NULL_POINTER : _to->UpOctetArray(count, data); } \ + NS_IMETHOD UpOctetArray2(PRUint32 *count, PRUint8 **data) { return !_to ? NS_ERROR_NULL_POINTER : _to->UpOctetArray2(count, data); } \ + NS_IMETHOD CheckInterfaceArray(PRUint32 count, nsISupports **data, PRBool *all_non_null) { return !_to ? NS_ERROR_NULL_POINTER : _to->CheckInterfaceArray(count, data, all_non_null); } \ + NS_IMETHOD CopyInterfaceArray(PRUint32 count, nsISupports **data, nsISupports ***out_data, PRUint32 *out_count) { return !_to ? NS_ERROR_NULL_POINTER : _to->CopyInterfaceArray(count, data, out_data, out_count); } \ + NS_IMETHOD GetInterfaceArray(PRUint32 *count, nsISupports ***data) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetInterfaceArray(count, data); } \ + NS_IMETHOD ExtendInterfaceArray(PRUint32 *count, nsISupports ***data) { return !_to ? NS_ERROR_NULL_POINTER : _to->ExtendInterfaceArray(count, data); } \ + NS_IMETHOD CheckIIDArray(PRUint32 count, const nsIID & *data, PRBool *all_mine) { return !_to ? NS_ERROR_NULL_POINTER : _to->CheckIIDArray(count, data, all_mine); } \ + NS_IMETHOD GetIIDArray(PRUint32 *count, nsIID & **data) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetIIDArray(count, data); } \ + NS_IMETHOD ExtendIIDArray(PRUint32 *count, nsIID & **data) { return !_to ? NS_ERROR_NULL_POINTER : _to->ExtendIIDArray(count, data); } \ + NS_IMETHOD SumArrays(PRUint32 count, PRInt32 *array1, PRInt32 *array2, PRInt32 *result) { return !_to ? NS_ERROR_NULL_POINTER : _to->SumArrays(count, array1, array2, result); } \ + NS_IMETHOD GetArrays(PRUint32 *count, PRInt32 **array1, PRInt32 **array2) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetArrays(count, array1, array2); } \ + NS_IMETHOD GetFixedArray(PRUint32 count, PRInt32 **array1) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetFixedArray(count, array1); } \ + NS_IMETHOD CopyArray(PRUint32 count, PRInt32 *array1, PRInt32 **array2) { return !_to ? NS_ERROR_NULL_POINTER : _to->CopyArray(count, array1, array2); } \ + NS_IMETHOD CopyAndDoubleArray(PRUint32 *count, PRInt32 *array1, PRInt32 **array2) { return !_to ? NS_ERROR_NULL_POINTER : _to->CopyAndDoubleArray(count, array1, array2); } \ + NS_IMETHOD AppendArray(PRUint32 *count, PRInt32 *array1, PRInt32 **array2) { return !_to ? NS_ERROR_NULL_POINTER : _to->AppendArray(count, array1, array2); } \ + NS_IMETHOD AppendVariant(nsIVariant *variant, nsIVariant **result) { return !_to ? NS_ERROR_NULL_POINTER : _to->AppendVariant(variant, result); } \ + NS_IMETHOD CopyVariant(nsIVariant *variant, nsIVariant **_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->CopyVariant(variant, _retval); } \ + NS_IMETHOD SumVariants(PRUint32 incount, nsIVariant **variants, nsIVariant **_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->SumVariants(incount, variants, _retval); } + +#if 0 +/* Use the code below as a template for the implementation class for this interface. */ + +/* Header file */ +class nsPythonTestInterfaceExtra : public nsIPythonTestInterfaceExtra +{ +public: + NS_DECL_ISUPPORTS + NS_DECL_NSIPYTHONTESTINTERFACEEXTRA + + nsPythonTestInterfaceExtra(); + +private: + ~nsPythonTestInterfaceExtra(); + +protected: + /* additional members */ +}; + +/* Implementation file */ +NS_IMPL_ISUPPORTS1(nsPythonTestInterfaceExtra, nsIPythonTestInterfaceExtra) + +nsPythonTestInterfaceExtra::nsPythonTestInterfaceExtra() +{ + /* member initializers and constructor code */ +} + +nsPythonTestInterfaceExtra::~nsPythonTestInterfaceExtra() +{ + /* destructor code */ +} + +/* void MultiplyEachItemInIntegerArray (in PRInt32 val, in PRUint32 count, [array, size_is (count)] inout PRInt32 valueArray); */ +NS_IMETHODIMP nsPythonTestInterfaceExtra::MultiplyEachItemInIntegerArray(PRInt32 val, PRUint32 count, PRInt32 **valueArray) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* void MultiplyEachItemInIntegerArrayAndAppend (in PRInt32 val, inout PRUint32 count, [array, size_is (count)] inout PRInt32 valueArray); */ +NS_IMETHODIMP nsPythonTestInterfaceExtra::MultiplyEachItemInIntegerArrayAndAppend(PRInt32 val, PRUint32 *count, PRInt32 **valueArray) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* void CompareStringArrays ([array, size_is (count)] in string arr1, [array, size_is (count)] in string arr2, in unsigned long count, [retval] out short result); */ +NS_IMETHODIMP nsPythonTestInterfaceExtra::CompareStringArrays(const char **arr1, const char **arr2, PRUint32 count, PRInt16 *result) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* void DoubleStringArray (inout PRUint32 count, [array, size_is (count)] inout string valueArray); */ +NS_IMETHODIMP nsPythonTestInterfaceExtra::DoubleStringArray(PRUint32 *count, char ***valueArray) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* void ReverseStringArray (in PRUint32 count, [array, size_is (count)] inout string valueArray); */ +NS_IMETHODIMP nsPythonTestInterfaceExtra::ReverseStringArray(PRUint32 count, char ***valueArray) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* void DoubleString (inout PRUint32 count, [size_is (count)] inout string str); */ +NS_IMETHODIMP nsPythonTestInterfaceExtra::DoubleString(PRUint32 *count, char **str) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* void DoubleString2 (in PRUint32 in_count, [size_is (in_count)] in string in_str, out PRUint32 out_count, [size_is (out_count)] out string out_str); */ +NS_IMETHODIMP nsPythonTestInterfaceExtra::DoubleString2(PRUint32 in_count, const char *in_str, PRUint32 *out_count, char **out_str) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* void DoubleString3 (in PRUint32 in_count, [size_is (in_count)] in string in_str, out PRUint32 out_count, [size_is (out_count), retval] out string out_str); */ +NS_IMETHODIMP nsPythonTestInterfaceExtra::DoubleString3(PRUint32 in_count, const char *in_str, PRUint32 *out_count, char **out_str) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* void DoubleString4 ([size_is (count)] in string in_str, inout PRUint32 count, [size_is (count)] out string out_str); */ +NS_IMETHODIMP nsPythonTestInterfaceExtra::DoubleString4(const char *in_str, PRUint32 *count, char **out_str) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* void UpString (in PRUint32 count, [size_is (count)] inout string str); */ +NS_IMETHODIMP nsPythonTestInterfaceExtra::UpString(PRUint32 count, char **str) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* void UpString2 (in PRUint32 count, [size_is (count)] in string in_str, [size_is (count)] out string out_str); */ +NS_IMETHODIMP nsPythonTestInterfaceExtra::UpString2(PRUint32 count, const char *in_str, char **out_str) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* void CopyUTF8String (in AUTF8String in_str, out AUTF8String out_str); */ +NS_IMETHODIMP nsPythonTestInterfaceExtra::CopyUTF8String(const nsACString & in_str, nsACString & out_str) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* void CopyUTF8String2 (in AUTF8String in_str, out AUTF8String out_str); */ +NS_IMETHODIMP nsPythonTestInterfaceExtra::CopyUTF8String2(const nsACString & in_str, nsACString & out_str) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* void GetFixedString (in PRUint32 count, [size_is (count)] out string out_str); */ +NS_IMETHODIMP nsPythonTestInterfaceExtra::GetFixedString(PRUint32 count, char **out_str) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* void DoubleWideString (inout PRUint32 count, [size_is (count)] inout wstring str); */ +NS_IMETHODIMP nsPythonTestInterfaceExtra::DoubleWideString(PRUint32 *count, PRUnichar **str) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* void DoubleWideString2 (in PRUint32 in_count, [size_is (in_count)] in wstring in_str, out PRUint32 out_count, [size_is (out_count)] out wstring out_str); */ +NS_IMETHODIMP nsPythonTestInterfaceExtra::DoubleWideString2(PRUint32 in_count, const PRUnichar *in_str, PRUint32 *out_count, PRUnichar **out_str) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* void DoubleWideString3 (in PRUint32 in_count, [size_is (in_count)] in wstring in_str, out PRUint32 out_count, [size_is (out_count), retval] out wstring out_str); */ +NS_IMETHODIMP nsPythonTestInterfaceExtra::DoubleWideString3(PRUint32 in_count, const PRUnichar *in_str, PRUint32 *out_count, PRUnichar **out_str) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* void DoubleWideString4 ([size_is (count)] in wstring in_str, inout PRUint32 count, [size_is (count)] out wstring out_str); */ +NS_IMETHODIMP nsPythonTestInterfaceExtra::DoubleWideString4(const PRUnichar *in_str, PRUint32 *count, PRUnichar **out_str) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* void UpWideString (in PRUint32 count, [size_is (count)] inout wstring str); */ +NS_IMETHODIMP nsPythonTestInterfaceExtra::UpWideString(PRUint32 count, PRUnichar **str) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* void UpWideString2 (in PRUint32 count, [size_is (count)] in wstring in_str, [size_is (count)] out wstring out_str); */ +NS_IMETHODIMP nsPythonTestInterfaceExtra::UpWideString2(PRUint32 count, const PRUnichar *in_str, PRUnichar **out_str) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* void GetFixedWideString (in PRUint32 count, [size_is (count)] out string out_str); */ +NS_IMETHODIMP nsPythonTestInterfaceExtra::GetFixedWideString(PRUint32 count, char **out_str) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* void GetStrings (out PRUint32 count, [array, size_is (count), retval] out string str); */ +NS_IMETHODIMP nsPythonTestInterfaceExtra::GetStrings(PRUint32 *count, char ***str) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* void UpOctetArray (inout PRUint32 count, [array, size_is (count)] inout PRUint8 data); */ +NS_IMETHODIMP nsPythonTestInterfaceExtra::UpOctetArray(PRUint32 *count, PRUint8 **data) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* void UpOctetArray2 (inout PRUint32 count, [array, size_is (count)] inout PRUint8 data); */ +NS_IMETHODIMP nsPythonTestInterfaceExtra::UpOctetArray2(PRUint32 *count, PRUint8 **data) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* void CheckInterfaceArray (in PRUint32 count, [array, size_is (count)] in nsISupports data, [retval] out PRBool all_non_null); */ +NS_IMETHODIMP nsPythonTestInterfaceExtra::CheckInterfaceArray(PRUint32 count, nsISupports **data, PRBool *all_non_null) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* void CopyInterfaceArray (in PRUint32 count, [array, size_is (count)] in nsISupports data, [array, size_is (out_count)] out nsISupports out_data, out PRUint32 out_count); */ +NS_IMETHODIMP nsPythonTestInterfaceExtra::CopyInterfaceArray(PRUint32 count, nsISupports **data, nsISupports ***out_data, PRUint32 *out_count) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* void GetInterfaceArray (out PRUint32 count, [array, size_is (count)] out nsISupports data); */ +NS_IMETHODIMP nsPythonTestInterfaceExtra::GetInterfaceArray(PRUint32 *count, nsISupports ***data) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* void ExtendInterfaceArray (inout PRUint32 count, [array, size_is (count)] inout nsISupports data); */ +NS_IMETHODIMP nsPythonTestInterfaceExtra::ExtendInterfaceArray(PRUint32 *count, nsISupports ***data) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* void CheckIIDArray (in PRUint32 count, [array, size_is (count)] in nsIIDRef data, [retval] out PRBool all_mine); */ +NS_IMETHODIMP nsPythonTestInterfaceExtra::CheckIIDArray(PRUint32 count, const nsIID & *data, PRBool *all_mine) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* void GetIIDArray (out PRUint32 count, [array, size_is (count)] out nsIIDRef data); */ +NS_IMETHODIMP nsPythonTestInterfaceExtra::GetIIDArray(PRUint32 *count, nsIID & **data) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* void ExtendIIDArray (inout PRUint32 count, [array, size_is (count)] inout nsIIDRef data); */ +NS_IMETHODIMP nsPythonTestInterfaceExtra::ExtendIIDArray(PRUint32 *count, nsIID & **data) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* void SumArrays (in PRUint32 count, [array, size_is (count)] in PRInt32 array1, [array, size_is (count)] in PRInt32 array2, [retval] out PRInt32 result); */ +NS_IMETHODIMP nsPythonTestInterfaceExtra::SumArrays(PRUint32 count, PRInt32 *array1, PRInt32 *array2, PRInt32 *result) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* void GetArrays (out PRUint32 count, [array, size_is (count)] out PRInt32 array1, [array, size_is (count)] out PRInt32 array2); */ +NS_IMETHODIMP nsPythonTestInterfaceExtra::GetArrays(PRUint32 *count, PRInt32 **array1, PRInt32 **array2) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* void GetFixedArray (in PRUint32 count, [array, size_is (count)] out PRInt32 array1); */ +NS_IMETHODIMP nsPythonTestInterfaceExtra::GetFixedArray(PRUint32 count, PRInt32 **array1) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* void CopyArray (in PRUint32 count, [array, size_is (count)] in PRInt32 array1, [array, size_is (count)] out PRInt32 array2); */ +NS_IMETHODIMP nsPythonTestInterfaceExtra::CopyArray(PRUint32 count, PRInt32 *array1, PRInt32 **array2) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* void CopyAndDoubleArray (inout PRUint32 count, [array, size_is (count)] in PRInt32 array1, [array, size_is (count)] out PRInt32 array2); */ +NS_IMETHODIMP nsPythonTestInterfaceExtra::CopyAndDoubleArray(PRUint32 *count, PRInt32 *array1, PRInt32 **array2) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* void AppendArray (inout PRUint32 count, [array, size_is (count)] in PRInt32 array1, [array, size_is (count)] inout PRInt32 array2); */ +NS_IMETHODIMP nsPythonTestInterfaceExtra::AppendArray(PRUint32 *count, PRInt32 *array1, PRInt32 **array2) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* void AppendVariant (in nsIVariant variant, inout nsIVariant result); */ +NS_IMETHODIMP nsPythonTestInterfaceExtra::AppendVariant(nsIVariant *variant, nsIVariant **result) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* nsIVariant CopyVariant (in nsIVariant variant); */ +NS_IMETHODIMP nsPythonTestInterfaceExtra::CopyVariant(nsIVariant *variant, nsIVariant **_retval) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* nsIVariant SumVariants (in PRUint32 incount, [array, size_is (incount)] in nsIVariant variants); */ +NS_IMETHODIMP nsPythonTestInterfaceExtra::SumVariants(PRUint32 incount, nsIVariant **variants, nsIVariant **_retval) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* End of implementation class template. */ +#endif + + +/* starting interface: nsIPythonTestInterfaceDOMStrings */ +#define NS_IPYTHONTESTINTERFACEDOMSTRINGS_IID_STR "657ae651-a973-4818-8c06-f4b948b3d758" + +#define NS_IPYTHONTESTINTERFACEDOMSTRINGS_IID \ + {0x657ae651, 0xa973, 0x4818, \ + { 0x8c, 0x06, 0xf4, 0xb9, 0x48, 0xb3, 0xd7, 0x58 }} + +class NS_NO_VTABLE nsIPythonTestInterfaceDOMStrings : public nsIPythonTestInterfaceExtra { + public: + + NS_DEFINE_STATIC_IID_ACCESSOR(NS_IPYTHONTESTINTERFACEDOMSTRINGS_IID) + + /* DOMString GetDOMStringResult (in PRInt32 length); */ + NS_IMETHOD GetDOMStringResult(PRInt32 length, nsAString & _retval) = 0; + + /* void GetDOMStringOut (in PRInt32 length, [retval] out DOMString s); */ + NS_IMETHOD GetDOMStringOut(PRInt32 length, nsAString & s) = 0; + + /* PRUint32 GetDOMStringLength (in DOMString s); */ + NS_IMETHOD GetDOMStringLength(const nsAString & s, PRUint32 *_retval) = 0; + + /* PRUint32 GetDOMStringRefLength (in DOMStringRef s); */ + NS_IMETHOD GetDOMStringRefLength(const nsAString & s, PRUint32 *_retval) = 0; + + /* PRUint32 GetDOMStringPtrLength (in DOMStringPtr s); */ + NS_IMETHOD GetDOMStringPtrLength(const nsAString * s, PRUint32 *_retval) = 0; + + /* void ConcatDOMStrings (in DOMString s1, in DOMString s2, out DOMString ret); */ + NS_IMETHOD ConcatDOMStrings(const nsAString & s1, const nsAString & s2, nsAString & ret) = 0; + + /* attribute DOMString domstring_value; */ + NS_IMETHOD GetDomstring_value(nsAString & aDomstring_value) = 0; + NS_IMETHOD SetDomstring_value(const nsAString & aDomstring_value) = 0; + + /* readonly attribute DOMString domstring_value_ro; */ + NS_IMETHOD GetDomstring_value_ro(nsAString & aDomstring_value_ro) = 0; + +}; + +/* Use this macro when declaring classes that implement this interface. */ +#define NS_DECL_NSIPYTHONTESTINTERFACEDOMSTRINGS \ + NS_IMETHOD GetDOMStringResult(PRInt32 length, nsAString & _retval); \ + NS_IMETHOD GetDOMStringOut(PRInt32 length, nsAString & s); \ + NS_IMETHOD GetDOMStringLength(const nsAString & s, PRUint32 *_retval); \ + NS_IMETHOD GetDOMStringRefLength(const nsAString & s, PRUint32 *_retval); \ + NS_IMETHOD GetDOMStringPtrLength(const nsAString * s, PRUint32 *_retval); \ + NS_IMETHOD ConcatDOMStrings(const nsAString & s1, const nsAString & s2, nsAString & ret); \ + NS_IMETHOD GetDomstring_value(nsAString & aDomstring_value); \ + NS_IMETHOD SetDomstring_value(const nsAString & aDomstring_value); \ + NS_IMETHOD GetDomstring_value_ro(nsAString & aDomstring_value_ro); + +/* Use this macro to declare functions that forward the behavior of this interface to another object. */ +#define NS_FORWARD_NSIPYTHONTESTINTERFACEDOMSTRINGS(_to) \ + NS_IMETHOD GetDOMStringResult(PRInt32 length, nsAString & _retval) { return _to GetDOMStringResult(length, _retval); } \ + NS_IMETHOD GetDOMStringOut(PRInt32 length, nsAString & s) { return _to GetDOMStringOut(length, s); } \ + NS_IMETHOD GetDOMStringLength(const nsAString & s, PRUint32 *_retval) { return _to GetDOMStringLength(s, _retval); } \ + NS_IMETHOD GetDOMStringRefLength(const nsAString & s, PRUint32 *_retval) { return _to GetDOMStringRefLength(s, _retval); } \ + NS_IMETHOD GetDOMStringPtrLength(const nsAString * s, PRUint32 *_retval) { return _to GetDOMStringPtrLength(s, _retval); } \ + NS_IMETHOD ConcatDOMStrings(const nsAString & s1, const nsAString & s2, nsAString & ret) { return _to ConcatDOMStrings(s1, s2, ret); } \ + NS_IMETHOD GetDomstring_value(nsAString & aDomstring_value) { return _to GetDomstring_value(aDomstring_value); } \ + NS_IMETHOD SetDomstring_value(const nsAString & aDomstring_value) { return _to SetDomstring_value(aDomstring_value); } \ + NS_IMETHOD GetDomstring_value_ro(nsAString & aDomstring_value_ro) { return _to GetDomstring_value_ro(aDomstring_value_ro); } + +/* Use this macro to declare functions that forward the behavior of this interface to another object in a safe way. */ +#define NS_FORWARD_SAFE_NSIPYTHONTESTINTERFACEDOMSTRINGS(_to) \ + NS_IMETHOD GetDOMStringResult(PRInt32 length, nsAString & _retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetDOMStringResult(length, _retval); } \ + NS_IMETHOD GetDOMStringOut(PRInt32 length, nsAString & s) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetDOMStringOut(length, s); } \ + NS_IMETHOD GetDOMStringLength(const nsAString & s, PRUint32 *_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetDOMStringLength(s, _retval); } \ + NS_IMETHOD GetDOMStringRefLength(const nsAString & s, PRUint32 *_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetDOMStringRefLength(s, _retval); } \ + NS_IMETHOD GetDOMStringPtrLength(const nsAString * s, PRUint32 *_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetDOMStringPtrLength(s, _retval); } \ + NS_IMETHOD ConcatDOMStrings(const nsAString & s1, const nsAString & s2, nsAString & ret) { return !_to ? NS_ERROR_NULL_POINTER : _to->ConcatDOMStrings(s1, s2, ret); } \ + NS_IMETHOD GetDomstring_value(nsAString & aDomstring_value) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetDomstring_value(aDomstring_value); } \ + NS_IMETHOD SetDomstring_value(const nsAString & aDomstring_value) { return !_to ? NS_ERROR_NULL_POINTER : _to->SetDomstring_value(aDomstring_value); } \ + NS_IMETHOD GetDomstring_value_ro(nsAString & aDomstring_value_ro) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetDomstring_value_ro(aDomstring_value_ro); } + +#if 0 +/* Use the code below as a template for the implementation class for this interface. */ + +/* Header file */ +class nsPythonTestInterfaceDOMStrings : public nsIPythonTestInterfaceDOMStrings +{ +public: + NS_DECL_ISUPPORTS + NS_DECL_NSIPYTHONTESTINTERFACEDOMSTRINGS + + nsPythonTestInterfaceDOMStrings(); + +private: + ~nsPythonTestInterfaceDOMStrings(); + +protected: + /* additional members */ +}; + +/* Implementation file */ +NS_IMPL_ISUPPORTS1(nsPythonTestInterfaceDOMStrings, nsIPythonTestInterfaceDOMStrings) + +nsPythonTestInterfaceDOMStrings::nsPythonTestInterfaceDOMStrings() +{ + /* member initializers and constructor code */ +} + +nsPythonTestInterfaceDOMStrings::~nsPythonTestInterfaceDOMStrings() +{ + /* destructor code */ +} + +/* DOMString GetDOMStringResult (in PRInt32 length); */ +NS_IMETHODIMP nsPythonTestInterfaceDOMStrings::GetDOMStringResult(PRInt32 length, nsAString & _retval) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* void GetDOMStringOut (in PRInt32 length, [retval] out DOMString s); */ +NS_IMETHODIMP nsPythonTestInterfaceDOMStrings::GetDOMStringOut(PRInt32 length, nsAString & s) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* PRUint32 GetDOMStringLength (in DOMString s); */ +NS_IMETHODIMP nsPythonTestInterfaceDOMStrings::GetDOMStringLength(const nsAString & s, PRUint32 *_retval) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* PRUint32 GetDOMStringRefLength (in DOMStringRef s); */ +NS_IMETHODIMP nsPythonTestInterfaceDOMStrings::GetDOMStringRefLength(const nsAString & s, PRUint32 *_retval) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* PRUint32 GetDOMStringPtrLength (in DOMStringPtr s); */ +NS_IMETHODIMP nsPythonTestInterfaceDOMStrings::GetDOMStringPtrLength(const nsAString * s, PRUint32 *_retval) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* void ConcatDOMStrings (in DOMString s1, in DOMString s2, out DOMString ret); */ +NS_IMETHODIMP nsPythonTestInterfaceDOMStrings::ConcatDOMStrings(const nsAString & s1, const nsAString & s2, nsAString & ret) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* attribute DOMString domstring_value; */ +NS_IMETHODIMP nsPythonTestInterfaceDOMStrings::GetDomstring_value(nsAString & aDomstring_value) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} +NS_IMETHODIMP nsPythonTestInterfaceDOMStrings::SetDomstring_value(const nsAString & aDomstring_value) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* readonly attribute DOMString domstring_value_ro; */ +NS_IMETHODIMP nsPythonTestInterfaceDOMStrings::GetDomstring_value_ro(nsAString & aDomstring_value_ro) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* End of implementation class template. */ +#endif + + +#endif /* __gen_py_test_component_h__ */ diff --git a/src/libs/xpcom18a4/python/test/test_component/py_test_component.html b/src/libs/xpcom18a4/python/test/test_component/py_test_component.html new file mode 100644 index 00000000..1e17d24c --- /dev/null +++ b/src/libs/xpcom18a4/python/test/test_component/py_test_component.html @@ -0,0 +1,182 @@ +<!-- ***** 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 PyXPCOM. + - + - The Initial Developer of the Original Code is + - ActiveState Tool Corporation. + - Portions created by the Initial Developer are Copyright (C) 2000-2001 + - the Initial Developer. All Rights Reserved. + - + - Contributor(s): + - + - 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 LGPL or the GPL. 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 ***** --> + +<center><b><font size=+2>Python Component Sample</font></b> + +<p> +<br> +Last modified +<script> +document.write(document.lastModified); +</script> +</center> + +<p>XPConnect allows JavaScript +to transparantly access and manipulate XPCOM objects; + +<p>Big Deal, I hear you say! But it also works for Python!!! + +<p> +This sample demonstrates accessing a XPCOM object through XPConnect. +The JavaScript executed when this page loads creates an instance +of the Python object by +using the <tt>Components</tt> object, then accesses it through +the <a href="py_test_component.idl">nsISample</a> interface by calling <tt>QueryInterface</tt>: +<br> +<pre> +netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); +var sample = Components.classes["component://mozilla/sample/sample-world"].createInstance(); +sample = sample.QueryInterface(Components.interfaces.nsISample); +</pre> + +<p> +The buttons on the form are connected to JavaScript event handlers which +call the methods defined in Python + + +<p><b><a name="Compiling">Compiling the idl</b> + +<p>The XPIDL compiler (xpidl on Unix, xpidl.exe on Windows, and a CodeWarrior plugin on Mac) +is compiled at build time (except on Mac) thus +you will have to build mozilla in order to test this out. If you +have already built mozilla then the compiler will be located at <tt>mozilla\dist\WIN32_D.OBJ\bin\xpidl.exe</tt>. + +<p>Once you have the XPIDL compiler enter the following command at your +prompt: +<br><tt>D:\whereever\xpcom\test\test_component>d:\mozilla\dist\WIN32_D.OBJ\bin\xpidl -I +d:\mozilla\dist\idl -m typelib py_test_component.idl</tt>. You must then copy the generated .xpt file +to the mozilla component directory. + +<p>The <tt>-I d:\mozilla\dist\idl</tt> points the compiler to the folder +containing the other idl files, needed because nsISample.idl inherits from +nsISupports.idl. The <tt>-m typelib</tt> instruction tells the compiler +to build the .XPT typelib file.</tt>. + +<p> +For more information on compilation see the <a href="http://www.mozilla.org/scriptable/xpidl/">xpidl +compiler page</a>. + +<p><b>Running the sample</b> +<p><b>NOTE: This doesnt work for me - I get an access denied error using XPConnect!</b> +<p>Using Mozilla, load this file. Pay attention +to the console when clicking "write". + +<!-- XXX keep in sync with stuff in pre tag below --> +<script> +netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); +var sample = Components.classes["Python.TestComponent"].createInstance(); +sample = sample.QueryInterface(Components.interfaces.nsIPythonTestInterface); +dump("sample = " + sample + "\n"); + +function get() +{ + var field = document.getElementById('Value'); + field.value = sample.str_value; +} + +function set() +{ + var field = document.getElementById('Value'); + sample.str_value = field.value; +} + +function poke() +{ + var field = document.getElementById('Value'); + sample.poke(field.value); +} + +function write() +{ + sample.writeValue("here is what I'm writing: "); +} +</script> + +<p> +<form name="form"> +<input type="button" value="Get" onclick="get();"> +<input type="button" value="Set" onclick="set();"> +<input type="button" value="Poke" onclick="poke();"> +<input type="text" id="Value"> +<input type="button" value="Write" onclick="write();"> +<form> + +<hr> + +<p> +JavaScript and form source: + +<!-- XXX keep in sync with actual script --> +<pre> +<script> +netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); +var sample = Components.classes["component://Python.TestComponent"].createInstance(); +sample = sample.QueryInterface(Components.interfaces.nsIPythonTestInterface); +dump("sample = " + sample + "\n"); + +function get() +{ + var field = document.getElementById('Value'); + field.value = sample.str_value; +} + +function set() +{ + var field = document.getElementById('Value'); + sample.str_value = field.value; +} + +function poke() +{ + var field = document.getElementById('Value'); + sample.poke(field.value); +} + +function write() +{ + sample.writeValue("here is what I'm writing: "); +} +</script> + +<form name="form"> +<input type="button" value="Get" onclick="get();"> +<input type="button" value="Set" onclick="set();"> +<input type="button" value="Poke" onclick="poke();"> +<input type="text" id="Value"> +<input type="button" value="Write" onclick="write();"> +<form> + +</pre> diff --git a/src/libs/xpcom18a4/python/test/test_component/py_test_component.idl b/src/libs/xpcom18a4/python/test/test_component/py_test_component.idl new file mode 100644 index 00000000..cd3e1c45 --- /dev/null +++ b/src/libs/xpcom18a4/python/test/test_component/py_test_component.idl @@ -0,0 +1,231 @@ +/* ***** 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 the Python XPCOM language bindings. + * + * The Initial Developer of the Original Code is + * ActiveState Tool Corp. + * Portions created by the Initial Developer are Copyright (C) 2000 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Mark Hammond <MarkH@ActiveState.com> (original author) + * + * 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 ***** */ + +// NOTE: This is a TEST interface, not a DEMO interface :-) +// We try to get as many data-types etc exposed, meaning this +// doesnt really make a good demo of a "simple component" +#include "nsISupports.idl" +#include "nsIVariant.idl" + +[scriptable, uuid(1ECAED4F-E4D5-4ee7-ABF0-7D72AE1441D7)] +interface nsIPythonTestInterface : nsISupports +{ + // Some constants for us to test - one for every type supported by xpidl + const short One = 1; + const long Two = 2; + const long MinusOne = -1; + const long BigLong = 0x7FFFFFFF; + const long BiggerLong = 0xFFFFFFFF; + const unsigned long BigULong = 0xFFFFFFFF; + + // Declare every type supported as an attribute. + attribute boolean boolean_value; // PRBool + attribute octet octet_value; // PRUint8 + attribute short short_value; // PRInt16 + attribute unsigned short ushort_value; // PRUint16 + attribute long long_value; // PRInt32 + attribute unsigned long ulong_value; // PRUint32 + attribute long long long_long_value; // PRInt64 + attribute unsigned long long ulong_long_value; // PRUint64 + attribute float float_value; // float + attribute double double_value; // double + attribute char char_value; // char + attribute wchar wchar_value; // PRUnichar + attribute string string_value; // char * + attribute wstring wstring_value; // PRUnichar* + attribute AString astring_value; // nsAString & + attribute ACString acstring_value; // nsACString & + attribute AUTF8String utf8string_value; // nsAUTF8String & + attribute nsIIDRef iid_value; // an IID + attribute nsIPythonTestInterface interface_value; // A specific interface + attribute nsISupports isupports_value; // A generic interface + + // Declare every type supported as a method with an "in", "in/out" and "out" params + boolean do_boolean(in boolean p1, inout boolean p2, out boolean p3); + octet do_octet(in octet p1, inout octet p2, out octet p3); + short do_short(in short p1, inout short p2, out short p3); + unsigned short do_unsigned_short(in unsigned short p1, inout unsigned short p2, out unsigned short p3); + long do_long(in long p1, inout long p2, out long p3); + unsigned long do_unsigned_long(in unsigned long p1, inout unsigned long p2, out unsigned long p3); + long long do_long_long(in long long p1, inout long long p2, out long long p3); + unsigned long long do_unsigned_long_long(in unsigned long long p1, inout unsigned long long p2, out unsigned long long p3); + float do_float(in float p1, inout float p2, out float p3); + double do_double(in double p1, inout double p2, out double p3); + char do_char(in char p1, inout char p2, out char p3); + wchar do_wchar(in wchar p1, inout wchar p2, out wchar p3); + string do_string(in string p1, inout string p2, out string p3); + wstring do_wstring(in wstring p1, inout wstring p2, out wstring p3); + nsIIDRef do_nsIIDRef(in nsIIDRef p1, inout nsIIDRef p2, out nsIIDRef p3); + nsIPythonTestInterface do_nsIPythonTestInterface(in nsIPythonTestInterface p1, inout nsIPythonTestInterface p2, out nsIPythonTestInterface p3); + nsISupports do_nsISupports(in nsISupports p1, inout nsISupports p2, out nsISupports p3); + void do_nsISupportsIs(in nsIIDRef iid, [iid_is(iid),retval] out nsQIResult result); +// Do I really need these?? +// void do_nsISupportsIs2(inout nsIIDRef iid, [iid_is(iid)] inout nsQIResult result); +// void do_nsISupportsIs3(out nsIIDRef iid, [iid_is(iid)] inout nsQIResult result); +// void do_nsISupportsIs4(out nsIIDRef iid, [iid_is(iid)] out nsQIResult result); +}; + +// Another interface - we use another interface purely for testing purposes - +// We ensure that the entire interface hierarcy is available correctly. +[scriptable, uuid(B38D1538-FE92-42c3-831F-285242EDEEA4)] +interface nsIPythonTestInterfaceExtra : nsIPythonTestInterface +{ + // These were copied from the XPCOM test 'xpctest.idl' + // (and a few extras added) + void MultiplyEachItemInIntegerArray( + in PRInt32 val, + in PRUint32 count, + [array, size_is(count)] inout PRInt32 valueArray); + void MultiplyEachItemInIntegerArrayAndAppend( + in PRInt32 val, + inout PRUint32 count, + [array, size_is(count)] inout PRInt32 valueArray); + + // Note that this method shares a single "size_is" between 2 params! + void CompareStringArrays([array, size_is(count)] in string arr1, + [array, size_is(count)] in string arr2, + in unsigned long count, + [retval] out short result); + + void DoubleStringArray(inout PRUint32 count, + [array, size_is(count)] inout string valueArray); + void ReverseStringArray(in PRUint32 count, + [array, size_is(count)] inout string valueArray); + + // One count, one inout array. + void DoubleString(inout PRUint32 count, + [size_is(count)] inout string str); + // One in count and in array, plus out count and out array + void DoubleString2(in PRUint32 in_count, [size_is(in_count)] in string in_str, + out PRUint32 out_count, [size_is(out_count)] out string out_str); + // As per DoubleString2, but out string also marked retval + void DoubleString3(in PRUint32 in_count, [size_is(in_count)] in string in_str, + out PRUint32 out_count, [size_is(out_count), retval] out string out_str); + // One in array, one out array, one share inout count. + void DoubleString4([size_is(count)] in string in_str, inout PRUint32 count, [size_is(count)] out string out_str); + // UpString defines the count as only "in" - meaning the result must be the same size + void UpString(in PRUint32 count, + [size_is(count)] inout string str); + // UpString2 defines count as only "in", and a string as only "out" + void UpString2(in PRUint32 count, + [size_is(count)] in string in_str, + [size_is(count)]out string out_str); + void CopyUTF8String(in AUTF8String in_str, out AUTF8String out_str); + void CopyUTF8String2(in AUTF8String in_str, out AUTF8String out_str); + // Test we can get an "out" array with an "in" size (and the size is not used anywhere as a size for an in!) + void GetFixedString(in PRUint32 count, [size_is(count)]out string out_str); + + void DoubleWideString(inout PRUint32 count, + [size_is(count)] inout wstring str); + void DoubleWideString2(in PRUint32 in_count, [size_is(in_count)] in wstring in_str, + out PRUint32 out_count, [size_is(out_count)] out wstring out_str); + void DoubleWideString3(in PRUint32 in_count, [size_is(in_count)] in wstring in_str, + out PRUint32 out_count, [size_is(out_count), retval] out wstring out_str); + void DoubleWideString4([size_is(count)] in wstring in_str, inout PRUint32 count, [size_is(count)] out wstring out_str); + // UpWideString defines the count as only "in" - meaning the result must be the same size + void UpWideString(in PRUint32 count, + [size_is(count)] inout wstring str); + // UpWideString2 defines count as only "in", and a string as only "out" + void UpWideString2(in PRUint32 count, + [size_is(count)] in wstring in_str, + [size_is(count)]out wstring out_str); + // Test we can get an "out" array with an "in" size (and the size is not used anywhere as a size for an in!) + void GetFixedWideString(in PRUint32 count, [size_is(count)]out string out_str); + + void GetStrings(out PRUint32 count, + [retval, array, size_is(count)] out string str); + + void UpOctetArray(inout PRUint32 count, + [array, size_is(count)] inout PRUint8 data); + + void UpOctetArray2(inout PRUint32 count, + [array, size_is(count)] inout PRUint8 data); + + // Arrays of interfaces + void CheckInterfaceArray(in PRUint32 count, + [array, size_is(count)] in nsISupports data, + [retval] out PRBool all_non_null); + void CopyInterfaceArray(in PRUint32 count, + [array, size_is(count)] in nsISupports data, + [array, size_is(out_count)] out nsISupports out_data, + out PRUint32 out_count); + void GetInterfaceArray(out PRUint32 count, + [array, size_is(count)] out nsISupports data); + void ExtendInterfaceArray(inout PRUint32 count, + [array, size_is(count)] inout nsISupports data); + + // Arrays of IIDs + void CheckIIDArray(in PRUint32 count, + [array, size_is(count)] in nsIIDRef data, + [retval] out PRBool all_mine); + void GetIIDArray(out PRUint32 count, + [array, size_is(count)] out nsIIDRef data); + void ExtendIIDArray(inout PRUint32 count, + [array, size_is(count)] inout nsIIDRef data); + + // More specific tests. + // Test our count param can be shared as an "in" param. + void SumArrays(in PRUint32 count, [array, size_is(count)]in PRInt32 array1, [array, size_is(count)]in PRInt32 array2, [retval]out PRInt32 result); + // Test our count param can be shared as an "out" param. + void GetArrays(out PRUint32 count, [array, size_is(count)]out PRInt32 array1, [array, size_is(count)]out PRInt32 array2); + // Test we can get an "out" array with an "in" size (and the size is not used anywhere as a size for an in!) + void GetFixedArray(in PRUint32 count, [array, size_is(count)]out PRInt32 array1); + // Test our "in" count param can be shared as one "in", plus one "out" param. + void CopyArray(in PRUint32 count, [array, size_is(count)]in PRInt32 array1, [array, size_is(count)]out PRInt32 array2); + // Test our "in-out" count param can be shared as one "in", plus one "out" param. + void CopyAndDoubleArray(inout PRUint32 count, [array, size_is(count)]in PRInt32 array1, [array, size_is(count)]out PRInt32 array2); + // Test our "in-out" count param can be shared as one "in", plus one "in-out" param. + void AppendArray(inout PRUint32 count, [array, size_is(count)]in PRInt32 array1, [array, size_is(count)]inout PRInt32 array2); + void AppendVariant(in nsIVariant variant, inout nsIVariant result); + nsIVariant CopyVariant(in nsIVariant variant); + nsIVariant SumVariants(in PRUint32 incount, [array, size_is(incount)]in nsIVariant variants); +}; + +// DOM String support is a "recent" (01/2001) addition to XPCOM. These test +// have their own interface for no real good reason ;-) +[scriptable, uuid(657ae651-a973-4818-8c06-f4b948b3d758)] +interface nsIPythonTestInterfaceDOMStrings : nsIPythonTestInterfaceExtra +{ + DOMString GetDOMStringResult(in PRInt32 length); + void GetDOMStringOut(in PRInt32 length, [retval] out DOMString s); + PRUint32 GetDOMStringLength(in DOMString s); + PRUint32 GetDOMStringRefLength(in DOMStringRef s); + PRUint32 GetDOMStringPtrLength(in DOMStringPtr s); + void ConcatDOMStrings(in DOMString s1, in DOMString s2, out DOMString ret); + attribute DOMString domstring_value; + readonly attribute DOMString domstring_value_ro; +}; diff --git a/src/libs/xpcom18a4/python/test/test_component/py_test_component.py b/src/libs/xpcom18a4/python/test/test_component/py_test_component.py new file mode 100755 index 00000000..c0373de9 --- /dev/null +++ b/src/libs/xpcom18a4/python/test/test_component/py_test_component.py @@ -0,0 +1,421 @@ +# ***** 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 the Python XPCOM language bindings. +# +# The Initial Developer of the Original Code is +# ActiveState Tool Corp. +# Portions created by the Initial Developer are Copyright (C) 2000, 2001 +# the Initial Developer. All Rights Reserved. +# +# Contributor(s): +# Mark Hammond <MarkH@ActiveState.com> (original author) +# +# 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 ***** + +# NOTE: This is a TEST interface, not a DEMO interface :-) +# We try to get as many data-types etc exposed, meaning this +# doesnt really make a good demo of a "simple component" + + +from xpcom import components, verbose + +class PythonTestComponent: + # Note we only list the "child" interface, not our intermediate interfaces + # (which we must, by definition, also support) + _com_interfaces_ = components.interfaces.nsIPythonTestInterfaceDOMStrings + _reg_clsid_ = "{7EE4BDC6-CB53-42c1-A9E4-616B8E012ABA}" + _reg_contractid_ = "Python.TestComponent" + def __init__(self): + self.boolean_value = 1 + self.octet_value = 2 + self.short_value = 3 + self.ushort_value = 4 + self.long_value = 5 + self.ulong_value = 6 + self.long_long_value = 7 + self.ulong_long_value = 8 + self.float_value = 9.0 + self.double_value = 10.0 + self.char_value = "a" + self.wchar_value = "b" + self.string_value = "cee" + self.wstring_value = "dee" + self.astring_value = "astring" + self.acstring_value = "acstring" + self.utf8string_value = "utf8string" + self.iid_value = self._reg_clsid_ + self.interface_value = None + self.isupports_value = None + self.domstring_value = "dom" + + def __del__(self): + if verbose: + print "Python.TestComponent: __del__ method called - object is destructing" + + def do_boolean(self, p1, p2): + # boolean do_boolean(in boolean p1, inout boolean p2, out boolean p3); + ret = p1 ^ p2 + return ret, not ret, ret + + def do_octet(self, p1, p2): + # octet do_octet(in octet p1, inout octet p2, out octet p3); + return p1+p2, p1-p2, p1*p2 + + def do_short(self, p1, p2): + # short do_short(in short p1, inout short p2, out short p3); + return p1+p2, p1-p2, p1*p2 + + def do_unsigned_short(self, p1, p2): + # unsigned short do_unsigned_short(in unsigned short p1, inout unsigned short p2, out unsigned short p3); + return p1+p2, p1-p2, p1*p2 + def do_long(self, p1, p2): + # long do_long(in long p1, inout long p2, out long p3); + return p1+p2, p1-p2, p1*p2 + + def do_unsigned_long(self, p1, p2): + # unsigned long do_unsigned_long(in unsigned long p1, inout unsigned long p2, out unsigned long p3); + return p1+p2, p1-p2, p1*p2 + def do_long_long(self, p1, p2): + # long long do_long_long(in long long p1, inout long long p2, out long long p3); + return p1+p2, p1-p2, p1*p2 + def do_unsigned_long_long(self, p1, p2): + # unsigned long long do_unsigned_long_long(in unsigned long long p1, inout unsigned long long p2, out unsigned long long p3); + return p1+p2, p1-p2, p1*p2 + def do_float(self, p1, p2): + # float do_float(in float p1, inout float p2, out float p3); + return p1+p2, p1-p2, p1*p2 + def do_double(self, p1, p2): + # double do_double(in double p1, inout double p2, out double p3); + return p1+p2, p1-p2, p1*p2 + def do_char(self, p1, p2): + # char do_char(in char p1, inout char p2, out char p3); + return chr(ord(p1)+ord(p2)), p2, p1 + def do_wchar(self, p1, p2): + # wchar do_wchar(in wchar p1, inout wchar p2, out wchar p3); + return chr(ord(p1)+ord(p2)), p2, p1 + def do_string(self, p1, p2): + # string do_string(in string p1, inout string p2, out string p3); + ret = "" + if p1 is not None: ret = ret + p1 + if p2 is not None: ret = ret + p2 + return ret, p1, p2 + def do_wstring(self, p1, p2): + # wstring do_wstring(in wstring p1, inout wstring p2, out wstring p3); + ret = u"" + if p1 is not None: ret = ret + p1 + if p2 is not None: ret = ret + p2 + return ret, p1, p2 + def do_nsIIDRef(self, p1, p2): + # nsIIDRef do_nsIIDRef(in nsIIDRef p1, inout nsIIDRef p2, out nsIIDRef p3); + return p1, self._reg_clsid_, p2 + def do_nsIPythonTestInterface(self, p1, p2): + # nsIPythonTestInterface do_nsIPythonTestInterface(in nsIPythonTestInterface p1, inout nsIPythonTestInterface p2, out nsIPythonTestInterface p3); + return p2, p1, self + def do_nsISupports(self, p1, p2): + # nsISupports do_nsISupports(in nsISupports p1, inout nsISupports p2, out nsISupports p3); + return self, p1, p2 + def do_nsISupportsIs(self, iid): + # void do_nsISupportsIs(in nsIIDRef iid, [iid_is(iid),retval] out nsQIResult result) + # Note the framework does the QI etc on us, so there is no real point me doing it. + # (However, user code _should_ do the QI - otherwise any errors are deemed "internal" (as they + # are raised by the C++ framework), and therefore logged to the console, etc. + # A user QI allows the user to fail gracefully, whatever gracefully means for them! + return self +# Do I really need these?? +## def do_nsISupportsIs2(self, iid, interface): +## # void do_nsISupportsIs2(inout nsIIDRef iid, [iid_is(iid),retval] inout nsQIResult result); +## return iid, interface +## def do_nsISupportsIs3(self, interface): +## # void do_nsISupportsIs3(out nsIIDRef iid, [iid_is(iid)] inout nsQIResult result); +## return self._com_interfaces_, interface +## def do_nsISupportsIs4(self): +## # void do_nsISupportsIs4(out nsIIDRef iid, [iid_is(iid)] out nsQIResult result); +## return self._com_interfaces_, self + + # Methods from the nsIPythonTestInterfaceExtra interface + # + def MultiplyEachItemInIntegerArray(self, val, valueArray): + # void MultiplyEachItemInIntegerArray( + # in PRInt32 val, + # in PRUint32 count, + # [array, size_is(count)] inout PRInt32 valueArray); + # NOTE - the "sizeis" params are never passed to or returned from Python! + results = [] + for item in valueArray: + results.append(item * val) + return results + def MultiplyEachItemInIntegerArrayAndAppend(self, val, valueArray): + #void MultiplyEachItemInIntegerArrayAndAppend( + # in PRInt32 val, + # inout PRUint32 count, + # [array, size_is(count)] inout PRInt32 valueArray); + results = valueArray[:] + for item in valueArray: + results.append(item * val) + return results + def DoubleStringArray(self, valueArray): + # void DoubleStringArray(inout PRUint32 count, + # [array, size_is(count)] inout string valueArray); + results = [] + for item in valueArray: + results.append(item * 2) + return results + + def ReverseStringArray(self, valueArray): + # void ReverseStringArray(in PRUint32 count, + # [array, size_is(count)] inout string valueArray); + valueArray.reverse() + return valueArray + + # Note that this method shares a single "size_is" between 2 params! + def CompareStringArrays(self, ar1, ar2): + # void CompareStringArrays([array, size_is(count)] in string arr1, + # [array, size_is(count)] in string arr2, + # in unsigned long count, + # [retval] out short result); + return cmp(ar1, ar2) + + def DoubleString(self, val): + # void DoubleString(inout PRUint32 count, + # [size_is(count)] inout string str); + return val * 2 + def DoubleString2(self, val): + # void DoubleString2(in PRUint32 in_count, [size_is(in_count)] in string in_str, + # out PRUint32 out_count, [size_is(out_count)] out string out_str); + return val * 2 + def DoubleString3(self, val): + # void DoubleString3(in PRUint32 in_count, [size_is(in_count)] in string in_str, + # out PRUint32 out_count, [size_is(out_count), retval] string out_str); + return val * 2 + def DoubleString4(self, val): + # void DoubleString4([size_is(count)] in string in_str, inout PRUint32 count, [size_is(count)] out string out_str); + return val * 2 + def UpString(self, val): + # // UpString defines the count as only "in" - meaning the result must be the same size + # void UpString(in PRUint32 count, + # [size_is(count)] inout string str); + return val.upper() + UpString2 = UpString + # // UpString2 defines count as only "in", and a string as only "out" + # void UpString2(in PRUint32 count, + # [size_is(count)] inout string in_str, + # [size_is(count)]out string out_str); + + def GetFixedString(self, count): + # void GetFixedString(in PRUint32 count, [size_is(count)out string out_str); + return "A" * count + + # DoubleWideString functions are identical to DoubleString, except use wide chars! + def DoubleWideString(self, val): + return val * 2 + def DoubleWideString2(self, val): + return val * 2 + def DoubleWideString3(self, val): + return val * 2 + def DoubleWideString4(self, val): + return val * 2 + def UpWideString(self, val): + return val.upper() + UpWideString2 = UpWideString + def CopyUTF8String(self, v): + return v + def CopyUTF8String2(self, v): + return v.encode("utf8") + # Test we can get an "out" array with an "in" size (and the size is not used anywhere as a size for an in!) + def GetFixedWideString(self, count): + # void GetFixedWideString(in PRUint32 count, [size_is(count)out string out_str); + return u"A" * count + + def GetStrings(self): + # void GetStrings(out PRUint32 count, + # [retval, array, size_is(count)] out string str); + return "Hello from the Python test component".split() + # Some tests for our special "PRUint8" support. + def UpOctetArray( self, data ): + # void UpOctetArray(inout PRUint32 count, + # [array, size_is(count)] inout PRUint8 data); + return data.upper() + + def UpOctetArray2( self, data ): + # void UpOctetArray2(inout PRUint32 count, + # [array, size_is(count)] inout PRUint8 data); + data = data.upper() + # This time we return a list of integers. + return map( ord, data ) + + # Arrays of interfaces + def CheckInterfaceArray(self, interfaces): + # void CheckInterfaceArray(in PRUint32 count, + # [array, size_is(count)] in nsISupports data, + # [retval] out PRBool all_non_null); + ret = 1 + for i in interfaces: + if i is None: + ret = 0 + break + return ret + def CopyInterfaceArray(self, a): + return a + def GetInterfaceArray(self): + # void GetInterfaceArray(out PRUint32 count, + # [array, size_is(count)] out nsISupports data); + return self, self, self, None + def ExtendInterfaceArray(self, data): + # void ExtendInterfaceArray(inout PRUint32 count, + # [array, size_is(count)] inout nsISupports data); + return data * 2 + + # Arrays of IIDs + def CheckIIDArray(self, data): + # void CheckIIDArray(in PRUint32 count, + # [array, size_is(count)] in nsIIDRef data, + # [retval] out PRBool all_mine); + ret = 1 + for i in data: + if i!= self._com_interfaces_ and i != self._reg_clsid_: + ret = 0 + break + return ret + def GetIIDArray(self): + # void GetIIDArray(out PRUint32 count, + # [array, size_is(count)] out nsIIDRef data); + return self._com_interfaces_, self._reg_clsid_ + def ExtendIIDArray(self, data): + # void ExtendIIDArray(inout PRUint32 count, + # [array, size_is(count)] inout nsIIDRef data); + return data * 2 + + # Test our count param can be shared as an "in" param. + def SumArrays(self, array1, array2): + # void SumArrays(in PRUint32 count, [array, size_is(count)]in array1, [array, size_is(count)]in array2, [retval]result); + if len(array1)!=len(array2): + print "SumArrays - not expecting different lengths!" + result = 0 + for i in array1: + result = result + i + for i in array2: + result = result+i + return result + + # Test our count param can be shared as an "out" param. + def GetArrays(self): + # void GetArrays(out PRUint32 count, [array, size_is(count)]out array1, [array, size_is(count)]out array2); + return (1,2,3), (4,5,6) + # Test we can get an "out" array with an "in" size + def GetFixedArray(self, size): + # void GetFixedArray(in PRUint32 count, [array, size_is(count)]out PRInt32 array1]); + return 0 * size + + # Test our "in" count param can be shared as one "in", plus one "out" param. + def CopyArray(self, array1): + # void CopyArray(in PRUint32 count, [array, size_is(count)]in array1, [array, size_is(count)]out array2); + return array1 + # Test our "in-out" count param can be shared as one "in", plus one "out" param. + def CopyAndDoubleArray(self, array): + # void CopyAndDoubleArray(inout PRUint32 count, [array, size_is(count)]in array1, [array, size_is(count)]out array2); + return array + array + # Test our "in-out" count param can be shared as one "in", plus one "in-out" param. + def AppendArray(self, array1, array2): + # void AppendArray(inout PRUint32 count, [array, size_is(count)]in array1, [array, size_is(count)]inout array2); + rc = array1 + if array2 is not None: + rc.extend(array2) + return rc + # Test nsIVariant support + def AppendVariant(self, invar, inresult): + if type(invar)==type([]): + invar_use = invar[0] + for v in invar[1:]: + invar_use += v + else: + invar_use = invar + if type(inresult)==type([]): + inresult_use = inresult[0] + for v in inresult[1:]: + inresult_use += v + else: + inresult_use = inresult + if inresult_use is None and invar_use is None: + return None + return inresult_use + invar_use + + def CopyVariant(self, invar): + return invar + + def SumVariants(self, variants): + if len(variants) == 0: + return None + result = variants[0] + for v in variants[1:]: + result += v + return result + + # Some tests for the "new" (Feb-2001) DOMString type. + def GetDOMStringResult( self, length ): + # Result: DOMString & + if length == -1: + return None + return "P" * length + def GetDOMStringOut( self, length ): + # Result: DOMString & + if length == -1: + return None + return "y" * length + def GetDOMStringLength( self, param0 ): + # Result: uint32 + # In: param0: DOMString & + if param0 is None: return -1 + return len(param0) + + def GetDOMStringRefLength( self, param0 ): + # Result: uint32 + # In: param0: DOMString & + if param0 is None: return -1 + return len(param0) + + def GetDOMStringPtrLength( self, param0 ): + # Result: uint32 + # In: param0: DOMString * + if param0 is None: return -1 + return len(param0) + + def ConcatDOMStrings( self, param0, param1 ): + # Result: void - None + # In: param0: DOMString & + # In: param1: DOMString & + # Out: DOMString & + return param0 + param1 + def get_domstring_value( self ): + # Result: DOMString & + return self.domstring_value + def set_domstring_value( self, param0 ): + # Result: void - None + # In: param0: DOMString & + self.domstring_value = param0 + + def get_domstring_value_ro( self ): + # Result: DOMString & + return self.domstring_value diff --git a/src/libs/xpcom18a4/python/test/test_components.py b/src/libs/xpcom18a4/python/test/test_components.py new file mode 100755 index 00000000..80007722 --- /dev/null +++ b/src/libs/xpcom18a4/python/test/test_components.py @@ -0,0 +1,109 @@ +# ***** 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 the Python XPCOM language bindings. +# +# The Initial Developer of the Original Code is +# ActiveState Tool Corp. +# Portions created by the Initial Developer are Copyright (C) 2000, 2001 +# the Initial Developer. All Rights Reserved. +# +# Contributor(s): +# Mark Hammond <markh@activestate.com> (original author) +# +# 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 ***** + +"""Tests the "xpcom.components" object. +""" + +import xpcom.components +from pyxpcom_test_tools import suite_from_functions, testmain + +if not __debug__: + raise RuntimeError, "This test uses assert, so must be run in debug mode" + +def test_interfaces(): + "Test the xpcom.components.interfaces object" + + iid = xpcom.components.interfaces.nsISupports + assert iid == xpcom._xpcom.IID_nsISupports, "Got the wrong IID!" + iid = xpcom.components.interfaces['nsISupports'] + assert iid == xpcom._xpcom.IID_nsISupports, "Got the wrong IID!" + + # Test dictionary semantics + num_fetched = num_nsisupports = 0 + for name, iid in xpcom.components.interfaces.items(): + num_fetched = num_fetched + 1 + if name == "nsISupports": + num_nsisupports = num_nsisupports + 1 + assert iid == xpcom._xpcom.IID_nsISupports, "Got the wrong IID!" + assert xpcom.components.interfaces[name] == iid + # Check all the lengths match. + assert len(xpcom.components.interfaces.keys()) == len(xpcom.components.interfaces.values()) == \ + len(xpcom.components.interfaces.items()) == len(xpcom.components.interfaces) == \ + num_fetched, "The collection lengths were wrong" + assert num_nsisupports == 1, "Didnt find exactly 1 nsiSupports!" + +def test_classes(): + # Need a well-known contractID here? + prog_id = "@mozilla.org/supports-array;1" + clsid = xpcom.components.ID("{bda17d50-0d6b-11d3-9331-00104ba0fd40}") + + # Check we can create the instance (dont check we can do anything with it tho!) + klass = xpcom.components.classes[prog_id] + instance = klass.createInstance() + + # Test dictionary semantics + num_fetched = num_mine = 0 + for name, klass in xpcom.components.classes.items(): + num_fetched = num_fetched + 1 + if name == prog_id: + assert klass.clsid == clsid, "Eeek - didn't get the correct IID - got %s" %klass.clsid + num_mine = num_mine + 1 + +# xpcom appears to add charset info to the contractid!? +# assert xpcom.components.classes[name].contractid == prog_id, "Expected '%s', got '%s'" % (prog_id, xpcom.components.classes[name].contractid) + # Check all the lengths match. + if len(xpcom.components.classes.keys()) == len(xpcom.components.classes.values()) == \ + len(xpcom.components.classes.items()) == len(xpcom.components.classes) == \ + num_fetched: + pass + else: + raise RuntimeError, "The collection lengths were wrong" + if num_fetched <= 0: + raise RuntimeError, "Didnt get any classes!!!" + if num_mine != 1: + raise RuntimeError, "Didnt find exactly 1 of my contractid! (%d)" % (num_mine,) + +def test_id(): + id = xpcom.components.ID(str(xpcom._xpcom.IID_nsISupports)) + assert id == xpcom._xpcom.IID_nsISupports + +# Make this test run under our std test suite +def suite(): + return suite_from_functions(test_interfaces, test_classes, test_id) + +if __name__=='__main__': + testmain() diff --git a/src/libs/xpcom18a4/python/test/test_isupports_primitives.py b/src/libs/xpcom18a4/python/test/test_isupports_primitives.py new file mode 100755 index 00000000..3d0e7023 --- /dev/null +++ b/src/libs/xpcom18a4/python/test/test_isupports_primitives.py @@ -0,0 +1,207 @@ +# ***** 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 the Python XPCOM language bindings. +# +# The Initial Developer of the Original Code is +# ActiveState Tool Corp. +# Portions created by the Initial Developer are Copyright (C) 2000, 2001 +# the Initial Developer. All Rights Reserved. +# +# Contributor(s): +# Mark Hammond <MarkH@ActiveState.com> (original author) +# +# 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 ***** + +# Test our support for the interfaces defined in nsISupportsPrimitives.idl +# +# The framework supports nsISupportsCString and nsISupportsString, but +# only if our class doesnt provide explicit support. + +from xpcom import components +from xpcom import primitives +import xpcom.server, xpcom.client +from pyxpcom_test_tools import testmain +import unittest + +class NoSupportsString: + _com_interfaces_ = [components.interfaces.nsISupports] + +class ImplicitSupportsString: + _com_interfaces_ = [components.interfaces.nsISupports] + def __str__(self): + return "<MyImplicitStrObject>" + +class ExplicitSupportsString: + _com_interfaces_ = [components.interfaces.nsISupportsPrimitive, + components.interfaces.nsISupportsCString] + type = components.interfaces.nsISupportsPrimitive.TYPE_CSTRING + test_data = "<MyExplicitStrObject>" + # __str__ will be ignored by XPCOM, as we have _explicit_ support. + def __str__(self): + return "<MyImplicitStrObject>" + # These are the ones that will be used. + def get_data(self): + return self.test_data + def toString(self): + return self.test_data + +class ImplicitSupportsUnicode: + _com_interfaces_ = [components.interfaces.nsISupports] + test_data = u"Copyright \xa9 the initial developer" + def __unicode__(self): + # An extended character in unicode tests can't hurt! + return self.test_data + +class ExplicitSupportsUnicode: + _com_interfaces_ = [components.interfaces.nsISupportsPrimitive, + components.interfaces.nsISupportsString] + type = components.interfaces.nsISupportsPrimitive.TYPE_STRING + # __unicode__ will be ignored by XPCOM, as we have _explicit_ support. + test_data = u"Copyright \xa9 the initial developer" + def __unicode__(self): + return self.test_data + def get_data(self): + return self.test_data + +class ImplicitSupportsInt: + _com_interfaces_ = [components.interfaces.nsISupports] + def __int__(self): + return 99 + +class ExplicitSupportsInt: + _com_interfaces_ = [components.interfaces.nsISupportsPrimitive, + components.interfaces.nsISupportsPRInt32] + type = components.interfaces.nsISupportsPrimitive.TYPE_PRINT32 + def get_data(self): + return 99 + +class ImplicitSupportsLong: + _com_interfaces_ = [components.interfaces.nsISupports] + def __long__(self): + return 99L + +class ExplicitSupportsLong: + _com_interfaces_ = [components.interfaces.nsISupportsPrimitive, + components.interfaces.nsISupportsPRInt64] + type = components.interfaces.nsISupportsPrimitive.TYPE_PRINT64 + def get_data(self): + return 99 + +class ExplicitSupportsFloat: + _com_interfaces_ = [components.interfaces.nsISupportsPrimitive, + components.interfaces.nsISupportsDouble] + type = components.interfaces.nsISupportsPrimitive.TYPE_DOUBLE + def get_data(self): + return 99.99 + +class ImplicitSupportsFloat: + _com_interfaces_ = [components.interfaces.nsISupports] + def __float__(self): + return 99.99 + +class PrimitivesTestCase(unittest.TestCase): + def testNoSupports(self): + ob = xpcom.server.WrapObject( NoSupportsString(), components.interfaces.nsISupports) + if not str(ob).startswith("<XPCOM "): + raise RuntimeError, "Wrong str() value: %s" % (ob,) + + def testImplicitString(self): + ob = xpcom.server.WrapObject( ImplicitSupportsString(), components.interfaces.nsISupports) + self.failUnlessEqual(str(ob), "<MyImplicitStrObject>") + + def testExplicitString(self): + ob = xpcom.server.WrapObject( ExplicitSupportsString(), components.interfaces.nsISupports) + self.failUnlessEqual(str(ob), "<MyExplicitStrObject>") + + def testImplicitUnicode(self): + ob = xpcom.server.WrapObject( ImplicitSupportsUnicode(), components.interfaces.nsISupports) + self.failUnlessEqual(unicode(ob), ImplicitSupportsUnicode.test_data) + + def testExplicitUnicode(self): + ob = xpcom.server.WrapObject( ExplicitSupportsUnicode(), components.interfaces.nsISupports) + self.failUnlessEqual(unicode(ob), ExplicitSupportsUnicode.test_data) + + def testConvertInt(self): + # Try our conversions. + ob = xpcom.server.WrapObject( ExplicitSupportsString(), components.interfaces.nsISupports) + self.failUnlessRaises( ValueError, int, ob) + + def testExplicitInt(self): + ob = xpcom.server.WrapObject( ExplicitSupportsInt(), components.interfaces.nsISupports) + self.failUnlessAlmostEqual(float(ob), 99.0) + self.failUnlessEqual(int(ob), 99) + + def testImplicitInt(self): + ob = xpcom.server.WrapObject( ImplicitSupportsInt(), components.interfaces.nsISupports) + self.failUnlessAlmostEqual(float(ob), 99.0) + self.failUnlessEqual(int(ob), 99) + + def testExplicitLong(self): + ob = xpcom.server.WrapObject( ExplicitSupportsLong(), components.interfaces.nsISupports) + if long(ob) != 99 or not repr(long(ob)).endswith("L"): + raise RuntimeError, "Bad value: %s" % (repr(long(ob)),) + self.failUnlessAlmostEqual(float(ob), 99.0) + + def testImplicitLong(self): + ob = xpcom.server.WrapObject( ImplicitSupportsLong(), components.interfaces.nsISupports) + if long(ob) != 99 or not repr(long(ob)).endswith("L"): + raise RuntimeError, "Bad value: %s" % (repr(long(ob)),) + self.failUnlessAlmostEqual(float(ob), 99.0) + + def testExplicitFloat(self): + ob = xpcom.server.WrapObject( ExplicitSupportsFloat(), components.interfaces.nsISupports) + self.failUnlessEqual(float(ob), 99.99) + self.failUnlessEqual(int(ob), 99) + + def testImplicitFloat(self): + ob = xpcom.server.WrapObject( ImplicitSupportsFloat(), components.interfaces.nsISupports) + self.failUnlessEqual(float(ob), 99.99) + self.failUnlessEqual(int(ob), 99) + +class PrimitivesModuleTestCase(unittest.TestCase): + def testExplicitString(self): + ob = xpcom.server.WrapObject( ExplicitSupportsString(), components.interfaces.nsISupports) + self.failUnlessEqual(primitives.GetPrimitive(ob), "<MyExplicitStrObject>") + + def testExplicitUnicode(self): + ob = xpcom.server.WrapObject( ExplicitSupportsUnicode(), components.interfaces.nsISupports) + self.failUnlessEqual(primitives.GetPrimitive(ob), ExplicitSupportsUnicode.test_data) + self.failUnlessEqual(type(primitives.GetPrimitive(ob)), unicode) + + def testExplicitInt(self): + ob = xpcom.server.WrapObject( ExplicitSupportsInt(), components.interfaces.nsISupports) + self.failUnlessEqual(primitives.GetPrimitive(ob), 99) + + def testExplicitLong(self): + ob = xpcom.server.WrapObject( ExplicitSupportsLong(), components.interfaces.nsISupports) + self.failUnlessEqual(primitives.GetPrimitive(ob), 99) + + def testExplicitFloat(self): + ob = xpcom.server.WrapObject( ExplicitSupportsFloat(), components.interfaces.nsISupports) + self.failUnlessEqual(primitives.GetPrimitive(ob), 99.99) + +if __name__=='__main__': + testmain() diff --git a/src/libs/xpcom18a4/python/test/test_misc.py b/src/libs/xpcom18a4/python/test/test_misc.py new file mode 100755 index 00000000..6cf1b74e --- /dev/null +++ b/src/libs/xpcom18a4/python/test/test_misc.py @@ -0,0 +1,236 @@ +# ***** 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 the Python XPCOM language bindings. +# +# The Initial Developer of the Original Code is +# Activestate Tool Corp. +# Portions created by the Initial Developer are Copyright (C) 2000 +# the Initial Developer. All Rights Reserved. +# +# Contributor(s): +# Mark Hammond <MarkH@ActiveState.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 xpcom +import xpcom.client +import xpcom.server +import xpcom._xpcom +import xpcom.components +import string +from pyxpcom_test_tools import testmain + +import unittest + +import traceback, getopt, sys + +verbose_level = 0 + +reportedSampleMissing = 0 + +def get_sample_component_cpp(): + global reportedSampleMissing + contractid = "@mozilla.org/sample;1" # The C++ version. + try: + return xpcom.components.classes[contractid].createInstance() + except xpcom.COMException: + if not reportedSampleMissing: + print "***" + print "*** This test requires an XPCOM sample component," + print "*** which does not exist. To build this test, you" + print "*** should change to the 'mozilla/xpcom/sample' directory," + print "*** and run 'make', then run this test again." + print "***" + reportedSampleMissing = 1 + else: + print "(skipping - no C++ sample...) ", + return None + +def get_sample_component_js(): + # This should *always* exist - no special make process. + contractid = "@mozilla.org/jssample;1" # the JS version + return xpcom.components.classes[contractid].createInstance() + +class TestDumpInterfaces(unittest.TestCase): + def testAllInterfaces(self): + "Dump every interface under the sun!" + import xpcom, xpcom.xpt, xpcom._xpcom + iim = xpcom._xpcom.XPTI_GetInterfaceInfoManager() + + if verbose_level: + print "Dumping every interface I can find" + enum = iim.EnumerateInterfaces() + rc = enum.First() + num = 0 + while rc==0: + item = enum.CurrentItem(xpcom._xpcom.IID_nsIInterfaceInfo) + try: + iid = item.GetIID() + except xpcom.COMException: + if verbose_level: + print "Can't dump", item + continue # Dont bother dumping this. + interface = xpcom.xpt.Interface(iid) + num = num + 1 + text = interface.Describe() + if verbose_level: + print text + + rc = enum.Next() + if num < 200: + print "Only found", num, "interfaces - this seems unusually low!" + +class TestEnumContractIDs(unittest.TestCase): + def testContractIDs(self): + """Enumerate all the ContractIDs registered""" + enum = xpcom.components.registrar.enumerateContractIDs() + n = 0 + while enum.hasMoreElements(): + item = enum.getNext(xpcom.components.interfaces.nsISupportsCString) + n = n + 1 + if verbose_level: + print "ContractID:", item.data + if n < 200: + print "Only found", n, "ContractIDs - this seems unusually low!" + +class TestSampleComponent(unittest.TestCase): + def _doTestSampleComponent(self, test_flat = 0): + """Test the standard Netscape 'sample' sample""" + c = get_sample_component_cpp() + if c is None: + return + if not test_flat: + c = c.queryInterface(xpcom.components.interfaces.nsISample) + self.failUnlessEqual(c.value, "initial value") + c.value = "new value" + self.failUnlessEqual(c.value, "new value") + c.poke("poked value") + self.failUnlessEqual(c.value, "poked value") + c.writeValue("Python just poked:") + + def testSampleComponentFlat(self): + """Test the standard Netscape 'sample' sample using interface flattening""" + self._doTestSampleComponent(1) + + def testSampleComponentOld(self): + """Test the standard Netscape 'sample' sample using explicit QI""" + self._doTestSampleComponent(0) + + def _doTestHash(self, c): + "Test that hashing COM objects works" + d = {} + d[c] = None + if not d.has_key(c): + raise RuntimeError, "Can't get the exact same object back!" + if not d.has_key(c.queryInterface(xpcom.components.interfaces.nsISupports)): + raise RuntimeError, "Can't get back as nsISupports" + + # And the same in reverse - stick an nsISupports in, and make sure an explicit interface comes back. + d = {} +# contractid = "@mozilla.org/sample;1" # The C++ version. +# c = xpcom.components.classes[contractid].createInstance() \ +# .queryInterface(xpcom.components.interfaces.nsISupports) + d[c] = None + if not d.has_key(c): + raise RuntimeError, "Can't get the exact same object back!" + if not d.has_key(c.queryInterface(xpcom.components.interfaces.nsISample)): + raise RuntimeError, "Can't get back as nsISupports" + + def testHashJS(self): + c = get_sample_component_js() + self._doTestHash(c) + + def testHashCPP(self): + c = get_sample_component_cpp() + if c is not None: + self._doTestHash(c) + + +class TestIIDs(unittest.TestCase): + def TestIIDs(self): + "Do some basic IID semantic tests." + iid_str = "{7ee4bdc6-cb53-42c1-a9e4-616b8e012aba}" + IID = xpcom._xpcom.IID + self.failUnlessEqual(IID(iid_str), IID(iid_str)) + self.failUnlessEqual(hash(IID(iid_str)), hash(IID(iid_str))) + self.failUnlessEqual(IID(iid_str), IID(iid_str.upper())) + self.failUnlessEqual(hash(IID(iid_str)), hash(IID(iid_str.upper()))) + # If the above work, this shoud too, but WTF + dict = {} + dict[IID(iid_str)] = None + self.failUnless(dict.has_key(IID(iid_str)), "hashes failed in dictionary") + self.failUnless(dict.has_key(IID(iid_str.upper())), "uppercase hash failed in dictionary") + +class TestRepr(unittest.TestCase): + def _doTestRepr(self, progid, interfaces): + if isinstance(progid, str): + ob = xpcom.components.classes[progid].createInstance() + else: + ob = progid + self.failUnless(repr(ob).find(str(progid)) >= 0, repr(ob)) + for interface_name in interfaces.split(): + self.failUnless(repr(ob).find(interface_name) >= 0, repr(ob)) + + def testReprPython(self): + "Test repr() of Python objects" + self._doTestRepr("Python.TestComponent", "nsIPythonTestInterfaceDOMStrings nsIPythonTestInterfaceExtra nsIPythonTestInterface") + + # JS does not provide class-info :( + #def testReprJS(self): + # self._doTestRepr("@mozilla.org/jssample;1", "nsISample") + + def testReprSample(self): + "Test repr() of non-Python objects" + ob = get_sample_component_cpp() + if ob is None: + return + self._doTestRepr(ob, "nsISample") + +class TestUnwrap(unittest.TestCase): + "Test the unwrap facilities" + def testUnwrap(self): + # First test that a Python object can be unwrapped. + ob = xpcom.components.classes["Python.TestComponent"].createInstance() + pyob = xpcom.server.UnwrapObject(ob) + # This depends on our __repr__ implementation, but that's OK - it + # can be updated should our __repr__ change :) + self.failUnless(str(pyob).startswith("<component:py_test_component.PythonTestComponent")) + # Test that a non-Python implemented object can NOT be unwrapped. + ob = get_sample_component_cpp() + if ob is None: + return + self.failUnlessRaises(ValueError, xpcom.server.UnwrapObject, ob) + +class TestNonScriptable(unittest.TestCase): + def testQI(self): + # Test we can QI for a non-scriptable interface. We can't *do* much + # with it (other than pass it on), but we should still work and get + # a basic wrapper. + ob = xpcom.components.classes["Python.TestComponent"].createInstance() + ob = ob.queryInterface(xpcom._xpcom.IID_nsIInternalPython) + +if __name__=='__main__': + testmain() diff --git a/src/libs/xpcom18a4/python/test/test_streams.py b/src/libs/xpcom18a4/python/test/test_streams.py new file mode 100755 index 00000000..96ac6559 --- /dev/null +++ b/src/libs/xpcom18a4/python/test/test_streams.py @@ -0,0 +1,96 @@ +# ***** 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 the Python XPCOM language bindings. +# +# The Initial Developer of the Original Code is +# ActiveState Tool Corp. +# Portions created by the Initial Developer are Copyright (C) 2000,2001 +# the Initial Developer. All Rights Reserved. +# +# Contributor(s): +# Mark Hammond <MarkH@ActiveState.com> (original author) +# +# 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 xpcom +from xpcom import _xpcom, components, COMException, ServerException, nsError +from StringIO import StringIO +import unittest +from pyxpcom_test_tools import testmain + +test_data = "abcdefeghijklmnopqrstuvwxyz" + +class koTestSimpleStream: + _com_interfaces_ = [components.interfaces.nsIInputStream] + # We avoid registering this object - see comments in get_test_inout_? below. + + def __init__(self): + self.data=StringIO(test_data) + self._non_blocking = False + + def close( self ): + pass + + def available( self ): + return self.data.len-self.data.pos + + def readStr( self, amount): + return self.data.read(amount) + + read=readStr + + def get_observer( self ): + raise ServerException(nsError.NS_ERROR_NOT_IMPLEMENTED) + + def set_observer( self, param0 ): + raise ServerException(nsError.NS_ERROR_NOT_IMPLEMENTED) + + def isNonBlocking(self): + return self._non_blocking + +def get_test_input(): + # We use a couple of internal hacks here that mean we can avoid having the object + # registered. This code means that we are still working over the xpcom boundaries, tho + # (and the point of this test is not the registration, etc). + import xpcom.server, xpcom.client + ob = xpcom.server.WrapObject( koTestSimpleStream(), _xpcom.IID_nsISupports) + ob = xpcom.client.Component(ob._comobj_, components.interfaces.nsIInputStream) + return ob + +class StreamTests(unittest.TestCase): + def testInput(self): + self.do_test_input( get_test_input() ) + + def do_test_input(self, myStream): + self.failUnlessEqual(str(myStream.read(5)), test_data[:5]) + self.failUnlessEqual(str(myStream.read(0)), '') + self.failUnlessEqual(str(myStream.read(5)), test_data[5:10]) + self.failUnlessEqual(str(myStream.read(-1)), test_data[10:]) + self.failIf(myStream.isNonBlocking(), "Expected default to be blocking") + # stream observer mechanism has changed - we should test that. + +if __name__=='__main__': + testmain() diff --git a/src/libs/xpcom18a4/python/test/test_test_component.js b/src/libs/xpcom18a4/python/test/test_test_component.js new file mode 100644 index 00000000..54e39382 --- /dev/null +++ b/src/libs/xpcom18a4/python/test/test_test_component.js @@ -0,0 +1,138 @@ +/* ***** 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 the Python XPCOM language bindings. + * + * The Initial Developer of the Original Code is + * ActiveState Tool Corp. + * Portions created by the Initial Developer are Copyright (C) 2000 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Mark Hammond <MarkH@ActiveState.com> (original author) + * + * 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 ***** */ + +/* Javascript code calling the Python test interface. */ + +var extended_unicode_string = "The Euro Symbol is '\u20ac'"; + +function MakeTestInterface() +{ + var clazz = Components.classes["Python.TestComponent"]; + var iface = Components.interfaces.nsIPythonTestInterfaceDOMStrings; + return new clazz(iface); +} + +var c = new MakeTestInterface(); + +if (c.boolean_value != 1) + throw("boolean_value has wrong initial value"); +c.boolean_value = false; +if (c.boolean_value != false) + throw("boolean_value has wrong new value"); + +// Python's own test does thorough testing of all numeric types +// Wont bother from here! + +if (c.char_value != 'a') + throw("char_value has wrong initial value"); +c.char_value = 'b'; +if (c.char_value != 'b') + throw("char_value has wrong new value"); + +if (c.wchar_value != 'b') + throw("wchar_value has wrong initial value"); +c.wchar_value = 'c'; +if (c.wchar_value != 'c') + throw("wchar_value has wrong new value"); + +if (c.string_value != 'cee') + throw("string_value has wrong initial value"); +c.string_value = 'dee'; +if (c.string_value != 'dee') + throw("string_value has wrong new value"); + +if (c.wstring_value != 'dee') + throw("wstring_value has wrong initial value"); +c.wstring_value = 'eee'; +if (c.wstring_value != 'eee') + throw("wstring_value has wrong new value"); +c.wstring_value = extended_unicode_string; +if (c.wstring_value != extended_unicode_string) + throw("wstring_value has wrong new value"); + +if (c.domstring_value != 'dom') + throw("domstring_value has wrong initial value"); +c.domstring_value = 'New value'; +if (c.domstring_value != 'New value') + throw("domstring_value has wrong new value"); +c.domstring_value = extended_unicode_string; +if (c.domstring_value != extended_unicode_string) + throw("domstring_value has wrong new value"); + +if (c.utf8string_value != 'utf8string') + throw("utf8string_value has wrong initial value"); +c.utf8string_value = 'New value'; +if (c.utf8string_value != 'New value') + throw("utf8string_value has wrong new value"); +c.utf8string_value = extended_unicode_string; +if (c.utf8string_value != extended_unicode_string) + throw("utf8string_value has wrong new value"); + +var v = new Object(); +v.value = "Hello" +var l = new Object(); +l.value = v.value.length; +c.DoubleString(l, v); +if ( v.value != "HelloHello") + throw("Could not double the string!"); + +var v = new Object(); +v.value = "Hello" +var l = new Object(); +l.value = v.value.length; +c.DoubleWideString(l, v); +if ( v.value != "HelloHello") + throw("Could not double the wide string!"); + +// Some basic array tests +var v = new Array() +v[0] = 1; +v[2] = 2; +v[3] = 3; +var v2 = new Array() +v2[0] = 4; +v2[2] = 5; +v2[3] = 6; +if (c.SumArrays(v.length, v, v2) != 21) + throw("Could not sum an array of integers!"); + +var count = new Object(); +count.value = 0; +var out = []; +c.DoubleStringArray(count, out); + +print("javascript successfully tested the Python test component."); diff --git a/src/libs/xpcom18a4/python/test/test_test_component.py b/src/libs/xpcom18a4/python/test/test_test_component.py new file mode 100755 index 00000000..dd78133a --- /dev/null +++ b/src/libs/xpcom18a4/python/test/test_test_component.py @@ -0,0 +1,575 @@ +# ***** 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 the Python XPCOM language bindings. +# +# The Initial Developer of the Original Code is +# ActiveState Tool Corp. +# Portions created by the Initial Developer are Copyright (C) 2000, 2001 +# the Initial Developer. All Rights Reserved. +# +# Contributor(s): +# Mark Hammond <MarkH@ActiveState.com> (original author) +# +# 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 sys, os, time +import xpcom.components +import xpcom._xpcom +import xpcom.nsError + +MakeVariant = xpcom._xpcom.MakeVariant + +try: + import gc +except ImportError: + gc = None + +num_errors = 0 + +component_iid = xpcom.components.ID("{7EE4BDC6-CB53-42c1-A9E4-616B8E012ABA}") +new_iid = xpcom.components.ID("{2AF747D3-ECBC-457b-9AF9-5C5D80EDC360}") + +contractid = "Python.TestComponent" + +really_big_string = "This is really repetitive!" * 10000 +really_big_wstring = u"This is really repetitive!" * 10000 +extended_unicode_string = u"The Euro Symbol is '\u20ac'" + +# Exception raised when a -ve integer is converted to an unsigned C integer +# (via an extension module). This changed in Python 2.2 +if sys.hexversion > 0x02010000: + UnsignedMismatchException = TypeError +else: + UnsignedMismatchException = OverflowError + +def print_error(error): + print error + global num_errors + num_errors = num_errors + 1 + +def _test_value(what, got, expecting): + ok = got == expecting + if type(got)==type(expecting)==type(0.0): + ok = abs(got-expecting) < 0.001 + if not ok: + print_error("*** Error %s - got '%r', but expecting '%r'" % (what, got, expecting)) + +def test_attribute(ob, attr_name, expected_init, new_value, new_value_really = None): + if xpcom.verbose: + print "Testing attribute %s" % (attr_name,) + if new_value_really is None: + new_value_really = new_value # Handy for eg bools - set a BOOL to 2, you still get back 1! + + _test_value( "getting initial attribute value (%s)" % (attr_name,), getattr(ob, attr_name), expected_init) + setattr(ob, attr_name, new_value) + _test_value( "getting new attribute value (%s)" % (attr_name,), getattr(ob, attr_name), new_value_really) + # And set it back to the expected init. + setattr(ob, attr_name, expected_init) + _test_value( "getting back initial attribute value after change (%s)" % (attr_name,), getattr(ob, attr_name), expected_init) + +def test_string_attribute(ob, attr_name, expected_init, is_dumb_sz = False, ascii_only = False): + test_attribute(ob, attr_name, expected_init, "normal value") + val = "a null >\0<" + if is_dumb_sz: + expected = "a null >" # dumb strings are \0 terminated. + else: + expected = val + test_attribute(ob, attr_name, expected_init, val, expected) + test_attribute(ob, attr_name, expected_init, "") + test_attribute(ob, attr_name, expected_init, really_big_string) + test_attribute(ob, attr_name, expected_init, u"normal unicode value") + val = u"a null >\0<" + if is_dumb_sz: + expected = "a null >" # dumb strings are \0 terminated. + else: + expected = val + test_attribute(ob, attr_name, expected_init, val, expected) + test_attribute(ob, attr_name, expected_init, u"") + test_attribute(ob, attr_name, expected_init, really_big_wstring) + if not ascii_only: + test_attribute(ob, attr_name, expected_init, extended_unicode_string) + +def test_attribute_failure(ob, attr_name, new_value, expected_exception): + try: + setattr(ob, attr_name, new_value) + print_error("*** Setting attribute '%s' to '%r' didnt yield an exception!" % (attr_name, new_value) ) + except: + exc_typ = sys.exc_info()[0] + exc_val = sys.exc_info()[1] + ok = issubclass(exc_typ, expected_exception) + if not ok: + print_error("*** Wrong exception setting '%s' to '%r'- got '%s: %s', expected '%s'" % (attr_name, new_value, exc_typ, exc_val, expected_exception)) + + +def test_method(method, args, expected_results): + if xpcom.verbose: + print "Testing %s%s" % (method.__name__, `args`) + ret = method(*args) + if ret != expected_results: + print_error("calling method %s - expected %r, but got %r" % (method.__name__, expected_results, ret)) + +def test_int_method(meth): + test_method(meth, (0,0), (0,0,0)) + test_method(meth, (1,1), (2,0,1)) + test_method(meth, (5,2), (7,3,10)) +# test_method(meth, (2,5), (7,-3,10)) + +def test_constant(ob, cname, val): + v = getattr(ob, cname) + if v != val: + print_error("Bad value for constant '%s' - got '%r'" % (cname, v)) + try: + setattr(ob, cname, 0) + print_error("The object allowed us to set the constant '%s'" % (cname,)) + except AttributeError: + pass + +def test_base_interface(c): + test_attribute(c, "boolean_value", 1, 0) + test_attribute(c, "boolean_value", 1, -1, 1) # Set a bool to anything, you should always get back 0 or 1 + test_attribute(c, "boolean_value", 1, 4, 1) # Set a bool to anything, you should always get back 0 or 1 + test_attribute(c, "boolean_value", 1, "1", 1) # This works by virtual of PyNumber_Int - not sure I agree, but... + test_attribute_failure(c, "boolean_value", "boo", ValueError) + test_attribute_failure(c, "boolean_value", test_base_interface, TypeError) + + test_attribute(c, "octet_value", 2, 5) + test_attribute(c, "octet_value", 2, 0) + test_attribute(c, "octet_value", 2, 128) # octet is unsigned 8 bit + test_attribute(c, "octet_value", 2, 255) # octet is unsigned 8 bit + test_attribute(c, "octet_value", 2, -1, 255) # octet is unsigned 8 bit + test_attribute_failure(c, "octet_value", "boo", ValueError) + + test_attribute(c, "short_value", 3, 10) + test_attribute(c, "short_value", 3, -1) # 16 bit signed + test_attribute(c, "short_value", 3, 0xFFFF, -1) # 16 bit signed + test_attribute(c, "short_value", 3, 0L) + test_attribute(c, "short_value", 3, 1L) + test_attribute(c, "short_value", 3, -1L) + test_attribute(c, "short_value", 3, 0xFFFFL, -1) + test_attribute_failure(c, "short_value", "boo", ValueError) + + test_attribute(c, "ushort_value", 4, 5) + test_attribute(c, "ushort_value", 4, 0) + test_attribute(c, "ushort_value", 4, -1, 0xFFFF) # 16 bit signed + test_attribute(c, "ushort_value", 4, 0xFFFF) # 16 bit signed + test_attribute(c, "ushort_value", 4, 0L) + test_attribute(c, "ushort_value", 4, 1L) + test_attribute(c, "ushort_value", 4, -1L, 0xFFFF) + test_attribute_failure(c, "ushort_value", "boo", ValueError) + + test_attribute(c, "long_value", 5, 7) + test_attribute(c, "long_value", 5, 0) + test_attribute(c, "long_value", 5, -1, -1) # 32 bit signed. + test_attribute(c, "long_value", 5, -1) # 32 bit signed. + test_attribute(c, "long_value", 5, 0L) + test_attribute(c, "long_value", 5, 1L) + test_attribute(c, "long_value", 5, -1L) + test_attribute_failure(c, "long_value", 0xFFFFL * 0xFFFF, OverflowError) # long int too long to convert + test_attribute_failure(c, "long_value", "boo", ValueError) + + test_attribute(c, "ulong_value", 6, 7) + test_attribute(c, "ulong_value", 6, 0) + test_attribute(c, "ulong_value", 6, -1) # 32 bit signed. + test_attribute_failure(c, "ulong_value", "boo", ValueError) + + test_attribute(c, "long_long_value", 7, 8) + test_attribute(c, "long_long_value", 7, 0) + test_attribute(c, "long_long_value", 7, -1) + test_attribute(c, "long_long_value", 7, 0xFFFF) + test_attribute(c, "long_long_value", 7, 0xFFFFL * 2) + test_attribute_failure(c, "long_long_value", 0xFFFFL * 0xFFFF * 0xFFFF * 0xFFFF, OverflowError) # long int too long to convert + test_attribute_failure(c, "long_long_value", "boo", ValueError) + + test_attribute(c, "ulong_long_value", 8, 9) + test_attribute(c, "ulong_long_value", 8, 0) + test_attribute_failure(c, "ulong_long_value", "boo", ValueError) + test_attribute_failure(c, "ulong_long_value", -1, UnsignedMismatchException) # can't convert negative value to unsigned long) + + test_attribute(c, "float_value", 9.0, 10.2) + test_attribute(c, "float_value", 9.0, 0) + test_attribute(c, "float_value", 9.0, -1) + test_attribute(c, "float_value", 9.0, 1L) + test_attribute_failure(c, "float_value", "boo", ValueError) + + test_attribute(c, "double_value", 10.0, 9.0) + test_attribute(c, "double_value", 10.0, 0) + test_attribute(c, "double_value", 10.0, -1) + test_attribute(c, "double_value", 10.0, 1L) + test_attribute_failure(c, "double_value", "boo", ValueError) + + test_attribute(c, "char_value", "a", "b") + test_attribute(c, "char_value", "a", "\0") + test_attribute_failure(c, "char_value", "xy", ValueError) + test_attribute(c, "char_value", "a", u"c") + test_attribute(c, "char_value", "a", u"\0") + test_attribute_failure(c, "char_value", u"xy", ValueError) + + test_attribute(c, "wchar_value", "b", "a") + test_attribute(c, "wchar_value", "b", "\0") + test_attribute_failure(c, "wchar_value", "hi", ValueError) + test_attribute(c, "wchar_value", "b", u"a") + test_attribute(c, "wchar_value", "b", u"\0") + test_attribute_failure(c, "wchar_value", u"hi", ValueError) + + test_string_attribute(c, "string_value", "cee", is_dumb_sz = True, ascii_only = True) + test_string_attribute(c, "wstring_value", "dee", is_dumb_sz = True) + test_string_attribute(c, "astring_value", "astring") + test_string_attribute(c, "acstring_value", "acstring", ascii_only = True) + + test_string_attribute(c, "utf8string_value", "utf8string") + # Test a string already encoded gets through correctly. + test_attribute(c, "utf8string_value", "utf8string", extended_unicode_string.encode("utf8"), extended_unicode_string) + + # This will fail internal string representation :( Test we don't crash + try: + c.wstring_value = "a big char >" + chr(129) + "<" + print_error("strings with chars > 128 appear to have stopped failing?") + except UnicodeError: + pass + + test_attribute(c, "iid_value", component_iid, new_iid) + test_attribute(c, "iid_value", component_iid, str(new_iid), new_iid) + test_attribute(c, "iid_value", component_iid, xpcom._xpcom.ID(new_iid)) + + test_attribute_failure(c, "no_attribute", "boo", AttributeError) + + test_attribute(c, "interface_value", None, c) + test_attribute_failure(c, "interface_value", 2, TypeError) + + test_attribute(c, "isupports_value", None, c) + + # The methods + test_method(c.do_boolean, (0,1), (1,0,1)) + test_method(c.do_boolean, (1,0), (1,0,1)) + test_method(c.do_boolean, (1,1), (0,1,0)) + + test_int_method(c.do_octet) + test_int_method(c.do_short) + + test_int_method(c.do_unsigned_short) + test_int_method(c.do_long) + test_int_method(c.do_unsigned_long) + test_int_method(c.do_long_long) + test_int_method(c.do_unsigned_long) + test_int_method(c.do_float) + test_int_method(c.do_double) + + test_method(c.do_char, ("A", " "), (chr(ord("A")+ord(" ")), " ","A") ) + test_method(c.do_char, ("A", "\0"), ("A", "\0","A") ) + test_method(c.do_wchar, ("A", " "), (chr(ord("A")+ord(" ")), " ","A") ) + test_method(c.do_wchar, ("A", "\0"), ("A", "\0","A") ) + + test_method(c.do_string, ("Hello from ", "Python"), ("Hello from Python", "Hello from ", "Python") ) + test_method(c.do_string, (u"Hello from ", u"Python"), ("Hello from Python", "Hello from ", "Python") ) + test_method(c.do_string, (None, u"Python"), ("Python", None, "Python") ) + test_method(c.do_string, (None, really_big_string), (really_big_string, None, really_big_string) ) + test_method(c.do_string, (None, really_big_wstring), (really_big_string, None, really_big_string) ) + test_method(c.do_wstring, ("Hello from ", "Python"), ("Hello from Python", "Hello from ", "Python") ) + test_method(c.do_wstring, (u"Hello from ", u"Python"), ("Hello from Python", "Hello from ", "Python") ) + test_method(c.do_string, (None, really_big_wstring), (really_big_wstring, None, really_big_wstring) ) + test_method(c.do_string, (None, really_big_string), (really_big_wstring, None, really_big_wstring) ) + test_method(c.do_nsIIDRef, (component_iid, new_iid), (component_iid, component_iid, new_iid)) + test_method(c.do_nsIIDRef, (new_iid, component_iid), (new_iid, component_iid, component_iid)) + test_method(c.do_nsIPythonTestInterface, (None, None), (None, None, c)) + test_method(c.do_nsIPythonTestInterface, (c, c), (c, c, c)) + test_method(c.do_nsISupports, (None, None), (c, None, None)) + test_method(c.do_nsISupports, (c,c), (c, c, c)) + test_method(c.do_nsISupportsIs, (xpcom._xpcom.IID_nsISupports,), c) + test_method(c.do_nsISupportsIs, (xpcom.components.interfaces.nsIPythonTestInterface,), c) +## test_method(c.do_nsISupportsIs2, (xpcom.components.interfaces.nsIPythonTestInterface,c), (xpcom.components.interfaces.nsIPythonTestInterface,c)) +## test_method(c.do_nsISupportsIs3, (c,), (xpcom.components.interfaces.nsIPythonTestInterface,c)) +## test_method(c.do_nsISupportsIs4, (), (xpcom.components.interfaces.nsIPythonTestInterface,c)) + # Test the constants. + test_constant(c, "One", 1) + test_constant(c, "Two", 2) + test_constant(c, "MinusOne", -1) + test_constant(c, "BigLong", 0x7FFFFFFF) + test_constant(c, "BiggerLong", -1) + test_constant(c, "BigULong", -1) + # Test the components.Interfaces semantics + i = xpcom.components.interfaces.nsIPythonTestInterface + test_constant(i, "One", 1) + test_constant(i, "Two", 2) + test_constant(i, "MinusOne", -1) + test_constant(i, "BigLong", 0x7FFFFFFF) + test_constant(i, "BigULong", -1) + +def test_derived_interface(c, test_flat = 0): + val = "Hello\0there" + expected = val * 2 + + test_method(c.DoubleString, (val,), expected) + test_method(c.DoubleString2, (val,), expected) + test_method(c.DoubleString3, (val,), expected) + test_method(c.DoubleString4, (val,), expected) + test_method(c.UpString, (val,), val.upper()) + test_method(c.UpString2, (val,), val.upper()) + test_method(c.GetFixedString, (20,), "A"*20) + val = u"Hello\0there" + expected = val * 2 + test_method(c.DoubleWideString, (val,), expected) + test_method(c.DoubleWideString2, (val,), expected) + test_method(c.DoubleWideString3, (val,), expected) + test_method(c.DoubleWideString4, (val,), expected) + test_method(c.UpWideString, (val,), val.upper()) + test_method(c.UpWideString2, (val,), val.upper()) + test_method(c.GetFixedWideString, (20,), u"A"*20) + val = extended_unicode_string + test_method(c.CopyUTF8String, ("foo",), "foo") + test_method(c.CopyUTF8String, (u"foo",), "foo") + test_method(c.CopyUTF8String, (val,), val) + test_method(c.CopyUTF8String, (val.encode("utf8"),), val) + test_method(c.CopyUTF8String2, ("foo",), "foo") + test_method(c.CopyUTF8String2, (u"foo",), "foo") + test_method(c.CopyUTF8String2, (val,), val) + test_method(c.CopyUTF8String2, (val.encode("utf8"),), val) + items = [1,2,3,4,5] + test_method(c.MultiplyEachItemInIntegerArray, (3, items,), map(lambda i:i*3, items)) + + test_method(c.MultiplyEachItemInIntegerArrayAndAppend, (3, items), items + map(lambda i:i*3, items)) + items = "Hello from Python".split() + expected = map( lambda x: x*2, items) + test_method(c.DoubleStringArray, (items,), expected) + + test_method(c.CompareStringArrays, (items, items), cmp(items, items)) + # Can we pass lists and tuples correctly? + test_method(c.CompareStringArrays, (items, tuple(items)), cmp(items, items)) + items2 = ["Not", "the", "same"] + test_method(c.CompareStringArrays, (items, items2), cmp(items, items2)) + + expected = items[:] + expected.reverse() + test_method(c.ReverseStringArray, (items,), expected) + + expected = "Hello from the Python test component".split() + test_method(c.GetStrings, (), expected) + + val = "Hello\0there" + test_method(c.UpOctetArray, (val,), val.upper()) + test_method(c.UpOctetArray, (unicode(val),), val.upper()) + # Passing Unicode objects here used to cause us grief. + test_method(c.UpOctetArray2, (val,), val.upper()) + + test_method(c.CheckInterfaceArray, ((c, c),), 1) + test_method(c.CheckInterfaceArray, ((c, None),), 0) + test_method(c.CheckInterfaceArray, ((),), 1) + test_method(c.CopyInterfaceArray, ((c, c),), [c,c]) + + test_method(c.GetInterfaceArray, (), [c,c,c, None]) + test_method(c.ExtendInterfaceArray, ((c,c,c, None),), [c,c,c,None,c,c,c,None] ) + + expected = [xpcom.components.interfaces.nsIPythonTestInterfaceDOMStrings, xpcom.components.classes[contractid].clsid] + test_method(c.GetIIDArray, (), expected) + + val = [xpcom.components.interfaces.nsIPythonTestInterfaceExtra, xpcom.components.classes[contractid].clsid] + expected = val * 2 + test_method(c.ExtendIIDArray, (val,), expected) + + test_method(c.GetArrays, (), ( [1,2,3], [4,5,6] ) ) + test_method(c.CopyArray, ([1,2,3],), [1,2,3] ) + test_method(c.CopyAndDoubleArray, ([1,2,3],), [1,2,3,1,2,3] ) + test_method(c.AppendArray, ([1,2,3],), [1,2,3]) + test_method(c.AppendArray, ([1,2,3],[4,5,6]), [1,2,3,4,5,6]) + + test_method(c.CopyVariant, (None,), None) + test_method(c.CopyVariant, (1,), 1) + test_method(c.CopyVariant, (1.0,), 1.0) + test_method(c.CopyVariant, (-1,), -1) + test_method(c.CopyVariant, (sys.maxint+1,), sys.maxint+1) + test_method(c.CopyVariant, ("foo",), "foo") + test_method(c.CopyVariant, (u"foo",), u"foo") + test_method(c.CopyVariant, (c,), c) + test_method(c.CopyVariant, (component_iid,), component_iid) + test_method(c.CopyVariant, ((1,2),), [1,2]) + test_method(c.CopyVariant, ((1.2,2.1),), [1.2,2.1]) + test_method(c.CopyVariant, (("foo","bar"),), ["foo", "bar"]) + test_method(c.CopyVariant, ((component_iid,component_iid),), [component_iid,component_iid]) + test_method(c.CopyVariant, ((c,c),), [c,c]) + sup = c.queryInterface(xpcom.components.interfaces.nsISupports)._comobj_ + test_method(c.CopyVariant, ((sup, sup),), [sup,sup]) + test_method(c.AppendVariant, (1,2), 3) + test_method(c.AppendVariant, ((1,2),(3,4)), 10) + test_method(c.AppendVariant, ("bar", "foo"), "foobar") + test_method(c.AppendVariant, (None, None), None) + + test_method(c.SumVariants, ([],), None) + # Array's dont expose their interface, so we are unable to auto-wrap + # variant arrays, as they aren't aware if the IID of the array + test_method(c.SumVariants, ([MakeVariant(1),MakeVariant(2),MakeVariant(3)],), 6) + test_method(c.SumVariants, ([MakeVariant('foo'), MakeVariant('bar')],), 'foobar') + + if not test_flat: + c = c.queryInterface(xpcom.components.interfaces.nsIPythonTestInterfaceDOMStrings) +# NULL DOM strings don't work yet. +# test_method(c.GetDOMStringResult, (-1,), None) + test_method(c.GetDOMStringResult, (3,), "PPP") +# test_method(c.GetDOMStringOut, (-1,), None) + test_method(c.GetDOMStringOut, (4,), "yyyy") + val = "Hello there" + test_method(c.GetDOMStringLength, (val,), len(val)) + test_method(c.GetDOMStringRefLength, (val,), len(val)) + test_method(c.GetDOMStringPtrLength, (val,), len(val)) + test_method(c.ConcatDOMStrings, (val,val), val+val) + test_attribute(c, "domstring_value", "dom", "new dom") + if c.domstring_value_ro != "dom": + print "Read-only DOMString not correct - got", c.domstring_ro + try: + c.dom_string_ro = "new dom" + print "Managed to set a readonly attribute - eek!" + except AttributeError: + pass + except: + print "Unexpected exception when setting readonly attribute: %s: %s" % (sys.exc_info()[0], sys.exc_info()[1]) + if c.domstring_value_ro != "dom": + print "Read-only DOMString not correct after failed set attempt - got", c.domstring_ro + +def do_test_failures(): + c = xpcom.client.Component(contractid, xpcom.components.interfaces.nsIPythonTestInterfaceExtra) + try: + ret = c.do_nsISupportsIs( xpcom._xpcom.IID_nsIInterfaceInfoManager ) + print "*** got", ret, "***" + raise RuntimeError, "We worked when using an IID we dont support!?!" + except xpcom.Exception, details: + if details.errno != xpcom.nsError.NS_ERROR_NO_INTERFACE: + raise RuntimeError, "Wrong COM exception type: %r" % (details,) + +def test_failures(): + # This extra stack-frame ensures Python cleans up sys.last_traceback etc + do_test_failures() + +def test_all(): + c = xpcom.client.Component(contractid, xpcom.components.interfaces.nsIPythonTestInterface) + test_base_interface(c) + # Now create an instance using the derived IID, and test that. + c = xpcom.client.Component(contractid, xpcom.components.interfaces.nsIPythonTestInterfaceExtra) + test_base_interface(c) + test_derived_interface(c) + # Now create an instance and test interface flattening. + c = xpcom.components.classes[contractid].createInstance() + test_base_interface(c) + test_derived_interface(c, test_flat=1) + + # We had a bug where a "set" of an attribute before a "get" failed. + # Don't let it happen again :) + c = xpcom.components.classes[contractid].createInstance() + c.boolean_value = 0 + + # This name is used in exceptions etc - make sure we got it from nsIClassInfo OK. + assert c._object_name_ == "Python.TestComponent" + + test_failures() + +try: + from sys import gettotalrefcount +except ImportError: + # Not a Debug build - assume no references (can't be leaks then :-) + def gettotalrefcount(): + return 0 + +from pyxpcom_test_tools import getmemusage + +def test_from_js(): + # Ensure we can find the js test script - same dir as this! + # Assume the path of sys.argv[0] is where we can find the js test code. + # (Running under the regression test is a little painful) + script_dir = os.path.split(sys.argv[0])[0] + fname = os.path.join( script_dir, "test_test_component.js") + if not os.path.isfile(fname): + raise RuntimeError, "Can not find '%s'" % (fname,) + # Note we _dont_ pump the test output out, as debug "xpcshell" spews + # extra debug info that will cause our output comparison to fail. + data = os.popen('xpcshell "' + fname + '"').readlines() + good = 0 + for line in data: + if line.strip() == "javascript successfully tested the Python test component.": + good = 1 + if not good: + print "** The javascript test appeared to fail! Test output follows **" + print "".join(data) + print "** End of javascript test output **" + raise RuntimeError, "test failed" + +def doit(num_loops = -1): + if "-v" in sys.argv: # Hack the verbose flag for the server + xpcom.verbose = 1 + # Do the test lots of times - can help shake-out ref-count bugs. + if num_loops == -1: num_loops = 5 + for i in xrange(num_loops): + test_all() + + if i==0: + # First loop is likely to "leak" as we cache things. + # Leaking after that is a problem. + if gc is not None: + gc.collect() + num_refs = gettotalrefcount() + mem_usage = getmemusage() + + if num_errors: + break + + if gc is not None: + gc.collect() + + lost = gettotalrefcount() - num_refs + # Sometimes we get spurious counts off by 1 or 2. + # This can't indicate a real leak, as we have looped + # more than twice! + if abs(lost)>3: # 2 or 3 :) + print "*** Lost %d references" % (lost,) + + # sleep to allow the OS to recover + time.sleep(1) + mem_lost = getmemusage() - mem_usage + # working set size is fickle, and when we were leaking strings, this test + # would report a leak of 100MB. So we allow a 3MB buffer - but even this + # may still occasionally report spurious warnings. If you are really + # worried, bump the counter to a huge value, and if there is a leak it will + # show. + if mem_lost > 3000000: + print "*** Lost %.6f MB of memory" % (mem_lost/1000000.0,) + + assert num_errors==0, "There were %d errors testing the Python component" % (num_errors,) + +def suite(): + from pyxpcom_test_tools import suite_from_functions + return suite_from_functions(doit, test_from_js) + +if __name__=='__main__': + num_iters = 10 # times times is *lots* - we do a fair bit of work! + if __name__=='__main__' and len(sys.argv) > 1: + num_iters = int(sys.argv[1]) + + print "Testing the Python.TestComponent component" + doit(num_iters) + print "The Python test component worked." + test_from_js() + print "JS successfully used our Python test component." + xpcom._xpcom.NS_ShutdownXPCOM() + ni = xpcom._xpcom._GetInterfaceCount() + ng = xpcom._xpcom._GetGatewayCount() + if ni or ng: + print "********* WARNING - Leaving with %d/%d objects alive" % (ni,ng) diff --git a/src/libs/xpcom18a4/python/test/test_weakreferences.py b/src/libs/xpcom18a4/python/test/test_weakreferences.py new file mode 100755 index 00000000..9bfb3fbc --- /dev/null +++ b/src/libs/xpcom18a4/python/test/test_weakreferences.py @@ -0,0 +1,114 @@ +# ***** 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 the Python XPCOM language bindings. +# +# The Initial Developer of the Original Code is +# ActiveState Tool Corp. +# Portions created by the Initial Developer are Copyright (C) 2000, 2001 +# the Initial Developer. All Rights Reserved. +# +# Contributor(s): +# Mark Hammond <markh@activestate.com> (original author) +# +# 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 ***** + +# test_weakreferences.py - Test our weak reference implementation. +from xpcom import components, _xpcom +import xpcom.server, xpcom.client +from pyxpcom_test_tools import suite_from_functions, testmain + +try: + from sys import gettotalrefcount +except ImportError: + # Not a Debug build - assume no references (can't be leaks then :-) + gettotalrefcount = lambda: 0 + +num_alive = 0 + +class koTestSimple: + _com_interfaces_ = [components.interfaces.nsIInputStream] + def __init__(self): + global num_alive + num_alive += 1 + def __del__(self): + global num_alive + num_alive -= 1 + def close( self ): + pass + +def test(): + ob = xpcom.server.WrapObject( koTestSimple(), components.interfaces.nsIInputStream) + + if num_alive != 1: raise RuntimeError, "Eeek - there are %d objects alive" % (num_alive,) + + # Check we can create a weak reference to our object. + wr = xpcom.client.WeakReference(ob) + if num_alive != 1: raise RuntimeError, "Eeek - there are %d objects alive" % (num_alive,) + + # Check we can call methods via the weak reference. + if wr() is None: raise RuntimeError, "Our weak-reference is returning None before it should!" + wr().close() + + ob = None # This should kill the object. + if num_alive != 0: raise RuntimeError, "Eeek - there are %d objects alive" % (num_alive,) + if wr() is not None: raise RuntimeError, "Our weak-reference is not returning None when it should!" + + # Now a test that we can get a _new_ interface from the weak reference - ie, + # an IID the real object has never previously been queried for + # (this behaviour previously caused a bug - never again ;-) + ob = xpcom.server.WrapObject( koTestSimple(), components.interfaces.nsISupports) + if num_alive != 1: raise RuntimeError, "Eeek - there are %d objects alive" % (num_alive,) + wr = xpcom.client.WeakReference(ob, components.interfaces.nsIInputStream) + if num_alive != 1: raise RuntimeError, "Eeek - there are %d objects alive" % (num_alive,) + wr() # This would die once upon a time ;-) + ob = None # This should kill the object. + if num_alive != 0: raise RuntimeError, "Eeek - there are %d objects alive" % (num_alive,) + if wr() is not None: raise RuntimeError, "Our weak-reference is not returning None when it should!" + +def test_refcount(num_loops=-1): + # Do the test lots of times - can help shake-out ref-count bugs. + if num_loops == -1: num_loops = 10 + for i in xrange(num_loops): + test() + + if i==0: + # First loop is likely to "leak" as we cache things. + # Leaking after that is a problem. + num_refs = gettotalrefcount() + + lost = gettotalrefcount() - num_refs + # Sometimes we get spurious counts off by 1 or 2. + # This can't indicate a real leak, as we have looped + # more than twice! + if abs(lost)>2: + print "*** Lost %d references" % (lost,) + +# Make this test run under our std test suite +def suite(): + return suite_from_functions(test_refcount) + +if __name__=='__main__': + testmain() |