python-efl/efl/ewe/__init__.pyx

46 lines
1.2 KiB
Cython

from libc.string cimport memcpy
from cpython cimport PyMem_Malloc, PyUnicode_AsUTF8String
import sys
def init():
"""Initialize Elementary Widget Extensions library
:return: The init counter value.
:rtype: int
This function initializes Ewe and increments a counter of
the number of calls to it. It returns the new counter's value.
"""
cdef:
int argc, i, arg_len
char **argv
char *arg
argc = len(sys.argv)
argv = <char **>PyMem_Malloc(argc * sizeof(char *))
for i in range(argc):
t = sys.argv[i]
if isinstance(t, unicode): t = PyUnicode_AsUTF8String(t)
arg = t
arg_len = len(arg)
argv[i] = <char *>PyMem_Malloc(arg_len + 1)
memcpy(argv[i], arg, arg_len + 1)
return ewe_init(argc, argv)
def shutdown():
"""Shut down Elementary Widget Extensions library
:return: The init counter value.
:rtype: int
This should be called at the end of your application, just
before it ceases to do any more processing. This will clean up
any permanent resources your application may have allocated via
Ewe that would otherwise persist.
"""
return ewe_shutdown()