ffi/ffi-swig-generator — pull request #14 by phemmer (2013-10-18 03:12:22+00:00)
Title: Add typedef support

This adds typedef support.

Consider the following swig file:

%module test
typedef uint64_t pop;

int foo(pop tart);

Without this commit the following output is produced:

attach_function :foo, :foo, [ :uint32 ], :int

With this commit the following output is produced:

typedef :uint32, :pop
attach_function :foo, :foo, [ :pop ], :int

---

This also made another bug pop up in that pointer arguments to functions were coming back as the type of object the pointer was to.

For example:

%module Test
typedef struct {
int foo;
int bar;
} mystruct;
void pop(mystruct *tart);

Resulted in:

class Mystruct < FFI::Struct
layout(
:foo, :int,
:bar, :int
)
end
attach_function :pop, :pop, [ :mystruct ], :void

Note the argument of the function should be `:pointer`, not `:mystruct`.

The last commit on this pull request fixes it. But without this change, that section of the code wasn't even running at all. So I'm not completely certain what it was originally for.