Commit graph

4,346 commits

Author SHA1 Message Date
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
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
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
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
d98ef6ca07 Remove C-specific enum unit tests
These tests are just a small subset of the full language-independent tests and
it doesn't make much sense to keep them now that the full tests pass.
2016-04-16 00:48:17 +02:00
Vadim Zeitlin
44d68197d6 Hack for "true" and "false" used as enum element values
This is not a full solution by far, but should address the most common case.

This also allows "cpp_enum" unit test to pass.
2016-04-16 00:45:58 +02:00
Vadim Zeitlin
2a4bc0e7e5 Fix function names in the cpp_enum C test
This was just an error in the test.
2016-04-16 00:45:41 +02:00
Vadim Zeitlin
3d21bb2c96 Hack around parser bug with char enum element values
Enum element somehow lose the single quotes around them, compensate for it in
C module code (other modules use module-specific constvalue feature to work
around it, but it seems better to do it in SWIG itself rather than leaving the
user code to deal with it).

This finally makes the "enums" unit test pass.
2016-04-16 00:25:50 +02:00
Vadim Zeitlin
168e16ec67 Hack to support variables of anonymous enum types
Declare the variable as int as this is how variables of enum types are stored
(although this would have to be revised when support for C++11 base enum type
is added) and, although ugly, this at least allows the generated code to
compile.

This fixes some (but not all yet) errors in the "enums" and "cpp_enum" unit
tests.
2016-04-16 00:25:10 +02:00
Vadim Zeitlin
fb4d700279 Represent enums as themselves in generated code
Define enum type and enum values as the elements of this enum instead of using
preprocessor #defines for them.

This fixes a couple of enum-related unit tests.
2016-04-16 00:10:48 +02:00
Vadim Zeitlin
e1a4b02f69 No real changes, just convert files to Unix EOLs
Some tests and examples files as well as the C manual chapter used DOS EOLs,
get rid of them for consistency with all the other text files.
2016-04-16 00:10:22 +02:00
Vadim Zeitlin
c05f03d485 Fix esoteric regression in the previous commit
Implement the check for duplicate SWIG_derives_from<> specializations which
could happen if a template type with default parameters was exported both with
implicit default values used for these parameters and the same values
specified explicitly.

This makes the code more complicated and is very rarely needed (in addition to
the above, the template class must also have a base class to trigger the bug),
but it does happen and used to work, so restore this after breaking it in the
last commit and reenable the template_default2 unit test.
2016-04-16 00:06:35 +02:00
Vadim Zeitlin
818b399c9e Drastically simplify and optimize object creation and destruction
Don't populate the typenames array for each and every created object and don't
search it when deleting every object, this is O(N) in number of classes and is
completely impractical for any big library where N can easily be several
thousands. Use destructor function which will correctly destroy the object
instead.

Also don't store each created objects in the global registry, there doesn't
seem to be any point in it.

And, in fact, don't bother with the typenames at all, just use another
pseudo-virtual function for checking whether a class inherits from a class
with the given name.

There is unfortunately one problem with the new approach: it doesn't work when
the same C++ type is wrapped under different names as this results in multiple
specializations of SWIG_derives_from<> for this type. But this is a relatively
rare situation (but which does arise in template_default2 unit test, which had
to be disabled) and could be fixed in the future by completely resolving the
type, including the default template parameters values, and checking if
SWIG_derives_from had been already specialized for it. In the meanwhile, this
regression is not a big deal compared to the advantages of the new approach.
2016-04-15 23:25:32 +02:00
Vadim Zeitlin
2a37e53b62 Remove abstract_access from broken tests
It passes now with C backend.
2016-04-14 02:44:46 +02:00
Vadim Zeitlin
795e3adb0d Use CFLAGS when compiling test code for C module tests
This is useful to pass e.g. CFLAGS=-g on make command line.
2016-04-14 02:44:46 +02:00
Vadim Zeitlin
3d6880aad1 Start removing proxy layer, just use the wrapped functions directly
The proxy layer, and all the extra complexity associated with it, seemed to be
only necessary in order to try to allow using the same name for the wrapped
global functions as were used for them in the original C or C++ code being
wrapped. However this could simply never work in all cases, notably it didn't
work at all when using ELF shared libraries under Unix as the functions with
the same name defined in the main program were interposed and replaced the
functions defined in the shared library, meaning that the proxy function foo()
called wrapper function _wrap_foo() which called back into proxy function
foo() itself again, resulting in guaranteed stack overflow. The only possible
way to fix this would be to use "protected" ELF visibility for the original
functions, but this is not always possible (e.g. if the sources of the
original library are not available) and not simple even when it is and,
besides, protected visibility has its own problems -- notably by making it
impossible to hook the library functions when you actually want to do it.
Besides, proxy-based approach simply couldn't work at all when using static
linking as it resulted in two copies of the function with the same name

Most importantly, however, the main task of this module is to wrap C++
classes, not C functions, and renaming them in the wrapper is not necessary at
all in this case as there is no conflict with the original names in this case.
So simply drop the idea of generating a separate proxy header and generate a
header declaring the functions declared in the wrapper instead and, also, do
not give them "_wrap_" prefix whenever possible, i.e. only do it for the
global functions.

This simplifies SWIG code itself and makes it simpler to use its output as
it's not necessary to link both with the wrapper (dynamically) and with the
proxy (statically) and it's not enough to link with the wrapper only and it
can be done in any way (i.e. either statically or dynamically).

