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