Permalink
Browse files

[src] Fixed all CONST_STRING macros so that they don't break across l…

…ines.

This should make it easier for picky compilers to get the #line numbers right.

git-svn-id: https://svn.parrot.org/parrot/trunk@34094 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
  • Loading branch information...
1 parent b12b4af commit 0006ce782f20689ef04b86c29219045bc402cffb @chromatic chromatic committed Dec 19, 2008
View
@@ -470,14 +470,18 @@ PARROT_CANNOT_RETURN_NULL
PMC *
Parrot_clone_lib_into(ARGMOD(Interp *d), ARGMOD(Interp *s), ARGIN(PMC *lib_pmc))
{
+ STRING * const filename = CONST_STRING(s, "_filename");
+ STRING * const libname = CONST_STRING(s, "_lib_name");
+ STRING * const type_str = CONST_STRING(s, "_type");
+ STRING * const ops = CONST_STRING(s, "Ops");
+
STRING * const wo_ext = clone_string_into(d, s,
- VTABLE_getprop(s, lib_pmc, CONST_STRING(s, "_filename")));
+ VTABLE_getprop(s, lib_pmc, filename));
STRING * const lib_name = clone_string_into(d, s,
- VTABLE_getprop(s, lib_pmc, CONST_STRING(s, "_lib_name")));
+ VTABLE_getprop(s, lib_pmc, libname));
void * const handle = PMC_data(lib_pmc);
STRING * const type =
- VTABLE_get_string(s, VTABLE_getprop(s, lib_pmc, CONST_STRING(s, "_type")));
- STRING * const ops = CONST_STRING(s, "Ops");
+ VTABLE_get_string(s, VTABLE_getprop(s, lib_pmc, type_str));
if (!string_equal(s, type, ops)) {
/* we can't clone oplibs in the normal way, since they're actually
View
@@ -1357,9 +1357,10 @@ event_to_exception(PARROT_INTERP, ARGIN(const parrot_event* event))
* installed: set severity to EXCEPT_exit
*/
{
- PMC *exception = Parrot_ex_build_exception(interp,
- EXCEPT_exit, exit_code,
- CONST_STRING(interp, "Caught signal."));
+ STRING * const message = CONST_STRING(interp, "Caught signal.");
+ PMC *exception = Parrot_ex_build_exception(interp,
+ EXCEPT_exit, exit_code, message);
+
Parrot_ex_throw_from_c(interp, exception);
}
break;
View
@@ -396,8 +396,7 @@ PMC *
Parrot_ns_get_name(PARROT_INTERP, ARGIN(PMC *_namespace))
{
PMC *names;
- Parrot_PCCINVOKE(interp, _namespace,
- CONST_STRING(interp, "get_name"), "->P", &names);
+ Parrot_PCCINVOKE(interp, _namespace, CONST_STRING(interp, "get_name"), "->P", &names);
return names;
}
View
@@ -1427,17 +1427,19 @@ void
Parrot_mmd_add_multi_from_long_sig(PARROT_INTERP,
ARGIN(STRING *sub_name), ARGIN(STRING *long_sig), ARGIN(PMC *sub_obj))
{
- PMC *type_list = string_split(interp, CONST_STRING(interp, ","), long_sig);
- STRING *ns_name = VTABLE_get_string_keyed_int(interp, type_list, 0);
+ PMC *type_list = string_split(interp, CONST_STRING(interp, ","), long_sig);
+ STRING *ns_name = VTABLE_get_string_keyed_int(interp, type_list, 0);
+ STRING *sub_str = CONST_STRING(interp, "Sub");
+ STRING *closure_str = CONST_STRING(interp, "Closure");
/* Attach a type tuple array to the sub for multi dispatch */
PMC *multi_sig = mmd_build_type_tuple_from_type_list(interp, type_list);
if (sub_obj->vtable->base_type == enum_class_NCI) {
PMC_pmc_val(sub_obj) = multi_sig;
}
- else if (VTABLE_isa(interp, sub_obj, CONST_STRING(interp, "Sub"))
- || VTABLE_isa(interp, sub_obj, CONST_STRING(interp, "Closure"))) {
+ else if (VTABLE_isa(interp, sub_obj, sub_str)
+ || VTABLE_isa(interp, sub_obj, closure_str)) {
PMC_sub(sub_obj)->multi_signature = multi_sig;
}
View
@@ -88,8 +88,7 @@ Parrot_oo_extract_methods_from_namespace(PARROT_INTERP, ARGIN(PMC *self), ARGIN(
return;
/* Import any methods. */
- Parrot_PCCINVOKE(interp, ns,
- CONST_STRING(interp, "get_associated_methods"), "->P", &methods);
+ Parrot_PCCINVOKE(interp, ns, CONST_STRING(interp, "get_associated_methods"), "->P", &methods);
if (!PMC_IS_NULL(methods)) {
PMC * const iter = VTABLE_get_iter(interp, methods);
@@ -103,8 +102,7 @@ Parrot_oo_extract_methods_from_namespace(PARROT_INTERP, ARGIN(PMC *self), ARGIN(
}
/* Import any vtable methods. */
- Parrot_PCCINVOKE(interp, ns,
- CONST_STRING(interp, "get_associated_vtable_methods"), "->P", &vtable_overrides);
+ Parrot_PCCINVOKE(interp, ns, CONST_STRING(interp, "get_associated_vtable_methods"), "->P", &vtable_overrides);
if (!PMC_IS_NULL(vtable_overrides)) {
PMC * const iter = VTABLE_get_iter(interp, vtable_overrides);
@@ -119,8 +117,7 @@ Parrot_oo_extract_methods_from_namespace(PARROT_INTERP, ARGIN(PMC *self), ARGIN(
STRING *vtable_name = string_from_cstring(interp, meth_c, 0);
/* Strip leading underscores in the vtable name */
- if (string_str_index(interp, vtable_name,
- CONST_STRING(interp, "__"), 0) == 0) {
+ if (string_str_index(interp, vtable_name, CONST_STRING(interp, "__"), 0) == 0) {
vtable_name = string_substr(interp, vtable_name, 2,
string_length(interp, vtable_name) - 2, NULL, 0);
}
@@ -820,8 +817,7 @@ Parrot_find_method_direct(PARROT_INTERP, ARGIN(PMC *_class), ARGIN(STRING *metho
if (!string_equal(interp, method_name, CONST_STRING(interp, "__get_string")))
- return find_method_direct_1(interp, _class,
- CONST_STRING(interp, "__get_repr"));
+ return find_method_direct_1(interp, _class, CONST_STRING(interp, "__get_repr"));
return PMCNULL;
}
@@ -1208,8 +1204,7 @@ Parrot_ComposeRole(PARROT_INTERP, ARGIN(PMC *role),
return;
/* Get the methods from the role. */
- Parrot_PCCINVOKE(interp, role,
- CONST_STRING(interp, "methods"), "->P", &methods);
+ Parrot_PCCINVOKE(interp, role, CONST_STRING(interp, "methods"), "->P", &methods);
if (PMC_IS_NULL(methods))
return;
@@ -1325,8 +1320,7 @@ Parrot_ComposeRole(PARROT_INTERP, ARGIN(PMC *role),
* that it did itself. Note that we already have the correct methods
* as roles "flatten" the methods they get from other roles into their
* own method list. */
- Parrot_PCCINVOKE(interp, role,
- CONST_STRING(interp, "roles"), "->P", &roles_of_role);
+ Parrot_PCCINVOKE(interp, role, CONST_STRING(interp, "roles"), "->P", &roles_of_role);
roles_of_role_count = VTABLE_elements(interp, roles_of_role);
for (i = 0; i < roles_of_role_count; i++) {
View
@@ -41,8 +41,10 @@ Returns a C string for the name of C<*pmc>.
static STRING *
caller(PARROT_INTERP, PMC *pmc /*NULLOK*/)
{
- return pmc && pmc->vtable && pmc->vtable->whoami ?
- VTABLE_name(interp, pmc) : CONST_STRING(interp, "(null)");
+ STRING * const null_str = CONST_STRING(interp, "(null)");
+
+ return pmc && pmc->vtable && pmc->vtable->whoami
+ ? VTABLE_name(interp, pmc) : null_str;
}
/*
View
@@ -92,14 +92,10 @@ handler to care
code = data;
}
else if (VTABLE_isa(INTERP, data, CONST_STRING(INTERP, "Hash"))) {
- code =
- VTABLE_get_pmc_keyed_str(INTERP, data, CONST_STRING(INTERP, "code"));
- interpreter =
- VTABLE_get_pmc_keyed_str(INTERP, data, CONST_STRING(INTERP, "interp"));
- type =
- VTABLE_get_string_keyed_str(INTERP, data, CONST_STRING(INTERP, "type"));
- priority =
- VTABLE_get_integer_keyed_str(INTERP, data, CONST_STRING(INTERP, "priority"));
+ code = VTABLE_get_pmc_keyed_str(INTERP, data, CONST_STRING(INTERP, "code"));
+ interpreter = VTABLE_get_pmc_keyed_str(INTERP, data, CONST_STRING(INTERP, "interp"));
+ type = VTABLE_get_string_keyed_str(INTERP, data, CONST_STRING(INTERP, "type"));
+ priority = VTABLE_get_integer_keyed_str(INTERP, data, CONST_STRING(INTERP, "priority"));
}
else {
Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_INVALID_OPERATION,
View
@@ -111,8 +111,12 @@ Initializes the exception with supplied values.
*/
VTABLE void init_pmc(PMC *values) {
+ STRING * const severity = CONST_STRING(interp, "severity");
+ STRING * const message = CONST_STRING(interp, "message");
+
Parrot_Exception_attributes * const core_struct =
mem_allocate_zeroed_typed(Parrot_Exception_attributes);
+
INTVAL ishash = VTABLE_isa(interp, values, CONST_STRING(interp, 'Hash'));
/* Set flags for custom DOD mark and destroy. */
@@ -121,13 +125,13 @@ Initializes the exception with supplied values.
/* Set up the core struct and default values for the exception object. */
PMC_data(SELF) = core_struct;
- core_struct->severity = ishash ?
- VTABLE_get_integer_keyed_str(interp, values, CONST_STRING(interp, 'severity')) :
- EXCEPT_error;
+ core_struct->severity = ishash
+ ? VTABLE_get_integer_keyed_str(interp, values, severity)
+ : EXCEPT_error;
core_struct->handled = 0;
- core_struct->message = ishash ?
- VTABLE_get_string_keyed_str(interp, values, CONST_STRING(interp, 'message')) :
- VTABLE_get_string(interp, values);
+ core_struct->message = ishash
+ ? VTABLE_get_string_keyed_str(interp, values, message)
+ : VTABLE_get_string(interp, values);
core_struct->payload = PMCNULL;
core_struct->resume = PMCNULL;
core_struct->backtrace = PMCNULL;
@@ -523,8 +527,10 @@ exit_code.
*/
VTABLE INTVAL is_equal(PMC *value) {
+ STRING * const exception_str = CONST_STRING(INTERP, "Exception");
+
if (value->vtable->base_type == SELF->vtable->base_type
- && VTABLE_isa(INTERP, value, CONST_STRING(INTERP, "Exception"))) {
+ && VTABLE_isa(INTERP, value, exception_str)) {
INTVAL self_compare, value_compare;
GET_ATTR_type(interp, SELF, self_compare);
GET_ATTR_type(interp, value, value_compare);
@@ -191,13 +191,15 @@ Report whether the exception handler can handle a particular type of exception.
*/
METHOD can_handle(PMC *exception) {
+ STRING * const sev = CONST_STRING(interp, "severity");
+ STRING * const ex_str = CONST_STRING(interp, "Exception");
+
Parrot_ExceptionHandler_attributes * const core_struct =
PARROT_EXCEPTIONHANDLER(SELF);
- INTVAL severity =
- VTABLE_get_integer_keyed_str(interp, exception, CONST_STRING(interp, "severity"));
+ INTVAL severity = VTABLE_get_integer_keyed_str(interp, exception, sev);
if (exception->vtable->base_type == enum_class_Exception
- || VTABLE_isa(INTERP, exception, CONST_STRING(INTERP, "Exception"))) {
+ || VTABLE_isa(INTERP, exception, ex_str)) {
if (severity < core_struct->min_severity) {
RETURN(INTVAL 0);
View
@@ -245,9 +245,10 @@ Throws an exception if an unknown PMC type is passed.
*/
METHOD globals(PMC *glb :optional, int got_glb :opt_flag) {
- STRING *s_str = CONST_STRING(interp, "String");
- STRING *s_arr = CONST_STRING(interp, "array");
- STRING *s_hash = CONST_STRING(interp, "hash");
+ STRING * const s_str = CONST_STRING(interp, "String");
+ STRING * const s_arr = CONST_STRING(interp, "array");
+ STRING * const s_hash = CONST_STRING(interp, "hash");
+ STRING * const s_space = CONST_STRING(interp, " ");
if (got_glb) {
STRING * const s_empty = CONST_STRING(interp, "");
@@ -261,9 +262,8 @@ Throws an exception if an unknown PMC type is passed.
INTVAL n, i;
if (VTABLE_isa(interp, glb, s_str))
- glb_array = string_split(interp,
- CONST_STRING(interp, " "),
- VTABLE_get_string(interp, glb));
+ glb_array = string_split(interp, s_space,
+ VTABLE_get_string(interp, glb));
else
glb_array = glb;
View
@@ -154,8 +154,7 @@ Initializes a PMCProxy PMC.
/* Link the proxy and the namespace, caching the proxy object for
* later retrieval on class lookup. */
- Parrot_PCCINVOKE(interp, proxy_info->_namespace,
- CONST_STRING(interp, "set_class"), "P->", SELF);
+ Parrot_PCCINVOKE(interp, proxy_info->_namespace, CONST_STRING(interp, "set_class"), "P->", SELF);
/* Extract any methods from the namespace */
Parrot_oo_extract_methods_from_namespace(interp, SELF,
@@ -372,16 +371,22 @@ inspect_str.
{
/* Create a hash, then use inspect_str to get all of the data to
* fill it up with. */
+ STRING * const name_str = CONST_STRING(interp, "name");
+ STRING * const ns_str = CONST_STRING(interp, "namespace");
+ STRING * const meth_str = CONST_STRING(interp, "methods");
+ STRING * const parents_str = CONST_STRING(interp, "parents");
+
PMC * const metadata = pmc_new(interp, enum_class_Hash);
- VTABLE_set_pmc_keyed_str(interp, metadata, CONST_STRING(interp, "name"),
- VTABLE_inspect_str(interp, SELF, CONST_STRING(interp, "name")));
- VTABLE_set_pmc_keyed_str(interp, metadata, CONST_STRING(interp, "namespace"),
- VTABLE_inspect_str(interp, SELF, CONST_STRING(interp, "namespace")));
- VTABLE_set_pmc_keyed_str(interp, metadata, CONST_STRING(interp, "methods"),
- VTABLE_inspect_str(interp, SELF, CONST_STRING(interp, "methods")));
- VTABLE_set_pmc_keyed_str(interp, metadata, CONST_STRING(interp, "parents"),
- VTABLE_inspect_str(interp, SELF, CONST_STRING(interp, "parents")));
+ VTABLE_set_pmc_keyed_str(interp, metadata, name_str,
+ VTABLE_inspect_str(interp, SELF, name_str));
+ VTABLE_set_pmc_keyed_str(interp, metadata, ns_str,
+ VTABLE_inspect_str(interp, SELF, ns_str));
+ VTABLE_set_pmc_keyed_str(interp, metadata, meth_str,
+ VTABLE_inspect_str(interp, SELF, meth_str));
+ VTABLE_set_pmc_keyed_str(interp, metadata, parents_str,
+ VTABLE_inspect_str(interp, SELF, parents_str));
+
return metadata;
}
View
@@ -631,8 +631,7 @@ providing a set of key/value pairs describing the attribute.
*/
METHOD attributes() {
- PMC *ret_attrib_metadata =
- VTABLE_inspect_str(interp, SELF, CONST_STRING(interp, "attributes"));
+ PMC *ret_attrib_metadata = VTABLE_inspect_str(interp, SELF, CONST_STRING(interp, "attributes"));
RETURN(PMC *ret_attrib_metadata);
}
View
@@ -459,21 +459,23 @@ PMCNULL.
*/
METHOD find_handler(PMC *task) {
- PMC *iter;
+ STRING * const handled_str = CONST_STRING(interp, "handled");
+ STRING * const iter_str = CONST_STRING(interp, "handler_iter");
+ PMC *iter;
/* Exceptions store the handler iterator for rethrow, other kinds of
* tasks don't (though they could). */
if (task->vtable->base_type == enum_class_Exception
- && VTABLE_get_integer_keyed_str(interp, task, CONST_STRING(interp, "handled")) == -1) {
- iter = VTABLE_get_attr_str(interp, task, CONST_STRING(interp, "handler_iter"));
+ && VTABLE_get_integer_keyed_str(interp, task, handled_str) == -1) {
+ iter = VTABLE_get_attr_str(interp, task, iter_str);
}
else {
PMC *handlers;
GET_ATTR_handlers(interp, SELF, handlers);
iter = VTABLE_get_iter(interp, handlers);
if (task->vtable->base_type == enum_class_Exception)
- VTABLE_set_attr_str(interp, task, CONST_STRING(interp, "handler_iter"), iter);
+ VTABLE_set_attr_str(interp, task, iter_str, iter);
}
/* Loop from newest handler to oldest handler. */
View
@@ -891,10 +891,9 @@ slurpy arguments).
}
METHOD arity() {
- PMC *pos_required =
- VTABLE_inspect_str(interp, SELF, CONST_STRING(interp, "pos_required"));
- PMC *named_required =
- VTABLE_inspect_str(interp, SELF, CONST_STRING(interp, "named_required"));
+ PMC *pos_required = VTABLE_inspect_str(interp, SELF, CONST_STRING(interp, "pos_required"));
+ PMC *named_required = VTABLE_inspect_str(interp, SELF, CONST_STRING(interp, "named_required"));
+
INTVAL arity = VTABLE_get_integer(INTERP, pos_required) +
VTABLE_get_integer(INTERP, named_required);
View
@@ -169,10 +169,8 @@ An interpreter in which to execute this task.
else
core_struct->birthtime = 0.0;
- core_struct->codeblock =
- VTABLE_get_pmc_keyed_str(INTERP, data, CONST_STRING(INTERP, "code"));
- core_struct->interp = (Parrot_Interp)
- VTABLE_get_pmc_keyed_str(INTERP, data, CONST_STRING(INTERP, "data"));
+ core_struct->codeblock = VTABLE_get_pmc_keyed_str(INTERP, data, CONST_STRING(INTERP, "code"));
+ core_struct->interp = (Parrot_Interp)VTABLE_get_pmc_keyed_str(INTERP, data, CONST_STRING(INTERP, "data"));
}
/*
Oops, something went wrong.

0 comments on commit 0006ce7

Please sign in to comment.