Index: src/pmc/exceptionhandler.pmc =================================================================== --- src/pmc/exceptionhandler.pmc (revision 36509) +++ src/pmc/exceptionhandler.pmc (working copy) @@ -192,20 +192,22 @@ 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, sev); if (exception->vtable->base_type == enum_class_Exception || VTABLE_isa(INTERP, exception, ex_str)) { - PMC * handled_types; + PMC *handled_types; + PMC *handled_types_except; + INTVAL min_severity, max_severity; GET_ATTR_handled_types(INTERP, SELF, handled_types); + GET_ATTR_handled_types_except(INTERP, SELF, handled_types_except); + GET_ATTR_max_severity(INTERP, SELF, max_severity); + GET_ATTR_min_severity(INTERP, SELF, min_severity); - if (severity < core_struct->min_severity) { + if (severity < min_severity) { RETURN(INTVAL 0); } - if (core_struct->max_severity > 0 - && severity > core_struct->max_severity) { + if (max_severity > 0 && severity > max_severity) { RETURN(INTVAL 0); } if (! PMC_IS_NULL(handled_types)) { @@ -222,22 +224,21 @@ RETURN(INTVAL 0); } - if (core_struct->handled_types_except != PMCNULL) { - const INTVAL elems = VTABLE_elements(interp, core_struct->handled_types_except); + if (handled_types_except != PMCNULL) { + const INTVAL elems = VTABLE_elements(interp, handled_types_except); const INTVAL type = VTABLE_get_integer_keyed_str(interp, exception, CONST_STRING(interp, "type")); INTVAL i; for (i = 0; i < elems; i++) { const INTVAL handled_type = VTABLE_get_integer_keyed_int(interp, - core_struct->handled_types_except, i); + handled_types_except, i); if (handled_type == type) RETURN(INTVAL 0); } RETURN(INTVAL 1); } - else if (core_struct->max_severity > 0 || - core_struct->min_severity > 0) { + else if (max_severity > 0 || min_severity > 0) { RETURN(INTVAL 1); } Index: src/pmc/pmcproxy.pmc =================================================================== --- src/pmc/pmcproxy.pmc (revision 36509) +++ src/pmc/pmcproxy.pmc (working copy) @@ -160,6 +160,23 @@ Parrot_oo_extract_methods_from_namespace(interp, SELF, proxy_info->_namespace); } + + { /* Create inherited attributes */ + /* Each attribute is terminated by an space, + * the list is '\0' terminated + */ + const char * attr = interp->vtables[type_num]->inheritable_args; + while (* attr) { + const char * const current = attr; + STRING *sattr; + size_t l; + while (* attr != ' ') ++attr; + l= attr - current; + sattr = Parrot_str_new(interp, current, l); + SELF.add_attribute(sattr, NULL); + ++attr; + } + } } /* Index: lib/Parrot/Vtable.pm =================================================================== --- lib/Parrot/Vtable.pm (revision 36509) +++ lib/Parrot/Vtable.pm (working copy) @@ -175,6 +175,7 @@ PMC *pmc_class; /* for PMCs: a PMC of that type for objects: the class PMC */ PMC *mro; /* array PMC of [class, parents ... ] */ + const char *inheritable_args; /* list of ARGS inheritable from classes */ struct _vtable *ro_variant_vtable; /* A variant of this vtable with the opposite IS_READONLY flag */ /* Vtable Functions */ Index: lib/Parrot/Pmc2c/PMCEmitter.pm =================================================================== --- lib/Parrot/Pmc2c/PMCEmitter.pm (revision 36509) +++ lib/Parrot/Pmc2c/PMCEmitter.pm (working copy) @@ -435,6 +435,7 @@ NULL, /* isa_hash */ NULL, /* class */ NULL, /* mro */ + inh_args, /* inheritable_args */ NULL, /* ro_variant_vtable */ $methlist }; @@ -487,6 +488,20 @@ void Parrot_${classname}_class_init(PARROT_INTERP, int entry, int pass) { + static const char inh_args [] = +EOC + $cout .= ' "'; + + my $attributes = $self->attributes; + foreach my $attribute ( @$attributes ) { + # Temporarily all attributes are listed here, + # TODO: select the inheritables with same criteria as generate_accessor + $cout .= $attribute->name; + $cout .= ' '; + } + + $cout .= "\";\n"; + $cout .= <<"EOC"; $vtable_decl EOC Index: lib/Parrot/Pmc2c/Attribute.pm =================================================================== --- lib/Parrot/Pmc2c/Attribute.pm (revision 36509) +++ lib/Parrot/Pmc2c/Attribute.pm (working copy) @@ -104,6 +104,7 @@ my $isptrtostring = qr/STRING\s*\*$/; my $isptrtopmc = qr/PMC\s*\*$/; + my $inherit = 1; my $decl = <<"EOA"; /* Generated macro accessors for '$attrname' attribute of $pmcname PMC. */ @@ -116,21 +117,21 @@ $decl .= <<"EOA"; PMC *attr_value = VTABLE_get_attr_str(interp, \\ pmc, Parrot_str_new_constant(interp, "$attrname")); \\ - (dest) = VTABLE_get_integer(interp, attr_value); \\ + (dest) = (PMC_IS_NULL(attr_value) ? (INTVAL) 0: VTABLE_get_integer(interp, attr_value)); \\ EOA } elsif ($attrtype eq "FLOATVAL") { $decl .= <<"EOA"; PMC *attr_value = VTABLE_get_attr_str(interp, \\ pmc, Parrot_str_new_constant(interp, "$attrname")); \\ - (dest) = VTABLE_get_number(interp, attr_value); \\ + (dest) = (PMC_IS_NULL(attr_value) ? (FLOATVAL) 0.0: VTABLE_get_number(interp, attr_value)); \\ EOA } elsif ($attrtype =~ $isptrtostring) { $decl .= <<"EOA"; PMC *attr_value = VTABLE_get_attr_str(interp, \\ pmc, Parrot_str_new_constant(interp, "$attrname")); \\ - (dest) = VTABLE_get_string(interp, attr_value); \\ + (dest) = (PMC_IS_NULL(attr_value) ? (STRING *) 0: VTABLE_get_string(interp, attr_value)); \\ EOA } elsif ($attrtype =~ $isptrtopmc) { @@ -141,6 +142,7 @@ } else { + $inherit = 0; $decl .= <<"EOA"; Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION, \\ "Attributes of type '$attrtype' cannot be " \\ @@ -206,6 +208,8 @@ EOA + $self->{inherit} = $inherit; + $h->emit($decl); return 1;