Dynamic Objects

version 8/140515 by Jesse McGrew

  • Home page
  • Beginning
  • Previous
  • Next



  • Section 2 - Cloning the property table
    Include (-
    [ DO_CloneProperties src orig size i rv;
        ! find source object's property table
        src = (src + 9 + NUM_ATTR_BYTES)-->0;
        orig = src;
        ! measure size of table
        size = 4;
        i = src-->0;
        src = src + 4;
        while (i > 0) {
            size = size + 10 + ((src-->0 & $FFFF) * WORDSIZE);
            src = src + 10;
            i--;
        }
        ! obtain memory for new table
        rv = DT_Alloc(size + OBJECT_STRUCT_SIZE);
        if (~~rv) rfalse;
        rv = rv + OBJECT_STRUCT_SIZE;
        ! copy it
        DT_CopyBytes(size, orig, rv);
        ! adjust property data pointers
        i = rv-->0;
        src = rv + 4;
        while (i > 0) {
            src-->1 = src-->1 - orig + rv;
            src = src + 10;
            i--;
        }
        return rv - OBJECT_STRUCT_SIZE;
    ];
    -).