As a side effect of this change, Swig_name_proxy() is not necessary any more
and was removed, eliminating the only difference with the master branch in any
source file other than c.cxx itself.
2016-04-14 02:44:45 +02:00
Vadim Zeitlin
e8ec13f56b Remove SWIG_MAKE_DELETE() macro from C runtime
This doesn't seem to be necessary nor even useful at all, just get rid of it
completely and expand it manually in the only place where it was used.
2016-04-13 18:10:36 +02:00
Vadim Zeitlin
34431d72e6 Create output file with C++ extension for C++ C examples
This file contains C++ code when using "swig -c++", so create it with .cxx
extension.
2016-04-13 18:10:35 +02:00
Vadim Zeitlin
23d89c2cb4 Make "make check-c-version" work too
This is not very useful, but still add this target for consistency and to make
Travis CI script work with C too.
2016-04-13 18:10:35 +02:00
Vadim Zeitlin
82ce7e4725 Force the unit test suite to pass for C
Disable all currently failing tests.
2016-04-13 18:10:35 +02:00
Vadim Zeitlin
1af8e25d4d Add a possibility to disable failing test cases
Allow defining FAILING_{C,CPP,MULTI_CPP}_TESTS variables to exclude some tests
from the unit tests suite. This is useful to disable tests failing for some
language only.
2016-04-13 18:10:35 +02:00
Vadim Zeitlin
3b087fcb2b Fix running C test suite when using a separate build directory
Correct top_srcdir path and use ../$(srcdir) instead of just "../" which may
not be the same when building in another directory.
2016-04-13 18:10:35 +02:00
Vadim Zeitlin
19ed0b531d Fix and simplify C examples makefiles
Make "make check-c-examples" perform the correct build commands, e.g. not link
the proxy code into the shared library as this can't work because it defines
the same functions that are already present in it.

Also fix the c_xxx targets to work when SWIG is built in a separate build
directory.

Finally, simplify them by removing the unnecessary variables.

Notice that std_vector example still doesn't build, but at least now it is due
to a real problem in the C module and not makefile bugs.
2016-04-10 22:45:51 +02:00
Vadim Zeitlin
7c402ad148 Merge branch 'master' into C 2016-04-08 17:29:16 +02:00
William S Fulton
a97441613e Merge branch 'ahnolds-py_gettar'
* ahnolds-py_gettar:
  update changes file for attribute fix
  Add python AttributeError test for non-existent attribute
  Fixing python attribute lookup

Conflicts:
	CHANGES.current
2016-04-02 18:06:03 +01:00
William S Fulton
333a46f07d Add python AttributeError test for non-existent attribute 2016-04-02 18:03:08 +01:00
William S Fulton
bbd1b8ed05 Add tests for Python -builtin -O and compactdefaultargs and update changes file 2016-04-02 11:29:54 +01:00
William S Fulton
1d62790928 Fix assertion for some languages when wrapping a C++11 enum class that is private in a class.
Also don't wrap private enums for a few languages that attempted to do so.

Closes #594.
2016-03-31 20:27:36 +01:00
William S Fulton
a15bbbaee5 Java - unsigned long long marshalling improvements for negative numbers
Affects marshalling of negative numbers from Java to C only.
A cast to signed long long in the C layer will now result in the expected value.

Closes #623.
2016-03-31 18:56:32 +01:00
William S Fulton
896a0f1f31 Merge branch 'ptomulik-fix/nonclass-constants'
* ptomulik-fix/nonclass-constants:
  fix handling of function pointers by %constant directive
2016-03-24 19:24:02 +00:00
Paweł Tomulik
174523aa80 fix handling of function pointers by %constant directive 2016-03-24 11:22:51 +01:00
Paweł Tomulik
350d43d988 handle const pointers to functions 2016-03-24 10:59:23 +01:00
William S Fulton
d98f7050a0 Merge branch 'alexwarg-fix-lua-getitem'
* alexwarg-fix-lua-getitem:
  Add test case for Lua __getitem + inheritance
  Fix lua base class methods with __getitem
2016-03-22 20:44:12 +00:00
William S Fulton
7aa5f07dfd Fix 'make partialcheck-test-suite'
Python pep8 should not be run as part of partialcheck
Javascript should also only invoke SWIG during partialcheck
2016-03-18 18:56:55 +00:00
William S Fulton
9d4a4439da Revert "scilab: runtime initialization needed in examples"
This reverts commit 54b84b8fa1.
2016-03-18 08:56:23 +00:00
William S Fulton
5cd0678a4c Scilab test-suite warning suppression 2016-03-17 19:43:12 +00:00
Alexander Warg
be907f96e0 Add test case for Lua __getitem + inheritance 2016-03-17 07:48:01 +01:00
joequant
6212800fe3 Merge pull request #636 from richardbeare/RExtraStdVectorNumericTypes
R extra std vector numeric types
2016-03-16 18:55:58 +08:00
Richard Beare
351e21bd4a Added a run test for vector types. Tests creation of a std::vector
from and R vector and transparent conversion of the result.
2016-03-15 12:15:29 +11:00
Richard Beare
5c2cd32795 Corrected the testing in unittest so that all elements of
a vector result are checked. Previously it was just the first
element.
2016-03-15 12:14:20 +11:00
William S Fulton
5a4291911e Correct Java runtime test 2016-03-14 20:54:21 +00:00
William S Fulton
870b814f5e Add C++11 std::array container support for Java 2016-03-14 20:46:56 +00:00
William S Fulton
f119602447 clang illegal character encoding warning fixes in tests 2016-03-13 15:44:10 +00:00