Skip to content

Commit

Permalink
fix some conflicts in merge.
Browse files Browse the repository at this point in the history
  • Loading branch information
Whiteknight committed Dec 18, 2010
2 parents 65a3d51 + 5b52066 commit c2fd198
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 4 deletions.
21 changes: 21 additions & 0 deletions include/parrot/api.h
Expand Up @@ -444,6 +444,15 @@ Parrot_Int Parrot_api_pmc_get_keyed_int(
__attribute__nonnull__(4)
FUNC_MODIFIES(* value);

PARROT_API
Parrot_Int Parrot_api_pmc_get_keyed_string(
Parrot_PMC interp_pmc,
Parrot_PMC pmc,
Parrot_String key,
ARGOUT(Parrot_PMC * value))
__attribute__nonnull__(4)
FUNC_MODIFIES(* value);

PARROT_API
Parrot_Int Parrot_api_pmc_get_string(
Parrot_PMC interp_pmc,
Expand Down Expand Up @@ -484,6 +493,13 @@ Parrot_Int Parrot_api_pmc_set_keyed_int(
Parrot_Int key,
Parrot_PMC value);

PARROT_API
Parrot_Int Parrot_api_pmc_set_keyed_string(
Parrot_PMC interp_pmc,
Parrot_PMC pmc,
Parrot_String key,
Parrot_PMC value);

PARROT_API
Parrot_Int Parrot_api_pmc_set_string(
Parrot_PMC interp_pmc,
Expand Down Expand Up @@ -516,6 +532,9 @@ Parrot_Int Parrot_api_pmc_wrap_string_array(
PARROT_ASSERT_ARG(value))
#define ASSERT_ARGS_Parrot_api_pmc_get_keyed_int __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(value))
#define ASSERT_ARGS_Parrot_api_pmc_get_keyed_string \
__attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(value))
#define ASSERT_ARGS_Parrot_api_pmc_get_string __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(str))
#define ASSERT_ARGS_Parrot_api_pmc_invoke __attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
Expand All @@ -524,6 +543,8 @@ Parrot_Int Parrot_api_pmc_wrap_string_array(
#define ASSERT_ARGS_Parrot_api_pmc_set_float __attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
#define ASSERT_ARGS_Parrot_api_pmc_set_integer __attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
#define ASSERT_ARGS_Parrot_api_pmc_set_keyed_int __attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
#define ASSERT_ARGS_Parrot_api_pmc_set_keyed_string \
__attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
#define ASSERT_ARGS_Parrot_api_pmc_set_string __attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
#define ASSERT_ARGS_Parrot_api_pmc_wrap_string_array \
__attribute__unused__ int _ASSERT_ARGS_CHECK = (\
Expand Down
18 changes: 18 additions & 0 deletions src/embed/pmc.c
Expand Up @@ -76,6 +76,15 @@ Parrot_api_pmc_get_keyed_int(Parrot_PMC interp_pmc, Parrot_PMC pmc,
EMBED_API_CALLOUT(interp_pmc, interp)
}

PARROT_API
Parrot_Int
Parrot_api_pmc_get_keyed_string(Parrot_PMC interp_pmc, Parrot_PMC pmc, Parrot_String key, ARGOUT(Parrot_PMC * value))
{
EMBED_API_CALLIN(interp_pmc, interp)
*value = VTABLE_get_pmc_keyed_str(interp, pmc, key);
EMBED_API_CALLOUT(interp_pmc, interp)
}

PARROT_API
Parrot_Int
Parrot_api_pmc_set_string(Parrot_PMC interp_pmc, Parrot_PMC pmc,
Expand Down Expand Up @@ -116,6 +125,15 @@ Parrot_api_pmc_set_keyed_int(Parrot_PMC interp_pmc, Parrot_PMC pmc,
EMBED_API_CALLOUT(interp_pmc, interp)
}

PARROT_API
Parrot_Int
Parrot_api_pmc_set_keyed_string(Parrot_PMC interp_pmc, Parrot_PMC pmc, Parrot_String key, Parrot_PMC value)
{
EMBED_API_CALLIN(interp_pmc, interp)
VTABLE_set_pmc_keyed_str(interp, pmc, key, value);
EMBED_API_CALLOUT(interp_pmc, interp)
}

PARROT_API
Parrot_Int
Parrot_api_pmc_box_string(Parrot_PMC interp_pmc, Parrot_String str,
Expand Down
55 changes: 51 additions & 4 deletions t/src/embed/pmc.t
Expand Up @@ -12,7 +12,7 @@ use Parrot::Config;

=head1 NAME
t/src/embed/pmc.t - Parrot API PMC operations
t/src/embed/pmc.t - Parrot API PMC tests
=head1 SYNPOSIS
Expand All @@ -24,7 +24,7 @@ Tests PMC API support.
=cut

plan tests => 1;
plan tests => 2;

c_output_is( <<'CODE', <<'OUTPUT', "get/set_keyed_int" );
Expand Down Expand Up @@ -58,15 +58,62 @@ int main(int argc, char* argv[])
Parrot_api_pmc_get_string(interpmc, p_str, &s_outstr);
Parrot_api_string_export_ascii(interpmc, s_outstr, &c_outstr);
printf("%s\n", c_outstr);
return 0;
return 0;
}
CODE
I
i am a string.
OUTPUT


c_output_is( <<'CODE', <<'OUTPUT', "Tests get_keyed_string and set_keyed_string" );
#include <parrot/parrot.h>
#include <parrot/embed.h>
#include <parrot/api.h>
#include <stdio.h>
#define TEST_STR "The quick brown fox jumps over the lazy dog"
int main(int argc, char* argv[])
{
Parrot_Interp interp = Parrot_new(NULL);
Parrot_PMC interp_pmc = Parrot_pmc_new(interp, enum_class_ParrotInterpreter);
Parrot_PMC hash_pmc = Parrot_pmc_new(interp, enum_class_Hash);
Parrot_PMC str_pmc = Parrot_pmc_new(interp, enum_class_String);
Parrot_String test_str = Parrot_str_new(interp, TEST_STR, 0);
Parrot_api_pmc_set_string(interp_pmc, str_pmc, test_str);
Parrot_String idx_str = Parrot_str_new(interp, "name", 0);
Parrot_api_pmc_set_keyed_string(interp_pmc, hash_pmc, idx_str, str_pmc);
Parrot_PMC str_pmc_out = NULL;
Parrot_String str_out = NULL;
Parrot_api_pmc_get_keyed_string(interp_pmc, hash_pmc, idx_str, &str_pmc_out);
Parrot_api_pmc_get_string(interp_pmc, str_pmc_out, &str_out);
if (strcmp(Parrot_str_to_cstring(interp, str_out), TEST_STR) != 0) {
printf("Failed accessing a keyed Hash PMC\n");
return EXIT_FAILURE;
}
printf("ok 1\n");
Parrot_pmc_destroy(interp, interp_pmc);
Parrot_pmc_destroy(interp, hash_pmc);
Parrot_pmc_destroy(interp, str_pmc);
return 0;
}
CODE
ok 1
OUTPUT

# Local Variables:
# mode: cperl
# cperl-indent-level: 4
Expand Down

0 comments on commit c2fd198

Please sign in to comment.