PageRenderTime 36ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

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

#
Swig | 37 lines | 27 code | 7 blank | 3 comment | 0 complexity | b278978afa081ce59be238691fb089ef MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. /* This interface file checks how well SWIG handles passing data back
  2. through arguments WITHOUT returning it separately; for the cases where
  3. maybe multiple values are passed by reference and all want changing */
  4. %module argout
  5. %include cpointer.i
  6. %pointer_functions(int,intp);
  7. %inline %{
  8. // returns old value
  9. int incp(int *value) {
  10. return (*value)++;
  11. }
  12. // returns old value
  13. int incr(int &value) {
  14. return value++;
  15. }
  16. typedef int & IntRef;
  17. // returns old value
  18. int inctr(IntRef value) {
  19. return value++;
  20. }
  21. // example of the old DB login type routines where you keep
  22. // a void* which it points to its opaque struct when you login
  23. // So login function takes a void**
  24. void voidhandle(void** handle) {
  25. *handle=(void*)"Here it is";
  26. }
  27. char * handle(void* handle) {
  28. return (char *)handle;
  29. }
  30. %}