You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1.5 KiB

  1. // Rename Add(), Remove() and Delete() to {Add,Remove,Delete}Native() and
  2. // then implement Add() Remove() and Delete() in python so we can manage
  3. // the ownership flag: thisown.
  4. %rename(AddNative) BOARD_ITEM_CONTAINER::Add;
  5. %rename(RemoveNative) BOARD_ITEM_CONTAINER::Remove;
  6. %rename(DeleteNative) BOARD_ITEM_CONTAINER::Delete;
  7. %include board_item_container.h
  8. %{
  9. #include <board_item_container.h>
  10. %}
  11. %extend BOARD_ITEM_CONTAINER
  12. {
  13. %pythoncode
  14. %{
  15. def Add(self,item):
  16. """
  17. Add a BOARD_ITEM to this BOARD_ITEM_CONTAINER, clear the thisown to prevent
  18. python from deleting the object in the garbage collector
  19. Add(BOARD_ITEM_CONTAINER self, BOARD_ITEM aItem, ADD_MODE aMode=ADD_INSERT)
  20. Add(BOARD_ITEM_CONTAINER self, BOARD_ITEM aItem)
  21. """
  22. item.thisown=0
  23. self.AddNative(item)
  24. def Remove(self,item):
  25. """
  26. Remove a BOARD_ITEM from this BOARD_ITEM_CONTAINER, set the thisdown flag so that
  27. the python wrapper owns the C++ BOARD_ITEM
  28. Remove(self, BOARD_ITEM)
  29. """
  30. self.RemoveNative(item)
  31. if (not IsActionRunning()):
  32. item.thisown=1
  33. def Delete(self,item):
  34. """
  35. Remove a BOARD_ITEM from this BOARD_ITEM_CONTAINER, set the thisdown flag so that
  36. the python wrapper does not owns the C++ BOARD_ITEM
  37. Delete(self, BOARD_ITEM)
  38. """
  39. item.thisown=0 # C++'s BOARD_ITEM_CONTAINER::Delete() will delete
  40. self.DeleteNative(item)
  41. item.this = None
  42. %}
  43. }