On 10/8/07, Allison Randal <[EMAIL PROTECTED]> wrote:
>
> Klaas-Jan Stol wrote:
> > I think it should be something like this:
> >
> > /* RT46099 Check we don't already have this parent. */
> >
> > /* If we have already added a method with this name... */
> > if (VTABLE_exists_keyed_str(interp, _class->all_parents,
> > VTABLE_name(interp, parent))) {
> > real_exception(interp, NULL, E_NotImplementedError,
> > "This class already has this parent.");
> > }
>
> Great start. Change "method" to "parent" in the comment. You'll want to
> check the immediate parents of the class, not all inherited parents, so
> you need to be looking at _class->parents, instead of
> _class->all_parents. And, unlike methods, parents are stored as an array
> of class objects, not a hash keyed by class name, so you'll need to loop
> over the parents array and check 'VTABLE_is_same' on each.
>
> Also, it'd be good to add more information to the real_exception
> message, like:
>
> real_exception(interp, NULL, E_NotImplementedError,
> "The class '%S' already has a parent class '%S'. "
> "It may have been supplied by a role.",
> VTABLE_get_string(interp, SELF),
> VTABLE_get_string(interp, parent));thanks for your pointers. > can't test this, parrot does not build in pdd15 branch. > > it should be more or less like this, based on impl of add_attribute. > > > > the headerfile classobject.h is missing in the branch, while it is there > in > > trunk. Is this right? > > The pdd15oo branch does build (since Saturday), and passes most of its > tests. Try 'make realclean', as some files have moved (classobject.h, > for example, is now include/parrot/oo_private.h). thanks, works! Attached a patch that should do the trick. I could not get VTABLE_is_same working, some error about parrot_string_t not having a member 'vtable' or something like that. Instead I looked around and found some other comparison function. > btw, the type of exception should be changed, also for other methods. > > Agreed. but not sure which type yet. for now I didn't change it, they can be all reviewed in one go I think. kjs
add_parent_check.patch
Description: Binary data
