Author: allison
Date: Wed Nov 12 18:31:22 2008
New Revision: 32584
Modified:
branches/pdd22io/src/pmc/filehandle.pmc
Log:
[pdd22io] Strip the 'print' method of a FileHandle down to a single PMC
parameter. Vastly simpler code, and it actually works. (Before it was
autoboxing everything passed to it as an integer, not particularly useful.)
Modified: branches/pdd22io/src/pmc/filehandle.pmc
==============================================================================
--- branches/pdd22io/src/pmc/filehandle.pmc (original)
+++ branches/pdd22io/src/pmc/filehandle.pmc Wed Nov 12 18:31:22 2008
@@ -226,39 +226,14 @@
=item C<METHOD print([INTVAL|FLOATVAL|STRING *|PMC*] value)>
Print the passed in integer, number, string, or PMC to the filehandle.
+(Integers, numbers, and strings are auto-boxed as PMCs.)
=cut
*/
- METHOD print(INTVAL int_val :optional, INTVAL got_int :opt_flag,
- FLOATVAL num_val :optional, INTVAL got_num :opt_flag,
- STRING *str_val :optional, INTVAL got_str :opt_flag,
- PMC *pmc_val :optional, INTVAL got_pmc :opt_flag) {
- STRING *string_to_print;
-
- if (got_int && !(got_num || got_str || got_pmc)) {
- string_to_print = Parrot_sprintf_c(interp, INTVAL_FMT, int_val);
- }
- else if (got_num && !(got_str || got_pmc)) {
- string_to_print = Parrot_sprintf_c(interp, FLOATVAL_FMT, num_val);
- }
- else if (got_str && !(got_pmc)) {
- string_to_print = str_val;
- }
- else if (got_pmc) {
- string_to_print = VTABLE_get_string(INTERP, pmc_val);
- }
- else if ( !got_int && !got_num && !got_str && !got_pmc ) {
- Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_PIO_ERROR,
- "Not enough arguments passed to 'print', must pass either
an ",
- "integer, number, string, or PMC");
- }
- else {
- Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_PIO_ERROR,
- "Too many arguments passed to 'print', must pass either an
",
- "integer, number, string, or PMC");
- }
+ METHOD print(PMC *to_print) {
+ STRING *string_to_print = VTABLE_get_string(INTERP, to_print);
Parrot_io_putps(interp, SELF, string_to_print);
}