开发者

Define a swig interface file for generation of wrapper to every type from some header file

We're using some C library in our Java project. Several years ago some other developer which has retired few years ago (as always) has created all the wrappers for us. The wrappers were generated by the swig, but the interface file is lost now.

The basic idea of library and the wrappers for it开发者_Python百科 is following:

  • There only one function which returns pointer to some complex object. And there are wrapper for that function.
  • The complex object is a tree-like structure with dozens of node kinds and types (C structures) used to represent them. There are hundreds of wrappers for every field of every type and we're trying to use them all.

The library was updated some time ago and now there are some new data we unaware of which yet, but would like to use. This data is contained in some of the objects indirectly contained or referenced from the object created by the function we call (Some new fields and types were added).

I know that I shouldn't make any changes to the wrappers by hand and should rather modify the interface, but as I already wrote it's missing. For now I only want to generate wrappers some few types which are added/changed and them to our old wrappers, but later I want to start creation of interface file which will define "what and how should be wrapped".

All the definitions necessary for us are defined in single header file. Is it possible to tell swig to generate wrappers for every type in this header? If so, how can I write such interface file?


From the swig tutorial:

As it turns out, it is not always necessary to write a special interface file. If you have a header file, you can often just include it directly in the SWIG interface. For example:

 %module example
 %{
 /* Includes the header in the wrapper code */
 #include "header.h"
 %}

 /* Parse the header file to generate wrappers */
 %include "header.h"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