[svn:parrot] r41532 - in trunk: include/parrot src
NotFound at svn.parrot.org
NotFound at svn.parrot.org
Sun Sep 27 16:56:19 UTC 2009
Author: NotFound
Date: Sun Sep 27 16:56:18 2009
New Revision: 41532
URL: https://trac.parrot.org/parrot/changeset/41532
Log:
[hash] add NULLOK decoration to value parameter in hash_value_from_pmc and hash_value_from_string
Modified:
trunk/include/parrot/hash.h
trunk/src/hash.c
Modified: trunk/include/parrot/hash.h
==============================================================================
--- trunk/include/parrot/hash.h Sun Sep 27 16:37:26 2009 (r41531)
+++ trunk/include/parrot/hash.h Sun Sep 27 16:56:18 2009 (r41532)
@@ -273,18 +273,16 @@
PARROT_CAN_RETURN_NULL
void* hash_value_from_pmc(PARROT_INTERP,
ARGIN(const Hash * const hash),
- ARGIN(PMC *value))
+ ARGIN_NULLOK(PMC *value))
__attribute__nonnull__(1)
- __attribute__nonnull__(2)
- __attribute__nonnull__(3);
+ __attribute__nonnull__(2);
PARROT_CAN_RETURN_NULL
void* hash_value_from_string(PARROT_INTERP,
ARGIN(const Hash * const hash),
- ARGIN(STRING *value))
+ ARGIN_NULLOK(STRING *value))
__attribute__nonnull__(1)
- __attribute__nonnull__(2)
- __attribute__nonnull__(3);
+ __attribute__nonnull__(2);
INTVAL hash_value_to_int(PARROT_INTERP,
ARGIN(const Hash * const hash),
@@ -464,12 +462,10 @@
&& PARROT_ASSERT_ARG(hash)
#define ASSERT_ARGS_hash_value_from_pmc __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
- && PARROT_ASSERT_ARG(hash) \
- && PARROT_ASSERT_ARG(value)
+ && PARROT_ASSERT_ARG(hash)
#define ASSERT_ARGS_hash_value_from_string __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
- && PARROT_ASSERT_ARG(hash) \
- && PARROT_ASSERT_ARG(value)
+ && PARROT_ASSERT_ARG(hash)
#define ASSERT_ARGS_hash_value_to_int __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
&& PARROT_ASSERT_ARG(hash)
Modified: trunk/src/hash.c
==============================================================================
--- trunk/src/hash.c Sun Sep 27 16:37:26 2009 (r41531)
+++ trunk/src/hash.c Sun Sep 27 16:56:18 2009 (r41532)
@@ -1816,23 +1816,26 @@
PARROT_CAN_RETURN_NULL
void*
-hash_value_from_string(PARROT_INTERP, ARGIN(const Hash * const hash), ARGIN(STRING *value))
+hash_value_from_string(PARROT_INTERP, ARGIN(const Hash * const hash),
+ ARGIN_NULLOK(STRING *value))
{
ASSERT_ARGS(hash_value_from_string)
void *ret;
switch (hash->entry_type) {
case enum_type_INTVAL:
- {
- const INTVAL int_val = Parrot_str_to_int(interp, value);
- ret = INTVAL2PTR(void *, int_val);
+ {
+ const INTVAL int_val = STRING_IS_NULL(value) ?
+ (INTVAL) 0 : Parrot_str_to_int(interp, value);
+ ret = INTVAL2PTR(void *, int_val);
+ }
break;
- }
case enum_type_STRING:
ret = (void *)value;
break;
case enum_type_PMC:
{
- PMC * const s = get_string_pmc(interp, value);
+ PMC * const s = STRING_IS_NULL(value) ?
+ PMCNULL : get_string_pmc(interp, value);
ret = (void *)s;
}
break;
@@ -1856,19 +1859,22 @@
PARROT_CAN_RETURN_NULL
void*
-hash_value_from_pmc(PARROT_INTERP, ARGIN(const Hash * const hash), ARGIN(PMC *value))
+hash_value_from_pmc(PARROT_INTERP, ARGIN(const Hash * const hash),
+ ARGIN_NULLOK(PMC *value))
{
ASSERT_ARGS(hash_value_from_pmc)
void *ret;
switch (hash->entry_type) {
case enum_type_INTVAL:
- {
- const INTVAL int_val = VTABLE_get_integer(interp, value);
- ret = INTVAL2PTR(void *, int_val);
+ {
+ const INTVAL int_val = PMC_IS_NULL(value) ?
+ (INTVAL) 0 : VTABLE_get_integer(interp, value);
+ ret = INTVAL2PTR(void *, int_val);
+ }
break;
- }
case enum_type_STRING:
- ret = (void *)VTABLE_get_string(interp, value);
+ ret = PMC_IS_NULL(value) ?
+ PMCNULL : (void *)VTABLE_get_string(interp, value);
break;
case enum_type_PMC:
ret = (void *)value;
More information about the parrot-commits
mailing list