From 7ff7047562b96b74dfb180da5112237d74677510 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 27 Mar 2010 12:44:19 +0100 Subject: [PATCH] Fixes for Windows. --- Projects/MMLLib/libmml.lpr | 10 +++++----- Projects/MMLLib/test.py | 16 +++++++++++----- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/Projects/MMLLib/libmml.lpr b/Projects/MMLLib/libmml.lpr index 7ea7a02..2c208ae 100644 --- a/Projects/MMLLib/libmml.lpr +++ b/Projects/MMLLib/libmml.lpr @@ -23,12 +23,12 @@ begin C:=TCLient.Create(''); end; -function getmousepos: tpoint; +function getmousepos: tpoint; cdecl; begin C.IOManager.GetMousePos(result.x,result.y); end; -function returnpoints: PTPoint; +function returnpoints: PTPoint; cdecl; begin result := AllocMem(sizeof(TPoint) * 2); @@ -38,19 +38,19 @@ begin result[1].y := 30; end; -function printpoints(b: PTPoint; len: integer): boolean; +function printpoints(b: PTPoint; len: integer): boolean; cdecl; var i:integer; begin for i := 0 to len - 1 do writeln('X, Y: (' + inttostr(b[i].x) + ', ' + inttostr(b[i].y) + ')'); end; -procedure hoi(var i: integer); +procedure hoi(var i: integer); cdecl; begin i := i + 1; end; -function givedtm:PPDTM; +function givedtm:PPDTM; cdecl; var dtm: PPDTM; begin diff --git a/Projects/MMLLib/test.py b/Projects/MMLLib/test.py index d81e8db..9d4f54a 100755 --- a/Projects/MMLLib/test.py +++ b/Projects/MMLLib/test.py @@ -1,7 +1,12 @@ #!/usr/bin/env python from ctypes import * +import platform -dll = CDLL('./libmml.so') +if platform.system() == 'Windows': + dll = CDLL('./libmml.dll') + print 'On Windows' +else: + dll = CDLL('./libmml.so') dll.test.restype = c_char_p a = dll.test() print a @@ -10,10 +15,11 @@ dll.init.restype = None dll.init() class POINT(Structure): - _fields_ = [('x', c_int), - ('y', c_int)] + _fields_ = [('x', c_int), + ('y', c_int)] dll.getmousepos.restype = POINT +dll.getmousepos.argtypes = None b = dll.getmousepos() print b.x, b.y @@ -30,8 +36,8 @@ dll.printpoints.argtypes = [PPOINT, c_int] d = dll.printpoints(c, 2) -dll.hoi.restype = None -dll.hoi.argtypes = [POINTER(c_int)] +#dll.hoi.restype = None +#dll.hoi.argtypes = [POINTER(c_int)] e = c_int(5) dll.hoi(byref(e))