cvsuser     03/12/04 05:56:20

  Modified:    src      objects.c
  Log:
  Parrot_class_register sets ParrotObject vtable now; whitespace cleanup
  
  Revision  Changes    Path
  1.22      +153 -139  parrot/src/objects.c
  
  Index: objects.c
  ===================================================================
  RCS file: /cvs/public/parrot/src/objects.c,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -w -r1.21 -r1.22
  --- objects.c 4 Dec 2003 12:43:16 -0000       1.21
  +++ objects.c 4 Dec 2003 13:56:20 -0000       1.22
  @@ -1,7 +1,7 @@
   /* objects.c
    *  Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
    *  CVS Info
  - *     $Id: objects.c,v 1.21 2003/12/04 12:43:16 leo Exp $
  + *     $Id: objects.c,v 1.22 2003/12/04 13:56:20 leo Exp $
    *  Overview:
    *     Handles class and object manipulation
    *  Data Structure and Algorithms:
  @@ -157,24 +157,28 @@
   }
   
   /* This is the method to register a new Parrot class as an
  -   instantiatable type. Doing this invoves putting it in the class
  +   instantiatable type. Doing this involves putting it in the class
      hash, setting its vtable so that the init method inits objects of
      the class rather than the class itself, and adding it to the
      interpreter's base type table so you can "new Px, foo" the things.
   */
   void
  -Parrot_class_register(Parrot_Interp interpreter, STRING *class_name, PMC *new_class)
  +Parrot_class_register(Parrot_Interp interpreter, STRING *class_name,
  +        PMC *new_class)
   {
  +    /* Build a new vtable for this class and register it in the
  +     * global registry .
  +     * The child class PMC has a ParrotObject vtable, which is a
  +     * good base to work from
  +     */
  +    VTABLE *new_vtable = Parrot_clone_vtable(interpreter,
  +            Parrot_base_vtables[enum_class_ParrotObject]);
  +    INTVAL new_type = pmc_register(interpreter, class_name);
  +
  +    /* register the class */
     VTABLE_set_pmc_keyed_str(interpreter, interpreter->class_hash,
                          class_name, new_class);
   
  -  /* Now build a new vtable for this class and register it in the
  -     global registry */
  -  {
  -      /* The child class PMC has a ParrotClass vtable, which is a
  -         good base to work from */
  -      VTABLE *new_vtable = Parrot_clone_vtable(interpreter, new_class->vtable);
  -      INTVAL new_type = pmc_register(interpreter, class_name);
   
         /* Set the vtable's type to the newly allocated type */
         Parrot_vtable_set_type(interpreter, new_vtable, new_type);
  @@ -189,9 +193,6 @@
   
         /* Put our new vtable in the global table */
         Parrot_base_vtables[new_type] = new_vtable;
  -
  -  }
  -
   }
   
   
  @@ -314,7 +315,10 @@
   
       /* We're going to make this over and over, so get it once and
          skip the repeated string makes */
  -    shortcut_name = string_concat(interpreter, string_from_cstring(interpreter, 
PARROT_NAMESPACE_SEPARATOR, PARROT_NAMESPACE_SEPARATOR_LENGTH), method_name, 0);
  +    shortcut_name = string_concat(interpreter,
  +            string_from_cstring(interpreter, PARROT_NAMESPACE_SEPARATOR,
  +                PARROT_NAMESPACE_SEPARATOR_LENGTH),
  +            method_name, 0);
   
       /* The order of operations:
        *
  @@ -326,7 +330,11 @@
        */
   
       /* See if we get lucky and its in the class of the PMC */
  -    FQ_method = string_concat(interpreter, VTABLE_get_string(interpreter, 
VTABLE_get_pmc_keyed_int(interpreter, (PMC *)PMC_data(class), 1)), shortcut_name, 0);
  +    FQ_method = string_concat(interpreter,
  +            VTABLE_get_string(interpreter,
  +                VTABLE_get_pmc_keyed_int(interpreter,
  +                    (PMC *)PMC_data(class), 1)),
  +            shortcut_name, 0);
   
       method = find_global(interpreter, FQ_method);
   
  @@ -336,13 +344,19 @@
       }
   
       /* If not, time to walk through the parent class array. Wheee */
  -    classsearch_array = VTABLE_get_pmc_keyed_int(interpreter, (PMC 
*)PMC_data(class), 2);
  +    classsearch_array =
  +        VTABLE_get_pmc_keyed_int(interpreter, (PMC *)PMC_data(class), 2);
       classcount = VTABLE_get_integer(interpreter, classsearch_array);
   
  -    for (searchoffset = 0; NULL == method && searchoffset < classcount; 
searchoffset++) {
  -        curclass = VTABLE_get_pmc_keyed_int(interpreter, classsearch_array, 
searchoffset);
  +    for (searchoffset = 0; NULL == method && searchoffset < classcount;
  +            searchoffset++) {
  +        curclass = VTABLE_get_pmc_keyed_int(interpreter,
  +                classsearch_array, searchoffset);
   
  -        FQ_method = string_concat(interpreter, VTABLE_get_string(interpreter, 
VTABLE_get_pmc_keyed_int(interpreter, (PMC *)PMC_data(curclass), 1)), shortcut_name, 
0);
  +        FQ_method = string_concat(interpreter,
  +                VTABLE_get_string(interpreter,
  +                    VTABLE_get_pmc_keyed_int(interpreter,
  +                        (PMC *)PMC_data(curclass), 1)), shortcut_name, 0);
           method = find_global(interpreter, FQ_method);
       }
   
  
  
  

Reply via email to