One caveat with Cython is that we cannot statically initialize structs like we can in C, so we need to make a hook so that we can initialize cmd_entry
on Python startup:
cimport cmdpython
cdef public cmd_entry cmd_entry_python
With this, we now have a public declaration of cmd_entry_python
, which we will initialize in a startup hook as follows:
cdef public void tmux_init_cython () with gil: cmd_entry_python.name = "python" cmd_entry_python.alias = "py" cmd_entry_python.args_template = "" cmd_entry_python.args_lower = 0 cmd_entry_python.args_upper = 0 cmd_entry_python.usage = "python usage..." cmd_entry_python.flags = 0 #cmd_entry_python.key_binding = NULL #cmd_entry_python.check = NULL cmd_entry_python.execc = python_exec
Remember that because we declared this in the top level, we know it's on the heap and don't need to declare any memory to the structure, which is very handy for us. You've seen struct access before; the function...