Exemplo n.º 1
0
/*
    findClass gets a class object,
    either by finding it already or making it
    in addition, it makes sure it has a size, by setting
    the size to zero if it is nil.
*/
static ObjectHandle findClass(const char* name)
{   
    ObjectHandle newObj;

    newObj = globalSymbol(name);
    if (newObj == nilobj) {
        newObj = createAndRegisterNewClass(name);
    }
    if (newObj->basicAt(sizeInClass) == nilobj) 
    {
        newObj->basicAtPut(sizeInClass, newInteger(0));
    }
    return newObj;
}
Exemplo n.º 2
0
static ObjectHandle findClassWithMeta(const char* name, ObjectHandle metaObj)
{   
    ObjectHandle newObj, nameObj, methTable;
    int size;

    newObj = globalSymbol(name);
    if (newObj == nilobj)
    {
        size = getInteger(metaObj->basicAt(sizeInClass));
        newObj = MemoryManager::Instance()->allocObject(size);
        newObj->_class = metaObj;

        /* now make name */
        nameObj = createSymbol(name);
        newObj->basicAtPut(nameInClass, nameObj);
        methTable = newDictionary(39);
        newObj->basicAtPut(methodsInClass, methTable);
        newObj->basicAtPut(sizeInClass, newInteger(size));

        /* now put in global symbols table */
        nameTableInsert(symbols, strHash(name), nameObj, newObj);
    }
    return newObj;
}