2 Copyright (C) 2001-2008, The Perl Foundation.
7 src/warnings.c - Warning and error reporting
11 Parrot C<STRING> and C string versions of a function to print warning/error
20 #include "parrot/parrot.h"
24 /* HEADERIZER HFILE: include/parrot/warnings.h */
26 /* HEADERIZER BEGIN: static */
27 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
29 static INTVAL
print_warning(PARROT_INTERP
, ARGIN_NULLOK(STRING
*msg
))
30 __attribute__nonnull__(1);
32 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
33 /* HEADERIZER END: static */
37 =item C<void print_pbc_location>
39 Prints the bytecode location of the warning or error to C<PIO_STDERR>.
47 print_pbc_location(PARROT_INTERP
)
49 Interp
* const tracer
= interp
->debugger
? interp
->debugger
: interp
;
50 PIO_eprintf(tracer
, "%Ss\n",
51 Parrot_Context_infostr(interp
,
57 =item C<static INTVAL print_warning>
59 Prints the warning message and the bytecode location.
66 print_warning(PARROT_INTERP
, ARGIN_NULLOK(STRING
*msg
))
69 PIO_puts(interp
, PIO_STDERR(interp
), "Unknown warning\n");
71 PIO_putps(interp
, PIO_STDERR(interp
), msg
);
72 if (string_ord(interp
, msg
, -1) != '\n')
73 PIO_eprintf(interp
, "%c", '\n');
75 print_pbc_location(interp
);
83 =head2 Parrot Warnings Interface
87 =item C<INTVAL Parrot_warn>
89 The Parrot C string warning/error reporter.
91 Returns 2 on error, 1 on success.
93 C<message, ..> can be a C<Parrot_vsprintf_c()> format with arguments.
101 Parrot_warn(PARROT_INTERP
, INTVAL warnclass
,
102 ARGIN(const char *message
), ...)
104 PARROT_ASSERT(interp
);
105 if (!PARROT_WARNINGS_test(interp
, warnclass
))
111 va_start(args
, message
);
112 targ
= Parrot_vsprintf_c(interp
, message
, args
);
114 return print_warning(interp
, targ
);
120 =item C<INTVAL Parrot_warn_s>
122 The Parrot C<STRING> warning/error reporter.
124 Returns 2 on error, 1 on success.
126 C<message, ..> can be a C<Parrot_vsprintf_s()> format with arguments.
134 Parrot_warn_s(NULLOK_INTERP
, INTVAL warnclass
,
135 ARGIN(STRING
*message
), ...)
137 if (!interp
|| !PARROT_WARNINGS_test(interp
, warnclass
))
143 va_start(args
, message
);
144 targ
= Parrot_vsprintf_s(interp
, message
, args
);
147 return print_warning(interp
, targ
);
157 F<include/parrot/warnings.h>.
166 * c-file-style: "parrot"
168 * vim: expandtab shiftwidth=4: