79
73
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
80
74
/* HEADERIZER END: static */
84
=item C<static PMC* get_next_hash(PARROT_INTERP, const Hash *hash, const void
87
Get the next hash for multipart keys. Autovivify a hash if it doesn't exist.
93
PARROT_CANNOT_RETURN_NULL
94
PARROT_WARN_UNUSED_RESULT
96
get_next_hash(PARROT_INTERP, ARGIN(const Hash *hash), ARGIN(const void *key))
98
ASSERT_ARGS(get_next_hash)
101
if (hash->entry_type != enum_type_PMC)
102
entry_type_must_be_pmc(interp);
104
bucket = Parrot_hash_get_bucket(interp, hash, key);
107
return (PMC *)bucket->value;
112
76
pmclass Hash provides hash auto_attrs {
81
=head2 Vtable functions
117
85
=item C<void init()>
119
87
Initializes the instance.
264
232
Parrot_hash_destroy(INTERP, old_hash);
267
METHOD set_key_type(INTVAL type) {
268
SELF.set_integer_native(type);
273
=item C<METHOD get_key_type()>
275
Return type of keys in Hash.
280
METHOD get_key_type() {
281
const INTVAL ret = ((Hash *)SELF.get_pointer())->key_type;
287
=item C<METHOD set_value_type(INTVAL type)>
289
Reset Hash to use different value-type for stored items. If there is no
290
previous _hash was set defaults to STRING* keys.
292
NB: this method will destroy all old data!
296
METHOD set_value_type(INTVAL type) {
297
Hash * const old_hash = (Hash *)SELF.get_pointer();
301
If someone called Hash.set_pointer with NULL pointer...
302
It will create STRING* keys hash.
305
if (old_hash && old_hash->entry_type == type)
309
case enum_type_INTVAL:
310
case enum_type_STRING:
312
new_hash = Parrot_hash_create(INTERP,
313
(PARROT_DATA_TYPE)type,
314
old_hash ? old_hash->key_type : Hash_key_type_STRING);
317
Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_UNIMPLEMENTED,
318
"Hash: unsupported entry_type %d", type);
321
PARROT_HASH(SELF)->hash = new_hash;
324
Parrot_hash_destroy(INTERP, old_hash);
327
METHOD get_value_type() {
328
const INTVAL ret = ((Hash *)SELF.get_pointer())->entry_type;
334
237
=item C<void *get_pointer()>
1204
1107
/* Thawed Hash was created from pmc_new_noinit */
1205
1108
PObj_custom_mark_destroy_SETALL(SELF);
1119
=item C<METHOD set_key_type(INTVAL)>
1121
Set the type of key in the hash.
1123
=item C<METHOD get_key_type()>
1125
Return type of keys in Hash.
1127
=item C<METHOD set_value_type(INTVAL type)>
1129
Reset Hash to use different value-type for stored items. If there is no
1130
previous _hash was set defaults to STRING* keys.
1132
NB: this method will destroy all old data!
1134
=item C<METHOD get_value_type()>
1136
Return type of values in Hash.
1142
METHOD set_key_type(INTVAL type) {
1143
SELF.set_integer_native(type);
1146
METHOD get_key_type() {
1147
const INTVAL ret = ((Hash *)SELF.get_pointer())->key_type;
1151
METHOD set_value_type(INTVAL type) {
1152
Hash * const old_hash = (Hash *)SELF.get_pointer();
1156
If someone called Hash.set_pointer with NULL pointer...
1157
It will create STRING* keys hash.
1160
if (old_hash && old_hash->entry_type == (PARROT_DATA_TYPE)type)
1164
case enum_type_INTVAL:
1165
case enum_type_STRING:
1167
new_hash = Parrot_hash_create(INTERP,
1168
(PARROT_DATA_TYPE)type,
1169
old_hash ? old_hash->key_type : Hash_key_type_STRING);
1172
Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_UNIMPLEMENTED,
1173
"Hash: unsupported entry_type %d", type);
1176
PARROT_HASH(SELF)->hash = new_hash;
1179
Parrot_hash_destroy(INTERP, old_hash);
1182
METHOD get_value_type() {
1183
const INTVAL ret = ((Hash *)SELF.get_pointer())->entry_type;
1197
=item C<static PMC* get_next_hash(PARROT_INTERP, const Hash *hash, const void
1200
Get the next hash for multipart keys. Autovivify a hash if it doesn't exist.
1206
PARROT_CANNOT_RETURN_NULL
1207
PARROT_WARN_UNUSED_RESULT
1209
get_next_hash(PARROT_INTERP, ARGIN(const Hash *hash), ARGIN(const void *key))
1211
ASSERT_ARGS(get_next_hash)
1214
if (hash->entry_type != enum_type_PMC)
1215
entry_type_must_be_pmc(interp);
1217
bucket = Parrot_hash_get_bucket(interp, hash, key);
1220
return (PMC *)bucket->value;
1217
1227
=item C<static void entry_type_must_be_pmc(PARROT_INTERP)>
1219
1229
=item C<static void cannot_autovivify_nested(PARROT_INTERP)>
1231
Throw the appropiate exception.
1223
1237
PARROT_DOES_NOT_RETURN