Skip to content

Commit

Permalink
Alternative solution
Browse files Browse the repository at this point in the history
  • Loading branch information
tisnik committed Jun 7, 2023
1 parent f4f905a commit 70621fb
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions cffi/array_printer_6/call_via_cffi2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import pathlib

from cffi import FFI

ffi = FFI()

def load_header(filename):
directory = pathlib.Path().absolute()
header = directory / filename
with open(header) as fin:
return fin.read()


def load_library(library_name):
return ffi.dlopen(library_name)


ffi.cdef(load_header("array_printer.h"))

array = ffi.new("float [10][3]")

array = ((1,2,3),
(4,5,6),
(7,8,9),
(0,0,0),
(0,0,0),
(1,2,3),
(4,5,6),
(7,8,9),
(0,0,0),
(0,0,0))

printer = load_library("libaprinter.so")
printer.print_array(array, 10)

0 comments on commit 70621fb

Please sign in to comment.