gmessages.inc 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. {*
  2. * gmessages.inc
  3. *
  4. * depends on gtypes.inc
  5. *}
  6. { calculate a string size, guarranteed to fit format + args.
  7. }
  8. {$IFNDEF KYLIX}
  9. function g_printf_string_upper_bound(format:Pgchar; args:array of const):gsize;cdecl;external gliblib name 'g_printf_string_upper_bound';
  10. {$ELSE}
  11. function g_printf_string_upper_bound(format:Pgchar):gsize;varargs;cdecl;external gliblib name 'g_printf_string_upper_bound';
  12. {$ENDIF}
  13. { Log level shift offset for user defined
  14. log levels (0-7 are used by GLib).
  15. }
  16. const
  17. G_LOG_LEVEL_USER_SHIFT = 8;
  18. { Glib log levels and flags. }
  19. type
  20. PGLogLevelFlags = ^TGLogLevelFlags;
  21. TGLogLevelFlags = longint;
  22. const
  23. G_LOG_FLAG_RECURSION = 1 shl 0;
  24. G_LOG_FLAG_FATAL = 1 shl 1;
  25. G_LOG_LEVEL_ERROR = 1 shl 2;
  26. G_LOG_LEVEL_CRITICAL = 1 shl 3;
  27. G_LOG_LEVEL_WARNING = 1 shl 4;
  28. G_LOG_LEVEL_MESSAGE = 1 shl 5;
  29. G_LOG_LEVEL_INFO = 1 shl 6;
  30. G_LOG_LEVEL_DEBUG = 1 shl 7;
  31. G_LOG_LEVEL_MASK = not 3;
  32. // G_LOG_LEVEL_MASK = not (G_LOG_FLAG_RECURSION or G_LOG_FLAG_FATAL);
  33. { GLib log levels that are considered fatal by default }
  34. const
  35. G_LOG_FATAL_MASK = 5;
  36. type
  37. TGLogFunc = procedure (log_domain:Pgchar; log_level:TGLogLevelFlags; TheMessage:Pgchar; user_data:gpointer);cdecl;
  38. { Logging mechanism }
  39. function g_log_set_handler(log_domain:Pgchar; log_levels:TGLogLevelFlags; log_func:TGLogFunc; user_data:gpointer):guint;cdecl;external gliblib name 'g_log_set_handler';
  40. procedure g_log_remove_handler(log_domain:Pgchar; handler_id:guint);cdecl;external gliblib name 'g_log_remove_handler';
  41. procedure g_log_default_handler(log_domain:Pgchar; log_level:TGLogLevelFlags; TheMessage:Pgchar; unused_data:gpointer);cdecl;external gliblib name 'g_log_default_handler';
  42. {$IFNDEF KYLIX}
  43. procedure g_log(log_domain:Pgchar; log_level:TGLogLevelFlags; format:Pgchar; args:array of const);cdecl;overload;external gliblib name 'g_log';
  44. procedure g_log(log_domain:Pgchar; log_level:TGLogLevelFlags; format:Pgchar);cdecl;overload;external gliblib name 'g_log';
  45. procedure g_logv(log_domain:Pgchar; log_level:TGLogLevelFlags; format:Pgchar; args:array of const);cdecl;overload;external gliblib name 'g_logv';
  46. procedure g_logv(log_domain:Pgchar; log_level:TGLogLevelFlags; format:Pgchar);cdecl;overload;external gliblib name 'g_logv';
  47. {$ELSE}
  48. procedure g_log(log_domain:Pgchar; log_level:TGLogLevelFlags; format:Pgchar);varargs;cdecl;external gliblib name 'g_log';
  49. procedure g_logv(log_domain:Pgchar; log_level:TGLogLevelFlags; format:Pgchar);varargs;cdecl;external gliblib name 'g_logv';
  50. {$ENDIF}
  51. function g_log_set_fatal_mask(log_domain:Pgchar; fatal_mask:TGLogLevelFlags):TGLogLevelFlags;cdecl;external gliblib name 'g_log_set_fatal_mask';
  52. function g_log_set_always_fatal(fatal_mask:TGLogLevelFlags):TGLogLevelFlags;cdecl;external gliblib name 'g_log_set_always_fatal';
  53. { internal }
  54. procedure _g_log_fallback_handler(log_domain:Pgchar; log_level:TGLogLevelFlags; message:Pgchar; unused_data:gpointer);cdecl;external gliblib name '_g_log_fallback_handler';
  55. const
  56. G_LOG_DOMAIN = nil;
  57. // or try this:
  58. //
  59. // function G_LOG_DOMAIN : pgchar;
  60. // begin
  61. // G_LOG_DOMAIN := PGChar(0);
  62. // end;
  63. procedure g_error (format:Pgchar; args: array of const); overload;
  64. procedure g_error (format:Pgchar); overload;
  65. procedure g_message (format:Pgchar; args: array of const); overload;
  66. procedure g_message (format:Pgchar); overload;
  67. procedure g_critical (format:Pgchar; args: array of const); overload;
  68. procedure g_critical (format:Pgchar); overload;
  69. procedure g_warning (format:Pgchar; args: array of const); overload;
  70. procedure g_warning (format:Pgchar); overload;
  71. type
  72. TGPrintFunc = procedure (_string: pgchar);
  73. {$IFNDEF KYLIX}
  74. procedure g_print(format:Pgchar; args:array of const);cdecl;overload;external gliblib name 'g_print';
  75. procedure g_print(format:Pgchar);cdecl;overload;external gliblib name 'g_print';
  76. {$ELSE}
  77. procedure g_print(format:Pgchar);varargs;cdecl;external gliblib name 'g_print';
  78. {$ENDIF}
  79. function g_set_print_handler(func:TGPrintFunc):TGPrintFunc;cdecl;external gliblib name 'g_set_print_handler';
  80. {$IFNDEF KYLIX}
  81. procedure g_printerr(format:Pgchar; args:array of const);cdecl;overload;external gliblib name 'g_printerr';
  82. procedure g_printerr(format:Pgchar);cdecl;overload;external gliblib name 'g_printerr';
  83. {$ELSE}
  84. procedure g_printerr(format:Pgchar);varargs;cdecl;external gliblib name 'g_printerr';
  85. {$ENDIF}
  86. function g_set_printerr_handler(func:TGPrintFunc):TGPrintFunc;cdecl;external gliblib name 'g_set_printerr_handler';
  87. { Provide macros for error handling. The "assert" macros will
  88. exit on failure. The "return" macros will exit the current
  89. function. Two different definitions are given for the macros
  90. if G_DISABLE_ASSERT is not defined, in order to support gcc's
  91. __PRETTY_FUNCTION__ capability.
  92. }
  93. { ????????? }
  94. // #define g_assert(expr) G_STMT_START{ }G_STMT_END
  95. // #define g_assert_not_reached() G_STMT_START{ }G_STMT_END
  96. // #define g_return_if_fail(expr) G_STMT_START{ }G_STMT_END
  97. // #define g_return_val_if_fail(expr,val) G_STMT_START{ }G_STMT_END
  98. // #define g_return_if_reached() G_STMT_START{ return; }G_STMT_END
  99. // #define g_return_val_if_reached(val) G_STMT_START{ return (val); }G_STMT_END