GObject.def 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. DEFINITION MODULE FOR "C" GObject ;
  2. (*
  3. m2-GTK4 - GObject: reference counting, properties and signals.
  4. Mapped onto <glib-object.h>.
  5. Signals
  6. -------
  7. C exposes the g_signal_connect() macro which expands to
  8. g_signal_connect_data(instance, name, handler, data, NULL, 0).
  9. Because macros have no symbol, this binding calls the real
  10. function g_signal_connect_data() directly; the pure-M2 helper
  11. GtkUtils.Connect wraps the common case.
  12. A signal handler is a normal C function pointer whose first
  13. argument is the emitting instance and whose second is the
  14. user data. Declare a top-level Modula-2 procedure with the
  15. right signature and pass it directly or via ADR(...):
  16. PROCEDURE OnClicked (button: ADDRESS; data: ADDRESS);
  17. ...
  18. Connect(button, "clicked", ADR(OnClicked), NIL);
  19. Because the arity and return type depend on the signal, the
  20. generic GCallback below is an ADDRESS, as in C.
  21. *)
  22. FROM SYSTEM IMPORT ADDRESS;
  23. EXPORT UNQUALIFIED
  24. GObject, GType, GCallback, GClosureNotify, GConnectFlags, GSignalHandlerID,
  25. GConnectDefault, GConnectAfter, GConnectSwapped,
  26. g_object_get_type, g_object_new, g_type_from_name,
  27. g_object_ref, g_object_unref,
  28. g_signal_connect_data, g_signal_handler_disconnect,
  29. g_signal_emit_by_name,
  30. g_object_set, g_object_get;
  31. TYPE
  32. GObject = ADDRESS;
  33. (* A GType is a gsize-wide run-time type identifier. *)
  34. GType = LONGCARD;
  35. (* generic function pointer - pass ADR(proc) *)
  36. GCallback = ADDRESS;
  37. GClosureNotify = ADDRESS;
  38. GConnectFlags = CARDINAL;
  39. GSignalHandlerID = LONGCARD;
  40. CONST
  41. GConnectDefault = 0;
  42. GConnectAfter = 1; (* call the handler after the default handler *)
  43. GConnectSwapped = 2; (* swap instance and user data *)
  44. (* GType g_object_get_type(void) *)
  45. PROCEDURE g_object_get_type () : GType;
  46. (* GType g_type_from_name(const gchar *name) *)
  47. PROCEDURE g_type_from_name (name: ARRAY OF CHAR) : GType;
  48. (* gpointer g_object_new(GType object_type, const gchar *first_property_name, ...) *)
  49. PROCEDURE g_object_new (object_type: GType;
  50. first_property_name: ARRAY OF CHAR; ...) : ADDRESS;
  51. (* gpointer g_object_ref(gpointer object) *)
  52. PROCEDURE g_object_ref (object: GObject) : GObject;
  53. (* void g_object_unref(gpointer object) *)
  54. PROCEDURE g_object_unref (object: GObject);
  55. (* gulong g_signal_connect_data(gpointer instance, const gchar *detailed_signal,
  56. GCallback c_handler, gpointer data, GClosureNotify destroy_data,
  57. GConnectFlags connect_flags) *)
  58. PROCEDURE g_signal_connect_data (instance: GObject;
  59. detailed_signal: ARRAY OF CHAR;
  60. c_handler: GCallback;
  61. data: ADDRESS;
  62. destroy_data: GClosureNotify;
  63. connect_flags: GConnectFlags) : [ GSignalHandlerID ];
  64. (* void g_signal_handler_disconnect(gpointer instance, gulong handler_id) *)
  65. PROCEDURE g_signal_handler_disconnect (instance: GObject;
  66. handler_id: GSignalHandlerID);
  67. (* void g_signal_emit_by_name(gpointer instance, const gchar *detailed_signal, ...) *)
  68. PROCEDURE g_signal_emit_by_name (instance: GObject;
  69. detailed_signal: ARRAY OF CHAR; ...);
  70. (* void g_object_set(gpointer object, const gchar *first_property_name, ...) *)
  71. PROCEDURE g_object_set (object: GObject;
  72. first_property_name: ARRAY OF CHAR; ...);
  73. (* void g_object_get(gpointer object, const gchar *first_property_name, ...) *)
  74. PROCEDURE g_object_get (object: GObject;
  75. first_property_name: ARRAY OF CHAR; ...);
  76. END GObject.