示例#1
0
ECode CObjInfoList::AcquireLocalTypeInfo(
    /* [in] */ CARDataType type,
    /* [in] */ MemorySize size,
    /* [out] */ IDataTypeInfo** dataTypeInfo)
{
    if (!dataTypeInfo) {
        return E_INVALID_ARGUMENT;
    }

    LockHashTable(EntryType_Local);
    if (!mLocalTypeInfos[type]) {
        mLocalTypeInfos[type] = new CLocalTypeInfo(size);
        if (!mLocalTypeInfos[type]) {
            UnlockHashTable(EntryType_Local);
            return E_OUT_OF_MEMORY;
        }
        mLocalTypeInfos[type]->AddRef();
    }
    UnlockHashTable(EntryType_Local);

    *dataTypeInfo = mLocalTypeInfos[type];
    (*dataTypeInfo)->AddRef();

    return NOERROR;
}
示例#2
0
ECode CObjInfoList::AcquireConstantInfo(
    /* [in] */ CClsModule* clsModule,
    /* [in] */ ConstDirEntry* constDirEntry,
    /* [in, out] */ IInterface** object)
{
    if (!clsModule || !constDirEntry || !object) {
        return E_INVALID_ARGUMENT;
    }

    LockHashTable(EntryType_Constant);
    if (*object) {
        UnlockHashTable(EntryType_Constant);
        return NOERROR;
    }

    CConstantInfo* constantInfoObj = new CConstantInfo(clsModule, constDirEntry);
    if (constantInfoObj == NULL) {
        UnlockHashTable(EntryType_Constant);
        return E_OUT_OF_MEMORY;
    }

    *object = constantInfoObj;
    (*object)->AddRef();
    UnlockHashTable(EntryType_Constant);

    return NOERROR;
}
示例#3
0
ECode CObjInfoList::AcquireIntrinsicInfo(
    /* [in] */ CarDataType dataType,
    /* [out] */ IDataTypeInfo** dataTypeInfo,
    /* [in] */ UInt32 size)
{
    if (!dataTypeInfo) {
        return E_INVALID_ARGUMENT;
    }

    if (g_cDataTypeList[dataType].mSize) {
        size = g_cDataTypeList[dataType].mSize;
    }

    LockHashTable(EntryType_DataType);
    if (!mDataTypeInfos[dataType]) {
        mDataTypeInfos[dataType] = new CIntrinsicInfo(dataType, size);

        if (!mDataTypeInfos[dataType]) {
            UnlockHashTable(EntryType_DataType);
            return E_OUT_OF_MEMORY;
        }
        mDataTypeInfos[dataType]->AddRef();
    }
    UnlockHashTable(EntryType_DataType);

    *dataTypeInfo = mDataTypeInfos[dataType];
    (*dataTypeInfo)->AddRef();

    return NOERROR;
}
ECode CObjInfoList::AcquireMethodInfo(
    /* [in] */ CClsModule* clsModule,
    /* [in] */ MethodDescriptor* methodDescriptor,
    /* [in] */ UInt32 index,
    /* [in, out] */ IInterface** object)
{
    if (!clsModule || !methodDescriptor || !object) {
        return E_INVALID_ARGUMENT;
    }

    LockHashTable(EntryType_Method);
    if (*object) {
        UnlockHashTable(EntryType_Method);
        return NOERROR;
    }

    UInt64 keyValue;
    memcpy(&keyValue, &methodDescriptor, 4);
    memcpy((PByte)&keyValue + 4, &index, 4);
    IInterface** obj = mMethodInfos.Get(&keyValue);
    if (!obj) {
        IMethodInfo* iMethodInfo = NULL;
        AutoPtr<CMethodInfo> methodInfoObj = new CMethodInfo(clsModule,
                methodDescriptor, index);
        if (methodInfoObj == NULL) {
            UnlockHashTable(EntryType_Method);
            return E_OUT_OF_MEMORY;
        }

        ECode ec = methodInfoObj->Init();
        if (FAILED(ec)) {
            UnlockHashTable(EntryType_Method);
            return ec;
        }

        iMethodInfo = (IMethodInfo*)methodInfoObj.Get();
        if (!mMethodInfos.Put(&keyValue, (IInterface**)&iMethodInfo)) {
            UnlockHashTable(EntryType_Method);
            return E_OUT_OF_MEMORY;
        }
        *object = iMethodInfo;
        (*object)->AddRef();
    }
    else {
        *object = *obj;
        (*object)->AddRef();
    }

    UnlockHashTable(EntryType_Method);

    return NOERROR;
}
ECode CObjInfoList::AcquireInterfaceInfo(
    /* [in] */ CClsModule* clsModule,
    /* [in] */ UInt32 index,
    /* [in, out] */ IInterface** object)
{
    if (!clsModule || !object) {
        return E_INVALID_ARGUMENT;
    }

    LockHashTable(EntryType_Interface);
    if (*object) {
        UnlockHashTable(EntryType_Interface);
        return NOERROR;
    }

    InterfaceDirEntry* ifDir = getInterfaceDirAddr(clsModule->mBase,
            clsModule->mClsMod->mInterfaceDirs, index);
    EIID iid = adjustInterfaceDescAddr(clsModule->mBase, ifDir->mDesc)->mIID;

    IInterface** obj = mIFInfos.Get(&iid);
    if (!obj) {
        IInterface *interfaceObj = NULL;
        AutoPtr<CInterfaceInfo> ifInfoObj = new CInterfaceInfo(clsModule, index);
        if (ifInfoObj == NULL) {
            UnlockHashTable(EntryType_Interface);
            return E_OUT_OF_MEMORY;
        }

        ECode ec = ifInfoObj->Init();
        if (FAILED(ec)) {
            UnlockHashTable(EntryType_Interface);
            return ec;
        }

        interfaceObj = (IInterface*)ifInfoObj.Get();
        if (!mIFInfos.Put(&iid, (IInterface**)&interfaceObj)) {
            UnlockHashTable(EntryType_Interface);
            return E_OUT_OF_MEMORY;
        }

        *object = interfaceObj;
        (*object)->AddRef();
    }
    else {
        *object = *obj;
        (*object)->AddRef();
    }

    UnlockHashTable(EntryType_Interface);

    return NOERROR;
}
示例#6
0
ECode CObjInfoList::AcquireCppVectorInfo(
    /* [in] */ IDataTypeInfo* elementTypeInfo,
    /* [in] */ Int32 length,
    /* [out] */ ICppVectorInfo** cppVectorInfo)
{
    if (!elementTypeInfo || !cppVectorInfo) {
        return E_INVALID_ARGUMENT;
    }

    InfoLinkNode* node = mCCppVectorHead;
    Int32 len = 0;
    AutoPtr<ICppVectorInfo> cppVectorInfoObj;
    ECode ec = NOERROR;
    LockHashTable(EntryType_DataType);
    for (; node; node = node->mNext) {
        cppVectorInfoObj = (ICppVectorInfo *)node->mInfo;
        cppVectorInfoObj->GetLength(&len);
        if (len == length) {
            AutoPtr<IDataTypeInfo> elementInfo;
            ec = cppVectorInfoObj->GetElementTypeInfo((IDataTypeInfo **)&elementInfo);
            if (FAILED(ec)) {
                UnlockHashTable(EntryType_DataType);
                return ec;
            }
            if (elementInfo.Get() == elementTypeInfo) {
                *cppVectorInfo = cppVectorInfoObj;
                (*cppVectorInfo)->AddRef();
                UnlockHashTable(EntryType_DataType);
                return NOERROR;
            }
        }
    }

    cppVectorInfoObj = new CCppVectorInfo(elementTypeInfo, length);
    if (cppVectorInfoObj == NULL) {
        UnlockHashTable(EntryType_DataType);
        return E_OUT_OF_MEMORY;
    }

    ec = AddInfoNode(cppVectorInfoObj, &mCCppVectorHead);
    if (FAILED(ec)) {
        UnlockHashTable(EntryType_DataType);
        return ec;
    }

    *cppVectorInfo = cppVectorInfoObj;
    (*cppVectorInfo)->AddRef();
    UnlockHashTable(EntryType_DataType);

    return NOERROR;
}
ECode CObjInfoList::AcquireClassInfo(
    /* [in] */ CClsModule * clsModule,
    /* [in] */ ClassDirEntry* clsDirEntry,
    /* [in, out] */ IInterface** object)
{
    if (!clsModule || !clsDirEntry || !object) {
        return E_INVALID_ARGUMENT;
    }

    LockHashTable(EntryType_Class);
    if (*object) {
        UnlockHashTable(EntryType_Class);
        return NOERROR;
    }

    IInterface** obj = mClassInfos.Get(&clsDirEntry);
    if (!obj) {
        IInterface *interfaceObj = NULL;
        AutoPtr<CClassInfo> classInfoObj = new CClassInfo(clsModule, clsDirEntry);
        if (classInfoObj == NULL) {
            UnlockHashTable(EntryType_Class);
            return E_OUT_OF_MEMORY;
        }

        ECode ec = classInfoObj->Init();
        if (FAILED(ec)) {
            UnlockHashTable(EntryType_Class);
            return ec;
        }

        interfaceObj = (IInterface*)classInfoObj.Get();
        if (!mClassInfos.Put(&clsDirEntry, (IInterface**)&interfaceObj)) {
            UnlockHashTable(EntryType_Class);
            return E_OUT_OF_MEMORY;
        }

        *object = interfaceObj;
        (*object)->AddRef();
    }
    else {
        *object = *obj;
        (*object)->AddRef();
    }

    UnlockHashTable(EntryType_Class);

    return NOERROR;
}
ECode CObjInfoList::AcquireStaticEnumInfo(
    /* [in] */ CClsModule* clsModule,
    /* [in] */ EnumDirEntry* enumDirEntry,
    /* [in, out] */ IInterface** object)
{
    if (!clsModule || !enumDirEntry || !object) {
        return E_INVALID_ARGUMENT;
    }

    LockHashTable(EntryType_Enum);
    if (*object) {
        UnlockHashTable(EntryType_Enum);
        return NOERROR;
    }

    IInterface** obj = mEnumInfos.Get(&enumDirEntry);
    if (!obj) {
        IInterface *interfaceObj = NULL;
        AutoPtr<CEnumInfo> enumInfoObj = new CEnumInfo();
        if (enumInfoObj == NULL) {
            UnlockHashTable(EntryType_Enum);
            return E_OUT_OF_MEMORY;
        }

        ECode ec = enumInfoObj->InitStatic(clsModule, enumDirEntry);
        if (FAILED(ec)) {
            UnlockHashTable(EntryType_Enum);
            return ec;
        }

        interfaceObj = (IInterface*)enumInfoObj.Get();
        if (!mEnumInfos.Put(&enumDirEntry, (IInterface**)&interfaceObj)) {
            UnlockHashTable(EntryType_Enum);
            return E_OUT_OF_MEMORY;
        }

        *object = interfaceObj;
        (*object)->AddRef();
    }
    else {
        *object = *obj;
        (*object)->AddRef();
    }

    UnlockHashTable(EntryType_Enum);

    return NOERROR;
}
示例#9
0
ECode CObjInfoList::AcquireStaticStructInfo(
    /* [in] */ CClsModule* clsModule,
    /* [in] */ StructDirEntry* structDirEntry,
    /* [in, out] */ IInterface** object)
{
    if (!clsModule || !structDirEntry || !object) {
        return E_INVALID_ARGUMENT;
    }

    LockHashTable(EntryType_Struct);
    if (*object) {
        UnlockHashTable(EntryType_Struct);
        return NOERROR;
    }

    IInterface** obj = mStructInfos.Get(&structDirEntry);
    if (!obj) {
        AutoPtr<CStructInfo> structInfoObj = new CStructInfo();
        if (structInfoObj == NULL) {
            UnlockHashTable(EntryType_Struct);
            return E_OUT_OF_MEMORY;
        }

        ECode ec = structInfoObj->InitStatic(clsModule, structDirEntry);
        if (FAILED(ec)) {
            UnlockHashTable(EntryType_Struct);
            return ec;
        }

        if (!mStructInfos.Put(&structDirEntry, (IInterface**)&structInfoObj)) {
            UnlockHashTable(EntryType_Struct);
            return E_OUT_OF_MEMORY;
        }

        *object = structInfoObj;
        (*object)->AddRef();
    }
    else {
        *object = *obj;
        (*object)->AddRef();
    }

    UnlockHashTable(EntryType_Struct);

    return NOERROR;
}
ECode CObjInfoList::AcquireTypeAliasInfo(
    /* [in] */ CClsModule* clsModule,
    /* [in] */ AliasDirEntry* aliasDirEntry,
    /* [in, out] */ IInterface** object)
{
    if (!clsModule || !aliasDirEntry || !object) {
        return E_INVALID_ARGUMENT;
    }

    LockHashTable(EntryType_TypeAliase);
    if (*object) {
        UnlockHashTable(EntryType_TypeAliase);
        return NOERROR;
    }

    IInterface** obj = mTypeAliasInfos.Get(&aliasDirEntry);
    if (!obj) {
        IInterface *interfaceObj = NULL;
        AutoPtr<CTypeAliasInfo> aliasInfoObj = new CTypeAliasInfo(clsModule,
                aliasDirEntry);
        if (aliasInfoObj == NULL) {
            UnlockHashTable(EntryType_TypeAliase);
            return E_OUT_OF_MEMORY;
        }

        interfaceObj = (IInterface*)aliasInfoObj.Get();
        if (!mTypeAliasInfos.Put(&aliasDirEntry, (IInterface**)&interfaceObj)) {
            UnlockHashTable(EntryType_TypeAliase);
            return E_OUT_OF_MEMORY;
        }

        *object = interfaceObj;
        (*object)->AddRef();
    }
    else {
        *object = *obj;
        (*object)->AddRef();
    }

    UnlockHashTable(EntryType_TypeAliase);

    return NOERROR;
}
ECode CObjInfoList::AcquireLocalPtrInfo(
    /* [in] */ CClsModule* clsModule,
    /* [in] */ TypeDescriptor* typeDescriptor,
    /* [in] */ Int32 pointer,
    /* [out] */ ILocalPtrInfo** localPtrInfo)
{
    if (!clsModule || !typeDescriptor || !localPtrInfo) {
        return E_INVALID_ARGUMENT;
    }

    LockHashTable(EntryType_Local);

    UInt64 keyValue;
    memcpy(&keyValue, &typeDescriptor, 4);
    memcpy((PByte)&keyValue + 4, &pointer, 4);
    IInterface** obj = mLocalPtrInfos.Get(&keyValue);
    if (!obj) {
        ILocalPtrInfo *interfaceObj = NULL;
        AutoPtr<CLocalPtrInfo> localPtrInfoObj = new CLocalPtrInfo(clsModule,
                typeDescriptor, pointer);
        if (localPtrInfoObj == NULL) {
            UnlockHashTable(EntryType_Local);
            return E_OUT_OF_MEMORY;
        }

        interfaceObj = (ILocalPtrInfo*)localPtrInfoObj.Get();
        if (!mLocalPtrInfos.Put(&keyValue, (IInterface**)&interfaceObj)) {
            UnlockHashTable(EntryType_Local);
            return E_OUT_OF_MEMORY;
        }
        *localPtrInfo = interfaceObj;
        (*localPtrInfo)->AddRef();
    }
    else {
        *localPtrInfo = (ILocalPtrInfo *)*obj;
        (*localPtrInfo)->AddRef();
    }

    UnlockHashTable(EntryType_Local);

    return NOERROR;
}
示例#12
0
ECode CObjInfoList::AcquireCBMethodInfoInfo(
    /* [in] */ CClsModule* clsModule,
    /* [in] */ UInt32 eventNum,
    /* [in] */ MethodDescriptor* methodDescriptor,
    /* [in] */ UInt32 index,
    /* [in, out] */ IInterface** object)
{
    if (!clsModule || !methodDescriptor || !object) {
        return E_INVALID_ARGUMENT;
    }

    LockHashTable(EntryType_CBMethod);
    if (*object) {
        UnlockHashTable(EntryType_CBMethod);
        return NOERROR;
    }

    AutoPtr<CCallbackMethodInfo> cbMethodInfoObj = new CCallbackMethodInfo();
    if (cbMethodInfoObj == NULL) {
        UnlockHashTable(EntryType_CBMethod);
        return E_OUT_OF_MEMORY;
    }

    ECode ec = cbMethodInfoObj->Init(clsModule,
            eventNum, methodDescriptor, index);
    if (FAILED(ec)) {
        UnlockHashTable(EntryType_CBMethod);
        return ec;
    }

    *object = cbMethodInfoObj;
    (*object)->AddRef();
    UnlockHashTable(EntryType_CBMethod);

    return NOERROR;
}
示例#13
0
ECode CObjInfoList::AcquireConstructorInfo(
    /* [in] */ CClsModule* clsModule,
    /* [in] */ MethodDescriptor* methodDescriptor,
    /* [in] */ UInt32 index,
    /* [in] */ ClassID* clsId,
    /* [in, out] */ IInterface** object)
{
    if (!clsModule || !methodDescriptor || !clsId || !object) {
        return E_INVALID_ARGUMENT;
    }

    LockHashTable(EntryType_Constructor);
    if (*object) {
        UnlockHashTable(EntryType_Constructor);
        return NOERROR;
    }

    AutoPtr<CConstructorInfo> constructInfoObj = new CConstructorInfo();
    if (constructInfoObj == NULL) {
        UnlockHashTable(EntryType_Constructor);
        return E_OUT_OF_MEMORY;
    }

    ECode ec = constructInfoObj->Init(clsModule,
            methodDescriptor, index, clsId);
    if (FAILED(ec)) {
        UnlockHashTable(EntryType_Constructor);
        return ec;
    }

    *object = constructInfoObj;
    (*object)->AddRef();
    UnlockHashTable(EntryType_Constructor);

    return NOERROR;
}
示例#14
0
ECode CObjInfoList::AcquireDynamicEnumInfo(
    /* [in] */ const String& fullName,
    /* [in] */ ArrayOf<String>* itemNames,
    /* [in] */ ArrayOf<Int32>* itemValues,
    /* [out] */ IEnumInfo** enumInfo)
{
    if (fullName.IsNull() || itemNames == NULL
        || itemValues == NULL || !enumInfo
        || itemNames->GetLength() != itemValues->GetLength()) {
        return E_INVALID_ARGUMENT;
    }

    InfoLinkNode* node = mEnumInfoHead;
    String enumName;
    String enumNamespace;
    AutoPtr<CEnumInfo> enumInfoObj;
    Int32 count = 0, i = 0;

    LockHashTable(EntryType_Enum);
    for (; node; node = node->mNext) {
        enumInfoObj = (CEnumInfo *)node->mInfo;
        enumInfoObj->GetName(&enumName);
        enumInfoObj->GetNamespace(&enumNamespace);

        Int32 index = fullName.LastIndexOf(".");
        String name = index > 0 ? fullName.Substring(index + 1) : fullName;
        String nameSpace = index > 0 ? fullName.Substring(0, index - 1) : String("");
        if (name.Equals(enumName) && nameSpace.Equals(enumNamespace)) {
            enumInfoObj->GetItemCount(&count);
            if (count != itemNames->GetLength()) {
                if (!name.IsEmpty()) {
                    UnlockHashTable(EntryType_Enum);
                    return E_DATAINFO_EXIST;
                }
                else {
                    continue;
                }
            }

            AutoPtr< ArrayOf<String> > _itemNames = enumInfoObj->mItemNames;
            AutoPtr< ArrayOf<Int32> > _itemValues = enumInfoObj->mItemValues;
            for (i = 0; i < count; i++) {
                if (!(*itemNames)[i].Equals((*_itemNames)[i])) {
                    if (!name.IsEmpty()) {
                        UnlockHashTable(EntryType_Enum);
                        return E_DATAINFO_EXIST;
                    }
                    else {
                        continue;
                    }
                }
                if ((*itemValues)[i] != (*_itemValues)[i]) {
                    if (!name.IsEmpty()) {
                        UnlockHashTable(EntryType_Enum);
                        return E_DATAINFO_EXIST;
                    }
                    else {
                        continue;
                    }
                }
            }

            *enumInfo = enumInfoObj;
            (*enumInfo)->AddRef();
            return NOERROR;
        }
    }

    enumInfoObj = new CEnumInfo();
    if (enumInfoObj == NULL) {
        UnlockHashTable(EntryType_Enum);
        return E_OUT_OF_MEMORY;
    }

    ECode ec = enumInfoObj->InitDynamic(fullName, itemNames, itemValues);
    if (FAILED(ec)) {
        UnlockHashTable(EntryType_Enum);
        return ec;
    }

    ec = AddInfoNode(enumInfoObj, &mEnumInfoHead);
    if (FAILED(ec)) {
        UnlockHashTable(EntryType_Enum);
        return ec;
    }

    *enumInfo = enumInfoObj;
    (*enumInfo)->AddRef();

    UnlockHashTable(EntryType_Enum);

    return NOERROR;
}
示例#15
0
ECode CObjInfoList::AcquireDynamicStructInfo(
    /* [in] */ const String& name,
    /* [in] */ ArrayOf<String>* fieldNames,
    /* [in] */ ArrayOf<IDataTypeInfo*>* fieldTypeInfos,
    /* [out] */ IStructInfo** structInfo)
{
    if (name.IsNullOrEmpty() || fieldNames == NULL
        || fieldTypeInfos == NULL || !structInfo
        || fieldNames->GetLength() != fieldTypeInfos->GetLength()) {
        return E_INVALID_ARGUMENT;
    }

    InfoLinkNode* node = mStructInfoHead;
    String structName;
    AutoPtr<CStructInfo> structInfoObj;
    Int32 count = 0, i = 0;
    LockHashTable(EntryType_Struct);
    for (; node; node = node->mNext) {
        structInfoObj = (CStructInfo *)node->mInfo;
        structInfoObj->GetName(&structName);

        if (name.Equals(structName)) {
            structInfoObj->GetFieldCount(&count);
            if (count != fieldNames->GetLength()) {
                UnlockHashTable(EntryType_Struct);
                return E_DATAINFO_EXIST;
            }

            AutoPtr< ArrayOf<String> > _fieldNames = structInfoObj->mFieldNames;
            AutoPtr< ArrayOf<IDataTypeInfo*> > _fieldTypeInfos = structInfoObj->mFieldTypeInfos;
            for (i = 0; i < count; i++) {
                if (!(*fieldNames)[i].Equals((*_fieldNames)[i])) {
                    UnlockHashTable(EntryType_Struct);
                    return E_DATAINFO_EXIST;
                }
                if ((*_fieldTypeInfos)[i] != (*fieldTypeInfos)[i]) {
                    UnlockHashTable(EntryType_Struct);
                    return E_DATAINFO_EXIST;
                }
            }

            *structInfo = structInfoObj;
            (*structInfo)->AddRef();
            UnlockHashTable(EntryType_Struct);
            return NOERROR;
        }
    }

    structInfoObj = new CStructInfo();
    if (structInfoObj == NULL) {
        UnlockHashTable(EntryType_Struct);
        return E_OUT_OF_MEMORY;
    }

    ECode ec = structInfoObj->InitDynamic(name, fieldNames, fieldTypeInfos);
    if (FAILED(ec)) {
        UnlockHashTable(EntryType_Struct);
        return ec;
    }

    ec = AddInfoNode(structInfoObj, &mStructInfoHead);
    if (FAILED(ec)) {
        UnlockHashTable(EntryType_Struct);
        return ec;
    }

    *structInfo = structInfoObj;
    (*structInfo)->AddRef();

    UnlockHashTable(EntryType_Struct);

    return NOERROR;
}
示例#16
0
ECode CObjInfoList::AcquireCarArrayInfo(
    /* [in] */ CarDataType quintetType,
    /* [in] */ IDataTypeInfo* elementTypeInfo,
    /* [out] */ ICarArrayInfo** carArrayInfo)
{

    if ((quintetType != CarDataType_ArrayOf) || !elementTypeInfo || !carArrayInfo) {
        return E_INVALID_ARGUMENT;
    }

    InfoLinkNode* node = mCarArrayInfoHead;
    AutoPtr<ICarArrayInfo> carArrayInfoObj;

    CarDataType dataType;
    ECode ec = elementTypeInfo->GetDataType(&dataType);
    if (FAILED(ec)) return ec;

    if (dataType != CarDataType_Struct) {
        LockHashTable(EntryType_DataType);
        if (!mCarArrayInfos[dataType]) {
            mCarArrayInfos[dataType] =
                    new CCarArrayInfo(quintetType, elementTypeInfo, dataType);
            if (!mCarArrayInfos[dataType]) {
                UnlockHashTable(EntryType_DataType);
                return E_OUT_OF_MEMORY;
            }
            mCarArrayInfos[dataType]->AddRef();
        }
        UnlockHashTable(EntryType_DataType);

        *carArrayInfo = mCarArrayInfos[dataType];
        (*carArrayInfo)->AddRef();
    }
    else {
        AutoPtr<IDataTypeInfo> elementInfo;
        LockHashTable(EntryType_DataType);
        for (; node; node = node->mNext) {
            carArrayInfoObj = (ICarArrayInfo *)node->mInfo;
            elementInfo = NULL;
            ec = carArrayInfoObj->GetElementTypeInfo((IDataTypeInfo **)&elementInfo);
            if (FAILED(ec)) {
                UnlockHashTable(EntryType_DataType);
                return ec;
            }
            if (elementInfo.Get() == elementTypeInfo) {
                *carArrayInfo = carArrayInfoObj;
                (*carArrayInfo)->AddRef();
                UnlockHashTable(EntryType_DataType);
                return NOERROR;
            }
        }

        carArrayInfoObj = new CCarArrayInfo(quintetType, elementTypeInfo);
        if (carArrayInfoObj == NULL) {
            UnlockHashTable(EntryType_DataType);
            return E_OUT_OF_MEMORY;
        }

        ec = AddInfoNode(carArrayInfoObj, &mCarArrayInfoHead);
        if (FAILED(ec)) {
            UnlockHashTable(EntryType_DataType);
            return ec;
        }

        *carArrayInfo = carArrayInfoObj;
        (*carArrayInfo)->AddRef();
        UnlockHashTable(EntryType_DataType);
    }

    return NOERROR;
}
示例#17
0
ECode CObjInfoList::AcquireModuleInfo(
    /* [in] */ const String& name,
    /* [out] */ IModuleInfo** moduleInfo)
{
    if (name.IsNull() || !moduleInfo) {
        return E_INVALID_ARGUMENT;
    }

    ECode ec = NOERROR;

    void* module = dlopen(name.string(), RTLD_NOW);
    if(NULL == module){
        return E_FILE_NOT_FOUND;
    }

    LockHashTable(EntryType_Module);
    IModuleInfo** modInfo = mModInfos.Get(const_cast<char*>(name.string()));
    if (modInfo) {
        dlclose(module);
        *moduleInfo = *modInfo;
        (*moduleInfo)->AddRef();
        UnlockHashTable(EntryType_Module);
        return NOERROR;
    }

    AutoPtr<CModuleInfo> modInfoObj;
    CClsModule* clsModule = NULL;

    LockHashTable(EntryType_ClsModule);

    CClsModule** ppCClsModule = mClsModule.Get(const_cast<char*>(name.string()));
    if (ppCClsModule) {
        clsModule = *ppCClsModule;
    }

    if (!clsModule) {
        ppCClsModule = NULL;
        //get cls module metadata
        MemorySize size;
        void* lockRes;
        CLSModule* clsMod;
        Boolean isAllocedClsMod = FALSE;

        if (-1 == dlGetClassInfo(module, &lockRes, &size)) {
            ec = E_DOES_NOT_EXIST;
            goto Exit;
        }

        if (((CLSModule *)lockRes)->mAttribs & CARAttrib_compress) {
            if (RelocFlattedCLS((CLSModule *)lockRes, size, &clsMod) < 0) {
                ec = E_OUT_OF_MEMORY;
                goto Exit;
            }
            isAllocedClsMod = TRUE;
        }
        else {
            clsMod = (CLSModule *)lockRes;
        }

        clsModule = new CClsModule(clsMod, isAllocedClsMod, name, module);
        if (clsModule == NULL) {
            if (isAllocedClsMod) DisposeFlattedCLS(clsMod);
            ec = E_OUT_OF_MEMORY;
            goto Exit;
        }

        if (!mClsModule.Put(const_cast<char*>(name.string()), (CClsModule**)&clsModule)) {
            delete clsModule;
            ec = E_OUT_OF_MEMORY;
            goto Exit;
        }
    }

    modInfoObj = new CModuleInfo(clsModule, name);
    if (modInfoObj == NULL) {
        if (!ppCClsModule && clsModule) delete clsModule;
        ec = E_OUT_OF_MEMORY;
        goto Exit;
    }

    if (!g_objInfoList.mModInfos.Put(const_cast<char*>(name.string()),
            (IModuleInfo**)&modInfoObj)) {
        ec = E_OUT_OF_MEMORY;
        goto Exit;
    }

    *moduleInfo = (IModuleInfo *)modInfoObj;
    (*moduleInfo)->AddRef();

    ec = NOERROR;

Exit:
    UnlockHashTable(EntryType_ClsModule);
    UnlockHashTable(EntryType_Module);

    return ec;
}