예제 #1
0
VariantTypeRef VariantType::CreateNewVariantFromVariant(const VariantTypeRef& inputVariant)
{
    TypeManagerRef tm = THREAD_TADM();
    TypeRef underlyingType = inputVariant->_underlyingTypeRef;
    VariantTypeRef newVariant = VariantType::New(tm, underlyingType);
    newVariant->CopyData(inputVariant->Begin(kPARead), newVariant->Begin(kPAWrite));
    return newVariant;
}
예제 #2
0
VariantTypeRef VariantType::CreateNewVariantFromStaticTypeAndData(const StaticTypeAndData& input)
{
    TypeRef inputType = input._paramType;
    TypeManagerRef tm = THREAD_TADM();

    auto inputData = input._pData;
    if (inputType->IsVariant()) {
        VariantTypeRef variant = *reinterpret_cast<VariantTypeRef *>(input._pData);
        inputType = variant->_underlyingTypeRef;
        inputData = variant->Begin(kPARead);
    }
    VariantTypeRef newVariant = VariantType::New(tm, inputType);
    newVariant->CopyData(inputData, newVariant->Begin(kPAWrite));
    return newVariant;
}
예제 #3
0
//------------------------------------------------------------
//! Deallocates data and frees up memory in dataRef described by typeRef
VIREO_EXPORT EggShellResult EggShell_DeallocateData(TypeManagerRef tm, const TypeRef typeRef, void* dataRef)
{
    TypeManagerScope scope(tm);
    if (typeRef == nullptr || !typeRef->IsValid()) {
        return kEggShellResult_InvalidTypeRef;
    }

    if (dataRef == nullptr) {
        return kEggShellResult_InvalidDataPointer;
    }

    NIError error = typeRef->ClearData(dataRef);
    THREAD_TADM()->Free(dataRef);
    if (error != kNIError_Success) {
        return kEggShellResult_UnableToDeallocateData;
    }

    return kEggShellResult_Success;
}
예제 #4
0
//------------------------------------------------------------
//! Allocates enough memory to fit a new object of TypeRef
VIREO_EXPORT EggShellResult EggShell_AllocateData(TypeManagerRef tm, const TypeRef typeRef, void** dataRefLocation)
{
    TypeManagerScope scope(tm);
    if (typeRef == nullptr || !typeRef->IsValid()) {
        return kEggShellResult_InvalidTypeRef;
    }

    if (dataRefLocation == nullptr) {
        return kEggShellResult_InvalidDataPointer;
    }

    *dataRefLocation = nullptr;
    Int32 topSize = typeRef->TopAQSize();
    void* pData = THREAD_TADM()->Malloc(topSize);
    NIError error = typeRef->InitData(pData);
    if (error != kNIError_Success) {
        return kEggShellResult_UnableToAllocateData;
    }
    *dataRefLocation = pData;
    return kEggShellResult_Success;
}