Created
June 12, 2016 10:12
-
-
Save jerstlouis/ca03f41177db335bf9db01b75906edd1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
############## 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