@@ -32,6 +32,15 @@ under the License.
3232
3333%include " ../src/nsDefinitions.h"
3434
35+ #if defined(SWIGJAVA) || defined(SWIGCSHARP)
36+ %nspace COMMON_NS::AbstractObject;
37+ %nspace COMMON_NS::DataObjectReference;
38+ %nspace COMMON_NS::DataObjectRepository;
39+ %nspace COMMON_NS::EnumStringMapper;
40+ %nspace COMMON_NS::EpcDocument;
41+ %nspace COMMON_NS::HdfProxyFactory;
42+ #endif
43+
3544// ************************/
3645// JAVA
3746// ************************/
@@ -78,6 +87,14 @@ under the License.
7887 SWIG_CSBODY_PROXY (public, public, SWIGTYPE)
7988 SWIG_CSBODY_TYPEWRAPPER(public, public, public, SWIGTYPE)
8089
90+ %typemap(cscode) COMMON_NS::DataObjectRepository %{
91+ private HdfProxyFactory hdfProxyFactoryReference = null;
92+ %}
93+
94+ %typemap(csin,
95+ post =" hdfProxyFactoryReference = $csinput;"
96+ ) COMMON_NS::HdfProxyFactory * factory " HdfProxyFactory.getCPtr($csinput)"
97+
8198 %include " swigCsInclude.i"
8299#endif
83100
@@ -92,6 +109,22 @@ under the License.
92109 %}
93110 %include " swigPythonInclude.i"
94111
112+ /* Following extensions aims at preventing the Python garbage collector from
113+ garbage collecting an HDF Proxy factory that may be still used by a repository. */
114+ %fragment(" hdf_proxy_factory_reference_init" , " init" ) {
115+ hdf_proxy_factory_reference ();
116+ }
117+ %fragment(" hdf_proxy_factory_reference_function" , " header" , fragment=" hdf_proxy_factory_reference_init" ) {
118+ static PyObject *hdf_proxy_factory_reference () {
119+ static PyObject *hdf_proxy_factory_reference_string = SWIG_Python_str_FromChar (" __hdf_proxy_factory_reference" );
120+ return hdf_proxy_factory_reference_string;
121+ }
122+ }
123+ %extend COMMON_NS::DataObjectRepository {
124+ %typemap (ret, fragment=" hdf_proxy_factory_reference_function" ) void setHdfProxyFactory (COMMON_NS::HdfProxyFactory * factory) %{
125+ PyObject_SetAttr ($self, hdf_proxy_factory_reference (), args);
126+ %}
127+ }
95128#endif
96129
97130
@@ -172,15 +205,6 @@ under the License.
172205
173206typedef long long time_t ;
174207
175- #if defined(SWIGJAVA) || defined(SWIGCSHARP)
176- %nspace COMMON_NS::AbstractObject;
177- %nspace COMMON_NS::DataObjectReference;
178- %nspace COMMON_NS::DataObjectRepository;
179- %nspace COMMON_NS::EnumStringMapper;
180- %nspace COMMON_NS::EpcDocument;
181- %nspace COMMON_NS::HdfProxyFactory;
182- #endif
183-
184208namespace EML2_NS
185209{
186210 class Activity ;
@@ -813,12 +837,18 @@ import com.f2i_consulting.fesapi.*;
813837%}
814838%typemap(javainterfaces) COMMON_NS::DataObjectRepository " AutoCloseable"
815839%typemap(javacode) COMMON_NS::DataObjectRepository %{
840+ private HdfProxyFactory hdfProxyFactoryReference;
841+
816842 @Override
817843 public void close () {
818844 clear ();
819845 delete ();
820846 }
821847%}
848+ %typemap(javain,
849+ post =" hdfProxyFactoryReference = $javainput;"
850+ ) COMMON_NS::HdfProxyFactory * factory " HdfProxyFactory.getCPtr($javainput)"
851+
822852 /* *
823853 * @brief A DataObjectRepository stores in memory all dataObjects.
824854 * This is the in-memory container which holds deserialized (EPC) files and fetched ETP dataobjects.
0 commit comments