ctypes-commit Mailing List for ctypes (Page 57)
Brought to you by:
theller
You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
(8) |
May
(90) |
Jun
(143) |
Jul
(106) |
Aug
(94) |
Sep
(84) |
Oct
(163) |
Nov
(60) |
Dec
(58) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(128) |
Feb
(79) |
Mar
(227) |
Apr
(192) |
May
(179) |
Jun
(41) |
Jul
(53) |
Aug
(103) |
Sep
(28) |
Oct
(38) |
Nov
(81) |
Dec
(17) |
2006 |
Jan
(184) |
Feb
(111) |
Mar
(188) |
Apr
(67) |
May
(58) |
Jun
(123) |
Jul
(73) |
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
|
From: Thomas H. <th...@us...> - 2005-04-15 18:01:43
|
Update of /cvsroot/ctypes/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12148 Modified Files: Tag: branch_1_0 __init__.py Log Message: first version for os x Index: __init__.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/__init__.py,v retrieving revision 1.61.2.4 retrieving revision 1.61.2.5 diff -C2 -d -r1.61.2.4 -r1.61.2.5 *** __init__.py 15 Apr 2005 17:06:29 -0000 1.61.2.4 --- __init__.py 15 Apr 2005 18:01:33 -0000 1.61.2.5 *************** *** 412,415 **** --- 412,427 ---- return func + def find_lib(name): + from ctypes.macholib.dyld import dyld_find + import os + possible = ['lib'+name+'.dylib', name+'.dylib', name+'.framework/'+name] + + for dylib in possible: + try: + return os.path.realpath(dyld_find(dylib)) + except ValueError: + pass + raise ValueError, "%s not found" % (name,) + class _DLLS(object): def __init__(self, dlltype): *************** *** 420,424 **** if name[0] == '_': raise AttributeError, name ! dll = self._dlltype("lib%s.dylib" % name) setattr(self, name, dll) return dll --- 432,438 ---- if name[0] == '_': raise AttributeError, name ! ## libpath = find_lib(name) ! libpath = "lib%s.dylib" % name ! dll = self._dlltype(libpath) setattr(self, name, dll) return dll |
From: Thomas H. <th...@us...> - 2005-04-15 17:42:34
|
Update of /cvsroot/ctypes/ctypes/unittests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3035/unittests Modified Files: Tag: branch_1_0 test_macholib.py Log Message: correct stupid mistakes Index: test_macholib.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/unittests/Attic/test_macholib.py,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -C2 -d -r1.1.2.2 -r1.1.2.3 *** test_macholib.py 15 Apr 2005 17:40:07 -0000 1.1.2.2 --- test_macholib.py 15 Apr 2005 17:42:19 -0000 1.1.2.3 *************** *** 53,58 **** result = find_lib('z') ! self.failUnless(result.startswith('/usr/lib/libz.1') ! self.failUnless(result.endswith('.dylib') self.failUnlessEqual(find_lib('IOKit'), --- 53,58 ---- result = find_lib('z') ! self.failUnless(result.startswith('/usr/lib/libz.1')) ! self.failUnless(result.endswith('.dylib')) self.failUnlessEqual(find_lib('IOKit'), |
From: Thomas H. <th...@us...> - 2005-04-15 17:40:16
|
Update of /cvsroot/ctypes/ctypes/unittests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2343 Modified Files: Tag: branch_1_0 test_macholib.py Log Message: Make the test work on SF's compilerfarm. Index: test_macholib.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/unittests/Attic/test_macholib.py,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -C2 -d -r1.1.2.1 -r1.1.2.2 *** test_macholib.py 15 Apr 2005 17:29:25 -0000 1.1.2.1 --- test_macholib.py 15 Apr 2005 17:40:07 -0000 1.1.2.2 *************** *** 52,57 **** '/usr/lib/libSystem.B.dylib') ! self.failUnlessEqual(find_lib('z'), ! '/usr/lib/libz.1.dylib') self.failUnlessEqual(find_lib('IOKit'), --- 52,58 ---- '/usr/lib/libSystem.B.dylib') ! result = find_lib('z') ! self.failUnless(result.startswith('/usr/lib/libz.1') ! self.failUnless(result.endswith('.dylib') self.failUnlessEqual(find_lib('IOKit'), |
From: Thomas H. <th...@us...> - 2005-04-15 17:29:35
|
Update of /cvsroot/ctypes/ctypes/unittests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27912 Added Files: Tag: branch_1_0 test_macholib.py Log Message: A macholib test from Bob Ippolito. --- NEW FILE: test_macholib.py --- import os import sys import unittest # Bob Ippolito: """ Ok.. the code to find the filename for __getattr__ should look something like: import os from macholib.dyld import dyld_find def find_lib(name): possible = ['lib'+name+'.dylib', name+'.dylib', name+'.framework/'+name] for dylib in possible: try: return os.path.realpath(dyld_find(dylib)) except ValueError: pass raise ValueError, "%s not found" % (name,) It'll have output like this: >>> find_lib('pthread') '/usr/lib/libSystem.B.dylib' >>> find_lib('z') '/usr/lib/libz.1.dylib' >>> find_lib('IOKit') '/System/Library/Frameworks/IOKit.framework/Versions/A/IOKit' -bob """ from ctypes.macholib.dyld import dyld_find def find_lib(name): possible = ['lib'+name+'.dylib', name+'.dylib', name+'.framework/'+name] for dylib in possible: try: return os.path.realpath(dyld_find(dylib)) except ValueError: pass raise ValueError, "%s not found" % (name,) class MachOTest(unittest.TestCase): if sys.platform == "darwin": def test_find(self): self.failUnlessEqual(find_lib('pthread'), '/usr/lib/libSystem.B.dylib') self.failUnlessEqual(find_lib('z'), '/usr/lib/libz.1.dylib') self.failUnlessEqual(find_lib('IOKit'), '/System/Library/Frameworks/IOKit.framework/Versions/A/IOKit') if __name__ == "__main__": unittest.main() |
From: Thomas H. <th...@us...> - 2005-04-15 17:23:21
|
Update of /cvsroot/ctypes/ctypes/ctypes/macholib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23260 Added Files: Tag: branch_1_0 framework.py dylib.py dyld.py __init__.py README.ctypes Log Message: Import some bits from Bob Ippolito's macholib, SVN revision 452. --- NEW FILE: dylib.py --- """ Generic dylib path manipulation """ import re __all__ = ['dylib_info'] DYLIB_RE = re.compile(r"""(?x) (?P<location>^.*)(?:^|/) (?P<name> (?P<shortname>\w+?) (?:\.(?P<version>[^._]+))? (?:_(?P<suffix>[^._]+))? \.dylib$ ) """) def dylib_info(filename): """ A dylib name can take one of the following four forms: Location/Name.SomeVersion_Suffix.dylib Location/Name.SomeVersion.dylib Location/Name_Suffix.dylib Location/Name.dylib returns None if not found or a mapping equivalent to: dict( location='Location', name='Name.SomeVersion_Suffix.dylib', shortname='Name', version='SomeVersion', suffix='Suffix', ) Note that SomeVersion and Suffix are optional and may be None if not present. """ is_dylib = DYLIB_RE.match(filename) if not is_dylib: return None return is_dylib.groupdict() def test_dylib_info(): def d(location=None, name=None, shortname=None, version=None, suffix=None): return dict( location=location, name=name, shortname=shortname, version=version, suffix=suffix ) assert dylib_info('completely/invalid') is None assert dylib_info('completely/invalide_debug') is None assert dylib_info('P/Foo.dylib') == d('P', 'Foo.dylib', 'Foo') assert dylib_info('P/Foo_debug.dylib') == d('P', 'Foo_debug.dylib', 'Foo', suffix='debug') assert dylib_info('P/Foo.A.dylib') == d('P', 'Foo.A.dylib', 'Foo', 'A') assert dylib_info('P/Foo_debug.A.dylib') == d('P', 'Foo_debug.A.dylib', 'Foo_debug', 'A') assert dylib_info('P/Foo.A_debug.dylib') == d('P', 'Foo.A_debug.dylib', 'Foo', 'A', 'debug') if __name__ == '__main__': test_dylib_info() --- NEW FILE: framework.py --- """ Generic framework path manipulation """ import re __all__ = ['framework_info'] STRICT_FRAMEWORK_RE = re.compile(r"""(?x) (?P<location>^.*)(?:^|/) (?P<name> (?P<shortname>\w+).framework/ (?:Versions/(?P<version>[^/]+)/)? (?P=shortname) (?:_(?P<suffix>[^_]+))? )$ """) def framework_info(filename): """ A framework name can take one of the following four forms: Location/Name.framework/Versions/SomeVersion/Name_Suffix Location/Name.framework/Versions/SomeVersion/Name Location/Name.framework/Name_Suffix Location/Name.framework/Name returns None if not found, or a mapping equivalent to: dict( location='Location', name='Name.framework/Versions/SomeVersion/Name_Suffix', shortname='Name', version='SomeVersion', suffix='Suffix', ) Note that SomeVersion and Suffix are optional and may be None if not present """ is_framework = STRICT_FRAMEWORK_RE.match(filename) if not is_framework: return None return is_framework.groupdict() def test_framework_info(): def d(location=None, name=None, shortname=None, version=None, suffix=None): return dict( location=location, name=name, shortname=shortname, version=version, suffix=suffix ) assert framework_info('completely/invalid') is None assert framework_info('completely/invalid/_debug') is None assert framework_info('P/F.framework') is None assert framework_info('P/F.framework/_debug') is None assert framework_info('P/F.framework/F') == d('P', 'F.framework/F', 'F') assert framework_info('P/F.framework/F_debug') == d('P', 'F.framework/F_debug', 'F', suffix='debug') assert framework_info('P/F.framework/Versions') is None assert framework_info('P/F.framework/Versions/A') is None assert framework_info('P/F.framework/Versions/A/F') == d('P', 'F.framework/Versions/A/F', 'F', 'A') assert framework_info('P/F.framework/Versions/A/F_debug') == d('P', 'F.framework/Versions/A/F_debug', 'F', 'A', 'debug') if __name__ == '__main__': test_framework_info() --- NEW FILE: README.ctypes --- Files in this directory from from Bob Ippolito's py2app. License: Any components of the py2app suite may be distributed under the MIT or PSF open source licenses. This is version 0.7, SVN revision 452, from 2005/04/15. --- NEW FILE: __init__.py --- """ Enough Mach-O to make your head spin. See the relevant header files in /usr/include/mach-o And also Apple's documentation. """ __version__ = '0.7' --- NEW FILE: dyld.py --- """ dyld emulation """ import os from framework import framework_info from dylib import dylib_info from itertools import * __all__ = [ 'dyld_find', 'framework_find', 'framework_info', 'dylib_info', ] # These are the defaults as per man dyld(1) # DEFAULT_FRAMEWORK_FALLBACK = [ os.path.expanduser("~/Library/Frameworks"), "/Library/Frameworks", "/Network/Library/Frameworks", "/System/Library/Frameworks", ] DEFAULT_LIBRARY_FALLBACK = [ os.path.expanduser("~/lib"), "/usr/local/lib", "/lib", "/usr/lib", ] def ensure_utf8(s): """Not all of PyObjC and Python understand unicode paths very well yet""" if isinstance(s, unicode): return s.encode('utf8') return s def dyld_env(env, var): if env is None: env = os.environ rval = env.get(var) if rval is None: return [] return rval.split(':') def dyld_image_suffix(env=None): if env is None: env = os.environ return env.get('DYLD_IMAGE_SUFFIX') def dyld_framework_path(env=None): return dyld_env(env, 'DYLD_FRAMEWORK_PATH') def dyld_library_path(env=None): return dyld_env(env, 'DYLD_LIBRARY_PATH') def dyld_fallback_framework_path(env=None): return dyld_env(env, 'DYLD_FALLBACK_FRAMEWORK_PATH') def dyld_fallback_library_path(env=None): return dyld_env(env, 'DYLD_FALLBACK_LIBRARY_PATH') def dyld_image_suffix_search(iterator, env=None): """For a potential path iterator, add DYLD_IMAGE_SUFFIX semantics""" suffix = dyld_image_suffix() if suffix is None: return iterator def _inject(iterator=iterator,suffix=suffix): for path in iterator: if path.endswith('.dylib'): yield path[:-len('.dylib')] + suffix + '.dylib' else: yield path + suffix yield path return _inject() def dyld_override_search(name, env=None): # If DYLD_FRAMEWORK_PATH is set and this dylib_name is a # framework name, use the first file that exists in the framework # path if any. If there is none go on to search the DYLD_LIBRARY_PATH # if any. framework = framework_info(name) if framework is not None: for path in dyld_framework_path(): yield os.path.join(path, framework['name']) # If DYLD_LIBRARY_PATH is set then use the first file that exists # in the path. If none use the original name. for path in dyld_library_path(): yield os.path.join(path, os.path.dirname(name)) def dyld_executable_path_search(name, executable_path=None): # If we haven't done any searching and found a library and the # dylib_name starts with "@executable_path/" then construct the # library name. if name.startswith('@executable_path/') and executable_path is not None: yield os.path.join(executable_path, name[len('@executable_path/'):]) def dyld_default_search(name, env=None): yield name framework = framework_info(name) if framework is not None: fallback_framework_path = dyld_fallback_framework_path() for path in fallback_framework_path: yield os.path.join(path, framework['name']) fallback_library_path = dyld_fallback_library_path() for path in fallback_library_path: yield os.path.join(path, os.path.basename(name)) if framework is not None and not fallback_framework_path: for path in DEFAULT_FRAMEWORK_FALLBACK: yield os.path.join(path, framework['name']) if not fallback_library_path: for path in DEFAULT_LIBRARY_FALLBACK: yield os.path.join(path, os.path.basename(name)) def dyld_find(name, executable_path=None, env=None): """ Find a library or framework using dyld semantics """ name = ensure_utf8(name) executable_path = ensure_utf8(executable_path) for path in dyld_image_suffix_search(chain( dyld_override_search(name, env), dyld_executable_path_search(name, executable_path), dyld_default_search(name, env), ), env): if os.path.isfile(path): return path raise ValueError, "dylib %s could not be found" % (name,) def framework_find(fn, executable_path=None, env=None): """ Find a framework using dyld semantics in a very loose manner. Will take input such as: Python Python.framework Python.framework/Versions/Current """ try: return dyld_find(fn, executable_path=executable_path, env=env) except ValueError, e: pass fmwk_index = fn.rfind('.framework') if fmwk_index == -1: fmwk_index = len(fn) fn += '.framework' fn = os.path.join(fn, os.path.basename(fn[:fmwk_index])) try: return dyld_find(fn, executable_path=executable_path, env=env) except ValueError: raise e def test_dyld_find(): env = {} print dyld_find('libSystem') print dyld_find('System.framework/System') if __name__ == '__main__': test_dyld_find() |
From: Thomas H. <th...@us...> - 2005-04-15 17:17:31
|
Update of /cvsroot/ctypes/ctypes/ctypes/macholib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20281/macholib Log Message: Directory /cvsroot/ctypes/ctypes/ctypes/macholib added to the repository --> Using per-directory sticky tag `branch_1_0' |
From: Thomas H. <th...@us...> - 2005-04-15 17:07:59
|
Update of /cvsroot/ctypes/ctypes/unittests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14419 Added Files: Tag: branch_1_0 test_libc.py Log Message: Decorator tests, libc and libm tests. --- NEW FILE: test_libc.py --- import os import sys import unittest from ctypes import * def get_libc(): if os.name == "nt": return cdll.msvcrt try: return CDLL("libc.so.6") except OSError: return cdll.c libc = get_libc() if os.name == "nt": libm = cdll.msvcrt else: libm = cdll.m class LibTest(unittest.TestCase): def test_sqrt(self): libm.sqrt.argtypes = c_double, libm.sqrt.restype = c_double self.failUnlessEqual(libm.sqrt(4.0), 2.0) import math self.failUnlessEqual(libm.sqrt(2.0), math.sqrt(2.0)) def test_cdecl_decorator(self): from ctypes.decorators import cdecl, name_library if os.name == "nt": name_library("libm", "msvcrt") # @ cdecl(c_double, "libm", [c_double]) def sqrt(value): return sqrt._api_(value) # Oh well, compatibility with Python 2.3 sqrt = cdecl(c_double, "libm", [c_double]) (sqrt) self.failUnlessEqual(sqrt(4.0), 2.0) def test_qsort(self): comparefunc = CFUNCTYPE(c_int, POINTER(c_char), POINTER(c_char)) libc.qsort.argtypes = c_void_p, c_int, c_int, comparefunc libc.qsort.restype = None def sort(a, b): return cmp(a[0], b[0]) chars = create_string_buffer("spam, spam, and spam") libc.qsort(chars, len(chars)-1, sizeof(c_char), comparefunc(sort)) self.failUnlessEqual(chars.raw, " ,,aaaadmmmnpppsss\x00") def test_qsort_decorator(self): from ctypes.decorators import cdecl, name_library name_library("libc", "msvcrt") CMPFUNC = CFUNCTYPE(c_int, c_void_p, c_void_p) @ cdecl(None, "libc", [c_void_p, c_int, c_int, CMPFUNC]) def qsort(sequence, cmp_func): itemsize = sizeof(sequence) / len(sequence) qsort._api_(sequence, len(sequence), itemsize, CMPFUNC(cmp_func)) def sortfunc(a, b): a = cast(a, POINTER(c_int)) b = cast(b, POINTER(c_int)) return cmp(a[0], b[0]) ints = (c_int * 9)(1, 3, 5, 7, 9, 8, 6, 4, 2) qsort(ints, sortfunc) self.failUnlessEqual(ints[:], [1, 2, 3, 4, 5, 6, 7, 8, 9]) if __name__ == "__main__": unittest.main() |
From: Thomas H. <th...@us...> - 2005-04-15 17:06:38
|
Update of /cvsroot/ctypes/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12766 Modified Files: Tag: branch_1_0 __init__.py Log Message: cdll attributes do automatic shared library name mangling, depending on the platform. Index: __init__.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/__init__.py,v retrieving revision 1.61.2.3 retrieving revision 1.61.2.4 diff -C2 -d -r1.61.2.3 -r1.61.2.4 *** __init__.py 15 Apr 2005 07:49:57 -0000 1.61.2.3 --- __init__.py 15 Apr 2005 17:06:29 -0000 1.61.2.4 *************** *** 416,425 **** self._dlltype = dlltype ! def __getattr__(self, name): ! if name[0] == '_': ! raise AttributeError, name ! dll = self._dlltype(name) ! setattr(self, name, dll) ! return dll def __getitem__(self, name): --- 416,440 ---- self._dlltype = dlltype ! if _os.name == "posix" and sys.platform == "darwin": ! def __getattr__(self, name): ! if name[0] == '_': ! raise AttributeError, name ! dll = self._dlltype("lib%s.dylib" % name) ! setattr(self, name, dll) ! return dll ! elif _os.name == "posix": ! def __getattr__(self, name): ! if name[0] == '_': ! raise AttributeError, name ! dll = self._dlltype("lib%s.so" % name) ! setattr(self, name, dll) ! return dll ! else: ! def __getattr__(self, name): ! if name[0] == '_': ! raise AttributeError, name ! dll = self._dlltype(name) ! setattr(self, name, dll) ! return dll def __getitem__(self, name): |
From: Thomas H. <th...@us...> - 2005-04-15 15:48:20
|
Update of /cvsroot/ctypes/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5647 Modified Files: Tag: branch_1_0 decorators.py Log Message: Implement a name_library(name, so_name) function which allows to specify a mapping of short names to so-names for generated code. Index: decorators.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/decorators.py,v retrieving revision 1.6 retrieving revision 1.6.2.1 diff -C2 -d -r1.6 -r1.6.2.1 *** decorators.py 4 Feb 2005 18:15:18 -0000 1.6 --- decorators.py 15 Apr 2005 15:47:54 -0000 1.6.2.1 *************** *** 2,119 **** This module implements decorators for native api function calls. ! stdcall(restype, dllname, argtypes[, logging=False]) ! cdecl(restype, dllname, argtypes[, logging=False]) ! ! The decorator functions are used like this: ! ! >>> from ctypes import * ! >>> # wrap the GetModuleFileNameA function ! >>> @ stdcall(c_ulong, 'kernel32', [c_ulong, POINTER(c_char), c_ulong]) ! ... def GetModuleFileNameA(handle=0): ! ... buf = create_string_buffer(256) ! ... if 0 == GetModuleFileNameA._api_(handle, buf, sizeof(buf)): ! ... raise WinError() ! ... return buf.value ! >>> ! >>> sys.executable == GetModuleFileNameA() ! True ! >>> ! >>> @ cdecl(c_char_p, 'msvcrt', [c_char_p, c_int]) ! ... def strchr(string, c): ! ... 'find a character in a string' ! ... return strchr._api_(string, c) ! >>> print strchr('abcdef', ord('x')) ! None ! >>> print strchr('abcdef', ord('c')) ! cdef ! >>> """ ! # This doesn't work, see below. ! ##>>> @ cdecl(c_char_p, 'msvcrt', [c_char_p, c_int]) ! ##... def strchr(string, c): ! ##... 'find a character in a string' ! ##... ! ##>>> print strchr('abcdef', ord('x')) ! ##None ! ##>>> print strchr('abcdef', ord('c')) ! ##cdef ! ##>>> ! import sys import ctypes ! LOGGING = False - ##def _create_func_codestring(func, doc=None): - ## # given a function object <func>, build the source code for - ## # another function, having the same argument list, and a function - ## # body which contains a call to an _api_ function. - ## # - ## # Assuming the <func> has this definition: - ## # def func(first, second="spam", third=42): - ## # .... - ## # a string containing the following code is returned: - ## # def func(first, second="spam", third=42): - ## # return _api_(first, second, third) - ## import inspect - ## args, varargs, varkw, defaults = inspect.getargspec(func) - ## if varkw: - ## raise TypeError, "function argument list cannot contain ** argument" - ## if doc: - ## return "def %s%s:\n %r\n return %s._api_%s" % \ - ## (func.func_name, - ## inspect.formatargspec(args, varargs, varkw, defaults), - ## doc, - ## func.func_name, - ## inspect.formatargspec(args, varargs, varkw)) - ## return "def %s%s:\n return %s._api_%s" % \ - ## (func.func_name, - ## inspect.formatargspec(args, varargs, varkw, defaults), - ## func.func_name, - ## inspect.formatargspec(args, varargs, varkw)) ! ################################################################ ! def stdcall(restype, dll, argtypes, logging=False): ! """stdcall(restype, dll, argtypes, logging=False) -> decorator. - The decorator, when applied to a function, attaches an '_api_' - attribute to the function. Calling this attribute calls the - function exported from the dll, using the MS '__stdcall' calling - convention. ! restype - result type ! dll - name or instance of a dll ! argtypes - list of argument types ! logging - if this is True, the result of each function call ! is printed to stderr. ! """ ! def decorate(func): ! if isinstance(dll, basestring): ! # this call should cache the result ! this_dll = ctypes.CDLL(dll) ! else: ! this_dll = dll ! api = ctypes.WINFUNCTYPE(restype, *argtypes)(func.func_name, this_dll) ! # This simple way to find out an empty function body doesn't work. ! ## if len(func.func_code.co_code) == 4: ! ## codestring = _create_func_codestring(func, func.__doc__) ! ## d = {} ! ## exec codestring in d ! ## func = d[func.func_name] ! func._api_ = api ! if logging or LOGGING: ! def f(*args): ! result = func(*args) ! print >> sys.stderr, "# function call: %s%s -> %s" % (func.func_name, args, result) ! return result ! return f ! else: ! return func ! return decorate ! def cdecl(restype, dll, argtypes, logging=False): ! """cdecl(restype, dll, argtypes, logging=False) -> decorator. The decorator, when applied to a function, attaches an '_api_' --- 2,40 ---- This module implements decorators for native api function calls. ! name_library(name, so_name) ! cdecl(restype, dllname, argtypes) ! stdcall(restype, dllname, argtypes) - windows only """ ! LOGGING = False ! import os import ctypes ! _library_map = {} # map short name to so-name ! _loaded_libs = {} # map so-names to DLL instance ! def name_library(name, so_name): ! """ ! name_library(name, so_name) ! Register the <so_name> for a library. The library will be loaded ! if <name> is referenced in a decorator. ! """ ! _library_map[name] = so_name ! _library_map[so_name] = so_name ! def _get_library(name): ! # load and return a library. The library is cached. ! soname = _library_map.get(name, name) ! try: ! return _loaded_libs[soname] ! except KeyError: ! return _loaded_libs.setdefault(soname, ctypes.CDLL(soname)) ! def cdecl(restype, dllname, argtypes, logging=False): ! """cdecl(restype, dllname, argtypes, logging=False) -> decorator. The decorator, when applied to a function, attaches an '_api_' *************** *** 129,159 **** """ def decorate(func): ! if isinstance(dll, basestring): ! # this call should cache the result ! this_dll = ctypes.CDLL(dll) ! else: ! this_dll = dll ! api = ctypes.CFUNCTYPE(restype, *argtypes)(func.func_name, this_dll) ! # This simple way to find out an empty function body doesn't work. ! ## if len(func.func_code.co_code) == 4: ! ## codestring = _create_func_codestring(func, func.__doc__) ! ## d = {} ! ## exec codestring in d ! ## func = d[func.func_name] func._api_ = api if logging or LOGGING: def f(*args): result = func(*args) ! print >> sys.stderr, func.func_name, args, "->", result return result return f ! else: ! return func return decorate ################################################################ ! ##if __name__ == "__main__": ! if 0: ! import doctest ! doctest.testmod() --- 50,127 ---- """ def decorate(func): ! library = _get_library(dllname) ! api = ctypes.CFUNCTYPE(restype, *argtypes)(func.func_name, library) func._api_ = api + # The following few lines trigger a pychecker bug, see + # https://sourceforge.net/tracker/index.php?func=detail&aid=1114902&group_id=24686&atid=382217 if logging or LOGGING: def f(*args): result = func(*args) ! print >> sys.stderr, "# function call: %s%s -> %s" % (func.func_name, args, result) return result return f ! return func return decorate + if os.name == "nt": + def stdcall(restype, dllname, argtypes, logging=False): + """stdcall(restype, dllname, argtypes, logging=False) -> decorator. + + The decorator, when applied to a function, attaches an '_api_' + attribute to the function. Calling this attribute calls the + function exported from the dll, using the MS '__stdcall' calling + convention. + + restype - result type + dll - name or instance of a dll + argtypes - list of argument types + logging - if this is True, the result of each function call + is printed to stderr. + """ + def decorate(func): + library = _get_library(dllname) + api = ctypes.WINFUNCTYPE(restype, *argtypes)(func.func_name, library) + func._api_ = api + # The following few lines trigger a pychecker bug, see + # https://sourceforge.net/tracker/index.php?func=detail&aid=1114902&group_id=24686&atid=382217 + if logging or LOGGING: + def f(*args): + result = func(*args) + print >> sys.stderr, "# function call: %s%s -> %s" % (func.func_name, args, result) + return result + return f + return func + return decorate + ################################################################ ! def _test(): ! import os, sys ! from ctypes import c_char, c_int, c_ulong, c_double, \ ! POINTER, create_string_buffer, sizeof ! ! if os.name == "nt": ! from ctypes import WinError ! ! @ stdcall(ctypes.c_ulong, "kernel32", [c_ulong, POINTER(c_char), c_ulong]) ! def GetModuleFileNameA(handle=0): ! buf = create_string_buffer(256) ! if 0 == GetModuleFileNameA._api_(handle, buf, sizeof(buf)): ! raise WinError() ! return buf.value ! ! assert(sys.executable == GetModuleFileNameA()) ! ! if os.name == "nt": ! name_library("libm", "msvcrt") ! else: ! name_library("libm", "libm") ! ! @ cdecl(c_double, 'libm', [c_double]) ! def sqrt(value): ! return sqrt._api_(value) ! ! assert sqrt(4.0) == 2.0 ! ! if __name__ == "__main__": ! _test() |
From: Thomas H. <th...@us...> - 2005-04-15 13:01:42
|
Update of /cvsroot/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10979 Modified Files: Tag: branch_1_0 setup.py Log Message: Backport from trunk: Print an error message when a unittest-module cannot be imported, then continue. Index: setup.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/setup.py,v retrieving revision 1.122.2.1 retrieving revision 1.122.2.2 diff -C2 -d -r1.122.2.1 -r1.122.2.2 *** setup.py 7 Apr 2005 12:49:28 -0000 1.122.2.1 --- setup.py 15 Apr 2005 13:01:20 -0000 1.122.2.2 *************** *** 221,225 **** for pathname in test_files: modname = os.path.splitext(pathname)[0].split(os.sep)[-1] ! mod = __import__(modname) try: suite = doctest.DocTestSuite(mod) --- 221,230 ---- for pathname in test_files: modname = os.path.splitext(pathname)[0].split(os.sep)[-1] ! try: ! mod = __import__(modname) ! except Exception, e: ! print >> sys.stderr, \ ! "Could not import %s:\n %s" % (pathname, e) ! continue try: suite = doctest.DocTestSuite(mod) |
From: Thomas H. <th...@us...> - 2005-04-15 12:58:53
|
Update of /cvsroot/ctypes/ctypes/unittests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9412 Modified Files: test_pointers.py Log Message: The pointer crash test. Index: test_pointers.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/unittests/test_pointers.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** test_pointers.py 14 Oct 2004 13:16:13 -0000 1.16 --- test_pointers.py 15 Apr 2005 12:58:37 -0000 1.17 *************** *** 12,15 **** --- 12,24 ---- class PointersTestCase(unittest.TestCase): + def test_pointer_crash(self): + + class A(POINTER(c_ulong)): + pass + + print POINTER(c_ulong)(c_ulong(22)) + # Pointer can't set contents: has no _type_ + self.failUnlessRaises(TypeError, A, c_ulong(33)) + def test_pass_pointers(self): dll = CDLL(find_test_dll()) |
From: Thomas H. <th...@us...> - 2005-04-15 12:54:47
|
Update of /cvsroot/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6742 Modified Files: setup.py Log Message: Need to catch all errors, not just ImportError. Index: setup.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/setup.py,v retrieving revision 1.125 retrieving revision 1.126 diff -C2 -d -r1.125 -r1.126 *** setup.py 15 Apr 2005 12:44:27 -0000 1.125 --- setup.py 15 Apr 2005 12:54:23 -0000 1.126 *************** *** 223,229 **** try: mod = __import__(modname) ! except ImportError: ! import traceback ! traceback.print_exc() continue try: --- 223,229 ---- try: mod = __import__(modname) ! except Exception, e: ! print >> sys.stderr, \ ! "Could not import %s:\n %s" % (pathname, e) continue try: |
From: Thomas H. <th...@us...> - 2005-04-15 12:44:35
|
Update of /cvsroot/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1039 Modified Files: setup.py Log Message: Print a traceback and continue when a test module cannot be imported. Index: setup.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/setup.py,v retrieving revision 1.124 retrieving revision 1.125 diff -C2 -d -r1.124 -r1.125 *** setup.py 5 Apr 2005 16:58:03 -0000 1.124 --- setup.py 15 Apr 2005 12:44:27 -0000 1.125 *************** *** 221,225 **** for pathname in test_files: modname = os.path.splitext(pathname)[0].split(os.sep)[-1] ! mod = __import__(modname) try: suite = doctest.DocTestSuite(mod) --- 221,230 ---- for pathname in test_files: modname = os.path.splitext(pathname)[0].split(os.sep)[-1] ! try: ! mod = __import__(modname) ! except ImportError: ! import traceback ! traceback.print_exc() ! continue try: suite = doctest.DocTestSuite(mod) |
From: Thomas H. <th...@us...> - 2005-04-15 11:52:12
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6670 Modified Files: _ctypes.c Log Message: Fix a typo - the member field has been renamed. Index: _ctypes.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/_ctypes.c,v retrieving revision 1.301 retrieving revision 1.302 diff -C2 -d -r1.301 -r1.302 *** _ctypes.c 15 Apr 2005 10:10:26 -0000 1.301 --- _ctypes.c 15 Apr 2005 11:52:02 -0000 1.302 *************** *** 3591,3595 **** stgdict = PyObject_stgdict((PyObject *)self); /* should have been catched in Pointer_new() */ ! assert(stgdict->proto); if (!CDataObject_Check(value) || 0 == PyObject_IsInstance(value, stgdict->itemtype)) { --- 3591,3595 ---- stgdict = PyObject_stgdict((PyObject *)self); /* should have been catched in Pointer_new() */ ! assert(stgdict->itemtype); if (!CDataObject_Check(value) || 0 == PyObject_IsInstance(value, stgdict->itemtype)) { |
From: Thomas H. <th...@us...> - 2005-04-15 10:17:30
|
Update of /cvsroot/ctypes/ctypes/unittests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23943/unittests Modified Files: test_libc.py Log Message: cdll attributes are more magic now - they prepend 'lib' and append '.so' or '.dylib'. Index: test_libc.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/unittests/test_libc.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** test_libc.py 12 Apr 2005 19:01:19 -0000 1.2 --- test_libc.py 15 Apr 2005 10:17:21 -0000 1.3 *************** *** 9,16 **** return CDLL("libc.so.6") except OSError: ! return cdll.libc libc = get_libc() ! libm = cdll.libm class LibTest(unittest.TestCase): --- 9,16 ---- return CDLL("libc.so.6") except OSError: ! return cdll.c libc = get_libc() ! libm = cdll.m class LibTest(unittest.TestCase): |
From: Thomas H. <th...@us...> - 2005-04-15 10:10:40
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20076 Modified Files: _ctypes.c Log Message: oops, that didnt compile Index: _ctypes.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/_ctypes.c,v retrieving revision 1.300 retrieving revision 1.301 diff -C2 -d -r1.300 -r1.301 *** _ctypes.c 14 Apr 2005 18:55:46 -0000 1.300 --- _ctypes.c 15 Apr 2005 10:10:26 -0000 1.301 *************** *** 3641,3646 **** Pointer_new(PyTypeObject *type, PyObject *args, PyObject *kw) { ! StgDictObject *dict = PyType_stgdict(type); ! if (!dict || !dict->itemtype) PyErr_SetString(PyExc_TypeError, "Cannot create instance: has no _type_"); --- 3641,3646 ---- Pointer_new(PyTypeObject *type, PyObject *args, PyObject *kw) { ! StgDictObject *dict = PyType_stgdict((PyObject *)type); ! if (!dict || !dict->itemtype) { PyErr_SetString(PyExc_TypeError, "Cannot create instance: has no _type_"); |
From: Thomas H. <th...@us...> - 2005-04-15 08:28:14
|
Update of /cvsroot/ctypes/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv584 Modified Files: __init__.py Log Message: Only the cdll attributes do automatic shared library name mangling, depending on the platform. Index: __init__.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/__init__.py,v retrieving revision 1.70 retrieving revision 1.71 diff -C2 -d -r1.70 -r1.71 *** __init__.py 15 Apr 2005 07:51:36 -0000 1.70 --- __init__.py 15 Apr 2005 08:27:49 -0000 1.71 *************** *** 121,133 **** elif _os.name == "posix": ! from _ctypes import dlopen as _dlopen _FreeLibrary = None - def _LoadLibrary(name): - try: - return _dlopen(name) - except OSError: - if not name.endswith(".so"): - return _dlopen(name + ".so") - raise from _ctypes import sizeof, byref, addressof, alignment --- 121,126 ---- elif _os.name == "posix": ! from _ctypes import dlopen as _LoadLibrary _FreeLibrary = None from _ctypes import sizeof, byref, addressof, alignment *************** *** 409,418 **** self._dlltype = dlltype ! def __getattr__(self, name): ! if name[0] == '_': ! raise AttributeError, name ! dll = self._dlltype(name) ! setattr(self, name, dll) ! return dll def __getitem__(self, name): --- 402,426 ---- self._dlltype = dlltype ! if _os.name == "posix" and sys.platform == "darwin": ! def __getattr__(self, name): ! if name[0] == '_': ! raise AttributeError, name ! dll = self._dlltype("lib%s.dylib" % name) ! setattr(self, name, dll) ! return dll ! elif _os.name == "posix": ! def __getattr__(self, name): ! if name[0] == '_': ! raise AttributeError, name ! dll = self._dlltype("lib%s.so" % name) ! setattr(self, name, dll) ! return dll ! else: ! def __getattr__(self, name): ! if name[0] == '_': ! raise AttributeError, name ! dll = self._dlltype(name) ! setattr(self, name, dll) ! return dll def __getitem__(self, name): |
From: Thomas H. <th...@us...> - 2005-04-15 07:51:44
|
Update of /cvsroot/ctypes/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15020 Modified Files: __init__.py Log Message: Use new style classes. Index: __init__.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/__init__.py,v retrieving revision 1.69 retrieving revision 1.70 diff -C2 -d -r1.69 -r1.70 *** __init__.py 13 Apr 2005 19:51:42 -0000 1.69 --- __init__.py 15 Apr 2005 07:51:36 -0000 1.70 *************** *** 315,319 **** ! class CDLL: class _CdeclFuncPtr(_CFuncPtr): _flags_ = _FUNCFLAG_CDECL --- 315,319 ---- ! class CDLL(object): class _CdeclFuncPtr(_CFuncPtr): _flags_ = _FUNCFLAG_CDECL *************** *** 405,409 **** return func ! class _DLLS: def __init__(self, dlltype): self._dlltype = dlltype --- 405,409 ---- return func ! class _DLLS(object): def __init__(self, dlltype): self._dlltype = dlltype |
From: Thomas H. <th...@us...> - 2005-04-15 07:50:14
|
Update of /cvsroot/ctypes/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14049 Modified Files: Tag: branch_1_0 __init__.py Log Message: Use new style classes. Index: __init__.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/__init__.py,v retrieving revision 1.61.2.2 retrieving revision 1.61.2.3 diff -C2 -d -r1.61.2.2 -r1.61.2.3 *** __init__.py 13 Apr 2005 19:32:12 -0000 1.61.2.2 --- __init__.py 15 Apr 2005 07:49:57 -0000 1.61.2.3 *************** *** 322,326 **** ! class CDLL: class _CdeclFuncPtr(_CFuncPtr): _flags_ = _FUNCFLAG_CDECL --- 322,326 ---- ! class CDLL(object): class _CdeclFuncPtr(_CFuncPtr): _flags_ = _FUNCFLAG_CDECL *************** *** 412,416 **** return func ! class _DLLS: def __init__(self, dlltype): self._dlltype = dlltype --- 412,416 ---- return func ! class _DLLS(object): def __init__(self, dlltype): self._dlltype = dlltype |
Update of /cvsroot/ctypes/ctypes-java/src/java/ctypes/java In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4975/src/java/ctypes/java Modified Files: CType.java CString.java CInt.java CPointer.java CULongPtr.java CCallbackFunction.java CStruct.java CIntPtr.java CWChar.java CShort.java CWCharPtr.java CWString.java CBuffer.java CMalloc.java CException.java CChar.java CByte.java CLongLong.java CFloat.java CDouble.java CSymbolNotFoundException.java CCharPtr.java CULong.java Added Files: CAddress.java Log Message: All win32 unit tests pass. Index: CException.java =================================================================== RCS file: /cvsroot/ctypes/ctypes-java/src/java/ctypes/java/CException.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CException.java 29 Aug 2004 01:25:28 -0000 1.2 --- CException.java 15 Apr 2005 03:15:44 -0000 1.3 *************** *** 27,31 **** * @author Bradley Schatz * ! * Copyright 2003 Managed Data Security */ public class CException extends Exception { --- 27,31 ---- * @author Bradley Schatz * ! * Copyright 2003 Bradley Schatz */ public class CException extends Exception { Index: CChar.java =================================================================== RCS file: /cvsroot/ctypes/ctypes-java/src/java/ctypes/java/CChar.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CChar.java 5 Aug 2003 22:54:59 -0000 1.1 --- CChar.java 15 Apr 2005 03:15:44 -0000 1.2 *************** *** 31,37 **** public class CChar extends CByte { ! /** ! * @param value ! */ public CChar(byte value) { super(value); --- 31,38 ---- public class CChar extends CByte { ! public CChar() { ! super(); ! } ! public CChar(byte value) { super(value); *************** *** 46,52 **** } ! public CChar(long handle) { super(handle); } public void dump(StringBuffer buf, int level) throws CException { super.dump(buf, level); --- 47,54 ---- } ! public CChar(CAddress handle) throws CException { super(handle); } + public void dump(StringBuffer buf, int level) throws CException { super.dump(buf, level); *************** *** 56,59 **** --- 58,62 ---- buf.append(getValue()); } + public void dump(int level) throws CException { super.dump(level); Index: CDouble.java =================================================================== RCS file: /cvsroot/ctypes/ctypes-java/src/java/ctypes/java/CDouble.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CDouble.java 5 Aug 2003 22:54:59 -0000 1.1 --- CDouble.java 15 Apr 2005 03:15:44 -0000 1.2 *************** *** 52,62 **** ! public void setAddress(long i, int syncDirection) throws CException { super.setAddress(i, syncDirection); if (isMemoryBacked()) { ! if (syncDirection == SYNCDIR_TOC) { setDouble(value); ! } else if (syncDirection == SYNCDIR_TOJAVA) { value = getDouble(); } --- 52,62 ---- ! public void setAddress(CAddress i, CType.SyncDirection syncDirection) throws CException { super.setAddress(i, syncDirection); if (isMemoryBacked()) { ! if (syncDirection == CType.SyncDirection.ToC) { setDouble(value); ! } else if (syncDirection == CType.SyncDirection.ToJava) { value = getDouble(); } Index: CLongLong.java =================================================================== RCS file: /cvsroot/ctypes/ctypes-java/src/java/ctypes/java/CLongLong.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CLongLong.java 5 Aug 2003 22:54:59 -0000 1.1 --- CLongLong.java 15 Apr 2005 03:15:44 -0000 1.2 *************** *** 33,36 **** --- 33,40 ---- } + public CLongLong() { + super(8); + } + public void setValue(long v ) { value = v; *************** *** 39,49 **** } } ! public void setAddress(long i, int syncDirection) throws CException { super.setAddress(i, syncDirection); if (isMemoryBacked()) { ! if (syncDirection == SYNCDIR_TOC) { setLong(value); ! } else if (syncDirection == SYNCDIR_TOJAVA) { value = getLong(); } --- 43,53 ---- } } ! public void setAddress(CAddress i, CType.SyncDirection syncDirection) throws CException { super.setAddress(i, syncDirection); if (isMemoryBacked()) { ! if (syncDirection == CType.SyncDirection.ToC) { setLong(value); ! } else if (syncDirection == CType.SyncDirection.ToJava) { value = getLong(); } Index: CULongPtr.java =================================================================== RCS file: /cvsroot/ctypes/ctypes-java/src/java/ctypes/java/CULongPtr.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CULongPtr.java 5 Aug 2003 22:54:59 -0000 1.1 --- CULongPtr.java 15 Apr 2005 03:15:44 -0000 1.2 *************** *** 42,46 **** * @param handle */ ! public CULongPtr(long handle) { super(handle); } --- 42,46 ---- * @param handle */ ! public CULongPtr(CAddress handle) { super(handle); } *************** *** 55,59 **** public CULong getCULong() throws CException { ! CULong c = new CULong(address); return c; } --- 55,59 ---- public CULong getCULong() throws CException { ! CULong c = new CULong(caddress); return c; } Index: CIntPtr.java =================================================================== RCS file: /cvsroot/ctypes/ctypes-java/src/java/ctypes/java/CIntPtr.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CIntPtr.java 19 Apr 2004 13:39:03 -0000 1.1 --- CIntPtr.java 15 Apr 2005 03:15:44 -0000 1.2 *************** *** 43,50 **** * @param handle */ ! public CIntPtr(long handle) { super(handle); } /** * @param obj --- 43,54 ---- * @param handle */ ! public CIntPtr(CAddress handle) { super(handle); } + public CIntPtr(long handle) { + super(new CAddress(handle)); + } + /** * @param obj *************** *** 58,62 **** if (pointee == null) { pointee = new CInt(); ! pointee.setAddress(address, CType.SYNCDIR_TOJAVA); } return pointee; --- 62,66 ---- if (pointee == null) { pointee = new CInt(); ! pointee.setAddress(caddress, CType.SyncDirection.ToJava); } return pointee; Index: CCallbackFunction.java =================================================================== RCS file: /cvsroot/ctypes/ctypes-java/src/java/ctypes/java/CCallbackFunction.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** CCallbackFunction.java 29 Aug 2004 01:25:28 -0000 1.5 --- CCallbackFunction.java 15 Apr 2005 03:15:44 -0000 1.6 *************** *** 38,42 **** synchronized (this) { fini(this.thunk); ! this.address = 0; this.memoryBacked = false; this.isAtomic = false; --- 38,42 ---- synchronized (this) { fini(this.thunk); ! this.caddress = CAddress.NULL; this.memoryBacked = false; this.isAtomic = false; *************** *** 65,75 **** protected native void fini(long thunk ); ! public void setAddress(long i, int syncDirection) throws CException { super.setAddress(i, syncDirection); if (isMemoryBacked()) { ! if (syncDirection == SYNCDIR_TOC) { pokeThunk(thunk); ! } else if (syncDirection == SYNCDIR_TOJAVA) { thunk = peekThunk(); } --- 65,75 ---- protected native void fini(long thunk ); ! public void setAddress(CAddress i, CType.SyncDirection syncDirection) throws CException { super.setAddress(i, syncDirection); if (isMemoryBacked()) { ! if (syncDirection == CType.SyncDirection.ToC) { pokeThunk(thunk); ! } else if (syncDirection == CType.SyncDirection.ToJava) { thunk = peekThunk(); } Index: CFloat.java =================================================================== RCS file: /cvsroot/ctypes/ctypes-java/src/java/ctypes/java/CFloat.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CFloat.java 5 Aug 2003 22:54:59 -0000 1.1 --- CFloat.java 15 Apr 2005 03:15:44 -0000 1.2 *************** *** 55,65 **** ! public void setAddress(long i, int syncDirection) throws CException { super.setAddress(i, syncDirection); if (isMemoryBacked()) { ! if (syncDirection == SYNCDIR_TOC) { setFloat(value); ! } else if (syncDirection == SYNCDIR_TOJAVA) { value = getFloat(); } --- 55,65 ---- ! public void setAddress(CAddress i, CType.SyncDirection syncDirection) throws CException { super.setAddress(i, syncDirection); if (isMemoryBacked()) { ! if (syncDirection == CType.SyncDirection.ToC) { setFloat(value); ! } else if (syncDirection == CType.SyncDirection.ToJava) { value = getFloat(); } Index: CCharPtr.java =================================================================== RCS file: /cvsroot/ctypes/ctypes-java/src/java/ctypes/java/CCharPtr.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CCharPtr.java 5 Aug 2003 22:54:59 -0000 1.1 --- CCharPtr.java 15 Apr 2005 03:15:44 -0000 1.2 *************** *** 39,46 **** } /** * @param handle */ ! public CCharPtr(long handle) { super(handle); } --- 39,49 ---- } + public CCharPtr(long handle) { + super(new CAddress(handle)); + } /** * @param handle */ ! public CCharPtr(CAddress handle) { super(handle); } *************** *** 55,69 **** public CString getCString() throws CException { ! CChar c = new CChar(address); ! long ptr = address; ! byte b; ! while ((b = c.getValue()) != 0) { ! System.out.println((char)b); ! ptr++; ! c.setAddress(ptr, CType.SYNCDIR_TOJAVA); } ! long size = ptr - address; ! return new CString(address, (int) size); } --- 58,71 ---- public CString getCString() throws CException { ! CChar c = new CChar(caddress); ! CAddress ptr = (CAddress) caddress.clone(); ! while ((c.getValue()) != 0) { ! //System.out.println((char)b); ! ptr = ptr.add(1); ! c.setAddress(ptr, CType.SyncDirection.ToJava); } ! long size = ptr.difference(caddress); ! return new CString(caddress, (int) size); } *************** *** 71,81 **** if (subject == null) { subject = new CString(); ! subject.setAddress(getValue(), CType.SYNCDIR_TOJAVA); } else { if (isMemoryBacked()) { long v = getPointer(); ! long j = subject.getAddress(); if (v != j) { ! subject.setAddress(v, CType.SYNCDIR_TOJAVA); } } --- 73,83 ---- if (subject == null) { subject = new CString(); ! subject.setAddress(new CAddress(getValue()), CType.SyncDirection.ToJava); } else { if (isMemoryBacked()) { long v = getPointer(); ! long j = subject.getAddress().getValue(); if (v != j) { ! subject.setAddress(new CAddress(v), CType.SyncDirection.ToJava); } } Index: CWChar.java =================================================================== RCS file: /cvsroot/ctypes/ctypes-java/src/java/ctypes/java/CWChar.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CWChar.java 5 Aug 2003 22:54:59 -0000 1.1 --- CWChar.java 15 Apr 2005 03:15:44 -0000 1.2 *************** *** 40,46 **** } ! public CWChar(long handle) { super(2); ! this.address = handle; this.memoryBacked = true; } --- 40,47 ---- } ! public CWChar(CAddress handle) throws CException { super(2); ! setAddress(handle, CType.SyncDirection.ToJava); ! this.caddress = handle; this.memoryBacked = true; } *************** *** 63,71 **** protected native char getWChar(); ! public void setAddress(long i, int syncDirection) throws CException { super.setAddress(i, syncDirection); ! if (syncDirection == SYNCDIR_TOC) { setWChar(value); ! } else if (syncDirection == SYNCDIR_TOJAVA) { value = getWChar(); } --- 64,72 ---- protected native char getWChar(); ! public void setAddress(CAddress i, CType.SyncDirection syncDirection) throws CException { super.setAddress(i, syncDirection); ! if (syncDirection == CType.SyncDirection.ToC) { setWChar(value); ! } else if (syncDirection == CType.SyncDirection.ToJava) { value = getWChar(); } Index: CString.java =================================================================== RCS file: /cvsroot/ctypes/ctypes-java/src/java/ctypes/java/CString.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CString.java 5 Aug 2003 22:54:59 -0000 1.1 --- CString.java 15 Apr 2005 03:15:44 -0000 1.2 *************** *** 41,47 **** } ! public CString(long handle, int size) throws CException { super(size); ! this.address = handle; this.memoryBacked = true; hasValue = false; --- 41,47 ---- } ! public CString(CAddress handle, int size) throws CException { super(size); ! this.caddress = handle; this.memoryBacked = true; hasValue = false; *************** *** 63,70 **** } ! public void setAddress(long i, int syncDirection) throws CException { super.setAddress(i, syncDirection); if (isMemoryBacked()) { ! if (syncDirection == SYNCDIR_TOC) { if (hasValueAssigned()) { byte[] bytes = new byte[size]; --- 63,70 ---- } ! public void setAddress(CAddress i, CType.SyncDirection syncDirection) throws CException { super.setAddress(i, syncDirection); if (isMemoryBacked()) { ! if (syncDirection == CType.SyncDirection.ToC) { if (hasValueAssigned()) { byte[] bytes = new byte[size]; *************** *** 73,77 **** } ! } else if (syncDirection == SYNCDIR_TOJAVA) { // TODO --- 73,77 ---- } ! } else if (syncDirection == CType.SyncDirection.ToJava) { // TODO Index: CPointer.java =================================================================== RCS file: /cvsroot/ctypes/ctypes-java/src/java/ctypes/java/CPointer.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CPointer.java 2 Mar 2004 04:36:19 -0000 1.2 --- CPointer.java 15 Apr 2005 03:15:44 -0000 1.3 *************** *** 39,45 **** } ! public CPointer(long handle) { super(4); ! this.address = handle; } --- 39,46 ---- } ! public CPointer(CAddress handle) { super(4); ! this.caddress = handle; ! address = handle.getValue(); } *************** *** 47,54 **** super(4); if (obj.isMemoryBacked()) { ! setValue(obj.getAddress()); } else { buf = new CBuffer(obj); ! setValue(buf.getAddress()); } subject = obj; --- 48,55 ---- super(4); if (obj.isMemoryBacked()) { ! setValue(obj.getAddress().getValue()); } else { buf = new CBuffer(obj); ! setValue(buf.getAddress().getValue()); } subject = obj; *************** *** 66,84 **** return value; } ! public long getAddress() throws CException { if (!isMemoryBacked() && subject != null) { CBuffer buf = new CBuffer(this); ! setAddress(buf.getAddress(), CType.SYNCDIR_TOC); ! setValue(subject.getAddress()); } ! return address; } ! public void setAddress(long i, int syncDirection) throws CException { super.setAddress(i, syncDirection); if (isMemoryBacked()) { ! if (syncDirection == SYNCDIR_TOC) { setPointer(value); ! } else if (syncDirection == SYNCDIR_TOJAVA) { value = getPointer(); } --- 67,85 ---- return value; } ! public CAddress getAddress() throws CException { if (!isMemoryBacked() && subject != null) { CBuffer buf = new CBuffer(this); ! setAddress(buf.getAddress(), CType.SyncDirection.ToC); ! setValue(subject.getAddress().getValue()); } ! return caddress; } ! public void setAddress(CAddress i, CType.SyncDirection syncDirection) throws CException { super.setAddress(i, syncDirection); if (isMemoryBacked()) { ! if (syncDirection == CType.SyncDirection.ToC) { setPointer(value); ! } else if (syncDirection == CType.SyncDirection.ToJava) { value = getPointer(); } *************** *** 87,94 **** public void setSubject(CType obj) throws CException { if (obj.isMemoryBacked()) { ! setValue(obj.getAddress()); } else { buf = new CBuffer(obj); ! setValue(buf.getAddress()); } --- 88,95 ---- public void setSubject(CType obj) throws CException { if (obj.isMemoryBacked()) { ! setValue(obj.getAddress().getValue()); } else { buf = new CBuffer(obj); ! setValue(buf.getAddress().getValue()); } *************** *** 102,108 **** if (isMemoryBacked() && subject != null) { long v = getPointer(); ! long j = subject.getAddress(); if (v != j) { ! subject.setAddress(v, CType.SYNCDIR_TOJAVA); } } --- 103,109 ---- if (isMemoryBacked() && subject != null) { long v = getPointer(); ! long j = subject.getAddress().getValue(); if (v != j) { ! subject.setAddress(new CAddress(v), CType.SyncDirection.ToJava); } } *************** *** 112,116 **** public void setValue(long v) throws CException { if (hasValueAssigned()) { ! subject.setAddress(v, CType.SYNCDIR_TOJAVA); } value = v; --- 113,117 ---- public void setValue(long v) throws CException { if (hasValueAssigned()) { ! subject.setAddress(new CAddress(v), CType.SyncDirection.ToJava); } value = v; Index: CMalloc.java =================================================================== RCS file: /cvsroot/ctypes/ctypes-java/src/java/ctypes/java/CMalloc.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CMalloc.java 5 Aug 2003 22:54:59 -0000 1.1 --- CMalloc.java 15 Apr 2005 03:15:44 -0000 1.2 *************** *** 32,45 **** public class CMalloc { ! public static long malloc(int size) throws OutOfMemoryError { long peer = alloc(size); if (peer == 0) { throw new OutOfMemoryError(); } ! return peer; } public native static long alloc(int size); ! public native static void free(long address); } --- 32,47 ---- public class CMalloc { ! public static CAddress malloc(int size) throws OutOfMemoryError { long peer = alloc(size); if (peer == 0) { throw new OutOfMemoryError(); } ! return new CAddress(peer); } public native static long alloc(int size); ! public static void free(CAddress address) { ! free(address.getValue()); ! } public native static void free(long address); } Index: CShort.java =================================================================== RCS file: /cvsroot/ctypes/ctypes-java/src/java/ctypes/java/CShort.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CShort.java 5 Aug 2003 22:54:59 -0000 1.1 --- CShort.java 15 Apr 2005 03:15:44 -0000 1.2 *************** *** 56,65 **** protected native short getShort(); ! public void setAddress(long i, int syncDirection) throws CException { super.setAddress(i, syncDirection); if (isMemoryBacked()) { ! if (syncDirection == SYNCDIR_TOC) { setShort(value); ! } else if (syncDirection == SYNCDIR_TOJAVA) { value = getShort(); } --- 56,65 ---- protected native short getShort(); ! public void setAddress(CAddress i, CType.SyncDirection syncDirection) throws CException { super.setAddress(i, syncDirection); if (isMemoryBacked()) { ! if (syncDirection == CType.SyncDirection.ToC) { setShort(value); ! } else if (syncDirection == CType.SyncDirection.ToJava) { value = getShort(); } Index: CBuffer.java =================================================================== RCS file: /cvsroot/ctypes/ctypes-java/src/java/ctypes/java/CBuffer.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** CBuffer.java 29 Aug 2004 01:25:28 -0000 1.4 --- CBuffer.java 15 Apr 2005 03:15:44 -0000 1.5 *************** *** 33,38 **** public CBuffer(CType t) throws CException { ! allocate(t.sizeOf()); ! t.setAddress(address, CType.SYNCDIR_TOC); } --- 33,38 ---- public CBuffer(CType t) throws CException { ! CAddress caddress = allocate(t.sizeOf()); ! t.setAddress(caddress, CType.SyncDirection.ToC); } *************** *** 52,65 **** } ! protected long allocate(int size) throws CException { ! this.size = size; ! address = CMalloc.alloc(size); ! memoryBacked = true; ! isAtomic = true; ! return address; ! } public byte[] getData() throws CException { ! return doGetData(address, size); } --- 52,59 ---- } ! public byte[] getData() throws CException { ! return doGetData(caddress.getValue(), size); } *************** *** 70,74 **** allocate(size); } ! doSetData(address, data); } --- 64,68 ---- allocate(size); } ! doSetData(caddress.getValue(), data); } *************** *** 76,80 **** public String toString() { ! return "CBuffer object " + Long.toHexString(address) + " length " + size; } --- 70,74 ---- public String toString() { ! return "CBuffer object " + caddress.toString() + " length " + size; } Index: CSymbolNotFoundException.java =================================================================== RCS file: /cvsroot/ctypes/ctypes-java/src/java/ctypes/java/CSymbolNotFoundException.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CSymbolNotFoundException.java 5 Aug 2003 22:54:59 -0000 1.1 --- CSymbolNotFoundException.java 15 Apr 2005 03:15:44 -0000 1.2 *************** *** 26,30 **** * @author Bradley Schatz * ! * Copyright 2003 Managed Data Security */ public class CSymbolNotFoundException extends CException { --- 26,30 ---- * @author Bradley Schatz * ! * Copyright 2003 Bradley Schatz */ public class CSymbolNotFoundException extends CException { Index: CULong.java =================================================================== RCS file: /cvsroot/ctypes/ctypes-java/src/java/ctypes/java/CULong.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CULong.java 5 Aug 2003 22:54:59 -0000 1.1 --- CULong.java 15 Apr 2005 03:15:44 -0000 1.2 *************** *** 32,35 **** --- 32,40 ---- this.value = value; } + + public CULong(CAddress addr) throws CException { + super(4); + setAddress(addr, CType.SyncDirection.ToJava); + } public CULong() { *************** *** 55,65 **** protected native long getLong(); ! public void setAddress(long i, int syncDirection) throws CException { super.setAddress(i, syncDirection); if (isMemoryBacked()) { ! if (syncDirection == SYNCDIR_TOC) { setLong(value); ! } else if (syncDirection == SYNCDIR_TOJAVA) { value = getLong(); } --- 60,70 ---- protected native long getLong(); ! public void setAddress(CAddress i, CType.SyncDirection syncDirection) throws CException { super.setAddress(i, syncDirection); if (isMemoryBacked()) { ! if (syncDirection == CType.SyncDirection.ToC) { setLong(value); ! } else if (syncDirection == CType.SyncDirection.ToJava) { value = getLong(); } Index: CWString.java =================================================================== RCS file: /cvsroot/ctypes/ctypes-java/src/java/ctypes/java/CWString.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CWString.java 5 Aug 2003 22:54:59 -0000 1.1 --- CWString.java 15 Apr 2005 03:15:44 -0000 1.2 *************** *** 34,38 **** String value = null; /** ! * @param size * @throws Exception */ --- 34,38 ---- String value = null; /** ! * @param size The size in characters, not bytes and excluding any terminator. * @throws Exception */ *************** *** 41,47 **** } ! public CWString(long handle, int size) { super(size*2); ! this.address = handle; memoryBacked = true; } --- 41,52 ---- } ! /** ! * @param handle An address. ! * @param size The size in characters, not bytes and excluding any terminator. ! * @throws Exception ! */ ! public CWString(CAddress handle, int size) { super(size*2); ! this.caddress = handle; memoryBacked = true; } *************** *** 63,71 **** } ! public void setAddress(long i, int syncDirection) throws CException { super.setAddress(i, syncDirection); if (isMemoryBacked()) { ! if (syncDirection == SYNCDIR_TOC) { if (hasValueAssigned()) { byte[] bytes = new byte[size]; --- 68,76 ---- } ! public void setAddress(CAddress i, CType.SyncDirection syncDirection) throws CException { super.setAddress(i, syncDirection); if (isMemoryBacked()) { ! if (syncDirection == CType.SyncDirection.ToC) { if (hasValueAssigned()) { byte[] bytes = new byte[size]; *************** *** 73,77 **** setData(bytes); } ! } else if (syncDirection == SYNCDIR_TOJAVA) { //TODO } --- 78,82 ---- setData(bytes); } ! } else if (syncDirection == CType.SyncDirection.ToJava) { //TODO } Index: CInt.java =================================================================== RCS file: /cvsroot/ctypes/ctypes-java/src/java/ctypes/java/CInt.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** CInt.java 19 Apr 2004 13:39:03 -0000 1.3 --- CInt.java 15 Apr 2005 03:15:44 -0000 1.4 *************** *** 39,43 **** this.value = 0; } ! public void setValue(int v) throws CException { value = v; --- 39,55 ---- this.value = 0; } ! public CInt(long handle) throws CException { ! super(new CAddress(handle)); ! setAddress(caddress, CType.SyncDirection.ToJava); ! memoryBacked = true; ! } ! ! public CInt(CAddress handle) throws CException { ! super(4); ! setAddress(handle, CType.SyncDirection.ToJava); ! this.caddress = handle; ! memoryBacked = true; ! } ! public void setValue(int v) throws CException { value = v; *************** *** 58,68 **** protected native int getInt(); ! public void setAddress(long i, int syncDirection) throws CException { super.setAddress(i, syncDirection); if (isMemoryBacked()) { ! if (syncDirection == SYNCDIR_TOC) { setInt(value); ! } else if (syncDirection == SYNCDIR_TOJAVA) { value = getInt(); } --- 70,80 ---- protected native int getInt(); ! public void setAddress(CAddress i, CType.SyncDirection syncDirection) throws CException { super.setAddress(i, syncDirection); if (isMemoryBacked()) { ! if (syncDirection == CType.SyncDirection.ToC) { setInt(value); ! } else if (syncDirection == CType.SyncDirection.ToJava) { value = getInt(); } Index: CStruct.java =================================================================== RCS file: /cvsroot/ctypes/ctypes-java/src/java/ctypes/java/CStruct.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** CStruct.java 29 Aug 2004 01:25:28 -0000 1.5 --- CStruct.java 15 Apr 2005 03:15:44 -0000 1.6 *************** *** 54,66 **** } ! public void setAddress(long handle, int syncDirection) throws CException { ! if (handle != 0 && !isMemoryBacked()) { super.setAddress(handle, syncDirection); // now link each struct element onto the // memory buffer for (int i = 0 ; i < elements.length ; i++) { CType t = elements[i]; t.setAddress(handle, syncDirection); ! handle = handle + t.sizeOf(); allocated = allocated + t.sizeOf(); } --- 54,67 ---- } ! public void setAddress(CAddress handle, CType.SyncDirection syncDirection) throws CException { ! if (handle != CAddress.NULL && !isMemoryBacked()) { super.setAddress(handle, syncDirection); // now link each struct element onto the // memory buffer + for (int i = 0 ; i < elements.length ; i++) { CType t = elements[i]; t.setAddress(handle, syncDirection); ! handle = handle.add(t.sizeOf()); allocated = allocated + t.sizeOf(); } *************** *** 105,108 **** --- 106,120 ---- } + protected CAddress allocate(int size) throws CException { + this.size = size; + caddress = CMalloc.malloc(size); + address = caddress.getValue(); + + // we arent yet _fully_ memory backed + memoryBacked = false; + isAtomic = false; + return caddress; + } + public void dump(StringBuffer buf, int level) throws CException { if (!initialized) { Index: CByte.java =================================================================== RCS file: /cvsroot/ctypes/ctypes-java/src/java/ctypes/java/CByte.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CByte.java 5 Aug 2003 22:54:59 -0000 1.1 --- CByte.java 15 Apr 2005 03:15:44 -0000 1.2 *************** *** 30,38 **** byte value = -1; ! public CByte(long handle) { super(1); ! this.address = handle; memoryBacked = true; } public CByte(byte value) { //init with size of 4 bytes --- 30,45 ---- byte value = -1; ! public CByte(CAddress handle) throws CException { super(1); ! setAddress(handle, CType.SyncDirection.ToJava); ! this.caddress = handle; memoryBacked = true; } + + public CByte() { + super(1); + memoryBacked = false; + } + public CByte(byte value) { //init with size of 4 bytes *************** *** 61,71 **** protected native byte getByte(); ! public void setAddress(long i, int syncDirection) throws CException { super.setAddress(i, syncDirection); if (isMemoryBacked()) { ! if (syncDirection == SYNCDIR_TOC) { setByte(value); ! } else if (syncDirection == SYNCDIR_TOJAVA) { value = getByte(); } --- 68,78 ---- protected native byte getByte(); ! public void setAddress(CAddress i, CType.SyncDirection syncDirection) throws CException { super.setAddress(i, syncDirection); if (isMemoryBacked()) { ! if (syncDirection == CType.SyncDirection.ToC) { setByte(value); ! } else if (syncDirection == CType.SyncDirection.ToJava) { value = getByte(); } Index: CWCharPtr.java =================================================================== RCS file: /cvsroot/ctypes/ctypes-java/src/java/ctypes/java/CWCharPtr.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CWCharPtr.java 5 Aug 2003 22:54:59 -0000 1.1 --- CWCharPtr.java 15 Apr 2005 03:15:44 -0000 1.2 *************** *** 38,45 **** } - /** - * @param handle - */ public CWCharPtr(long handle) { super(handle); } --- 38,46 ---- } public CWCharPtr(long handle) { + super(new CAddress(handle)); + } + + public CWCharPtr(CAddress handle) { super(handle); } *************** *** 54,66 **** public CWString getCWString() throws Exception { ! CWChar c = new CWChar(address); ! long ptr = address; while (c.getValue() != 0) { ! ptr = ptr + 2; ! c.setAddress(ptr, CType.SYNCDIR_TOJAVA); } ! long size = ptr - address; ! return new CWString(address, (int)size/2); } } --- 55,67 ---- public CWString getCWString() throws Exception { ! CWChar c = new CWChar(caddress); ! CAddress ptr = (CAddress) caddress.clone(); while (c.getValue() != 0) { ! ptr = ptr.add(2); ! c.setAddress(ptr, CType.SyncDirection.ToJava); } ! long size = ptr.difference(caddress); ! return new CWString(caddress, (int)size/2); } } --- NEW FILE: CAddress.java --- /* * Created on 20/01/2005 * * TODO To change the template for this generated file go to * Window - Preferences - Java - Code Style - Code Templates */ package ctypes.java; /** * @author bradley * */ public class CAddress { private long value = 0; public static CAddress NULL = new CAddress(); public CAddress() { } public CAddress(long value) { this.value = value; } public long getValue() { return value; } public void setValue(long value) { this.value = value; } public CInt asCInt() throws CException { CInt i = new CInt(); i.setAddress(this, CType.SyncDirection.ToJava); return i; } public CLong asCLong() throws CException { CLong i = new CLong(); i.setAddress(this, CType.SyncDirection.ToJava); return i; } public CLongLong asCLongLong() throws CException { CLongLong i = new CLongLong(); i.setAddress(this, CType.SyncDirection.ToJava); return i; } public CShort asCShort() throws CException { CShort i = new CShort(); i.setAddress(this, CType.SyncDirection.ToJava); return i; } public CAddress add(long val) { return new CAddress(val + value); } public long difference(CAddress o) { return value - o.value; } public String toString() { return " Address 0x" + Long.toHexString(value); } public Object clone() { return new CAddress(value); } } Index: CType.java =================================================================== RCS file: /cvsroot/ctypes/ctypes-java/src/java/ctypes/java/CType.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** CType.java 29 Aug 2004 01:25:28 -0000 1.6 --- CType.java 15 Apr 2005 03:15:44 -0000 1.7 *************** *** 31,40 **** */ public class CType { - public static int SYNCDIR_TOC = 0; - public static int SYNCDIR_TOJAVA = 1; ! public long address = 0; public int size = 0; /* * indicates that this is pinned to cspace memory --- 31,48 ---- */ public class CType { ! public CAddress caddress = null; ! long address = 0; ! public int size = 0; + public static class SyncDirection { + public static SyncDirection ToC = new SyncDirection(); + public static SyncDirection ToJava = new SyncDirection(); + + private SyncDirection() {}; + } + + /* * indicates that this is pinned to cspace memory *************** *** 74,78 **** ! protected CType(int size) { --- 82,89 ---- ! public CType(CAddress handle) { ! this.caddress = handle; ! address = handle.getValue(); ! } protected CType(int size) { *************** *** 86,92 **** * @return */ ! public long getAddress() throws CException { ! return address; } --- 97,103 ---- * @return */ ! public CAddress getAddress() throws CException { ! return caddress; } *************** *** 99,107 **** /** * @param i */ ! public void setAddress(long i, int syncDirection) throws CException { ! address = i; ! if (address != 0) { memoryBacked = true; } --- 110,121 ---- /** + * Set the caddress of the ctype, and store the real address + * in the (local) address field. * @param i */ ! public void setAddress(CAddress i, SyncDirection dir) throws CException { ! caddress = i; ! address = i.getValue(); ! if (caddress != CAddress.NULL) { memoryBacked = true; } *************** *** 122,126 **** --- 136,153 ---- return hasValue; } + + public void pin() throws CException { + CAddress caddress = allocate(sizeOf()); + setAddress(caddress, CType.SyncDirection.ToC); + } + protected CAddress allocate(int size) throws CException { + this.size = size; + caddress = CMalloc.malloc(size); + address = caddress.getValue(); + memoryBacked = true; + isAtomic = true; + return caddress; + } public void dump(StringBuffer buf, int level) throws CException { buf.append("\r\n"); *************** *** 132,137 **** buf.append(Integer.toHexString(hashCode())); if (isMemoryBacked()) { ! buf.append(" Address 0x"); ! buf.append(Long.toHexString(getAddress())); } } --- 159,163 ---- buf.append(Integer.toHexString(hashCode())); if (isMemoryBacked()) { ! buf.append(caddress.toString()); } } *************** *** 146,151 **** System.err.print(Integer.toHexString(hashCode())); if (isMemoryBacked()) { ! System.err.print(" Address 0x"); ! System.err.print(Long.toHexString(getAddress())); } --- 172,176 ---- System.err.print(Integer.toHexString(hashCode())); if (isMemoryBacked()) { ! System.err.print(caddress.toString()); } *************** *** 181,188 **** synchronized (this) { if (isAtomic()) { ! CMalloc.free(address); this.memoryBacked = false; this.isAtomic = false; ! this.address = 0; } } --- 206,213 ---- synchronized (this) { if (isAtomic()) { ! CMalloc.free(caddress); this.memoryBacked = false; this.isAtomic = false; ! this.caddress = CAddress.NULL; } } |
From: Bradley L S. <bs...@us...> - 2005-04-15 03:16:23
|
Update of /cvsroot/ctypes/ctypes-java/src/test/ctypes/java/test/generic In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4975/src/test/ctypes/java/test/generic Modified Files: PointerTest.java Added Files: TestNumbers.java StructTest.java TestChars.java Removed Files: CharTest.java Log Message: All win32 unit tests pass. --- NEW FILE: StructTest.java --- /* Copyright (c) 2004 Bradley Schatz Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ package ctypes.java.test.generic; import ctypes.java.CAddress; import ctypes.java.CArray; import ctypes.java.CException; import ctypes.java.CInt; import ctypes.java.CPointer; import ctypes.java.CStruct; import ctypes.java.CType; import ctypes.java.CWString; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; /** * @author bradley * * To change the template for this generated type comment go to * Window>Preferences>Java>Code Generation>Code and Comments */ public class StructTest extends TestCase { /** * Constructor for WinDLLTest. * @param arg0 */ public StructTest(String arg0) { super(arg0); } public void testContentsOfIntArray() { try { CType[] array = { new CInt(5), new CInt(4), new CInt(3), new CInt(1), new CInt(7), new CInt(9), new CInt(33), new CInt(2), new CInt(99), new CInt(0)}; CArray intArray = new CArray(array); intArray.pin(); CAddress addr = intArray.getAddress(); assertEquals(5, addr.asCInt().getValue()); addr = addr.add(4); assertEquals(4, addr.asCInt().getValue()); addr = addr.add(4); assertEquals(3, addr.asCInt().getValue()); addr = addr.add(4); assertEquals(1, addr.asCInt().getValue()); addr = addr.add(4); assertEquals(7, addr.asCInt().getValue()); addr = addr.add(4); assertEquals(9, addr.asCInt().getValue()); addr = addr.add(4); assertEquals(33, addr.asCInt().getValue()); addr = addr.add(4); assertEquals(2, addr.asCInt().getValue()); addr = addr.add(4); assertEquals(99, addr.asCInt().getValue()); addr = addr.add(4); assertEquals(0, addr.asCInt().getValue()); } catch (Exception e) { fail(); } } public void testStruct() { try { CType[] array = { new CInt(3), new CWString("foo"), new CInt(99)}; CStruct intArray = new CStruct(array); intArray.pin(); CAddress addr = intArray.getAddress(); assertEquals(3, addr.asCInt().getValue()); int strLen = addr.asCInt().getValue(); addr = addr.add(4); CWString str = new CWString(addr, strLen); assertEquals("foo", str.getValue()); // its in unicode, length, including terminating null is double the size addr = addr.add((strLen + 1)*2); assertEquals(99, addr.asCInt().getValue()); } catch (Exception e) { fail(); } } public static Test suite() { TestSuite suite= new TestSuite(); suite.addTest(new TestSuite(StructTest.class)); return suite; } public static void main(String args[]) { junit.textui.TestRunner.run(suite()); } } --- NEW FILE: TestChars.java --- /* Copyright (c) 2004 Bradley Schatz Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ package ctypes.java.test.generic; import ctypes.java.CArray; import ctypes.java.CBuffer; import ctypes.java.CChar; import ctypes.java.CString; import ctypes.java.CType; import ctypes.java.CWChar; import ctypes.java.CWString; import junit.framework.TestCase; /** * @author bradley * * To change the template for this generated type comment go to * Window>Preferences>Java>Code Generation>Code and Comments */ public class TestChars extends TestCase { /** * Constructor for WinDLLTest. * @param arg0 */ public TestChars(String arg0) { super(arg0); } public void testCharsFromUnicodeString() { try { CWString str = new CWString("Hello"); CBuffer buf = new CBuffer(str); CWChar c = new CWChar(); for (int i = 0; i < str.getValue().length(); i++) { c.setAddress(str.getAddress().add(i * 2), CType.SyncDirection.ToJava); assertEquals(c.getValue(), str.getValue().charAt(i)); } } catch (Exception e) { fail(); } } public void testCharsFromString() { try { CString str = new CString("Hello"); CBuffer buf = new CBuffer(str); CChar c = new CChar(); for (int i = 0; i < str.getValue().length(); i++) { c.setAddress(str.getAddress().add(i), CType.SyncDirection.ToJava); assertEquals(c.getValue(), str.getValue().charAt(i)); } } catch (Exception e) { fail(); } } public void testUnicodeStringFromUnicodeCharArray() { try { CWChar[] a = { new CWChar('H'), new CWChar('e'), new CWChar('l'), new CWChar('l'), new CWChar('o')}; CArray ary = new CArray(a); CBuffer buf = new CBuffer(ary); CWString cws = new CWString(5); cws.setAddress(buf.getAddress(), CType.SyncDirection.ToJava); assertEquals(cws.getValue(), "Hello"); } catch (Exception e) { fail(); } } public void testStringFromCharArray() { try { CChar[] a = { new CChar('H'), new CChar('e'), new CChar('l'), new CChar('l'), new CChar('o')}; CArray ary = new CArray(a); CBuffer buf = new CBuffer(ary); CString cws = new CString(5); cws.setAddress(buf.getAddress(), CType.SyncDirection.ToJava); assertEquals(cws.getValue(), "Hello"); } catch (Exception e) { fail(); } } } --- CharTest.java DELETED --- --- NEW FILE: TestNumbers.java --- /* Copyright (c) 2004 Bradley Schatz Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ package ctypes.java.test.generic; import junit.framework.TestCase; import ctypes.java.CAddress; import ctypes.java.CBuffer; import ctypes.java.CInt; import ctypes.java.CIntPtr; import ctypes.java.CLong; import ctypes.java.CLongLong; import ctypes.java.CShort; /** * @author bradley * */ public class TestNumbers extends TestCase { public TestNumbers(String arg0) { super(arg0); } public void testIntFromConstructor() { try { CInt i = new CInt(11); assertEquals(i.getValue(), 11); } catch (Exception e) { fail(); } } public void testIntFromPointer() { try { CInt i = new CInt(0xff); CBuffer buf = new CBuffer(i); CAddress addr = buf.getAddress(); CInt b = addr.asCInt(); assertEquals(0xff, b.getValue()); } catch (Exception e) { fail(); } } public void testLongFromConstructor() { try { CLong i = new CLong(11); assertEquals(i.getValue(), 11); } catch (Exception e) { fail(); } } public void testLongFromPointer() { try { CLong i = new CLong(0xff); CBuffer buf = new CBuffer(i); CAddress addr = buf.getAddress(); CLong b = addr.asCLong(); assertEquals(0xff, b.getValue()); } catch (Exception e) { fail(); } } public void testLongLongFromConstructor() { try { CLongLong i = new CLongLong(1234567890123456789L); assertEquals(i.getValue(), 1234567890123456789L); } catch (Exception e) { fail(); } } public void testLongLongFromPointer() { try { CLongLong i = new CLongLong(1234567890123456789L); CBuffer buf = new CBuffer(i); CAddress addr = buf.getAddress(); CLongLong b = addr.asCLongLong(); assertEquals(1234567890123456789L, b.getValue()); } catch (Exception e) { fail(); } } public void testShortFromConstructor() { try { CLong i = new CLong(11); assertEquals(i.getValue(), 11); } catch (Exception e) { fail(); } } public void testShortFromPointer() { try { CShort i = new CShort( (short) 12); CBuffer buf = new CBuffer(i); CAddress addr = buf.getAddress(); CShort b = addr.asCShort(); assertEquals(12, b.getValue()); } catch (Exception e) { fail(); } } } Index: PointerTest.java =================================================================== RCS file: /cvsroot/ctypes/ctypes-java/src/test/ctypes/java/test/generic/PointerTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PointerTest.java 22 Mar 2004 05:33:33 -0000 1.2 --- PointerTest.java 15 Apr 2005 03:15:44 -0000 1.3 *************** *** 50,55 **** CPointer ptra = new CPointer(i); CPointer ptrb = new CPointer(ptra); ! assertEquals(ptrb.getValue(), ptra.getAddress() ); ! assertEquals(i.getAddress(), ptra.getValue()); } catch (Exception e) { fail(); --- 50,55 ---- CPointer ptra = new CPointer(i); CPointer ptrb = new CPointer(ptra); ! assertEquals(ptrb.getValue(), ptra.getAddress().getValue() ); ! assertEquals(i.getAddress().getValue(), ptra.getValue()); } catch (Exception e) { fail(); *************** *** 66,70 **** CPointer ref = new CPointer(ptri); ! ref.setValue(ptrj.getAddress()); CPointer t = (CPointer) ref.getSubject(); CInt jj = (CInt) t.getSubject(); --- 66,70 ---- CPointer ref = new CPointer(ptri); ! ref.setValue(ptrj.getAddress().getValue()); CPointer t = (CPointer) ref.getSubject(); CInt jj = (CInt) t.getSubject(); |
Update of /cvsroot/ctypes/ctypes-java/src/examples/ctypes/java/ntlm/httpauth In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4975/src/examples/ctypes/java/ntlm/httpauth Modified Files: HTTPAuthA.java HTTPAuth.java HTTPSProxyAuthA.java HTTPProxyAuth.java HTTPSProxyAuth.java NTLMAuthenticator.java Log Message: All win32 unit tests pass. Index: HTTPSProxyAuthA.java =================================================================== RCS file: /cvsroot/ctypes/ctypes-java/src/examples/ctypes/java/ntlm/httpauth/HTTPSProxyAuthA.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** HTTPSProxyAuthA.java 29 Aug 2004 01:20:52 -0000 1.1 --- HTTPSProxyAuthA.java 15 Apr 2005 03:15:46 -0000 1.2 *************** *** 33,37 **** * @author Bradley Schatz * ! * Copyright 2003 Managed Data Security */ public class HTTPSProxyAuthA { --- 33,37 ---- * @author Bradley Schatz * ! * Copyright 2003 Bradley Schatz */ public class HTTPSProxyAuthA { Index: HTTPProxyAuth.java =================================================================== RCS file: /cvsroot/ctypes/ctypes-java/src/examples/ctypes/java/ntlm/httpauth/HTTPProxyAuth.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** HTTPProxyAuth.java 29 Aug 2004 01:20:52 -0000 1.1 --- HTTPProxyAuth.java 15 Apr 2005 03:15:46 -0000 1.2 *************** *** 33,37 **** * @author Bradley Schatz * ! * Copyright 2003 Managed Data Security */ public class HTTPProxyAuth { --- 33,37 ---- * @author Bradley Schatz * ! * Copyright 2003 Bradley Schatz */ public class HTTPProxyAuth { Index: HTTPSProxyAuth.java =================================================================== RCS file: /cvsroot/ctypes/ctypes-java/src/examples/ctypes/java/ntlm/httpauth/HTTPSProxyAuth.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** HTTPSProxyAuth.java 29 Aug 2004 01:20:52 -0000 1.1 --- HTTPSProxyAuth.java 15 Apr 2005 03:15:46 -0000 1.2 *************** *** 33,37 **** * @author Bradley Schatz * ! * Copyright 2003 Managed Data Security */ public class HTTPSProxyAuth { --- 33,37 ---- * @author Bradley Schatz * ! * Copyright 2003 Bradley Schatz */ public class HTTPSProxyAuth { Index: HTTPAuthA.java =================================================================== RCS file: /cvsroot/ctypes/ctypes-java/src/examples/ctypes/java/ntlm/httpauth/HTTPAuthA.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** HTTPAuthA.java 29 Aug 2004 01:20:52 -0000 1.1 --- HTTPAuthA.java 15 Apr 2005 03:15:46 -0000 1.2 *************** *** 33,37 **** * @author Bradley Schatz * ! * Copyright 2003 Managed Data Security */ public class HTTPAuthA { --- 33,37 ---- * @author Bradley Schatz * ! * Copyright 2003 Bradley Schatz */ public class HTTPAuthA { Index: NTLMAuthenticator.java =================================================================== RCS file: /cvsroot/ctypes/ctypes-java/src/examples/ctypes/java/ntlm/httpauth/NTLMAuthenticator.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** NTLMAuthenticator.java 29 Aug 2004 01:20:52 -0000 1.1 --- NTLMAuthenticator.java 15 Apr 2005 03:15:46 -0000 1.2 *************** *** 23,27 **** * @author Bradley Schatz * ! * Copyright 2003 Managed Data Security */ public class NTLMAuthenticator { --- 23,27 ---- * @author Bradley Schatz * ! * Copyright 2003 Bradley Schatz */ public class NTLMAuthenticator { Index: HTTPAuth.java =================================================================== RCS file: /cvsroot/ctypes/ctypes-java/src/examples/ctypes/java/ntlm/httpauth/HTTPAuth.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** HTTPAuth.java 29 Aug 2004 01:20:52 -0000 1.1 --- HTTPAuth.java 15 Apr 2005 03:15:46 -0000 1.2 *************** *** 20,24 **** * @author Bradley Schatz * ! * Copyright 2003 Managed Data Security */ public class HTTPAuth { --- 20,24 ---- * @author Bradley Schatz * ! * Copyright 2003 Bradley Schatz */ public class HTTPAuth { |
From: Bradley L S. <bs...@us...> - 2005-04-15 03:15:56
|
Update of /cvsroot/ctypes/ctypes-java/src/test/ctypes/java/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4975/src/test/ctypes/java/test Modified Files: TestAllGeneric.java TestAllWin32.java TestAllLinux.java Log Message: All win32 unit tests pass. Index: TestAllLinux.java =================================================================== RCS file: /cvsroot/ctypes/ctypes-java/src/test/ctypes/java/test/TestAllLinux.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** TestAllLinux.java 3 Apr 2004 05:51:07 -0000 1.4 --- TestAllLinux.java 15 Apr 2005 03:15:47 -0000 1.5 *************** *** 43,47 **** suite.addTest(new TestSuite(BuffersTest.class)); suite.addTest(new TestSuite(PointerTest.class)); ! suite.addTest(new TestSuite(CharTest.class)); suite.addTest(new TestSuite(ReturnPointersTest.class)); suite.addTest(new TestSuite(ByRefTest.class)); --- 43,47 ---- suite.addTest(new TestSuite(BuffersTest.class)); suite.addTest(new TestSuite(PointerTest.class)); ! suite.addTest(new TestSuite(TestChars.class)); suite.addTest(new TestSuite(ReturnPointersTest.class)); suite.addTest(new TestSuite(ByRefTest.class)); Index: TestAllWin32.java =================================================================== RCS file: /cvsroot/ctypes/ctypes-java/src/test/ctypes/java/test/TestAllWin32.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** TestAllWin32.java 22 Mar 2004 05:33:33 -0000 1.3 --- TestAllWin32.java 15 Apr 2005 03:15:47 -0000 1.4 *************** *** 37,44 **** public static Test suite() { TestSuite suite= new TestSuite(); suite.addTest(new TestSuite(WinDLLTest.class)); ! suite.addTest(new TestSuite(PrimitiveTypesTest.class)); suite.addTest(new TestSuite(BuffersTest.class)); ! suite.addTest(new TestSuite(CharTest.class)); suite.addTest(new TestSuite(ReturnPointersTest.class)); suite.addTest(new TestSuite(ByRefTest.class)); --- 37,46 ---- public static Test suite() { TestSuite suite= new TestSuite(); + suite.addTest(new TestSuite(TestNumbers.class)); suite.addTest(new TestSuite(WinDLLTest.class)); ! suite.addTest(new TestSuite(PrimitiveTypesMathTest.class)); suite.addTest(new TestSuite(BuffersTest.class)); ! suite.addTest(new TestSuite(StructTest.class)); ! suite.addTest(new TestSuite(TestChars.class)); suite.addTest(new TestSuite(ReturnPointersTest.class)); suite.addTest(new TestSuite(ByRefTest.class)); Index: TestAllGeneric.java =================================================================== RCS file: /cvsroot/ctypes/ctypes-java/src/test/ctypes/java/test/TestAllGeneric.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** TestAllGeneric.java 29 Aug 2004 01:28:07 -0000 1.4 --- TestAllGeneric.java 15 Apr 2005 03:15:47 -0000 1.5 *************** *** 25,41 **** import junit.framework.Test; import junit.framework.TestSuite; ! import ctypes.java.test.generic.CharTest; import ctypes.java.test.generic.PointerTest; /** * @author bradley * - * To change the template for this generated type comment go to - * Window>Preferences>Java>Code Generation>Code and Comments */ public class TestAllGeneric extends TestSuite { public static Test suite() { TestSuite suite= new TestSuite(); ! suite.addTest(new TestSuite(CharTest.class)); suite.addTest(new TestSuite(PointerTest.class)); return suite; --- 25,41 ---- import junit.framework.Test; import junit.framework.TestSuite; ! import ctypes.java.test.generic.TestChars; import ctypes.java.test.generic.PointerTest; + import ctypes.java.test.generic.TestNumbers; /** * @author bradley * */ public class TestAllGeneric extends TestSuite { public static Test suite() { TestSuite suite= new TestSuite(); ! suite.addTest(new TestSuite(TestNumbers.class)); ! suite.addTest(new TestSuite(TestChars.class)); suite.addTest(new TestSuite(PointerTest.class)); return suite; |
From: Bradley L S. <bs...@us...> - 2005-04-15 03:15:56
|
Update of /cvsroot/ctypes/ctypes-java/src/examples/ctypes/java/ntlm/httpclient In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4975/src/examples/ctypes/java/ntlm/httpclient Modified Files: NTLMAuthenticator.java Charset.java NTLMSecurityException.java Log Message: All win32 unit tests pass. Index: NTLMSecurityException.java =================================================================== RCS file: /cvsroot/ctypes/ctypes-java/src/examples/ctypes/java/ntlm/httpclient/NTLMSecurityException.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** NTLMSecurityException.java 29 Aug 2004 01:20:51 -0000 1.1 --- NTLMSecurityException.java 15 Apr 2005 03:15:47 -0000 1.2 *************** *** 10,14 **** * @author Bradley Schatz * ! * Copyright 2003 Managed Data Security */ public class NTLMSecurityException extends CException { --- 10,14 ---- * @author Bradley Schatz * ! * Copyright 2003 Bradley Schatz */ public class NTLMSecurityException extends CException { Index: NTLMAuthenticator.java =================================================================== RCS file: /cvsroot/ctypes/ctypes-java/src/examples/ctypes/java/ntlm/httpclient/NTLMAuthenticator.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** NTLMAuthenticator.java 29 Aug 2004 01:20:51 -0000 1.1 --- NTLMAuthenticator.java 15 Apr 2005 03:15:47 -0000 1.2 *************** *** 23,27 **** * @author Bradley Schatz * ! * Copyright 2003 Managed Data Security */ public class NTLMAuthenticator { --- 23,27 ---- * @author Bradley Schatz * ! * Copyright 2003 Bradley Schatz */ public class NTLMAuthenticator { Index: Charset.java =================================================================== RCS file: /cvsroot/ctypes/ctypes-java/src/examples/ctypes/java/ntlm/httpclient/Charset.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Charset.java 29 Aug 2004 01:20:51 -0000 1.1 --- Charset.java 15 Apr 2005 03:15:47 -0000 1.2 *************** *** 8,12 **** * @author Bradley Schatz * ! * Copyright 2003 Managed Data Security */ public class Charset { --- 8,12 ---- * @author Bradley Schatz * ! * Copyright 2003 Bradley Schatz */ public class Charset { |
From: Bradley L S. <bs...@us...> - 2005-04-15 03:15:55
|
Update of /cvsroot/ctypes/ctypes-java/src/java/ctypes/java/win32/sspi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4975/src/java/ctypes/java/win32/sspi Modified Files: TimeStamp.java SecurityInteger.java PCtxtHandle.java PCredHandle.java PSecBufferDesc.java PSecBuffer.java SecPkgInfoA.java SecHandle.java CtxtHandle.java PSecPkgInfoA.java CredHandle.java PTimeStamp.java SSPI.java Log Message: All win32 unit tests pass. Index: PTimeStamp.java =================================================================== RCS file: /cvsroot/ctypes/ctypes-java/src/java/ctypes/java/win32/sspi/PTimeStamp.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PTimeStamp.java 29 Aug 2004 01:28:23 -0000 1.1 --- PTimeStamp.java 15 Apr 2005 03:15:45 -0000 1.2 *************** *** 10,14 **** * @author Bradley Schatz * ! * Copyright 2003 Managed Data Security */ public class PTimeStamp extends CPointer { --- 10,14 ---- * @author Bradley Schatz * ! * Copyright 2003 Bradley Schatz */ public class PTimeStamp extends CPointer { Index: PSecBufferDesc.java =================================================================== RCS file: /cvsroot/ctypes/ctypes-java/src/java/ctypes/java/win32/sspi/PSecBufferDesc.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PSecBufferDesc.java 29 Aug 2004 01:28:23 -0000 1.1 --- PSecBufferDesc.java 15 Apr 2005 03:15:45 -0000 1.2 *************** *** 10,14 **** * @author Bradley Schatz * ! * Copyright 2003 Managed Data Security */ public class PSecBufferDesc extends CPointer { --- 10,14 ---- * @author Bradley Schatz * ! * Copyright 2003 Bradley Schatz */ public class PSecBufferDesc extends CPointer { Index: PSecPkgInfoA.java =================================================================== RCS file: /cvsroot/ctypes/ctypes-java/src/java/ctypes/java/win32/sspi/PSecPkgInfoA.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PSecPkgInfoA.java 29 Aug 2004 01:28:23 -0000 1.1 --- PSecPkgInfoA.java 15 Apr 2005 03:15:45 -0000 1.2 *************** *** 5,8 **** --- 5,9 ---- package ctypes.java.win32.sspi; + import ctypes.java.CAddress; import ctypes.java.CException; import ctypes.java.CPointer; *************** *** 12,16 **** * @author Bradley Schatz * ! * Copyright 2003 Managed Data Security */ public class PSecPkgInfoA extends CPointer { --- 13,17 ---- * @author Bradley Schatz * ! * Copyright 2003 Bradley Schatz */ public class PSecPkgInfoA extends CPointer { *************** *** 24,34 **** if (subject == null) { subject = new SecPkgInfoA(); ! subject.setAddress(getValue(), CType.SYNCDIR_TOJAVA); } else { if (isMemoryBacked()) { ! long v = getAddress(); ! long j = subject.getAddress(); if (v != j) { ! subject.setAddress(v, CType.SYNCDIR_TOJAVA); } } --- 25,35 ---- if (subject == null) { subject = new SecPkgInfoA(); ! subject.setAddress(new CAddress(getValue()), CType.SyncDirection.ToJava); } else { if (isMemoryBacked()) { ! long v = getAddress().getValue(); ! long j = subject.getAddress().getValue(); if (v != j) { ! subject.setAddress(new CAddress(v), CType.SyncDirection.ToJava); } } Index: SecurityInteger.java =================================================================== RCS file: /cvsroot/ctypes/ctypes-java/src/java/ctypes/java/win32/sspi/SecurityInteger.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SecurityInteger.java 29 Aug 2004 01:28:23 -0000 1.1 --- SecurityInteger.java 15 Apr 2005 03:15:45 -0000 1.2 *************** *** 26,30 **** * @author Bradley Schatz * ! * Copyright 2003 Managed Data Security */ --- 26,30 ---- * @author Bradley Schatz * ! * Copyright 2003 Bradley Schatz */ Index: PCredHandle.java =================================================================== RCS file: /cvsroot/ctypes/ctypes-java/src/java/ctypes/java/win32/sspi/PCredHandle.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PCredHandle.java 29 Aug 2004 01:28:23 -0000 1.1 --- PCredHandle.java 15 Apr 2005 03:15:45 -0000 1.2 *************** *** 10,14 **** * @author Bradley Schatz * ! * Copyright 2003 Managed Data Security */ public class PCredHandle extends CPointer { --- 10,14 ---- * @author Bradley Schatz * ! * Copyright 2003 Bradley Schatz */ public class PCredHandle extends CPointer { Index: SSPI.java =================================================================== RCS file: /cvsroot/ctypes/ctypes-java/src/java/ctypes/java/win32/sspi/SSPI.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SSPI.java 29 Aug 2004 01:28:23 -0000 1.1 --- SSPI.java 15 Apr 2005 03:15:45 -0000 1.2 *************** *** 17,21 **** * @author Bradley Schatz * ! * Copyright 2003 Managed Data Security */ public class SSPI { --- 17,21 ---- * @author Bradley Schatz * ! * Copyright 2003 Bradley Schatz */ public class SSPI { Index: TimeStamp.java =================================================================== RCS file: /cvsroot/ctypes/ctypes-java/src/java/ctypes/java/win32/sspi/TimeStamp.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TimeStamp.java 29 Aug 2004 01:28:23 -0000 1.1 --- TimeStamp.java 15 Apr 2005 03:15:44 -0000 1.2 *************** *** 10,14 **** * @author Bradley Schatz * ! * Copyright 2003 Managed Data Security */ public class TimeStamp extends SecurityInteger { --- 10,14 ---- * @author Bradley Schatz * ! * Copyright 2003 Bradley Schatz */ public class TimeStamp extends SecurityInteger { Index: SecHandle.java =================================================================== RCS file: /cvsroot/ctypes/ctypes-java/src/java/ctypes/java/win32/sspi/SecHandle.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SecHandle.java 29 Aug 2004 01:28:23 -0000 1.1 --- SecHandle.java 15 Apr 2005 03:15:45 -0000 1.2 *************** *** 13,17 **** * @author Bradley Schatz * ! * Copyright 2003 Managed Data Security */ public class SecHandle extends CStruct { --- 13,17 ---- * @author Bradley Schatz * ! * Copyright 2003 Bradley Schatz */ public class SecHandle extends CStruct { Index: CtxtHandle.java =================================================================== RCS file: /cvsroot/ctypes/ctypes-java/src/java/ctypes/java/win32/sspi/CtxtHandle.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CtxtHandle.java 29 Aug 2004 01:28:23 -0000 1.1 --- CtxtHandle.java 15 Apr 2005 03:15:45 -0000 1.2 *************** *** 10,14 **** * @author Bradley Schatz * ! * Copyright 2003 Managed Data Security */ public class CtxtHandle extends SecHandle { --- 10,14 ---- * @author Bradley Schatz * ! * Copyright 2003 Bradley Schatz */ public class CtxtHandle extends SecHandle { Index: SecPkgInfoA.java =================================================================== RCS file: /cvsroot/ctypes/ctypes-java/src/java/ctypes/java/win32/sspi/SecPkgInfoA.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SecPkgInfoA.java 29 Aug 2004 01:28:23 -0000 1.1 --- SecPkgInfoA.java 15 Apr 2005 03:15:45 -0000 1.2 *************** *** 14,18 **** * @author Bradley Schatz * ! * Copyright 2003 Managed Data Security */ public class SecPkgInfoA extends CStruct { --- 14,18 ---- * @author Bradley Schatz * ! * Copyright 2003 Bradley Schatz */ public class SecPkgInfoA extends CStruct { Index: PCtxtHandle.java =================================================================== RCS file: /cvsroot/ctypes/ctypes-java/src/java/ctypes/java/win32/sspi/PCtxtHandle.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PCtxtHandle.java 29 Aug 2004 01:28:23 -0000 1.1 --- PCtxtHandle.java 15 Apr 2005 03:15:45 -0000 1.2 *************** *** 10,14 **** * @author Bradley Schatz * ! * Copyright 2003 Managed Data Security */ public class PCtxtHandle extends CPointer { --- 10,14 ---- * @author Bradley Schatz * ! * Copyright 2003 Bradley Schatz */ public class PCtxtHandle extends CPointer { Index: PSecBuffer.java =================================================================== RCS file: /cvsroot/ctypes/ctypes-java/src/java/ctypes/java/win32/sspi/PSecBuffer.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PSecBuffer.java 29 Aug 2004 01:28:23 -0000 1.1 --- PSecBuffer.java 15 Apr 2005 03:15:45 -0000 1.2 *************** *** 11,15 **** * @author Bradley Schatz * ! * Copyright 2003 Managed Data Security */ public class PSecBuffer extends CPointer { --- 11,15 ---- * @author Bradley Schatz * ! * Copyright 2003 Bradley Schatz */ public class PSecBuffer extends CPointer { Index: CredHandle.java =================================================================== RCS file: /cvsroot/ctypes/ctypes-java/src/java/ctypes/java/win32/sspi/CredHandle.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CredHandle.java 29 Aug 2004 01:28:23 -0000 1.1 --- CredHandle.java 15 Apr 2005 03:15:45 -0000 1.2 *************** *** 10,14 **** * @author Bradley Schatz * ! * Copyright 2003 Managed Data Security */ public class CredHandle extends CtxtHandle { --- 10,14 ---- * @author Bradley Schatz * ! * Copyright 2003 Bradley Schatz */ public class CredHandle extends CtxtHandle { |