PageRenderTime 17ms CodeModel.GetById 15ms app.highlight 0ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/Examples/test-suite/memberin_extend.i

#
Swig | 33 lines | 28 code | 5 blank | 0 comment | 0 complexity | e1cd9e478104d7a37e70f590fabec740 MD5 | raw file
 1%module memberin_extend
 2
 3// Tests memberin typemap is not used for %extend.
 4// The test extends the struct with a pseudo member variable
 5
 6%inline %{
 7#include <string>
 8struct ExtendMe {
 9};
10%}
11
12%{
13#include <map>
14std::map<ExtendMe*, char *> ExtendMeStringMap;
15void ExtendMe_thing_set(ExtendMe *self, const char *val) {
16  char *old_val = ExtendMeStringMap[self];
17  delete [] old_val;
18  if (val) {
19    ExtendMeStringMap[self] = new char[strlen(val)+1];
20    strcpy(ExtendMeStringMap[self], val);
21  } else {
22    ExtendMeStringMap[self] = 0;
23  }
24}
25char * ExtendMe_thing_get(ExtendMe *self) {
26  return ExtendMeStringMap[self];
27}
28%}
29
30%extend ExtendMe {
31  char *thing;
32}
33