gmessages.inc 4.3 KB

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