fix codetest failure - ASSERT_ARGS does not have a ; after and
[parrot.git] / src / pmc / hashiteratorkey.pmc
blob62e78bce268ec6cb3367c6088256444446faf806
1 /*
2 Copyright (C) 2001-2009, Parrot Foundation.
3 $Id$
5 =head1 NAME
7 src/pmc/hashiteratorkey.pmc - accessor for single value during hash iteration.
9 =head1 DESCRIPTION
11 Single (key,value) pair.
14 =head1 Methods
16 =over 4
18 =cut
22 /* HEADERIZER HFILE: none */
23 /* HEADERIZER BEGIN: static */
24 /* HEADERIZER END: static */
26 pmclass HashIteratorKey no_ro auto_attrs {
27     ATTR Hash        *parrot_hash; /* Underlying parrot's hash */
28     ATTR HashBucket  *bucket;      /* Current bucket from HashItertor */
32 =item C<get_pmc()>
34 Get "key".
36 =cut
39     VTABLE PMC* get_pmc() {
40         Parrot_HashIteratorKey_attributes *attrs =
41                 PARROT_HASHITERATORKEY(SELF);
43         /* TT #1080 & TT #1081 Wallpapering problem with NULL attributes */
44         if (!attrs->parrot_hash || !attrs->bucket)
45             return PMCNULL;
47         return hash_key_to_pmc(INTERP, attrs->parrot_hash, attrs->bucket->key);
48     }
50     METHOD key() {
51         PMC *ret = SELF.get_pmc();
52         RETURN(PMC* ret);
53     }
55     METHOD value() {
56         Parrot_HashIteratorKey_attributes *attrs =
57                 PARROT_HASHITERATORKEY(SELF);
58         PMC *ret = hash_value_to_pmc(INTERP, attrs->parrot_hash, attrs->bucket->value);
59         RETURN(PMC* ret);
60     }
63     VTABLE INTVAL get_integer() {
64         return -1;
65     }
67     VTABLE STRING* get_string() {
68         Parrot_HashIteratorKey_attributes *attrs =
69                 PARROT_HASHITERATORKEY(SELF);
71         /* TT #1080 & TT #1081 Wallpapering problem with NULL attributes */
72         if (!attrs->parrot_hash || !attrs->bucket)
73             return CONST_STRING(INTERP, "");
75         return hash_key_to_string(INTERP, attrs->parrot_hash, attrs->bucket->key);
76     }
80 =item C<set_pointer_keyed_int()>
82 Set pointers to Hash and HashBucket. Not really part of public API.
84 =cut
87     VTABLE void set_pointer_keyed_int(INTVAL key, void *value) {
88         Parrot_HashIteratorKey_attributes *attrs =
89                 PARROT_HASHITERATORKEY(SELF);
91         PARROT_ASSERT_MSG(value, "Can't set NULL pointer into HashIteratorKey");
93         if (key == 0) {
94             attrs->parrot_hash = (Hash*)value;
95         }
96         else if (key == 1) {
97             attrs->bucket = (HashBucket*)value;
98         }
99     }
105 =back
107 =cut
112  * Local variables:
113  *   c-file-style: "parrot"
114  * End:
115  * vim: expandtab shiftwidth=4:
116  */