[svn:parrot] r45576 - in branches/stringnull: include/parrot src/string
petdance at svn.parrot.org
petdance at svn.parrot.org
Mon Apr 12 03:02:04 UTC 2010
Author: petdance
Date: Mon Apr 12 03:02:04 2010
New Revision: 45576
URL: https://trac.parrot.org/parrot/changeset/45576
Log:
Make the STRING_IS_NULL stuff behave like PMC_IS_NULL
Modified:
branches/stringnull/include/parrot/interpreter.h
branches/stringnull/src/string/api.c
Modified: branches/stringnull/include/parrot/interpreter.h
==============================================================================
--- branches/stringnull/include/parrot/interpreter.h Sun Apr 11 22:36:08 2010 (r45575)
+++ branches/stringnull/include/parrot/interpreter.h Mon Apr 12 03:02:04 2010 (r45576)
@@ -340,21 +340,22 @@
#endif
#if PARROT_CATCH_NULL
-PARROT_DATA PMC *PMCNULL; /* Holds single Null PMC */
#else
-# define PMCNULL ((PMC *)NULL)
#endif /* PARROT_CATCH_NULL */
-/* Maybe PMC_IS_NULL(interp, pmc) ? */
#if PARROT_CATCH_NULL
-# define PMC_IS_NULL(pmc) ((pmc) == PMCNULL || (pmc) == NULL)
+PARROT_DATA PMC *PMCNULL; /* Holds single Null PMC */
+PARROT_DATA STRING *STRINGNULL; /* a single Null STRING */
+# define PMC_IS_NULL(pmc) ((pmc) == PMCNULL || (pmc) == NULL)
+# define STRING_IS_NULL(s) ((s) == STRINGNULL || (s) == NULL)
#else
-# define PMC_IS_NULL(pmc) (pmc) == NULL
+# define PMCNULL ((PMC *)NULL)
+# define PMCNULL ((PMC *)NULL)
+# define PMC_IS_NULL(pmc) ((pmc) == NULL)
+# define STRING_IS_NULL(string) ((string) == NULL)
#endif
-PARROT_DATA STRING *STRINGNULL; /* a single Null STRING */
-#define STRING_IS_NULL(s) ((s) == STRINGNULL || (s) == NULL)
#define STRING_IS_EMPTY(s) !(int)(s)->strlen
/* &gen_from_def(sysinfo.pasm) prefix(SYSINFO_) */
Modified: branches/stringnull/src/string/api.c
==============================================================================
--- branches/stringnull/src/string/api.c Sun Apr 11 22:36:08 2010 (r45575)
+++ branches/stringnull/src/string/api.c Mon Apr 12 03:02:04 2010 (r45576)
@@ -28,7 +28,9 @@
#include "api.str"
/* for parrot/interpreter.h */
+#if PARROT_CATCH_NULL
STRING *STRINGNULL;
+#endif
#define nonnull_encoding_name(s) (s) ? (s)->encoding->name : "null string"
#define saneify_string(s) \
@@ -88,7 +90,7 @@
Parrot_str_is_null(SHIM_INTERP, ARGIN_NULLOK(const STRING *s))
{
ASSERT_ARGS(Parrot_str_is_null)
- return !s || s == STRINGNULL;
+ return STRING_IS_NULL(s);
}
@@ -109,7 +111,7 @@
STRING_is_null(SHIM_INTERP, ARGIN_NULLOK(const STRING *s))
{
ASSERT_ARGS(STRING_is_null)
- return !s || s == STRINGNULL;
+ return STRING_IS_NULL(s);
}
@@ -319,10 +321,12 @@
interp->const_cstring_hash = const_cstring_hash;
Parrot_charsets_encodings_init(interp);
+#if PARROT_CATCH_NULL
/* initialize STRINGNULL, but not in the constant table */
STRINGNULL = Parrot_str_new_init(interp, NULL, 0,
PARROT_DEFAULT_ENCODING, PARROT_DEFAULT_CHARSET,
PObj_constant_FLAG);
+#endif
interp->const_cstring_table =
mem_gc_allocate_n_zeroed_typed(interp, n_parrot_cstrings, STRING *);
More information about the parrot-commits
mailing list