test_object.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. #ifndef __GI_CPP_EXAMPLE_H__
  2. #define __GI_CPP_EXAMPLE_H__
  3. #include <glib-object.h>
  4. #include <glib.h>
  5. G_BEGIN_DECLS
  6. // enum
  7. typedef enum _CEnum { ENUM_VALUE_0, ENUM_VALUE_1 } CEnum;
  8. GType gi_cpp_enum_get_type(void);
  9. #define GI_CPP_TYPE_ENUM (gi_cpp_enum_get_type())
  10. // flags
  11. typedef enum _CFlags { FLAG_VALUE_0 = 1, FLAG_VALUE_1 = 2 } CFlags;
  12. GType gi_cpp_flags_get_type(void);
  13. #define GI_CPP_TYPE_FLAGS (gi_cpp_flags_get_type())
  14. // object
  15. GType gi_cpp_example_get_type();
  16. #define GI_CPP_TYPE_EXAMPLE (gi_cpp_example_get_type())
  17. #define GI_CPP_EXAMPLE(obj) \
  18. (G_TYPE_CHECK_INSTANCE_CAST((obj), GI_CPP_TYPE_EXAMPLE, GICppExample))
  19. #define GI_CPP_EXAMPLE_CLASS(klass) \
  20. (G_TYPE_CHECK_CLASS_CAST((klass), GI_CPP_TYPE_EXAMPLE, GICppExampleClass))
  21. #define GI_IS_CPP_EXAMPLE(obj) \
  22. (G_TYPE_CHECK_INSTANCE_TYPE((obj), GI_CPP_TYPE_EXAMPLE))
  23. #define GI_IS_CPP_EXAMPLE_CLASS(klass) \
  24. (G_TYPE_CHECK_CLASS_TYPE((klass), GI_CPP_TYPE_EXAMPLE))
  25. typedef struct _GICppExample GICppExample;
  26. typedef struct _GICppExampleClass GICppExampleClass;
  27. struct _GICppExampleClass
  28. {
  29. GObjectClass parent_class;
  30. /* virtual method */
  31. int (*vmethod)(GICppExample *, int a, int b);
  32. int (*cmethod)(GICppExample *, int a, int b);
  33. };
  34. enum {
  35. PROP_0,
  36. PROP_DATA,
  37. PROP_NUMBER,
  38. PROP_FNUMBER,
  39. PROP_OBJECT,
  40. PROP_PRESENT,
  41. PROP_ENUM,
  42. PROP_FLAGS,
  43. PROP_ERROR,
  44. PROP_LAST = PROP_ERROR
  45. };
  46. #define NAME_NUMBER "number"
  47. #define NAME_FNUMBER "fnumber"
  48. #define NAME_DATA "data"
  49. #define NAME_PRESENT "present"
  50. #define NAME_OBJECT "object"
  51. #define NAME_ENUM "choice"
  52. #define NAME_FLAGS "flags"
  53. #define NAME_ERROR "error"
  54. #define NAME_INUMBER "itf-number"
  55. // interface
  56. GICppExample *gi_cpp_example_new();
  57. typedef struct _GICppExampleItf GICppExampleItf;
  58. typedef struct _GICppExampleInterface GICppExampleInterface;
  59. struct _GICppExampleInterface
  60. {
  61. GTypeInterface iface;
  62. /* virtual method */
  63. int (*vmethod)(GICppExampleItf *, int a);
  64. int (*imethod)(GICppExampleItf *, int a);
  65. };
  66. GType gi_cpp_example_interface_get_type();
  67. // property interface
  68. typedef struct _GICppPropertyItf GICppPropertyItf;
  69. typedef struct _GICppPropertyInterface GICppPropertyInterface;
  70. struct _GICppPropertyInterface
  71. {
  72. GTypeInterface iface;
  73. };
  74. GType gi_cpp_property_interface_get_type();
  75. G_END_DECLS
  76. #endif /* __GI_CPP_EXAMPLE_H__ */