Implement OCTAVE::runtimeCode, wrap some parts of runtime in anonymous namespace, put Director rtdir map into module clientdata.

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10291 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Xavier Delacour 2008-03-02 15:35:49 +00:00
commit 2ded60495f
3 changed files with 24 additions and 7 deletions

View file

@ -91,6 +91,8 @@ SWIGRUNTIME void SWIG_Octave_SetModule(void* clientdata,swig_module_info* pointe
#include <string>
#include <ext/hash_map>
namespace {
typedef octave_value_list (*octave_func) (const octave_value_list&, int);
class octave_swig_type;
@ -114,8 +116,13 @@ namespace Swig {
using namespace __gnu_cxx;
SWIGINTERN rtdir_map& get_rtdir_map() {
static rtdir_map rtdir_map__;
return rtdir_map__;
static swig_module_info* module=0;
if (!module)
module=SWIG_GetModule(0);
assert(module);
if (!module->clientdata)
module->clientdata=new rtdir_map;
return *(rtdir_map*)module->clientdata;
}
SWIGINTERNINLINE void set_rtdir(void *vptr, Director *d) {
get_rtdir_map()[vptr] = d;
@ -371,7 +378,7 @@ class octave_swig_type : public octave_base_value {
}
std::string swig_type_name() const {
// * need some way to manually name subclasses.
// * eg optional first arg to subclass().
// * eg optional first arg to subclass(), or named_subclass()
std::string ret;
for (int j=0;j<types.size();++j) {
if (j)
@ -432,7 +439,7 @@ class octave_swig_type : public octave_base_value {
return own;
}
void director_destroyed(Swig::Director* d) {
bool found=false; // * could do better here...
bool found=false;
for (int j=0;j<types.size();++j) {
Swig::Director* dj=Swig::get_rtdir(types[j].second.ptr);
if (dj==d) {
@ -1144,3 +1151,6 @@ void swig_install_ops(int tid) {
swig_install_binary_ops(tid,j);
}
}
}

View file

@ -20,8 +20,8 @@ DEFUN_DLD (SWIG_name,args,nargout,SWIG_name_d) {
return octave_value_list();
already_init=true;
octave_swig_ref::register_type ();
octave_swig_packed::register_type ();
octave_swig_ref::register_type();
octave_swig_packed::register_type();
SWIG_InitializeModule(0);
SWIG_PropagateClientData();

View file

@ -1017,7 +1017,14 @@ public:
}
String *runtimeCode() {
String *s=Language::runtimeCode();
String *s = NewString("");
String *srun = Swig_include_sys("octrun.swg");
if (!srun) {
Printf(stderr, "*** Unable to open 'octrun.swg'\n");
} else {
Append(s, srun);
Delete(srun);
}
return s;
}