Example #1
0
# file: runme.py

import example 

a = 37
b = 42

# Now call our C function with a bunch of callbacks

print "Trying some C callback functions"
print "    a        =", a
print "    b        =", b
print "    ADD(a,b) =", example.do_op(a,b,example.ADD)
print "    SUB(a,b) =", example.do_op(a,b,example.SUB)
print "    MUL(a,b) =", example.do_op(a,b,example.MUL)

print "Here is what the C callback function objects look like in Python"
print "    ADD      =", example.ADD
print "    SUB      =", example.SUB
print "    MUL      =", example.MUL

print "Call the functions directly..."
print "    add(a,b) =", example.add(a,b)
print "    sub(a,b) =", example.sub(a,b)
Example #2
0
# file: runme.py

import example

a = 37
b = 42

# Now call our C function with a bunch of callbacks

print("Trying some C callback functions")
print("    a        = %s" % a)
print("    b        = %s" % b)
print("    ADD(a,b) = %s" % example.do_op(a, b, example.ADD))
print("    SUB(a,b) = %s" % example.do_op(a, b, example.SUB))
print("    MUL(a,b) = %s" % example.do_op(a, b, example.MUL))

print("Here is what the C callback function objects look like in Python")
print("    ADD      = %s" % example.ADD)
print("    SUB      = %s" % example.SUB)
print("    MUL      = %s" % example.MUL)

print("Call the functions directly...")
print("    add(a,b) = %s" % example.add(a, b))
print("    sub(a,b) = %s" % example.sub(a, b))
Example #3
0
# file: example.py

import example 

a = 37
b = 42

# Now call our C function with a bunch of callbacks

print "Trying some C callback functions"
print "    a        =", a
print "    b        =", b
print "    ADD(a,b) =", example.do_op(a,b,example.ADD)
print "    SUB(a,b) =", example.do_op(a,b,example.SUB)
print "    MUL(a,b) =", example.do_op(a,b,example.MUL)

print "Here is what the C callback function objects look like in Python"
print "    ADD      =", example.ADD
print "    SUB      =", example.SUB
print "    MUL      =", example.MUL
Example #4
0
# Get the pointers

area_pt = example.areapt()
perim_pt = example.perimeterpt()

print "area_pt  =", area_pt
print "perim_pt = ", perim_pt

# Create some objects

c = example.Circle(4)
s = example.Square(10)

# Do some calculations

print "Circle area  = ", example.do_op(c, area_pt)
print "Circle perim = ", example.do_op(c, perim_pt)
print "Square area  = ", example.do_op(s, area_pt)
print "Square perim = ", example.do_op(s, perim_pt)

print "cvar.areavar      =", example.cvar.areavar
print "cvar.perimetervar =", example.cvar.perimetervar

# Try the variables
print "Circle area  = ", example.do_op(c, example.cvar.areavar)
print "Circle perim = ", example.do_op(c, example.cvar.perimetervar)
print "Square area  = ", example.do_op(s, example.cvar.areavar)
print "Square perim = ", example.do_op(s, example.cvar.perimetervar)

# Modify one of the variables
example.cvar.areavar = perim_pt
Example #5
0
# file: runme.py

import example

a = 37
b = 42

# Now call our C function with a bunch of callbacks

print("Trying some C callback functions")
print("    a        =", a)
print("    b        =", b)
print("    ADD(a,b) =", example.do_op(a, b, example.ADD))
print("    SUB(a,b) =", example.do_op(a, b, example.SUB))
print("    MUL(a,b) =", example.do_op(a, b, example.MUL))

print("Here is what the C callback function objects look like in Python")
print("    ADD      =", example.ADD)
print("    SUB      =", example.SUB)
print("    MUL      =", example.MUL)

print("Call the functions directly...")
print("    add(a,b) =", example.add(a, b))
print("    sub(a,b) =", example.sub(a, b))
Example #6
0
# Get the pointers

area_pt = example.areapt()
perim_pt = example.perimeterpt()

print "area_pt  =", area_pt
print "perim_pt = ", perim_pt

# Create some objects

c = example.Circle(4)
s = example.Square(10)

# Do some calculations

print "Circle area  = ", example.do_op(c,area_pt)
print "Circle perim = ", example.do_op(c,perim_pt)
print "Square area  = ", example.do_op(s,area_pt)
print "Square perim = ", example.do_op(s,perim_pt)

print "cvar.areavar      =", example.cvar.areavar
print "cvar.perimetervar =", example.cvar.perimetervar

# Try the variables
print "Circle area  = ", example.do_op(c,example.cvar.areavar)
print "Circle perim = ", example.do_op(c,example.cvar.perimetervar)
print "Square area  = ", example.do_op(s,example.cvar.areavar)
print "Square perim = ", example.do_op(s,example.cvar.perimetervar)

# Modify one of the variables
example.cvar.areavar = perim_pt