Commit graph

23 commits

Author SHA1 Message Date
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
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
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
Leif Middelschulte
e4c486ae6f Add docs about known shortcomings of C++ wrapping.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-c@13710 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2012-08-20 19:08:54 +00:00
Leif Middelschulte
b5d2f4765f Update docs to reflect typemap changes.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-c@13708 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2012-08-20 18:55:34 +00:00
Leif Middelschulte
d6e0954620 Minor formatting tweaks.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-c@13649 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2012-08-18 13:42:39 +00:00
Leif Middelschulte
200a678f61 Remove docs about 'wrap_call' typemap.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-c@13648 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2012-08-18 13:42:28 +00:00
Leif Middelschulte
7330e2bbf7 Use actual generated code for 'would like' prologue.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-c@13646 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2012-08-17 17:23:10 +00:00
Leif Middelschulte
abe23f2ca0 Unify beginning of command line code
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-c@13645 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2012-08-17 17:22:59 +00:00
Leif Middelschulte
dc9f0e5076 Change style of command line snippets to "shell"
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-c@13644 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2012-08-17 17:22:48 +00:00
Leif Middelschulte
0db6a8c201 Change style of C code to "targetlang"
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-c@13643 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2012-08-17 17:22:38 +00:00
Leif Middelschulte
beb9851f04 Add docs about typemaps used by the C backend for proxy code generation.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-c@13642 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2012-08-17 17:22:28 +00:00
Leif Middelschulte
370a7926d8 Use "targetlang" style for C code in docs.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-c@13641 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2012-08-17 17:22:17 +00:00
Leif Middelschulte
a826cdda4e Add beginning of 'which typemap is for what' for C backend documentation.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-c@13639 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2012-08-17 17:21:51 +00:00
Leif Middelschulte
1c38df4ceb Correct some descriptions of the typemaps. Remove duplicates
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-c@13638 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2012-08-17 12:15:08 +00:00
Leif Middelschulte
d9c2e44b25 Fix compile instructions.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-c@13194 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2012-06-26 16:37:34 +00:00
Leif Middelschulte
3ac7a8fc78 Document typemaps; Correct compile instructions
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-c@13193 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2012-06-26 15:15:56 +00:00
William S Fulton
d0ae20ec39 set the references right
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-maciekd@10824 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2008-09-08 20:09:41 +00:00
William S Fulton
a3ad15a6d6 revert last checkin
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-maciekd@10822 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2008-09-08 20:02:18 +00:00
William S Fulton
a565b7250d updates after running makechap.py
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-maciekd@10821 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2008-09-08 19:53:42 +00:00
William S Fulton
fde19227a3 Fix typos after proof read
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-maciekd@10815 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2008-09-07 21:59:57 +00:00
Maciej Drwal
40fd778b23 1. char_strings runtime test
2. next chapters of HTML doc
3. minor bugfixes


git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-maciekd@10796 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2008-08-24 12:39:30 +00:00
Maciej Drwal
5b00567154 Beginning of module documentation.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-maciekd@10795 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2008-08-19 07:43:48 +00:00