Skip to content

Instantly share code, notes, and snippets.

@jrwells
Last active November 30, 2017 18:21
Show Gist options
  • Save jrwells/3669e151b04803e6c51405be2926e381 to your computer and use it in GitHub Desktop.
Save jrwells/3669e151b04803e6c51405be2926e381 to your computer and use it in GitHub Desktop.
Binding basic2d functionality in Python
import basic2d
proc scale*(m: ref Matrix2d, s: cdouble): ref Matrix2d {.cdecl, exportc, noinit.} =
m[] = scale(s)
return m
from ctypes import *
class Matrix2d(Structure):
_fields_ = [('ax', c_double),
('ay', c_double),
('bx', c_double),
('by', c_double),
('tx', c_double),
('ty', c_double)]
binding = CDLL('binding')
scale = binding.scale
scale.argtypes = [ c_double ]
scale.restype = Matrix2d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment