<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Hi, guys,<br>
<br>
I am writing a python module for X record extension. I have a callback
need to access the data member of xEvent:<br>
<blockquote>cdef void _event_callback_wrapper (XPointer priv,
XRecordInterceptData *hook):<br>
    cdef xEvent *data<br>
    data = &lt;xEvent*&gt; hook.data<br>
    if (hook.category != XRecordFromServer):<br>
        XRecordFreeData (hook)<br>
        return<br>
    ... ...<br>
</blockquote>
In order to access the members of one xEvent structure, I need declare
it as:<br>
<blockquote>cdef extern from "X11/Xproto.h":<br>
    ctypedef struct xEvent<br>
        ... ...<br>
        ... ...<br>
</blockquote>
Then I could use xEvent.member instead of xEvent-&gt;member to access
the members.<br>
<br>
However, the xEvent definition is too long and too complex, I am
wondering could I directly inline a small piece of c code to access
this structure, if I can ensure the reference counting or other issues?
<br>
<br>
Just like the following:<br>
<blockquote>cdef void _event_callback_wrapper (XPointer priv,
XRecordInterceptData *hook):<br>
    cdef xEvent *data<br>
    data = &lt;xEvent*&gt; hook.data<br>
    if (hook.category != XRecordFromServer):<br>
        XRecordFreeData (hook)<br>
        return<br>
    ''' inline c code:<br>
    switch (data-&gt;type) {<br>
    case KeyPress:<br>
    case KeyRelease:<br>
    ... ...<br>
    }<br>
    '''<br>
</blockquote>
Regards,<br>
<br>
</body>
</html>