Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jerstlouis/ca03f41177db335bf9db01b75906edd1 to your computer and use it in GitHub Desktop.
Save jerstlouis/ca03f41177db335bf9db01b75906edd1 to your computer and use it in GitHub Desktop.
############## ex1.py:
# -*- coding: utf-8 -*-
import pyEcere
pyEcere.funStuff("Hello, Python!\n")
############## pyEcere.py:
from _pyEcere import *
def funStuff(fun):
lib.my_funStuff(fun.encode('utf8'))
############## build_ecere.py:
from cffi import FFI
ffi = FFI()
ffi.cdef(
#open('cffi-ecere.h').read()
"""
int my_funStuff(const char *fun);
"""
)
ffi.set_source("_pyEcere",
"""
int my_funStuff(const char *fun);
""",
sources = [ "fun.c" ], include_dirs = ["c"])
if __name__ == "__main__":
ffi.compile(verbose=True)
/////////////// fun.c:
#include <stdio.h>
void my_funStuff(const char * fun)
{
printf(fun);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment