Module Import alias ImportFrom alias Assign NameStore Call NameLoad Assign NameStore Str Expr Call AttributeLoad NameLoad attr Str BinOpAdd NameLoad Str Expr Call AttributeLoad NameLoad attr NameLoad If CompareEq NameLoad Str body Expr Call AttributeLoad NameLoad attr
N/A N/A os cffi FFI N/A ffi N/A FFI N/A person_header 
    typedef struct {
        wchar_t *p_first_name;
        wchar_t *p_last_name;
        int p_age;
    } person_t;

    /* Creates a new person. Names are strdup(...)'d into the person. */
    person_t *person_create(const wchar_t *first_name, const wchar_t *last_name, int age);

    /* Writes the person's full name into *buf, up to n characters.
     * Returns the number of characters written. */
    int person_get_full_name(person_t *p, wchar_t *buf, size_t n);

    /* Destroys a person, including free()ing their names. */
    void person_destroy(person_t *p);
 N/A N/A N/A ffi set_source cffi_example._person N/A person_header 
    #include <stdlib.h>
    #include <string.h>
    #include <wchar.h>

    person_t *person_create(const wchar_t *first_name, const wchar_t *last_name, int age) {
        person_t *p = malloc(sizeof(person_t));
        if (!p)
            return NULL;
        p->p_first_name = wcsdup(first_name);
        p->p_last_name = wcsdup(last_name);
        p->p_age = age;
        return p;
    }

    int person_get_full_name(person_t *p, wchar_t *buf, size_t n) {
        return swprintf(buf, n, L"%S %S", p->p_first_name, p->p_last_name);
    }

    void person_destroy(person_t *p) {
        if (p->p_first_name)
            free(p->p_first_name);
        if (p->p_last_name)
            free(p->p_last_name);
        free(p);
    }
 N/A N/A N/A ffi cdef person_header N/A N/A __name__ __main__ N/A N/A N/A N/A ffi compile