Advertisement
Guest User

Untitled

a guest
Apr 24th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. # C++ data structure
  2.  
  3. ```c++
  4. struct Vector3d
  5. {
  6. double x, y, z;
  7. };
  8.  
  9. struct BigData
  10. {
  11. int n;
  12.  
  13. int *iarr;
  14. double *darr;
  15. Vector3d *varr;
  16. };
  17. ```
  18.  
  19. # SWIG interface
  20. ```swig
  21. %module hoge
  22.  
  23. %include "carrays.i"
  24.  
  25. %include "std_vector.i"
  26. %include "std_string.i"
  27.  
  28. %{
  29. #include "hoge.h"
  30. %}
  31.  
  32. %array_class(int, IntArray)
  33. %array_class(double, DoubleArray)
  34. // %array_functions(Vector3d, Vector3dArray)
  35. %array_class(Vector3d, Vector3dArray)
  36.  
  37. // grab the whole header
  38. %include "hoge.h"
  39. ```
  40.  
  41. # Lua access
  42. ```lua
  43. data_iarr = hoge.IntArray_frompointer(data.iarr)
  44. data_darr = hoge.DoubleArray_frompointer(data.darr)
  45. data_varr = hoge.Vector3dArray_frompointer(data.varr)
  46. ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement