Skip to content

Commit

Permalink
provide more descriptive error messages for missing NCI thunks
Browse files Browse the repository at this point in the history
  • Loading branch information
plobsing committed Apr 26, 2011
1 parent 8cc38ff commit 346910c
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
5 changes: 5 additions & 0 deletions include/parrot/nci.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ PMC * Parrot_nci_parse_signature(PARROT_INTERP, ARGIN(STRING *sig_str))
__attribute__nonnull__(1)
__attribute__nonnull__(2);

STRING * Parrot_nci_describe_sig(PARROT_INTERP, PMC *sig)
__attribute__nonnull__(1);

void Parrot_nci_sig_to_pcc(PARROT_INTERP,
ARGIN(PMC *sig_pmc),
ARGOUT(STRING **params_sig),
Expand All @@ -68,6 +71,8 @@ void Parrot_nci_sig_to_pcc(PARROT_INTERP,
#define ASSERT_ARGS_Parrot_nci_parse_signature __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
, PARROT_ASSERT_ARG(sig_str))
#define ASSERT_ARGS_Parrot_nci_describe_sig __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp))
#define ASSERT_ARGS_Parrot_nci_sig_to_pcc __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
, PARROT_ASSERT_ARG(sig_pmc) \
Expand Down
2 changes: 1 addition & 1 deletion src/nci/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ build_call_func(PARROT_INTERP, ARGIN(PMC *sig))

Parrot_ex_throw_from_c_args(interp, NULL,
EXCEPTION_UNIMPLEMENTED,
"No NCI thunk available for signature '%Ss'", VTABLE_get_repr(interp, sig));
"No NCI thunk available for signature `%Ss'", Parrot_nci_describe_sig(interp, sig));
}

/*
Expand Down
35 changes: 35 additions & 0 deletions src/nci/signatures.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,41 @@ Parrot_nci_sig_to_pcc(PARROT_INTERP, ARGIN(PMC *sig_pmc), ARGOUT(STRING **params

/*
=item C<STRING * Parrot_nci_describe_sig(PARROT_INTERP, PMC *sig)>
Provide a descriptive string for a signature.
=cut
*/

STRING *
Parrot_nci_describe_sig(PARROT_INTERP, PMC *sig)
{
ASSERT_ARGS(Parrot_nci_describe_sig)

STRING *s;
size_t n = VTABLE_elements(interp, sig);
size_t i;

/* return value */
s = Parrot_dt_get_datatype_name(interp, VTABLE_get_integer_keyed_int(interp, sig, 0));

/* arguments */
s = Parrot_str_concat(interp, s, CONST_STRING(interp, " ("));
for (i = 1; i < n; i++) {
s = Parrot_str_concat(interp, s, Parrot_dt_get_datatype_name(interp,
VTABLE_get_integer_keyed_int(interp, sig, i)));
if (i < n - 1)
s = Parrot_str_concat(interp, s, CONST_STRING(interp, ", "));
}
s = Parrot_str_concat(interp, s, CONST_STRING(interp, ")"));

return s;
}

/*
=back
=cut
Expand Down

0 comments on commit 346910c

Please sign in to comment.