tests/python/python@py_ext/py_ext.xml
author Edouard Tisserant
Thu, 18 Oct 2012 20:24:11 +0200
changeset 859 dbf82971f09d
parent 734 5c42cafaee15
child 862 bb59865db6e6
permissions -rw-r--r--
More pedagogical tests/python. Should be renamed python_ctypes_and_C_pragmas_in_ST or something
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
     1
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
728
e0424e96e3fd refactoring - library support is not anymore attached to configtree nodes, but handles by project controller
Edouard Tisserant
parents: 721
diff changeset
     2
<Python xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.w3.org/2001/XMLSchema" xsi:schemaLocation="py_ext_xsd.xsd">
859
dbf82971f09d More pedagogical tests/python. Should be renamed python_ctypes_and_C_pragmas_in_ST or something
Edouard Tisserant
parents: 734
diff changeset
     3
<![CDATA[import time,sys,ctypes
dbf82971f09d More pedagogical tests/python. Should be renamed python_ctypes_and_C_pragmas_in_ST or something
Edouard Tisserant
parents: 734
diff changeset
     4
Python_to_C_Call = PLCBinary.Python_to_C_Call
dbf82971f09d More pedagogical tests/python. Should be renamed python_ctypes_and_C_pragmas_in_ST or something
Edouard Tisserant
parents: 734
diff changeset
     5
Python_to_C_Call.restype = ctypes.c_int
dbf82971f09d More pedagogical tests/python. Should be renamed python_ctypes_and_C_pragmas_in_ST or something
Edouard Tisserant
parents: 734
diff changeset
     6
Python_to_C_Call.argtypes = [ctypes.c_int, ctypes.POINTER(ctypes.c_int)]
734
5c42cafaee15 Moved LPC sources to a separate project
Edouard Tisserant
parents: 728
diff changeset
     7
5c42cafaee15 Moved LPC sources to a separate project
Edouard Tisserant
parents: 728
diff changeset
     8
def MyPythonFunc(arg):
859
dbf82971f09d More pedagogical tests/python. Should be renamed python_ctypes_and_C_pragmas_in_ST or something
Edouard Tisserant
parents: 734
diff changeset
     9
    i = ctypes.c_int()
dbf82971f09d More pedagogical tests/python. Should be renamed python_ctypes_and_C_pragmas_in_ST or something
Edouard Tisserant
parents: 734
diff changeset
    10
    if(Python_to_C_Call(arg, i)):
dbf82971f09d More pedagogical tests/python. Should be renamed python_ctypes_and_C_pragmas_in_ST or something
Edouard Tisserant
parents: 734
diff changeset
    11
        res = i.value
dbf82971f09d More pedagogical tests/python. Should be renamed python_ctypes_and_C_pragmas_in_ST or something
Edouard Tisserant
parents: 734
diff changeset
    12
        print "toC:", arg, "from C:", res
dbf82971f09d More pedagogical tests/python. Should be renamed python_ctypes_and_C_pragmas_in_ST or something
Edouard Tisserant
parents: 734
diff changeset
    13
    else:
dbf82971f09d More pedagogical tests/python. Should be renamed python_ctypes_and_C_pragmas_in_ST or something
Edouard Tisserant
parents: 734
diff changeset
    14
        print "Failed Python_to_C_Call failed"
dbf82971f09d More pedagogical tests/python. Should be renamed python_ctypes_and_C_pragmas_in_ST or something
Edouard Tisserant
parents: 734
diff changeset
    15
        res = None
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
    16
    sys.stdout.flush()
859
dbf82971f09d More pedagogical tests/python. Should be renamed python_ctypes_and_C_pragmas_in_ST or something
Edouard Tisserant
parents: 734
diff changeset
    17
    return res
734
5c42cafaee15 Moved LPC sources to a separate project
Edouard Tisserant
parents: 728
diff changeset
    18
]]>
366
cd90e4c10261 Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff changeset
    19
</Python>