Ticket #544: fix_attr_parsing.patch
File fix_attr_parsing.patch, 3.9 KB (added by whiteknight, 13 years ago) |
---|
-
src/pmc/managedstruct.pmc
29 29 * custom_free_func is called before the normal destroy() function does any 30 30 * work. 31 31 */ 32 ATTR void *custom_free_func;32 ATTR void (*custom_free_func)(PARROT_INTERP, void *, void *); 33 33 ATTR void *custom_free_priv; 34 34 /* if custom_clone_func is set, it will be called *instead* of the normal 35 35 * clone() function logic. 36 36 */ 37 ATTR void *custom_clone_func;37 ATTR PMC * (*custom_clone_func)(PARROT_INTERP, PMC *ptr, void *priv); 38 38 ATTR void *custom_clone_priv; 39 39 40 40 /* … … 86 86 VTABLE void destroy() { 87 87 void *ptr = PARROT_MANAGEDSTRUCT(SELF)->ptr; 88 88 if (ptr) { 89 custom_free_func_t free_func = 90 (custom_free_func_t)PARROT_MANAGEDSTRUCT(SELF)->custom_free_func; 89 custom_free_func_t free_func = PARROT_MANAGEDSTRUCT(SELF)->custom_free_func; 91 90 if (free_func) { 92 91 void *free_data = PARROT_MANAGEDSTRUCT(SELF)->custom_free_priv; 93 92 free_func(interp, ptr, free_data); … … 144 143 */ 145 144 146 145 VTABLE PMC *clone() { 147 custom_clone_func_t clone_func = 148 (custom_clone_func_t)PARROT_MANAGEDSTRUCT(SELF)->custom_clone_func; 146 custom_clone_func_t clone_func = PARROT_MANAGEDSTRUCT(SELF)->custom_clone_func; 149 147 PMC *dest; 150 148 if (clone_func) { 151 149 void *clone_data = PARROT_MANAGEDSTRUCT(SELF)->custom_clone_priv; -
lib/Parrot/Pmc2c/Parser.pm
135 135 136 136 # name 137 137 \s* 138 (\w+) 138 ( 139 \w+ 140 | \(\*\w*\)\(.*?\) 141 ) 139 142 140 143 # modifiers 141 144 \s* -
lib/Parrot/Pmc2c/Attribute.pm
99 99 my $pmcname = $pmc->{name}; 100 100 my $attrtype = $self->{type}; 101 101 my $attrname = $self->{name}; 102 my $isfuncptr = 0; 103 my $origtype = $attrtype; 104 if($attrname =~ m/\(\*(\w*)\)\((.*?)\)/) { 105 $isfuncptr = 1; 106 $origtype = $attrtype . " (*)(" . $2 . ")"; 107 $attrname = $1; 108 } 102 109 103 110 # Store regexes used to check some types to avoid repetitions 104 111 my $isptrtostring = qr/STRING\s*\*$/; … … 113 120 if (PObj_is_object_TEST(pmc)) { \\ 114 121 EOA 115 122 116 if ($ attrtype eq "INTVAL") {123 if ($isfuncptr == 1) { 117 124 $decl .= <<"EOA"; 125 Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION, \\ 126 "Attributes of type '$origtype' cannot be " \\ 127 "subclassed from a high-level PMC."); \\ 128 EOA 129 } 130 elsif ($attrtype eq "INTVAL") { 131 $decl .= <<"EOA"; 118 132 PMC *attr_value = VTABLE_get_attr_str(interp, \\ 119 133 pmc, Parrot_str_new_constant(interp, "$attrname")); \\ 120 134 (dest) = (PMC_IS_NULL(attr_value) ? (INTVAL) 0: VTABLE_get_integer(interp, attr_value)); \\ … … 161 175 if (PObj_is_object_TEST(pmc)) { \\ 162 176 EOA 163 177 164 if ($ attrtype eq "INTVAL") {178 if ($isfuncptr == 1) { 165 179 $decl .= <<"EOA"; 180 Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION, \\ 181 "Attributes of type '$origtype' cannot be " \\ 182 "subclassed from a high-level PMC."); \\ 183 EOA 184 } 185 elsif ($attrtype eq "INTVAL") { 186 $decl .= <<"EOA"; 166 187 PMC *attr_value = pmc_new(interp, enum_class_Integer); \\ 167 188 VTABLE_set_integer_native(interp, attr_value, value); \\ 168 189 VTABLE_set_attr_str(interp, pmc, \\