extern void (*PrintLn)(Class * class_object, const void * object, ...);
+extern Class * class_int;
+// extern Class * class_float;
+extern Class * class_double;
extern Class * class_String;
extern Class * class_Window;
extern Class * class_GuiApplication;
import sys
from _pyEcere import *
-def printLn(args):
- lib.PrintLn(lib.class_String, args.encode('utf8'), ffi.NULL)
+def convertTypedArgs(args):
+ cargs = ()
+ for a in args:
+ if type(a) == str: cargs += (lib.class_String, ffi.new("char[]", a.encode('utf8')))
+ if type(a) == int: cargs += (lib.class_int, ffi.new("int *", a))
+ if type(a) == float: cargs += (lib.class_double, ffi.new("double *", a))
+ return cargs + (ffi.NULL,)
+
+def printLn(*args): lib.PrintLn(*convertTypedArgs(args))
class Color:
def __init__(self, r = 0, g = 0, b = 0):
# -*- coding: utf-8 -*-
from pyEcere import *
app = GuiApplication()
-Window(caption = "Hello, Python!!", hasClose = True, clientSize = Size(640, 480), background = Color(b = 255))
-Window(caption = "Bindings are cool", hasClose = True, clientSize = Size(320, 200), background = Color(255))
+printLn("Testing Variadic Functions!\n", 1, " + ", 2, " = ", 1+2)
+printLn("Pi = ", 3.141592653589)
+
+Window(
+ caption = "Hello, Python!!",
+ hasClose = True,
+ clientSize = Size(640, 480),
+ background = Color(b = 255))
+Window(
+ caption = "Bindings are cool, 詠春 too!",
+ hasClose = True,
+ clientSize = Size(320, 200),
+ background = Color(255))
+
app.main()