Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. 1typedef struct
  2. 2 {
  3. 3 int screen_number;
  4. 4 xcb_connection_t * ptr;
  5. 5 } Connection;
  6. 6 //extend classes
  7. 7 %feature("autodoc", "1");
  8. 8
  9. 9 %extend Connection {
  10. 10 Connection(const char *displayname)
  11. 11 {
  12. 12 Connection * c ;
  13. 13 c = (Connection * ) malloc(sizeof(Connection));
  14. 14 c->ptr = xcb_connect(displayname, &c->screen_number);
  15. 15 return c;
  16. 16 }
  17. 17 ~Connection()
  18. 18 {
  19. 19 free($self);
  20. 20 }
  21. ---anothers methods for this class
  22.  
  23. 2509 typedef struct{
  24. 2510 xcb_screen_t * ptr;
  25. 2511 } Screen;
  26. ------
  27. %extend Screen {
  28. 3421 Screen(xcb_screen_t * ptr)
  29. 3422 {
  30. 3423 Screen *p;
  31. 3424 p = (Screen *) malloc(sizeof(Screen));
  32. 3425 p->ptr = ptr;
  33. 3426 return p;
  34. 3427 }
  35. 3428 ~Screen()
  36. 3429 {
  37. 3430 free($self->ptr);
  38. 3431 free($self);
  39. 3432 }
  40. ---another methods for this class
  41.  
  42. xcb_screen_t *xcb_aux_get_screen (xcb_connection_t *c, int screen);
  43.  
  44. #a Connection class already created:
  45. conn
  46. screen_ptr = Xcb_util.xcb_aux_get_screen( conn->ptr , 1)
  47. my_screen = Screen.new(screen_ptr)
  48.  
  49. Screen * aux_get_screen( Connection * c, in screen)
  50. {
  51. Screen * s;
  52. s = malloc(sizeof(Screen);
  53. s->ptr = xcb_aux_get_screen( c->ptr , 1);
  54. return s;
  55. }
  56.  
  57. conn
  58. my_screen = Xcb_util.xcb_aux_get_screen( conn , 1)
  59. #my_screen is Xcb_core::Screen class or at least a Screen class with same methods of Xcb_core::Screen class
  60.  
  61. my_screen = Conn.xcb_aux_get_screen(1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement