Fixes for C enums used in an API and the definition of the enum has not been parsed.
For D, this fixes a segfault in SWIG. Java, C#, D, Go now produce code that compiles, although the definition of the enum is needed in order to use the enum properly from the target language.
This commit is contained in:
parent
15f4b3b19d
commit
cd2085aae7
7 changed files with 149 additions and 49 deletions
|
|
@ -580,6 +580,7 @@ C_TEST_CASES += \
|
|||
enums \
|
||||
enum_forward \
|
||||
enum_macro \
|
||||
enum_missing \
|
||||
extern_declaration \
|
||||
funcptr \
|
||||
function_typedef \
|
||||
|
|
|
|||
39
Examples/test-suite/enum_missing.i
Normal file
39
Examples/test-suite/enum_missing.i
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
%module enum_missing
|
||||
|
||||
// Test when SWIG does not parse the enum definition
|
||||
%{
|
||||
enum AVPixelFormat {
|
||||
AV_PIX_FMT_NONE = -1,
|
||||
AV_PIX_FMT_YUV420P
|
||||
};
|
||||
enum AVPixelFormat2 {
|
||||
AV_PIX_FMT_NONE2 = -1,
|
||||
AV_PIX_FMT_YUV420P2
|
||||
};
|
||||
|
||||
%}
|
||||
|
||||
%inline %{
|
||||
typedef struct AVCodecContext {
|
||||
enum AVPixelFormat pix_fmt;
|
||||
enum AVPixelFormat2 pix_fmt2;
|
||||
} AVCodecContext;
|
||||
|
||||
enum AVPixelFormat global_fmt;
|
||||
enum AVPixelFormat2 global_fmt2;
|
||||
|
||||
enum AVPixelFormat use_pixel_format(enum AVPixelFormat px) {
|
||||
return px;
|
||||
}
|
||||
enum AVPixelFormat * use_pixel_format_ptr(enum AVPixelFormat *px) {
|
||||
return px;
|
||||
}
|
||||
|
||||
const enum AVPixelFormat2 use_pixel_format2(const enum AVPixelFormat2 px) {
|
||||
return px;
|
||||
}
|
||||
const enum AVPixelFormat2 * use_pixel_format_ptr2(const enum AVPixelFormat2 *px) {
|
||||
return px;
|
||||
}
|
||||
%}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue