Commit graph

19,438 commits

Author SHA1 Message Date
Vadim Zeitlin
862abb42e6 Allow suppressing progress messages when running C test suite
This makes the warnings more noticeable.
2016-09-15 01:27:39 +02:00
Vadim Zeitlin
0480694a7a Remove the now unused functionWrapperCPPSpecificMarkFirstParam()
There is no need to set c:objstruct for the first parameter of the methods now
that we take care of it for disambiguating between overloads explicitly and
this function doesn't seem to be useful for anything else, simply drop it.
2016-09-15 01:27:39 +02:00
Vadim Zeitlin
8e30abf7ab Don't use "this" method parameter for disambiguating overloads
When building the unique suffix for each member of the overloaded functions
set, don't use the first "this" parameter of the object methods in it as it's
the same for all of them and so is completely useless for disambiguation
purposes and just results in unnecessarily long and ugly names.

Use "_const" suffix for the methods differing by their const-ness only, this
is necessary now that we don't use "_pFoo" or "_pcFoo" in their names.

This makes it superfluous to check for c:objstruct in
functionWrapperAppendOverloaded() (and checking for it there was not enough
neither, as the changes in the test suite show, sometimes the "this" parameter
type still found its way into the generated wrappers).
2016-09-15 01:27:39 +02:00
Vadim Zeitlin
1dfbd492b9 Add more warning-suppressing casts to special_variables test
Avoid harmless but annoying warning about assigning a literal string to
a non-const char pointer.
2016-09-15 01:27:39 +02:00
Vadim Zeitlin
e068aa8cc9 Simplify ctors/dtor handling by reusing base class code
Just use our custom object creation/destruction code, but let the base class
do everything else.

This uncovered complete lack of support for ctors/dtors defined using %extend,
but this is not new and will have to remain broken for now.
2016-09-15 01:27:39 +02:00
Vadim Zeitlin
2e3b427b7e Get rid of unnecessary and confusing c:stype attribute
We can just use "type" directly, there is no need for any C-specific stype.
2016-04-21 18:58:33 +02:00
Vadim Zeitlin
2c65b4db5b Remove obsolete RCS ID line
No real changes.
2016-04-21 18:58:33 +02:00
Vadim Zeitlin
02c52331cd Return scoped_dohptr from get_wrapper_func_proto()
This ensures that the pointer is not leaked.

Unfortunately it requires adding a dangerous, std::auto_ptr<>-like destructive
copy ctor to scoped_dohptr<>, but there is no better solution without C++11.
2016-04-21 18:58:33 +02:00
Vadim Zeitlin
e2738ad524 Refactor: add parentheses in get_wrapper_func_proto() itself
Return the prototype strings already surrounded by parentheses instead of
having to add them in the caller.

No real changes.
2016-04-21 18:58:33 +02:00
Vadim Zeitlin
c971919e2f Merge almost identical code generating wrapper function arguments
Reuse get_wrapper_func_proto() for the wrapper function definitions too, this
cuts down on the amount of duplicated code and also ensures that declarations
and definitions match.
2016-04-21 18:58:33 +02:00
Vadim Zeitlin
00ef2c4c7d Remove unused functionWrapperCPPSpecificProxyWrapperCallGet()
This is identical to the main part of functionWrapperCPPSpecificWrapper() now
and it is not used anywhere.
2016-04-21 18:58:33 +02:00
Vadim Zeitlin
8cae88dd39 Get rid of separate cmodtype typemap
Use the same ctype for wrapper declarations and definitions and just expand
$resolved_type differently in the two cases.

This simplifies the typemaps and ensures that the declarations and definitions
use the same types, at least for all non-object parameters.
2016-04-21 18:58:32 +02:00
Vadim Zeitlin
5de29df38e Simplify typemaps by merging both const and "unconst" versions
We can always just use the "unconst" one because it works when the type is
used for a return value and is the same as the other one when it's used for a
parameter anyhow because top-level const is ignored in function signatures, so
don't bother defining two sets of macros when one will do.
2016-04-21 17:55:47 +02:00
Vadim Zeitlin
160074a025 Suppress warnings about no typemaps being defined in C test suite
In many (although perhaps not all, so don't suppress this warning
unconditionally) cases, there is no need for special typemaps in C, the
parameters can be just used directly, so this warning is harmless but it was
given many times during the test suite execution, distracting from more
important messages.
2016-04-21 15:23:27 +02:00
Vadim Zeitlin
806f79de14 No real changes, just rename "proxy_header" to "cheader"
Continue getting rid of "proxy" terminology, there is no proxy when using C
module, so it's confusing to use this term.
2016-04-21 15:18:22 +02:00
Vadim Zeitlin
e2bb89ccb3 Replace unknown enums with int in the wrappers
An enum can be declared outside of the code wrapped by SWIG, just use int
instead of it then.
2016-04-21 01:37:42 +02:00
Vadim Zeitlin
41d46460b8 Add helper scoped_dohptr class
This is useful for avoiding having to explicitly write Delete() calls for DOH
objects.
2016-04-21 01:37:42 +02:00
Vadim Zeitlin
113ce5ae7d Add a blank line to the generated code
This is purely cosmetic: add an extra blank line after the __cplusplus ifdef
end.
2016-04-21 01:37:42 +02:00
Vadim Zeitlin
4b5e5d0cc8 Allow to use the original name of the global functions
It is impossible to have two functions with the same name inside the same
program, but it is possible to provide a #define to allow the user code to use
the original function name for the wrapper function, so do it for convenience.

Remove the old changes adding explicit "_wrap_" prefix to the examples and the
tests and remove the few more now passing tests from the list of failing tests.
2016-04-21 01:37:42 +02:00
Vadim Zeitlin
36fdd4e78f Wrap unknown type as opaque pointers
Don't give errors for the unknown types, instead wrap them using the mangled
name of the type.

This is the expected (even if not particularly useful) SWIG behaviour and
allows many more tests to pass.
2016-04-21 01:37:42 +02:00
Vadim Zeitlin
d9feedc37a Remove unnecessary SwigType_typedef_resolve_all() call
No real changes, just don't bother calling SwigType_typedef_resolve_all()
before calling classLookup() because the latter already does it anyhow.
2016-04-21 01:37:41 +02:00
Vadim Zeitlin
2ec9d9da6e Don't try to export variables in namespace scope directly
The generated code, which used C++ scope operator "::" in a C header, didn't
compile and couldn't work anyhow.

Just use the accessor functions for not really global variables.
2016-04-21 01:37:41 +02:00
Vadim Zeitlin
e39265ba13 Handle primitive types when expanding "resolved_type" in typemaps
Although the default typemaps only use "resolved_type" for non-simple types,
the generic SWIGTYPE typemap can also be applied explicitly to other types as
"apply_strings" and "char_binary" unit tests do.

In this case just use the original type unchanged if we can, this is enough to
make these tests pass.
2016-04-21 01:37:41 +02:00
Vadim Zeitlin
4c654d9369 Give an error if unsupported type is encountered
This is better than silently generating completely wrong code with
$resolved_type in it and makes it easier to understand what exactly went wrong
and where.
2016-04-21 01:37:41 +02:00
Vadim Zeitlin
59c131ea08 Fix broken anonymous_bitfield C checking code
For some reason the test expected another bit field be changed when setting
the given one, which was just plain wrong and prevented the test from passing.
2016-04-21 01:37:41 +02:00
Vadim Zeitlin
b062a63cd1 Fix abstract_typedef C test code
Don't refer to the typedef name (especially with a typo in it...), it is not
supposed to be exported.

Also fix the write() method call: use the right class for it and pass it the
correct arguments.
2016-04-21 01:37:41 +02:00
Vadim Zeitlin
e934c51425 Include stddef.h instead of stdio.h in the generated header
The sole reason for including this header seems to be to get size_t
declaration, so include the smallest header sufficient for this.

It would be even better to use a fragment for all size_t typemaps to only
include it if necessary, but it doesn't seem to be worth doing this right now.
2016-04-21 01:37:41 +02:00
Vadim Zeitlin
b7bd0165e8 Remove more tests which pass now
All tests detected as passing by "make check-failing".
2016-04-21 01:37:41 +02:00
Vadim Zeitlin
19268d0865 Add check-failing target to check that failing tests still do fail
This is useful to remove the tests which pass after the latest fixes from the
list of the failing tests.
2016-04-21 01:37:41 +02:00
Vadim Zeitlin
3764ee1764 Make anonymous_bitfield test compile
It still doesn't pass, but at least include the correct header from it.
2016-04-21 01:37:40 +02:00
Vadim Zeitlin
af9dd72bb6 Fix function name in cpp_basic_template_function test
Use "_wrap_" prefix to make the test compile and pass.
2016-04-21 01:37:40 +02:00
Vadim Zeitlin
2edbbfd87f Fix cpp_basic_global_var_built_in unit test
Use the correct header name in it and remove it from the list of the failing
tests.
2016-04-21 01:37:40 +02:00
Vadim Zeitlin
7bb7fe135a Let cpp_basic unit test pass without method pointers support
This was the only part of the test that didn't work, test at least the rest of
it.
2016-04-21 01:37:40 +02:00
Vadim Zeitlin
e8c6bfbc8f Remove completely broken handling of member function pointers
Member function pointers can't possibly be represented as function pointers,
they have a strictly bigger size and attempting to do it resulted in code
which, with a lot of bad casts, compiled, but crashed during run-time.

The proper solution is to represent C++ method pointers with an appropriate
opaque type, but for now this remains broken -- just make it explicitly broken
instead of pretending that it works when it actually has no chance to.

Let "namespace_spaces" unit test pass, as it's not really related to the
function pointers, by adding an explicit SWIGC test to it.
2016-04-21 01:37:40 +02:00
Vadim Zeitlin
11fbdba9de Remove cpp_basic_template_class from the list of failing tests
It passes now.
2016-04-21 01:37:40 +02:00
Vadim Zeitlin
e28bd6bf3a Fix cpp_basic_class_var_pub_member_built_in test compilation
Use the correct header name in the test.
2016-04-21 01:37:40 +02:00
Vadim Zeitlin
4d774887cc Only syntax check generated header when not using run test
There is no need to syntax check the header if it's going to be really used,
so this is a small optimization.

It also separates building of the wrappers from testing them better.
2016-04-21 01:37:40 +02:00
Vadim Zeitlin
87d4a0da71 Reuse c_compile rule in C unit test suite makefile
No real changes, just reuse the commands defined in the C section of the top
level Examples/Makefile instead of (imperfectly, i.e. CFLAGS was forgotten
here) duplicating them in Examples/test-suite/c/Makefile.
2016-04-21 01:37:40 +02:00
Vadim Zeitlin
208980f4de Avoid gcc warnings for nested anonymous enums in the generated code
Output anonymous enums defined inside C structs in the global scope, this
doesn't change the semantics as the constants defined inside a struct still
have global scope in C, but avoids gcc warnings given when compiling the
generated code.
2016-04-20 18:46:12 +02:00
Vadim Zeitlin
6813c7eacf No changes, just write emit_c_struct_def() in a more natural way
Don't force the caller to pass firstChild() of the struct node to this
function, just pass it the struct node itself and iterate over all of its
children inside it.
2016-04-20 18:46:12 +02:00
Vadim Zeitlin
7a392fd21f Fix typemaps for "void*"
Pass void pointers directly to C, don't handle them objects which was done by
default previously because we didn't define any specific typemaps for them.

This allows to reenable another test.
2016-04-20 18:46:12 +02:00
Vadim Zeitlin
85c9b87f9b Fix ctype typemap for bool& too
Don't add an extra pointer, this is already done at the code level currently.

This makes the "bools" unit test pass.
2016-04-20 18:46:12 +02:00
Vadim Zeitlin
18cb946405 Fix cmodtype typemap for "const bool &"
We need bool to be "const", not the pointer.

This fixes a few of the errors in the "bools" unit test.
2016-04-20 18:46:12 +02:00
Vadim Zeitlin
c8e4abd16e Use wrapper functions for global variables of non-C types
Don't try to export the variables whose type can't be represented in C
directly, this can't work.

Instead, just let use the default implementation to generate wrapper functions
for them.

Update "cpp_basic_global_var_class" unit test accordingly and remove it from
the list of the failing tests.
2016-04-20 18:45:42 +02:00
Vadim Zeitlin
8104c24f71 Fix typemaps for templates with more than one parameter
Ensure that any commas inside SWIG_STR() used in "out" typemaps for class
types are not interpreted as macro argument separators by using an extra pair
of parenthesis around the type.
2016-04-20 01:53:26 +02:00
Vadim Zeitlin
c73acc44a7 Show the number of passed tests in "make check"
This is especially useful when some tests are disabled by using
FAILING_XXX_TESTS variables.
2016-04-20 01:53:23 +02:00
Vadim Zeitlin
668f2b4a85 Syntax check headers by C module when running the unit tests suite
Catch errors in the generated headers even when we don't have a run test.

Unfortunately this uncovered that almost no unit tests actually pass, so many,
many more of them had to be disabled.
2016-04-18 20:30:49 +02:00
Vadim Zeitlin
200ea0e37d Don't output "decl" attribute into the wrapper declarations
This doesn't make any sense as "decl" is a SWIG type string and not a C
declaration.
2016-04-18 20:30:49 +02:00
Vadim Zeitlin
1f6ce1ed64 Reuse existing wrapper declarations code for C functions too
We just copied the function prototype without any changes from the original C
function to the wrappers header when in C mode, but this wasn't correct, e.g.
the original function could use typedefs not available in the wrapper.

Fix this by applying the typemaps in C mode too, but without the C++-specific
parts.

This also makes C and C++ code paths slightly less different from each other,
the long-term goal is to make them identical.
2016-04-18 20:30:49 +02:00
Vadim Zeitlin
c4036fdc58 Fix handling of forward-declared enums
Don't output the enum body if it just forward-declared, empty enums are
invalid in C.
2016-04-18 01:09:29 +02:00