update swig on windows

This commit is contained in:
Bassem Girgis
2019-08-04 21:38:19 -05:00
parent 8414b7136b
commit 76ad52be58
5943 changed files with 91790 additions and 71892 deletions

View File

@@ -1,133 +0,0 @@
Below are the changes for the current release.
See the CHANGES file for changes in older releases.
See the RELEASENOTES file for a summary of changes in each release.
Issue # numbers mentioned below can be found on Github. For more details, add
the issue number to the end of the URL: https://github.com/swig/swig/issues/
Version 3.0.12 (27 Jan 2017)
============================
2017-01-27: wsfulton
[C#] #882 Fix missing filename in error messages when there is a problem
writing out C# files.
2017-01-27: briancaine
[Guile] #744 Fix compilation errors in Guile wrappers - regression
introduced in swig-3.0.11.
2017-01-24: andrey-starodubtsev
[Java] Apply #704 - director typemap improvements.
Memory leak fixes, add support for "directorargout" typemap and
add director support to typemaps.i.
2017-01-24: wsfulton
Enhance %extend to extend a class with template constructors, eg:
struct Foo {
%extend {
template<typename T>
Foo(int a, T b) {
...
}
}
};
%template(Foo) Foo::Foo<double>;
2017-01-22: wsfulton
Issue #876 Enhance %extend to extend a class with template methods, eg:
struct Foo {
%extend {
template<typename T>
void do_stuff(int a, T b) {
...
}
}
};
%template(do_stuff_inst) Foo::do_stuff<double>;
Similarly for static template methods.
2017-01-22: kwwette
[Octave] add support for version 4.2
- The Octave API now uses some C++11 features. It is recommended to use
the mkoctfile program supplied by Octave to compile the SWIG-generated
wrapper code, as mkoctfile will ensure the correct C++ compiler/options
are used. Otherwise, the value of `mkoctfile -p CXX` should be parsed
for any -std=* flags which might be present.
- Octave has dropped support for << and >> operators, so SWIG now
ignores them.
- The Octave error() function now raises C++ exceptions to propagate
Octave errors, so %exception directives may need to be modified.
For convenience the SWIG_RETHROW_OCTAVE_EXCEPTIONS macro can be used
to rethrow any Octave exceptions for Octave itself to handle, e.g.:
try {
$action // may call error()
}
SWIG_RETHROW_OCTAVE_EXCEPTIONS // error() exceptions are rethrown
catch(...) {
... // all other exceptions
}
*** POTENTIAL INCOMPATIBILITY ***
2017-01-16: wkalinin
[C#] Fix #733 regression introduced in swig-3.0.9.
Missing virtual function override in C# layer when using %import.
2017-01-16: fschlimb
Fix #813 template symbol name lookup bug when typedef names are the same but in different
namespaces.
2017-01-15: wsfulton
[C# D Java]
The SWIG library no longer uses the javatype, dtype or cstype typemaps, thereby
completely freeing them up for users to use without having to replicate the library
code that they previously added. The code previously generated by these typemaps
has been replaced by the new %proxycode directive. Their use in the library code
was fairly minimal:
C# cstype: std_array.i std_map.i std_vector.i
D dtype: std_vector.i
Java javatype: arrays_java.i
2017-01-14: wsfulton
The %extend directive can now optionally support one of the 'class', 'struct' or 'union'
keywords before the identifier name, for example:
struct X { ... };
%extend struct X { ... }
Previously this had to specified as:
struct X { ... };
%extend X { ... }
2017-01-13: wsfulton
[C# D Java] Add new %proxycode directive which is a macro for %insert("proxycode").
This is a way of adding pure C#/D/Java code into the appropriate proxy class, eg:
%extend Proxy2 {
%proxycode %{
public int proxycode2(int i) {
return i+2;
}
%}
}
%inline %{
struct Proxy2 {};
%}
There will then be a pure Java/C#/D method called proxycode2 in the Proxy2 class.
2016-12-31: ajrheading1
Issue #860 - Remove use of std::unary_function and std::binary_function
which is deprecated in C++11.
2016-12-30: olly
[PHP7] Register internal 'swig_runtime_data_type_pointer' constant
as "CONST_PERSISTENT" to avoid segmentation fault on module unload.
Fixes #859 reported by Timotheus Pokorra. Thanks also to Javier Torres
for a minimal reproducer.

View File

@@ -1,38 +0,0 @@
Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "example-cs", "example-cs.csproj", "{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}"
ProjectSection(ProjectDependencies) = postProject
{C2302635-D489-4678-96B4-70F5309DCBE6} = {C2302635-D489-4678-96B4-70F5309DCBE6}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example-vc", "example-vc.vcproj", "{C2302635-D489-4678-96B4-70F5309DCBE6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
Release|Win32 = Release|Win32
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug|Win32.ActiveCfg = Debug|x86
{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug|Win32.Build.0 = Debug|x86
{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug|x64.ActiveCfg = Debug|x64
{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug|x64.Build.0 = Debug|x64
{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release|Win32.ActiveCfg = Release|x86
{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release|Win32.Build.0 = Release|x86
{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release|x64.ActiveCfg = Release|x64
{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release|x64.Build.0 = Release|x64
{C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|Win32.ActiveCfg = Debug|Win32
{C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|Win32.Build.0 = Debug|Win32
{C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|x64.ActiveCfg = Debug|x64
{C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|x64.Build.0 = Debug|x64
{C2302635-D489-4678-96B4-70F5309DCBE6}.Release|Win32.ActiveCfg = Release|Win32
{C2302635-D489-4678-96B4-70F5309DCBE6}.Release|Win32.Build.0 = Release|Win32
{C2302635-D489-4678-96B4-70F5309DCBE6}.Release|x64.ActiveCfg = Release|x64
{C2302635-D489-4678-96B4-70F5309DCBE6}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@@ -1,38 +0,0 @@
Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "example-cs", "example-cs.csproj", "{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}"
ProjectSection(ProjectDependencies) = postProject
{C2302635-D489-4678-96B4-70F5309DCBE6} = {C2302635-D489-4678-96B4-70F5309DCBE6}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example-vc", "example-vc.vcproj", "{C2302635-D489-4678-96B4-70F5309DCBE6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
Release|Win32 = Release|Win32
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug|Win32.ActiveCfg = Debug|x86
{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug|Win32.Build.0 = Debug|x86
{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug|x64.ActiveCfg = Debug|x64
{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug|x64.Build.0 = Debug|x64
{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release|Win32.ActiveCfg = Release|x86
{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release|Win32.Build.0 = Release|x86
{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release|x64.ActiveCfg = Release|x64
{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release|x64.Build.0 = Release|x64
{C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|Win32.ActiveCfg = Debug|Win32
{C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|Win32.Build.0 = Debug|Win32
{C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|x64.ActiveCfg = Debug|x64
{C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|x64.Build.0 = Debug|x64
{C2302635-D489-4678-96B4-70F5309DCBE6}.Release|Win32.ActiveCfg = Release|Win32
{C2302635-D489-4678-96B4-70F5309DCBE6}.Release|Win32.Build.0 = Release|Win32
{C2302635-D489-4678-96B4-70F5309DCBE6}.Release|x64.ActiveCfg = Release|x64
{C2302635-D489-4678-96B4-70F5309DCBE6}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@@ -1,38 +0,0 @@
Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "example-cs", "example-cs.csproj", "{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}"
ProjectSection(ProjectDependencies) = postProject
{C2302635-D489-4678-96B4-70F5309DCBE6} = {C2302635-D489-4678-96B4-70F5309DCBE6}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example-vc", "example-vc.vcproj", "{C2302635-D489-4678-96B4-70F5309DCBE6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
Release|Win32 = Release|Win32
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug|Win32.ActiveCfg = Debug|x86
{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug|Win32.Build.0 = Debug|x86
{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug|x64.ActiveCfg = Debug|x64
{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug|x64.Build.0 = Debug|x64
{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release|Win32.ActiveCfg = Release|x86
{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release|Win32.Build.0 = Release|x86
{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release|x64.ActiveCfg = Release|x64
{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release|x64.Build.0 = Release|x64
{C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|Win32.ActiveCfg = Debug|Win32
{C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|Win32.Build.0 = Debug|Win32
{C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|x64.ActiveCfg = Debug|x64
{C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|x64.Build.0 = Debug|x64
{C2302635-D489-4678-96B4-70F5309DCBE6}.Release|Win32.ActiveCfg = Release|Win32
{C2302635-D489-4678-96B4-70F5309DCBE6}.Release|Win32.Build.0 = Release|Win32
{C2302635-D489-4678-96B4-70F5309DCBE6}.Release|x64.ActiveCfg = Release|x64
{C2302635-D489-4678-96B4-70F5309DCBE6}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@@ -1,38 +0,0 @@
Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "example-cs", "example-cs.csproj", "{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}"
ProjectSection(ProjectDependencies) = postProject
{C2302635-D489-4678-96B4-70F5309DCBE6} = {C2302635-D489-4678-96B4-70F5309DCBE6}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example-vc", "example-vc.vcproj", "{C2302635-D489-4678-96B4-70F5309DCBE6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
Release|Win32 = Release|Win32
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug|Win32.ActiveCfg = Debug|x86
{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug|Win32.Build.0 = Debug|x86
{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug|x64.ActiveCfg = Debug|x64
{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug|x64.Build.0 = Debug|x64
{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release|Win32.ActiveCfg = Release|x86
{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release|Win32.Build.0 = Release|x86
{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release|x64.ActiveCfg = Release|x64
{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release|x64.Build.0 = Release|x64
{C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|Win32.ActiveCfg = Debug|Win32
{C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|Win32.Build.0 = Debug|Win32
{C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|x64.ActiveCfg = Debug|x64
{C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|x64.Build.0 = Debug|x64
{C2302635-D489-4678-96B4-70F5309DCBE6}.Release|Win32.ActiveCfg = Release|Win32
{C2302635-D489-4678-96B4-70F5309DCBE6}.Release|Win32.Build.0 = Release|Win32
{C2302635-D489-4678-96B4-70F5309DCBE6}.Release|x64.ActiveCfg = Release|x64
{C2302635-D489-4678-96B4-70F5309DCBE6}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@@ -1,38 +0,0 @@
Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "example-cs", "example-cs.csproj", "{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}"
ProjectSection(ProjectDependencies) = postProject
{C2302635-D489-4678-96B4-70F5309DCBE6} = {C2302635-D489-4678-96B4-70F5309DCBE6}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example-vc", "example-vc.vcproj", "{C2302635-D489-4678-96B4-70F5309DCBE6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
Release|Win32 = Release|Win32
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug|Win32.ActiveCfg = Debug|x86
{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug|Win32.Build.0 = Debug|x86
{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug|x64.ActiveCfg = Debug|x64
{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug|x64.Build.0 = Debug|x64
{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release|Win32.ActiveCfg = Release|x86
{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release|Win32.Build.0 = Release|x86
{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release|x64.ActiveCfg = Release|x64
{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release|x64.Build.0 = Release|x64
{C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|Win32.ActiveCfg = Debug|Win32
{C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|Win32.Build.0 = Debug|Win32
{C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|x64.ActiveCfg = Debug|x64
{C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|x64.Build.0 = Debug|x64
{C2302635-D489-4678-96B4-70F5309DCBE6}.Release|Win32.ActiveCfg = Release|Win32
{C2302635-D489-4678-96B4-70F5309DCBE6}.Release|Win32.Build.0 = Release|Win32
{C2302635-D489-4678-96B4-70F5309DCBE6}.Release|x64.ActiveCfg = Release|x64
{C2302635-D489-4678-96B4-70F5309DCBE6}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@@ -1,38 +0,0 @@
Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "example-cs", "example-cs.csproj", "{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}"
ProjectSection(ProjectDependencies) = postProject
{C2302635-D489-4678-96B4-70F5309DCBE6} = {C2302635-D489-4678-96B4-70F5309DCBE6}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example-vc", "example-vc.vcproj", "{C2302635-D489-4678-96B4-70F5309DCBE6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
Release|Win32 = Release|Win32
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug|Win32.ActiveCfg = Debug|x86
{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug|Win32.Build.0 = Debug|x86
{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug|x64.ActiveCfg = Debug|x64
{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug|x64.Build.0 = Debug|x64
{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release|Win32.ActiveCfg = Release|x86
{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release|Win32.Build.0 = Release|x86
{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release|x64.ActiveCfg = Release|x64
{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release|x64.Build.0 = Release|x64
{C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|Win32.ActiveCfg = Debug|Win32
{C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|Win32.Build.0 = Debug|Win32
{C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|x64.ActiveCfg = Debug|x64
{C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|x64.Build.0 = Debug|x64
{C2302635-D489-4678-96B4-70F5309DCBE6}.Release|Win32.ActiveCfg = Release|Win32
{C2302635-D489-4678-96B4-70F5309DCBE6}.Release|Win32.Build.0 = Release|Win32
{C2302635-D489-4678-96B4-70F5309DCBE6}.Release|x64.ActiveCfg = Release|x64
{C2302635-D489-4678-96B4-70F5309DCBE6}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@@ -1,38 +0,0 @@
Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "example-cs", "example-cs.csproj", "{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}"
ProjectSection(ProjectDependencies) = postProject
{C2302635-D489-4678-96B4-70F5309DCBE6} = {C2302635-D489-4678-96B4-70F5309DCBE6}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example-vc", "example-vc.vcproj", "{C2302635-D489-4678-96B4-70F5309DCBE6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
Release|Win32 = Release|Win32
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug|Win32.ActiveCfg = Debug|x86
{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug|Win32.Build.0 = Debug|x86
{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug|x64.ActiveCfg = Debug|x64
{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug|x64.Build.0 = Debug|x64
{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release|Win32.ActiveCfg = Release|x86
{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release|Win32.Build.0 = Release|x86
{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release|x64.ActiveCfg = Release|x64
{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release|x64.Build.0 = Release|x64
{C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|Win32.ActiveCfg = Debug|Win32
{C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|Win32.Build.0 = Debug|Win32
{C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|x64.ActiveCfg = Debug|x64
{C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|x64.Build.0 = Debug|x64
{C2302635-D489-4678-96B4-70F5309DCBE6}.Release|Win32.ActiveCfg = Release|Win32
{C2302635-D489-4678-96B4-70F5309DCBE6}.Release|Win32.Build.0 = Release|Win32
{C2302635-D489-4678-96B4-70F5309DCBE6}.Release|x64.ActiveCfg = Release|x64
{C2302635-D489-4678-96B4-70F5309DCBE6}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@@ -1,21 +0,0 @@
/* Simple example from documentation */
/* File : example.c */
#include <time.h>
double My_variable = 3.0;
int fact(int n) {
if (n <= 1) return 1;
else return n*fact(n-1);
}
int mod(int n, int m) {
return (n % m);
}
char *get_time() {
long ltime;
time(&ltime);
return ctime(&ltime);
}

View File

@@ -1,26 +0,0 @@
(define (mdisplay-newline . args) ; does guile-1.3.4 have `format #t'?
(for-each display args)
(newline))
(mdisplay-newline (get-time) "My variable = " (My-variable))
(do ((i 0 (1+ i)))
((= 14 i))
(mdisplay-newline i " factorial is " (fact i)))
(define (mods i imax j jmax)
(if (< i imax)
(if (< j jmax)
(begin
(My-variable (+ (My-variable) (mod i j)))
(mods i imax (+ j 1) jmax))
(mods (+ i 1) imax 1 jmax))))
(mods 1 150 1 150)
(mdisplay-newline "My-variable = " (My-variable))
(exit (and (= 1932053504 (fact 13))
(= 745470.0 (My-variable))))

View File

@@ -1,12 +0,0 @@
/* File : example.i */
%module example
%{
#include "example.h"
%}
%include "std_string.i"
/* Let's just grab the original header file here */
%include "example.h"

View File

@@ -1 +0,0 @@
Simple example from users manual.

View File

@@ -1,24 +0,0 @@
/* Simple example from documentation */
/* File : example.c */
#include <time.h>
double My_variable = 3.0;
/* Compute factorial of n */
int fact(int n) {
if (n <= 1) return 1;
else return n*fact(n-1);
}
/* Compute n mod m */
int my_mod(int n, int m) {
return (n % m);
}
char *get_time() {
long ltime;
time(&ltime);
return ctime(&ltime);
}

View File

@@ -1,16 +0,0 @@
/* File : example.i */
%module example
%{
/* Put headers and other declarations here */
%}
%include typemaps.i
%rename(mod) my_mod;
%inline %{
extern double My_variable;
extern int fact(int);
extern int my_mod(int n, int m);
extern char *get_time();
%}

View File

@@ -1,24 +0,0 @@
;; run with mzscheme -r runme.scm
(load-extension "example.so")
(display (get-time))
(printf "My-variable = ~a~n" (my-variable))
(let loop ((i 0))
(when (< i 14) (begin (display i)
(display " factorial is ")
(display (fact i))
(newline)
(loop (+ i 1)))))
(let loop ((i 1))
(when (< i 250)
(begin
(let loopi ((j 1))
(when (< j 250) (begin (my-variable (+ (my-variable) (mod i j)))
(loopi (+ j 1)))))
(loop (+ i 1)))))
(printf "My-variable = ~a~n" (my-variable))

View File

@@ -1,21 +0,0 @@
TOP = ../..
SWIGEXE = $(TOP)/../swig
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
SRCS =
TARGET = example
INTERFACE = example.i
SWIGOPT =
GPP = `which g++`
MZC = test -n "/usr/bin/mzc" && /usr/bin/mzc
check: build
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' mzscheme_run
build:
$(SWIGEXE) -mzscheme -c++ $(SWIGOPT) $(INTERFACE)
$(MZC) --compiler $(GPP) ++ccf "-I." --cc example_wrap.cxx
$(MZC) --linker $(GPP) --ld $(TARGET).so example_wrap.o
clean:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' mzscheme_clean

View File

@@ -1,31 +0,0 @@
TOP = ../..
SWIGEXE = $(TOP)/../swig
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
SRCS = example.c
TARGET = example
INTERFACE = example.i
MLFILE = example.ml
PROGFILE = example_prog.ml
OBJS = example.o
check: build
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' ocaml_run
build: static
static:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \
PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \
ocaml_static_cpp
dynamic:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \
PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \
ocaml_dynamic_cpp
clean:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' MLFILE='$(MLFILE)' ocaml_clean

View File

@@ -1,8 +0,0 @@
/* File : example.i */
%module example
%{
extern "C" void factor(int &x, int &y);
%}
extern "C" void factor(int &x, int &y);

View File

@@ -1,26 +0,0 @@
(* example_prog.ml *)
open Swig
open Example
exception BadReturn
let _ = if Array.length Sys.argv < 3 then
begin
print_endline
("Usage: " ^ Sys.argv.(0) ^ " n1 n2\n" ^
" Displays the least factors of the numbers that have the same\n" ^
" relationship, 16 12 -> 4 3\n") ;
exit 0
end
let x = int_of_string Sys.argv.(1)
let y = int_of_string Sys.argv.(2)
let (xf,yf) = match _factor '((x to int),(y to int)) with
C_list [ C_int a ; C_int b ] -> a,b
| _ -> raise BadReturn
let _ = print_endline
("Factorization of " ^ (string_of_int x) ^
" and " ^ (string_of_int y) ^
" is " ^ (string_of_int xf) ^
" and " ^ (string_of_int yf))

View File

@@ -1,4 +0,0 @@
open Swig
open Example
let _ = _f (match Sys.argv.(1) with "Tag1" -> ``Tag1 | _ -> ``Tag2)

View File

@@ -1,29 +0,0 @@
public class Example {
public int mPublicInt;
public Example() {
mPublicInt = 0;
}
public Example(int IntVal) {
mPublicInt = IntVal;
}
public int Add(int a, int b) {
return (a+b);
}
public float Add(float a, float b) {
return (a+b);
}
public String Add(String a, String b) {
return (a+b);
}
public Example Add(Example a, Example b) {
return new Example(a.mPublicInt + b.mPublicInt);
}
}

View File

@@ -1,24 +0,0 @@
TOP = ../..
SWIGEXE = $(TOP)/../swig
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
CXXSRCS =
TARGET = example
INTERFACE = example.i
LIBS = -lm
check: build
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_run
build: Example.class Example.h
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
CXXSHARED="gcj -fpic -shared Example.class" PERL5_CCFLAGS='' PERL5_EXP='' LIBS="-lstdc++" perl5_cpp
clean:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_clean
rm -f *.class Example.h
Example.class Example.h: $(SRCDIR)Example.java
gcj -d . -fPIC -C -c -g $(SRCDIR)Example.java
gcjh Example.class

View File

@@ -1,10 +0,0 @@
%module example
%include <cni.i>
%{
#include "Example.h"
%}
%include Example.h

View File

@@ -1,29 +0,0 @@
use example;
example::JvCreateJavaVM(undef);
example::JvAttachCurrentThread(undef, undef);
$e1 = new example::Example(1);
print $e1->{mPublicInt},"\n";
$e2 = new example::Example(2);
print $e2->{mPublicInt},"\n";
$i = $e1->Add(1,2);
print $i,"\n";
$d = $e2->Add(1.0,2.0);
print $d,"\n";
$d = $e2->Add("1","2");
print $d,"\n";
$e3 = $e1->Add($e1,$e2);
print $e3->{mPublicInt},"\n";
$s = $e2->Add("a","b");
print $s,"\n";
example::JvDetachCurrentThread()

View File

@@ -1,49 +0,0 @@
<?php
# This file illustrates the low-level C++ interface
# created by SWIG. In this case, all of our C++ classes
# get converted into function calls.
require("example.php");
# ----- Object creation -----
print "Creating some objects:\n";
$c = new Circle(10);
print " Created circle \$c\n";
$s = new Square(10);
print " Created square \$s\n";
# ----- Create the ShapeContainer ----
$container = new ShapeContainer();
$container->addShape($c);
$container->addShape($s);
# ----- Access a static member -----
print "\nA total of " . Shape::nshapes() . " shapes were created\n";
# ----- Delete by the old references -----
# This should not truely delete the shapes because they are now owned
# by the ShapeContainer.
print "Delete the old references.";
# Note: this invokes the virtual destructor
$c = NULL;
$s = NULL;
print "\nA total of " . Shape::nshapes() . " shapes remain\n";
# ----- Delete by the container -----
# This should truely delete the shapes
print "Delete the container.";
$container = NULL;
print "\nA total of " . Shape::nshapes() . " shapes remain\n";
print "Goodbye\n";
?>

View File

@@ -1,31 +0,0 @@
/* File : example.i */
%module example
%init{
zend_printf("This was %%init\n");
}
%minit{
zend_printf("This was %%minit\n");
}
%mshutdown{
zend_printf("This was %%shutdown\n");
}
%rinit{
zend_printf("This was %%rinit\n");
}
%rshutdown{
zend_printf("This was %%rshutdown\n");
}
%pragma(php) include="include.php";
%pragma(php) code="
# This code is inserted into example.php
echo \"this was php code\\n\";
"
%pragma(php) phpinfo="php_info_print_table_start();"

View File

@@ -1,5 +0,0 @@
<?php
require "example.php";
?>

View File

@@ -1,96 +0,0 @@
<?php
require "example.php";
echo "\nVariables (values printed from C)\n";
print_vars();
echo "Variables (values printed from PHP)\n";
echo "ivar = ".ivar_get()."\n";
echo "svar = ".svar_get()."\n";
echo "lvar = ".lvar_get()."\n";
echo "uivar = ".uivar_get()."\n";
echo "usvar = ".usvar_get()."\n";
echo "ulvar = ".ulvar_get()."\n";
echo "scvar = ".scvar_get()."\n";
echo "ucvar = ".ucvar_get()."\n";
echo "cvar = ".cvar_get()."\n";
echo "fvar = ".fvar_get()."\n";
echo "dvar = ".dvar_get()."\n";
echo "strvar = ".strvar_get()."\n";
echo "cstrvar = ".cstrvar_get()."\n";
echo "iptrvar = ".iptrvar_get()."\n";
echo "name = \"".name_get()."\"\n";
echo "ptptr = ".ptptr_get() , point_print(ptptr_get()) , "\n";
echo "pt = ".pt_get(), point_print(pt_get()) , "\n";
/* Try to set the values of some global variables */
$a = "42.14";
ivar_set($a);
echo "a = $a\n";
svar_set(-31000);
lvar_set(65537);
uivar_set(123456);
usvar_set(61000);
ulvar_set(654321);
scvar_set(-13);
ucvar_set(251);
cvar_set("S");
fvar_set(3.14159);
dvar_set(2.1828);
strvar_set("Hello World");
iptrvar_set(new_int(37));
ptptr_set(new_point(37,42));
name_set("B");
echo "Variables (values printed from PHP)\n";
echo "ivar = ".ivar_get()."\n";
echo "svar = ".svar_get()."\n";
echo "lvar = ".lvar_get()."\n";
echo "uivar = ".uivar_get()."\n";
echo "usvar = ".usvar_get()."\n";
echo "ulvar = ".ulvar_get()."\n";
echo "scvar = ".scvar_get()."\n";
echo "ucvar = ".ucvar_get()."\n";
echo "cvar = ".cvar_get()."\n";
echo "fvar = ".fvar_get()."\n";
echo "dvar = ".dvar_get()."\n";
echo "strvar = ".strvar_get()."\n";
echo "cstrvar = ".cstrvar_get()."\n";
echo "iptrvar = ".iptrvar_get()."\n";
echo "name = ".name_get()."\n";
echo "ptptr = ".ptptr_get() , point_print(ptptr_get()) , "\n";
echo "pt = ".pt_get(), point_print(pt_get()) , "\n";
echo "\nVariables (values printed from C)\n";
print_vars();
echo "\nI'm going to try and update a structure variable.\n";
pt_set(ptptr_get());
echo "The new value is \n";
pt_print();
echo "You should see the value", point_print(ptptr_get()), "\n";
echo "\nNow I'm going to try and modify some read only variables\n";
echo "Trying to set 'path'\n";
//path_set("Whoa!");
echo "Path = ".path_get()."\n";
echo "Trying to set 'status'\n";
/* And this */
//status_set(0);
echo "Status = ".status_get()."\n";
?>

View File

@@ -1,19 +0,0 @@
TOP = ../..
SWIGEXE = $(TOP)/../swig
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
CXXSRCS = example.cxx
TARGET = example
INTERFACE = example.i
LIBS = -lm
SWIGOPT =
check: build
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_run
build:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' $(SWIGLIB) CXXSRCS='$(CXXSRCS)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' php5_cpp
clean:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_clean

View File

@@ -1,19 +0,0 @@
<html>
<head>
<title>SWIG:Examples:php5:callback</title>
</head>
<body bgcolor="#ffffff">
<tt>SWIG/Examples/php5/callback/</tt>
<hr>
<H2>Implementing C++ callbacks in PHP5</H2>
<p>
This example illustrates how to use directors to implement C++ callbacks in PHP5.
<hr>
</body>
</html>

View File

@@ -1,47 +0,0 @@
<?php
# This file illustrates the cross language polymorphism using directors.
require("example.php");
# Class, which overwrites Callback::run().
class PhpCallback extends Callback {
function run() {
print "PhpCallback.run()\n";
}
};
# Create an Caller instance
$caller = new Caller();
# Add a simple C++ callback (caller owns the callback, so
# we disown it first by clearing the .thisown flag).
print "Adding and calling a normal C++ callback\n";
print "----------------------------------------\n";
$callback = new Callback();
$callback->thisown = 0;
$caller->setCallback($callback);
$caller->call();
$caller->delCallback();
print "\n";
print "Adding and calling a PHP callback\n";
print "------------------------------------\n";
# Add a PHP callback.
$callback = new PhpCallback();
$callback->thisown = 0;
$caller->setCallback($callback);
$caller->call();
$caller->delCallback();
# All done.
print "php exit\n";
?>

View File

@@ -1,19 +0,0 @@
# see top-level Makefile.in
# (see also top-level configure.ac kludge)
callback
class
constants
cpointer
disown
enum
extend
funcptr
overloading
pointer
pragmas
proxy
reference
simple
sync
value
variables

View File

@@ -1,60 +0,0 @@
<?php
# This example illustrates how member variables are wrapped.
require("example.php");
# ----- Object creation -----
print "Creating some objects:\n";
$c = new Circle(10);
print " Created circle\n";
$s = new Square(10);
print " Created square\n";
# ----- Access a static member -----
print "\nA total of " . Shape::nshapes() . " shapes were created\n";
# ----- Member data access -----
# Set the location of the object.
# Note: methods in the base class Shape are used since
# x and y are defined there.
$c->x = 20;
$c->y = 30;
$s->x = -10;
$s->y = 5;
print "\nHere is their current position:\n";
print " Circle = ({$c->x},{$c->y})\n";
print " Square = ({$s->x},{$s->y})\n";
# ----- Call some methods -----
# Notice how the Shape_area() and Shape_perimeter() functions really
# invoke the appropriate virtual method on each object.
print "\nHere are some properties of the shapes:\n";
foreach (array($c,$s) as $o) {
print " ". get_class($o) . "\n";
print " area = {$o->area()}\n";
print " perimeter = {$o->perimeter()}\n";
}
# ----- Delete everything -----
print "\nGuess I'll clean up now\n";
# Note: this invokes the virtual destructor
$c = NULL;
$s = NULL;
# and don't forget the $o from the for loop above. It still refers to
# the square.
$o = NULL;
print Shape::nshapes() . " shapes remain\n";
print "Goodbye\n";
?>

View File

@@ -1,20 +0,0 @@
TOP = ../..
SWIGEXE = $(TOP)/../swig
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
SRCS =
TARGET = example
INTERFACE = example.i
LIBS =
SWIGOPT =
check: build
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_run
build:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
php5
clean:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_clean

View File

@@ -1,26 +0,0 @@
/* File : example.i */
%module example
/* A few preprocessor macros */
#define ICONST 42
#define FCONST 2.1828
#define CCONST 'x'
#define CCONST2 '\n'
#define SCONST "Hello World"
#define SCONST2 "\"Hello World\""
/* This should work just fine */
#define EXPR ICONST + 3*(FCONST)
/* This shouldn't do anything */
#define EXTERN extern
/* Neither should this (BAR isn't defined) */
#define FOO (ICONST + BAR)
/* The following statements also produce constants */
%constant int iconst = 37;
%constant double fconst = 3.14;

View File

@@ -1,28 +0,0 @@
<?php
require "example.php";
print "ICONST = " . ICONST . " (should be 42)\n";
print "FCONST = " . FCONST . " (should be 2.1828)\n";
print "CCONST = " . CCONST . " (should be 'x')\n";
print "CCONST2 = " . CCONST2 . " (this should be on a new line)\n";
print "SCONST = " . SCONST . " (should be 'Hello World')\n";
print "SCONST2 = " . SCONST2 . " (should be '\"Hello World\"')\n";
print "EXPR = " . EXPR . " (should be 48.5484)\n";
print "iconst = " . iconst . " (should be 37)\n";
print "fconst = " . fconst . " (should be 3.14)\n";
if (EXTERN!="EXTERN") {
print "EXTERN = " . EXTERN . " (Arg! This shouldn't print anything)\n";
} else {
print "EXTERN defaults to 'EXTERN', it probably isn't defined (good)\n";
}
if (FOO!="FOO") {
print "FOO = " . FOO . "(Arg! This shouldn't print anything)\n";
} else {
print "FOO defaults to 'FOO', it probably isn't defined (good)\n";
}
?>

View File

@@ -1,20 +0,0 @@
TOP = ../..
SWIGEXE = $(TOP)/../swig
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
SRCS = example.c
TARGET = example
INTERFACE = example.i
LIBS =
SWIGOPT =
check: build
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_run
build:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
php5
clean:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_clean

View File

@@ -1,16 +0,0 @@
/* File : example.c */
void add(int *x, int *y, int *result) {
*result = *x + *y;
}
void sub(int *x, int *y, int *result) {
*result = *x - *y;
}
int divide(int n, int d, int *r) {
int q;
q = n/d;
*r = n - q*d;
return q;
}

View File

@@ -1,31 +0,0 @@
/* File : example.i */
%module example
%{
extern void add(int *, int *, int *);
extern void sub(int *, int *, int *);
%}
/* This example illustrates a couple of different techniques
for manipulating C pointers */
/* First we'll use the pointer library */
extern void add(int *x, int *y, int *result);
%include cpointer.i
%pointer_functions(int, intp);
/* Next we'll use some typemaps */
%include typemaps.i
extern void sub(int *INPUT, int *INPUT, int *OUTPUT);
/* Next we'll use typemaps and the %apply directive */
//%apply int *OUTPUT { int *r };
//extern int divide(int n, int d, int *r);

View File

@@ -1,47 +0,0 @@
<?php
require "example.php";
# First create some objects using the pointer library.
print "Testing the pointer library\n";
$a = example::new_intp();
$b = example::new_intp();
$c = example::new_intp();
example::intp_assign($a,37);
example::intp_assign($b,42);
print " a = $a\n";
print " b = $b\n";
print " c = $c\n";
# Call the add() function wuth some pointers
example::add($a,$b,$c);
# Now get the result
$r = example::intp_value($c);
print " 37 + 42 = $r\n";
# Clean up the pointers
example::delete_intp($a);
example::delete_intp($b);
example::delete_intp($c);
# Now try the typemap library
# This should be much easier. Now how it is no longer
# necessary to manufacture pointers.
print "Trying the typemap library\n";
$r = example::sub(37,42);
print " 37 - 42 = $r\n";
# Now try the version with multiple return values
# print "Testing multiple return values\n";
# $a = example::divide(42,37);
# $q = $a[0]
# $r = $a[1]
# print " 42/37 = $q remainder $r\n";
?>

View File

@@ -1,51 +0,0 @@
/* File : example.c */
#include "example.h"
#include <math.h>
#ifndef M_PI
# define M_PI 3.14159265358979323846
#endif
int Shape::get_nshapes() {
return nshapes;
}
/* Move the shape to a new location */
void Shape::move(double dx, double dy) {
x += dx;
y += dy;
}
int Shape::nshapes = 0;
void Circle::set_radius( double r ) {
radius = r;
}
double Circle::area(void) {
return M_PI*radius*radius;
}
double Circle::perimeter(void) {
return 2*M_PI*radius;
}
double Square::area(void) {
return width*width;
}
double Square::perimeter(void) {
return 4*width;
}
ShapeContainer::~ShapeContainer() {
iterator i=shapes.begin();
for( iterator i = shapes.begin(); i != shapes.end(); ++i ) {
delete *i;
}
}
void
ShapeContainer::addShape( Shape *s ) {
shapes.push_back( s );
}

View File

@@ -1,50 +0,0 @@
/* File : example.h */
#include <vector>
class Shape {
public:
Shape() {
nshapes++;
}
virtual ~Shape() {
nshapes--;
}
double x, y;
void move(double dx, double dy);
virtual double area(void) = 0;
virtual double perimeter(void) = 0;
static int nshapes;
static int get_nshapes();
};
class Circle : public Shape {
private:
double radius;
public:
Circle(double r) : radius(r) { }
~Circle() { }
void set_radius( double r );
virtual double area(void);
virtual double perimeter(void);
};
class Square : public Shape {
private:
double width;
public:
Square(double w) : width(w) { }
~Square() { }
virtual double area(void);
virtual double perimeter(void);
};
class ShapeContainer {
private:
typedef std::vector<Shape*>::iterator iterator;
std::vector<Shape*> shapes;
public:
ShapeContainer() : shapes() {}
~ShapeContainer();
void addShape( Shape *s );
};

View File

@@ -1,12 +0,0 @@
/* File : example.i */
%module example
%{
#include "example.h"
%}
%apply SWIGTYPE *DISOWN {(Shape *s)};
/* Let's just grab the original header file here */
%include "example.h"

View File

@@ -1,37 +0,0 @@
/* File : example.cxx */
#include "example.h"
#include <stdio.h>
void Foo::enum_test(speed s) {
if (s == IMPULSE) {
printf("IMPULSE speed\n");
} else if (s == WARP) {
printf("WARP speed\n");
} else if (s == LUDICROUS) {
printf("LUDICROUS speed\n");
} else {
printf("Unknown speed\n");
}
}
void enum_test(color c, Foo::speed s) {
if (c == RED) {
printf("color = RED, ");
} else if (c == BLUE) {
printf("color = BLUE, ");
} else if (c == GREEN) {
printf("color = GREEN, ");
} else {
printf("color = Unknown color!, ");
}
if (s == Foo::IMPULSE) {
printf("speed = IMPULSE speed\n");
} else if (s == Foo::WARP) {
printf("speed = WARP speed\n");
} else if (s == Foo::LUDICROUS) {
printf("speed = LUDICROUS speed\n");
} else {
printf("speed = Unknown speed!\n");
}
}

View File

@@ -1,32 +0,0 @@
<?php
require "example.php";
# ----- Object creation -----
# Print out the value of some enums
print "*** color ***";
print " RED =" . RED;
print " BLUE =" . BLUE;
print " GREEN =" . GREEN;
print "\n*** Foo::speed ***";
print " Foo_IMPULSE =" . Foo_IMPULSE;
print " Foo_WARP =" . Foo_WARP;
print " Foo_LUDICROUS =" . Foo_LUDICROUS;
print "\nTesting use of enums with functions\n";
enum_test(RED, Foo_IMPULSE);
enum_test(BLUE, Foo_WARP);
enum_test(GREEN, Foo_LUDICROUS);
enum_test(1234,5678);
print "\nTesting use of enum with class method\n";
$f = new_Foo();
Foo_enum_test($f,Foo_IMPULSE);
Foo_enum_test($f,Foo_WARP);
Foo_enum_test($f,Foo_LUDICROUS);
?>

View File

@@ -1,19 +0,0 @@
TOP = ../..
SWIGEXE = $(TOP)/../swig
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
CXXSRCS = example.cxx
TARGET = example
INTERFACE = example.i
LIBS = -lm
SWIGOPT =
check: build
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_run
build:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' $(SWIGLIB) CXXSRCS='$(CXXSRCS)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' php5_cpp
clean:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_clean

View File

@@ -1,19 +0,0 @@
<html>
<head>
<title>SWIG:Examples:php:extend</title>
</head>
<body bgcolor="#ffffff">
<tt>SWIG/Examples/php/extend/</tt>
<hr>
<H2>Extending a simple C++ class in PHP</H2>
<p>
This example illustrates the extending of a C++ class with cross language polymorphism.
<hr>
</body>
</html>

View File

@@ -1,76 +0,0 @@
<?php
# This file illustrates the cross language polymorphism using directors.
require("example.php");
# CEO class, which overrides Employee::getPosition().
class CEO extends Manager {
function getPosition() {
return "CEO";
}
}
# Create an instance of our employee extension class, CEO. The calls to
# getName() and getPosition() are standard, the call to getTitle() uses
# the director wrappers to call CEO.getPosition.
$e = new CEO("Alice");
print $e->getName() . " is a " . $e->getPosition() . "\n";
printf("Just call her \"%s\"\n", $e->getTitle());
print "----------------------\n";
# Create a new EmployeeList instance. This class does not have a C++
# director wrapper, but can be used freely with other classes that do.
$list = new EmployeeList();
# EmployeeList owns its items, so we must surrender ownership of objects
# we add. This involves first clearing the ->disown member to tell the
# C++ director to start reference counting.
$e->thisown = 0;
$list->addEmployee($e);
print "----------------------\n";
# Now we access the first four items in list (three are C++ objects that
# EmployeeList's constructor adds, the last is our CEO). The virtual
# methods of all these instances are treated the same. For items 0, 1, and
# 2, both all methods resolve in C++. For item 3, our CEO, getTitle calls
# getPosition which resolves in PHP. The call to getPosition is
# slightly different, however, from the e.getPosition() call above, since
# now the object reference has been "laundered" by passing through
# EmployeeList as an Employee*. Previously, PHP resolved the call
# immediately in CEO, but now PHP thinks the object is an instance of
# class Employee (actually EmployeePtr). So the call passes through the
# Employee proxy class and on to the C wrappers and C++ director,
# eventually ending up back at the CEO implementation of getPosition().
# The call to getTitle() for item 3 runs the C++ Employee::getTitle()
# method, which in turn calls getPosition(). This virtual method call
# passes down through the C++ director class to the PHP implementation
# in CEO. All this routing takes place transparently.
print "(position, title) for items 0-3:\n";
printf(" %s, \"%s\"\n", $list->get_item(0)->getPosition(), $list->get_item(0)->getTitle());
printf(" %s, \"%s\"\n", $list->get_item(1)->getPosition(), $list->get_item(1)->getTitle());
printf(" %s, \"%s\"\n", $list->get_item(2)->getPosition(), $list->get_item(2)->getTitle());
printf(" %s, \"%s\"\n", $list->get_item(3)->getPosition(), $list->get_item(3)->getTitle());
print "----------------------\n";
# Time to delete the EmployeeList, which will delete all the Employee*
# items it contains. The last item is our CEO, which gets destroyed as its
# reference count goes to zero. The PHP destructor runs, and is still
# able to call the getName() method since the underlying C++ object still
# exists. After this destructor runs the remaining C++ destructors run as
# usual to destroy the object.
unset($list);
print "----------------------\n";
# All done.
print "php exit\n";
?>

View File

@@ -1,20 +0,0 @@
TOP = ../..
SWIGEXE = $(TOP)/../swig
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
SRCS = example.c
TARGET = example
INTERFACE = example.i
LIBS =
SWIGOPT =
check: build
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_run
build:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
php5
clean:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_clean

View File

@@ -1,7 +0,0 @@
/* file: example.h */
extern int do_op(int,int, int (*op)(int,int));
extern int add(int,int);
extern int sub(int,int);
extern int mul(int,int);

View File

@@ -1,24 +0,0 @@
<?php
require "example.php";
$a = 37;
$b = 42;
# Now call our C function with a bunch of callbacks
print "Trying some C callback functions\n";
print " a = $a\n";
print " b = $b\n";
print " ADD(a,b) = ". do_op($a,$b,ADD)."\n";
print " SUB(a,b) = ". do_op($a,$b,SUB)."\n";
print " MUL(a,b) = ". do_op($a,$b,MUL)."\n";
print "Here is what the C callback function objects look like in php\n";
print "Using swig style string pointers as we need them registered as constants\n";
print " ADD = " . ADD . "\n";
print " SUB = " . SUB . "\n";
print " MUL = " . MUL . "\n";
?>

View File

@@ -1,20 +0,0 @@
TOP = ../..
SWIGEXE = $(TOP)/../swig
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
CXXSRCS = example.cxx
TARGET = example
INTERFACE = example.i
LIBS =
SWIGOPT =
check: build
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_run
build:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
php5_cpp
clean:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_clean

View File

@@ -1,55 +0,0 @@
/* File : example.c */
#include "example.h"
#include <math.h>
#ifndef M_PI
# define M_PI 3.14159265358979323846
#endif
int Shape::get_nshapes() {
return nshapes;
}
/* Move the shape to a new location */
void Shape::move(double dx, double dy) {
x += dx;
y += dy;
}
int Shape::nshapes = 0;
double Circle::area(void) {
return M_PI*radius*radius;
}
double Circle::perimeter(void) {
return 2*M_PI*radius;
}
double Square::area(void) {
return width*width;
}
double Square::perimeter(void) {
return 4*width;
}
const char *overloaded(int i) {
return "Overloaded with int";
}
const char *overloaded(double d) {
return "Overloaded with double";
}
const char *overloaded(const char * str) {
return "Overloaded with char *";
}
const char *overloaded( const Circle& ) {
return "Overloaded with Circle";
}
const char *overloaded( const Shape& ) {
return "Overloaded with Shape";
}

View File

@@ -1,46 +0,0 @@
/* File : example.h */
#include <stdio.h>
class Shape {
public:
Shape() {
nshapes++;
}
virtual ~Shape() {
nshapes--;
}
double x, y;
void move(double dx, double dy);
virtual double area(void) = 0;
virtual double perimeter(void) = 0;
static int nshapes;
static int get_nshapes();
};
class Circle : public Shape {
private:
double radius;
public:
Circle(double r) : radius(r) { }
~Circle() { }
virtual double area(void);
virtual double perimeter(void);
};
class Square : public Shape {
private:
double width;
public:
Square(double w) : width(w) { }
~Square() { }
virtual double area(void);
virtual double perimeter(void);
};
const char *overloaded( int i );
const char *overloaded( double d );
const char *overloaded( const char * str );
const char *overloaded( const Circle& );
const char *overloaded( const Shape& );

View File

@@ -1,8 +0,0 @@
/* File : example.i */
%module example
%{
#include "example.h"
%}
%include "example.h"

View File

@@ -1,58 +0,0 @@
<?php
# This file illustrates the low-level C++ interface
# created by SWIG. In this case, all of our C++ classes
# get converted into function calls.
include("example.php");
# ----- Object creation -----
print "Creating some objects:\n";
$c = new Circle(10);
print " Created circle \$c\n";
$s = new Square(10);
print " Created square \$s\n";
# ----- Access a static member -----
print "\nA total of " . Shape::nshapes() . " shapes were created\n";
# ----- Member data access -----
# Set the location of the object.
# Note: methods in the base class Shape are used since
# x and y are defined there.
$c->x = 20;
$c->y = 30;
$s->x = -10;
$s->y = 5;
print "\nHere is their current position:\n";
print " Circle = (" . $c->x . "," . $c->y . ")\n";
print " Square = (" . $s->x . "," . $s->y . ")\n";
# ----- Call some methods -----
print "\nCall some overloaded methods:\n";
foreach (array(1, 2.1, "quick brown fox", $c, $s) as $o) {
print " overloaded = " . overloaded($o) . "\n";
}
# Need to unset($o) or else we hang on to a reference to the Square object.
unset($o);
# ----- Delete everything -----
print "\nGuess I'll clean up now\n";
# Note: this invokes the virtual destructor
unset($c);
$s = 42;
print Shape::nshapes() . " shapes remain\n";
print "Goodbye\n";
?>

View File

@@ -1,20 +0,0 @@
TOP = ../..
SWIGEXE = $(TOP)/../swig
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
SRCS = example.c
TARGET = example
INTERFACE = example.i
LIBS =
SWIGOPT =
check: build
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_run
build:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
php5
clean:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_clean

View File

@@ -1,16 +0,0 @@
/* File : example.c */
void add(double *x, double *y, double *result) {
*result = *x + *y;
}
void sub(int *x, int *y, int *result) {
*result = *x - *y;
}
int divide(int n, int d, int *r) {
int q;
q = n/d;
*r = n - q*d;
return q;
}

View File

@@ -1,30 +0,0 @@
/* File : example.i */
%module example
%{
extern void add(double *, double *, double *);
extern void sub(int *, int *, int *);
extern int divide(int, int, int *);
%}
/* This example illustrates a couple of different techniques
for manipulating C pointers */
%include phppointers.i
/* First we'll use the pointer library */
extern void add(double *REF, double *REF, double *REF);
/* Next we'll use some typemaps */
%include typemaps.i
extern void sub(int *INPUT, int *INPUT, int *OUTPUT);
/* Next we'll use typemaps and the %apply directive */
//%apply int *OUTPUT { int *r };
//extern int divide(int n, int d, int *r);

View File

@@ -1,35 +0,0 @@
<?php
require "example.php";
# First create some objects using the pointer library.
print "Testing the pointer library\n";
$a = 37.145;
$b = 42.555;
$c = ""; // $c must be defined and not null.
print " a = $a\n";
print " b = $b\n";
print " c = $c\n";
# Call the add() function wuth some pointers
add($a,$b,$c);
print " $a + $b = $c\n";
# Now try the typemap library
# This should be much easier. Now how it is no longer
# necessary to manufacture pointers.
print "Trying the typemap library\n";
$r = sub(37,42);
print " 37 - 42 = $r\n";
# Now try the version with multiple return values
# print "Testing multiple return values\n";
# ($q,$r) = divide(42,37);
# print " 42/37 = $q remainder $r\n";
?>

View File

@@ -1,20 +0,0 @@
TOP = ../..
SWIGEXE = $(TOP)/../swig
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
SRCS =
TARGET = example
INTERFACE = example.i
LIBS =
SWIGOPT =
check: build
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_run
build:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
php5
clean:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_clean

View File

@@ -1,7 +0,0 @@
<?php
# This code is inserted into example.php
echo "this is include.php\n";
?>

View File

@@ -1,5 +0,0 @@
<?php
require "example.php";
?>

View File

@@ -1,20 +0,0 @@
TOP = ../..
SWIGEXE = $(TOP)/../swig
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
CXXSRCS = example.cxx
TARGET = example
INTERFACE = example.i
LIBS =
SWIGOPT =
check: build
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_run
build:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
php5_cpp
clean:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_clean

View File

@@ -1,43 +0,0 @@
/* File : example.c */
#include "example.h"
#include <math.h>
#ifndef M_PI
# define M_PI 3.14159265358979323846
#endif
int Shape::get_nshapes() {
return nshapes;
}
/* Move the shape to a new location */
void Shape::move(double dx, double dy) {
x += dx;
y += dy;
}
int Shape::nshapes = 0;
void Circle::set_radius( double r ) {
radius = r;
}
double Circle::area(void) {
return M_PI*radius*radius;
}
double Circle::perimeter(void) {
return 2*M_PI*radius;
}
double Square::area(void) {
return width*width;
}
double Square::perimeter(void) {
return 4*width;
}
Circle *CircleFactory( double r ) {
return new Circle(r);
}

View File

@@ -1,12 +0,0 @@
/* File : example.i */
%module example
%{
#include "example.h"
%}
/* Let's just grab the original header file here */
%newobject CircleFactory;
%include "example.h"

View File

@@ -1,68 +0,0 @@
<?php
# This file illustrates the low-level C++ interface
# created by SWIG. In this case, all of our C++ classes
# get converted into function calls.
include("example.php");
# ----- Object creation -----
print "Creating some objects:\n";
$c = example::CircleFactory(10);
print " Created circle \$c with area ". $c->area() ."\n";
$s = new Square(10);
print " Created square \$s\n";
# ----- Access a static member -----
print "\nA total of " . Shape::nshapes() . " shapes were created\n";
# ----- Member data access -----
# Set the location of the object.
# Note: methods in the base class Shape are used since
# x and y are defined there.
$c->x = 20;
$c->y = 30;
$s->x = -10;
$s->y = 5;
print "\nHere is their current position:\n";
print " Circle = (" . $c->x . "," . $c->y . ")\n";
print " Square = (" . $s->x . "," . $s->y . ")\n";
# ----- Call some methods -----
print "\nHere are some properties of the shapes:\n";
foreach (array($c,$s) as $o) {
print " ".get_class($o)." \$o\n";
print " x = " . $o->x . "\n";
print " y = " . $o->y . "\n";
print " area = " . $o->area() . "\n";
print " perimeter = " . $o->perimeter() . "\n";
}
# Need to unset($o) or else we hang on to a reference to the Square object.
unset($o);
# ----- Delete everything -----
print "\nGuess I'll clean up now\n";
# Note: this invokes the virtual destructor
unset($c);
$s = 42;
print Shape::nshapes() . " shapes remain\n";
print "Manually setting nshapes\n";
Shape::nshapes(42);
print Shape::get_nshapes() ." == 42\n";
print "Goodbye\n";
?>

View File

@@ -1,20 +0,0 @@
TOP = ../..
SWIGEXE = $(TOP)/../swig
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
CXXSRCS = example.cxx
TARGET = example
INTERFACE = example.i
LIBS =
SWIGOPT =
check: build
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_run
build:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
php5_cpp
clean:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_clean

View File

@@ -1,49 +0,0 @@
/* File : example.cxx */
/* Deal with Microsoft's attempt at deprecating C standard runtime functions */
#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER)
# define _CRT_SECURE_NO_DEPRECATE
#endif
#include "example.h"
#include <stdio.h>
#include <stdlib.h>
Vector operator+(const Vector &a, const Vector &b) {
Vector r;
r.x = a.x + b.x;
r.y = a.y + b.y;
r.z = a.z + b.z;
return r;
}
char *Vector::as_string() {
static char temp[512];
sprintf(temp,"Vector %p (%g,%g,%g)", (void *)this, x,y,z);
return temp;
}
VectorArray::VectorArray(int size) {
items = new Vector[size];
maxsize = size;
printf("VectorArray new: self=%p\n", (void *)this);
}
VectorArray::~VectorArray() {
printf("VectorArray delete: self=%p\n", (void *)this);
delete [] items;
}
Vector &VectorArray::operator[](int index) {
printf("VectorArray: read[%d] self=%p\n", index, (void *)this);
if ((index < 0) || (index >= maxsize)) {
printf("Panic! Array index out of bounds.\n");
exit(1);
}
return items[index];
}
int VectorArray::size() {
printf("VectorArray: size %d self=%p\n", maxsize, (void *)this);
return maxsize;
}

View File

@@ -1,22 +0,0 @@
/* File : example.h */
class Vector {
private:
double x,y,z;
public:
Vector() : x(0), y(0), z(0) { }
Vector(double x, double y, double z) : x(x), y(y), z(z) { }
friend Vector operator+(const Vector &a, const Vector &b);
char *as_string();
};
class VectorArray {
private:
Vector *items;
int maxsize;
public:
VectorArray(int maxsize);
~VectorArray();
Vector &operator[](int);
int size();
};

View File

@@ -1,43 +0,0 @@
/* File : example.i */
/* This file has a few "typical" uses of C++ references. */
%module example
%{
#include "example.h"
%}
class Vector {
public:
Vector(double x, double y, double z);
~Vector();
char *as_string();
};
/* This helper function calls an overloaded operator */
%inline %{
Vector addv(Vector &a, Vector &b) {
return a+b;
}
%}
/* Wrapper around an array of vectors class */
class VectorArray {
public:
VectorArray(int maxsize);
~VectorArray();
int size();
/* This wrapper provides an alternative to the [] operator */
%extend {
Vector &get(int index) {
printf("VectorArray extended get: %p %d\n", (void *)$self, index);
return (*$self)[index];
}
void set(int index, Vector &a) {
(*$self)[index] = a;
}
}
};

View File

@@ -1,49 +0,0 @@
<?php
# This file illustrates the manipulation of C++ references in PHP.
require "example.php";
# ----- Object creation -----
print "Creating some objects:\n";
$a = new Vector(3, 4, 5);
$b = new Vector(10, 11, 12);
print " Created a: {$a->as_string()}\n";
print " Created b: {$b->as_string()}\n";
# ----- Call an overloaded operator -----
# This calls the wrapper we placed around
#
# operator+(const Vector &a, const Vector &)
#
# It returns a new allocated object.
print "Adding a+b\n";
$c = example::addv($a, $b);
print " a+b ={$c->as_string()}\n";
# ----- Create a vector array -----
print "Creating an array of vectors\n";
$va = new VectorArray(10);
print " va: size={$va->size()}\n";
# ----- Set some values in the array -----
# These operators copy the value of $a and $b to the vector array
$va->set(0, $a);
$va->set(1, $b);
$va->set(2, addv($a, $b));
# Get some values from the array
print "Getting some array values\n";
for ($i = 0; $i < 5; $i++) {
print " va[$i] = {$va->get($i)->as_string()}\n";
}
?>

View File

@@ -1,20 +0,0 @@
TOP = ../..
SWIGEXE = $(TOP)/../swig
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
SRCS = example.c
TARGET = example
INTERFACE = example.i
LIBS =
SWIGOPT =
check: build
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_run
build:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
php5
clean:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_clean

View File

@@ -1,25 +0,0 @@
<?php
require "example.php";
# Call our gcd() function
$x = "42 aaa";
$y = 105;
$g = gcd($x,$y);
print "The gcd of $x and $y is $g\n";
# Manipulate the Foo global variable
# Output its current value
print "Foo = " . Foo_get() . "\n";
# Change its value
Foo_set(3.1415926);
# See if the change took effect ( this isn't a good example for php, see
# manual for why. )
print "Foo = " . Foo_get() . "\n";
print_Foo();
?>

View File

@@ -1,20 +0,0 @@
TOP = ../..
SWIGEXE = $(TOP)/../swig
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
CXXSRCS = example.cxx
TARGET = example
INTERFACE = example.i
LIBS =
SWIGOPT =
check: build
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_run
build:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
php5_cpp
clean:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_clean

View File

@@ -1,13 +0,0 @@
#include "example.h"
#include <stdio.h>
int x = 42;
char *s = (char *)"Test";
void Sync::printer(void) {
printf("The value of global s is %s\n", s);
printf("The value of global x is %d\n", x);
printf("The value of class s is %s\n", s);
printf("The value of class x is %d\n", x);
}

View File

@@ -1,9 +0,0 @@
extern char *s;
extern int x;
class Sync {
public:
int x;
char *s;
void printer(void);
};

View File

@@ -1,7 +0,0 @@
%module example
%{
#include "example.h"
%}
%include "example.h"

View File

@@ -1,15 +0,0 @@
<?
// Load module and PHP classes.
include("example.php");
echo "Got new object\n";
echo "Got string $s and value $x \n";
$s = new Sync();
echo "Got new object\n";
$s->printer();
?>

View File

@@ -1,20 +0,0 @@
TOP = ../..
SWIGEXE = $(TOP)/../swig
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
SRCS = example.c
TARGET = example
INTERFACE = example.i
LIBS =
SWIGOPT = -noproxy
check: build
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_run
build:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
php5
clean:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_clean

View File

@@ -1,13 +0,0 @@
/* File : example.c */
#include "example.h"
double dot_product(Vector a, Vector b) {
return (a.x*b.x + a.y*b.y + a.z*b.z);
}
void vector_add(Vector a, Vector b, Vector* result) {
result->x = a.x + b.x;
result->y = a.y + b.y;
result->z = a.z + b.z;
}

View File

@@ -1,8 +0,0 @@
/* File : example.h */
typedef struct {
double x, y, z;
} Vector;
double dot_product(Vector a, Vector b);
void vector_add(Vector a, Vector b, Vector* result);

View File

@@ -1,17 +0,0 @@
// Tests SWIG's handling of pass-by-value for complex datatypes
%module example
%{
#include "example.h"
%}
%include "example.h"
/* Some helper functions for our interface */
%inline %{
void vector_print(Vector *v) {
printf("Vector %p = (%g, %g, %g)\n", (void *)v, v->x, v->y, v->z);
}
%}

View File

@@ -1,43 +0,0 @@
<?php
require "example.php";
$v = new_vector();
vector_x_set($v,1.0);
vector_y_set($v,2.0);
vector_z_set($v,3.0);
$w = new_vector();
vector_x_set($w,10.0);
vector_y_set($w,11.0);
vector_z_set($w,12.0);
echo "I just created the following vector\n";
vector_print($v);
vector_print($w);
echo "\nNow I'm going to compute the dot product\n";
$d = dot_product($v, $w);
echo "dot product = $d (should be 68)\n";
echo "\nNow I'm going to add the vectors together\n";
$r = new_vector();
vector_add($v, $w, $r);
vector_print($r);
echo "The value should be (11,13,15)\n";
echo "\nNow I'm going to clean up the return result\n";
# free($r);
echo "Good\n";
?>

View File

@@ -1,20 +0,0 @@
TOP = ../..
SWIGEXE = $(TOP)/../swig
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
SRCS = example.c
TARGET = example
INTERFACE = example.i
LIBS =
SWIGOPT =
check: build
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_run
build:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
php5
clean:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_clean

View File

@@ -1,95 +0,0 @@
/* File : example.c */
/* I'm a file containing some C global variables */
/* Deal with Microsoft's attempt at deprecating C standard runtime functions */
#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER)
# define _CRT_SECURE_NO_DEPRECATE
#endif
#include <stdio.h>
#include <stdlib.h>
#include "example.h"
int ivar = 0;
short svar = 0;
long lvar = 0;
unsigned int uivar = 0;
unsigned short usvar = 0;
unsigned long ulvar = 0;
signed char scvar = 0;
unsigned char ucvar = 0;
char cvar = 0;
float fvar = 0;
double dvar = 0;
char *strvar = 0;
const char cstrvar[] = "Goodbye";
int *iptrvar = 0;
char name[5] = "Dave";
char path[256] = "/home/beazley";
/* Global variables involving a structure */
Point *ptptr = 0;
Point pt = { 10, 20 };
/* A variable that we will make read-only in the interface */
int status = 1;
/* A debugging function to print out their values */
void print_vars() {
printf("ivar = %d\n", ivar);
printf("svar = %d\n", svar);
printf("lvar = %ld\n", lvar);
printf("uivar = %u\n", uivar);
printf("usvar = %u\n", usvar);
printf("ulvar = %lu\n", ulvar);
printf("scvar = %d\n", scvar);
printf("ucvar = %u\n", ucvar);
printf("fvar = %g\n", fvar);
printf("dvar = %g\n", dvar);
printf("cvar = %c\n", cvar);
printf("strvar = %s\n", strvar ? strvar : "(null)");
printf("cstrvar = %s\n", cstrvar);
printf("iptrvar = %p\n", (void *)iptrvar);
printf("name = %c%c%c%c%c\n", name[0],name[1],name[2],name[3],name[4]);
printf("ptptr = %p %s\n", (void *)ptptr, Point_print( ptptr ) );
printf("pt = (%d, %d)\n", pt.x, pt.y);
printf("status = %d\n", status);
}
/* A function to create an integer (to test iptrvar) */
int *new_int(int value) {
int *ip = (int *) malloc(sizeof(int));
*ip = value;
return ip;
}
int value_int(int *value) {
return *value;
}
/* A function to create a point */
Point *new_Point(int x, int y) {
Point *p = (Point *) malloc(sizeof(Point));
p->x = x;
p->y = y;
return p;
}
char * Point_print(Point *p) {
static char buffer[256];
if (p) {
sprintf(buffer,"(%d,%d)", p->x,p->y);
} else {
sprintf(buffer,"null");
}
return buffer;
}
void pt_print() {
printf("(%d, %d)\n", pt.x, pt.y);
}

View File

@@ -1,34 +0,0 @@
/* File: example.h */
typedef struct {
int x,y;
} Point;
/* Some global variable declarations */
extern int ivar;
extern short svar;
extern long lvar;
extern unsigned int uivar;
extern unsigned short usvar;
extern unsigned long ulvar;
extern signed char scvar;
extern unsigned char ucvar;
extern char cvar;
extern float fvar;
extern double dvar;
extern char *strvar;
extern const char cstrvar[];
extern int *iptrvar;
extern char name[5];
extern Point *ptptr;
extern Point pt;
extern int status;
extern char path[256];
extern void print_vars();
extern int *new_int(int value);
extern Point *new_Point(int x, int y);
extern char *Point_print(Point *p);
extern void pt_print();

View File

@@ -1,44 +0,0 @@
/* File : example.i */
%module example
%{
#include "example.h"
%}
/* Some global variable declarations */
extern int ivar;
extern short svar;
extern long lvar;
extern unsigned int uivar;
extern unsigned short usvar;
extern unsigned long ulvar;
extern signed char scvar;
extern unsigned char ucvar;
extern char cvar;
extern float fvar;
extern double dvar;
extern char *strvar;
extern const char cstrvar[];
extern int *iptrvar;
extern char name[5];
extern Point *ptptr;
extern Point pt;
/* Some read-only variables */
%immutable;
extern int status;
extern char path[256];
%mutable;
/* Some helper functions to make it easier to test */
extern void print_vars();
extern int *new_int(int value);
extern Point *new_Point(int x, int y);
extern char *Point_print(Point *p);
extern void pt_print();

View File

@@ -1,4 +0,0 @@
/* File : example.cxx */
#include "example.h"

View File

@@ -1,4 +0,0 @@
/* File : example.cxx */
#include "example.h"

View File

@@ -1,56 +0,0 @@
/* File : example.h */
#include <cstdio>
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
class Employee {
private:
std::string name;
public:
Employee(const char* n): name(n) {}
virtual std::string getTitle() { return getPosition() + " " + getName(); }
virtual std::string getName() { return name; }
virtual std::string getPosition() const { return "Employee"; }
virtual ~Employee() { printf("~Employee() @ %p\n", (void *)this); }
};
class Manager: public Employee {
public:
Manager(const char* n): Employee(n) {}
virtual std::string getPosition() const { return "Manager"; }
};
class EmployeeList {
std::vector<Employee*> list;
public:
EmployeeList() {
list.push_back(new Employee("Bob"));
list.push_back(new Employee("Jane"));
list.push_back(new Manager("Ted"));
}
void addEmployee(Employee *p) {
list.push_back(p);
std::cout << "New employee added. Current employees are:" << std::endl;
std::vector<Employee*>::iterator i;
for (i=list.begin(); i!=list.end(); i++) {
std::cout << " " << (*i)->getTitle() << std::endl;
}
}
const Employee *get_item(int i) {
return list[i];
}
~EmployeeList() {
std::vector<Employee*>::iterator i;
std::cout << "~EmployeeList, deleting " << list.size() << " employees." << std::endl;
for (i=list.begin(); i!=list.end(); i++) {
delete *i;
}
std::cout << "~EmployeeList empty." << std::endl;
}
};

View File

@@ -1,15 +0,0 @@
/* File : example.i */
%module(directors="1") example
%{
#include "example.h"
%}
%include "std_vector.i"
%include "std_string.i"
/* turn on director wrapping for Manager */
%feature("director") Employee;
%feature("director") Manager;
%include "example.h"

View File

@@ -1,13 +0,0 @@
import sys
import os.path
# Test import of modules content from within __init__.py
testname = os.path.basename(os.path.dirname(os.path.abspath(__file__)))
print "Testing " + testname + " - %module(package=...) + python 'import' in __init__.py"
if sys.version_info < (3, 0):
import py2.pkg2
print " Finished importing py2.pkg2"
else:
import py3.pkg2
print " Finished importing py3.pkg2"

View File

@@ -1,13 +0,0 @@
import sys
import os.path
# Test import of modules content from within __init__.py
testname = os.path.basename(os.path.dirname(os.path.abspath(__file__)))
print "Testing " + testname + " - %module(package=...) + python 'import' in __init__.py"
if sys.version_info < (3, 0):
import py2.pkg2
print " Finished importing py2.pkg2"
else:
import py3.pkg2
print " Finished importing py3.pkg2"

View File

@@ -1,13 +0,0 @@
import sys
import os.path
# Test import of modules content from within __init__.py
testname = os.path.basename(os.path.dirname(os.path.abspath(__file__)))
print "Testing " + testname + " - %module(package=...) + python 'import' in __init__.py"
if sys.version_info < (3, 0):
import py2.pkg2
print " Finished importing py2.pkg2"
else:
import py3.pkg2
print " Finished importing py3.pkg2"

View File

@@ -1,5 +0,0 @@
# import robin as a module in the global namespace
import robin
assert(robin.run() == "AWAY!")

View File

@@ -1,7 +0,0 @@
import sys
# Package brave found under one path
sys.path.insert(0, 'path1')
from brave import robin
assert(robin.run() == "AWAY!")

View File

@@ -1,9 +0,0 @@
import sys
# Package brave split into two paths.
# path2/brave/robin.py and path3/brave/_robin.so
sys.path.insert(0, 'path2')
sys.path.insert(0, 'path3')
from brave import robin
assert(robin.run() == "AWAY!")

Some files were not shown because too many files have changed in this diff Show More