NAME
src/spf_vtable.c - Parrot sprintf
DESCRIPTION
Implements the two families of functions Parrot_sprintf
may use to retrieve arguments.
Var args Functions
static STRING *getchr_va
Gets a static HUGEINTVAL getint_va
Gets an integer out of the static UHUGEINTVAL getuint_va
Gets an unsigned integer out of the static HUGEFLOATVAL getfloat_va
Gets an floating-point number out of the static STRING *getstring_va
Gets an string out of the static void *getptr_va
Gets a
char
out of the va_list
in obj
and returns it as a Parrot STRING
.size
is unused.
va_list
in obj
and returns it as a Parrot STRING
.size
is an enum spf_type_t
value which indicates the storage type of the integer.
va_list
in obj
and returns it as a Parrot STRING
.size
is an enum spf_type_t
value which indicates the storage type of the integer.
va_list
in obj
and returns it as a Parrot STRING
.size
is an enum spf_type_t
value which indicates the storage type of the number.
va_list
in obj
and returns it as a Parrot STRING
.size
is an enum spf_type_t
value which indicates the storage type of the string.
void *
out of the va_list
in obj
and returns it.size
is unused.PMC Functions
static STRING *getchr_pmc
Same as static HUGEINTVAL getint_pmc
Same as static UHUGEINTVAL getuint_pmc
Same as static HUGEFLOATVAL getfloat_pmc
Same as static STRING *getstring_pmc
Same as static void *getptr_pmc
Same as
getchr_va()
except that a vtable is used to get the value from obj
.
getint_va()
except that a vtable is used to get the value from obj
.
getuint_va()
except that a vtable is used to get the value from obj
.
getfloat_va()
except that a vtable is used to get the value from obj
.
getstring_va()
except that a vtable is used to get the value from obj
.
getptr_va()
except that a vtable is used to get the value from obj
.SEE ALSO
src/misc.h, src/misc.c, src/spf_render.c.
HISTORY
When I was first working on this implementation of sprintf,
I ran into a problem.
I wanted to re-use the implementation for a Parrot bytecode-level sprintf,
but that couldn't be done,
since it used va_*
directly.
For a while I thought about generating two versions of the source with a Perl script,
but that seemed like overkill.
Eventually I came across this idea -- pass in a specialized vtable with methods for extracting things from the arglist,
whatever it happened to be.
This is the result.
TODO
In the future,
it may be deemed desirable to similarly vtable-ize appending things to the string,
allowing for faster Parrot_io_printf()
&c,
as well as a version that writes directly to a C string.
However,
at this point neither of those is needed.