Exemple #1
0
uObject* uField::GetValue(uObject* object)
{
    U_ASSERT(DeclaringType);
    DeclaringType->Init();
    const uFieldInfo& field = Info();
    return uBoxPtr(field.Type, FIELD_PTR, NULL, true);
}
// protected override sealed void OnSet(T value, object origin) :52
void UxProperty__OnSet_fn(UxProperty* __this, void* value, uObject* origin)
{
    uType* __types[] = {
        __this->__type->T(0),
    };
    uPtr(__this->_setter)->Invoke(2, uBoxPtr(__types[0], value), origin);
}
// protected override sealed void OnSet(T value, object origin) :53
void UxProperty__OnSet_fn(UxProperty* __this, void* value, uObject* origin)
{
    uType* __types[] = {
        __this->__type->T(0),
    };
    uStackFrame __("Outracks.Simulator.Runtime.UxProperty`1", "OnSet(T,object)");
    uPtr(__this->_setter)->Invoke(2, uBoxPtr(__types[0], value), origin);
}
Exemple #4
0
uObject* uDelegate::Invoke(uArray* array)
{
    uDelegateType* type = (uDelegateType*)GetType();
    size_t count = type->ParameterCount;
    uType** params = type->ParameterTypes;
    void** args = NULL;

    if (array)
    {
        if (!U_IS_OBJECT(((uArrayType*)array->GetType())->ElementType))
            U_THROW_ICE();
        if (count != array->Length())
            U_THROW_IOORE();

        uObject** objects = (uObject**)array->Ptr();
        void** ptr = args = count > 0
            ? (void**)U_ALLOCA(count * sizeof(void*))
            : NULL;

        for (size_t i = 0; i < count; i++)
        {
            uType* param = *params++;
            uObject* object = *objects++;

            switch (param->Type)
            {
            case uTypeTypeEnum:
            case uTypeTypeStruct:
                *ptr++ = (uint8_t*)object + sizeof(uObject);
                break;
            case uTypeTypeByRef:
                *ptr++ = U_IS_VALUE(((uByRefType*)param)->ValueType)
                        ? (uint8_t*)object + sizeof(uObject)
                        : (void*)&object;
                break;
            case uTypeTypeClass:
            case uTypeTypeDelegate:
            case uTypeTypeInterface:
            case uTypeTypeArray:
                *ptr++ = object;
                break;
            default:
                U_FATAL();
            }
        }
    }

    uType* returnType = type->ReturnType;
    void* retval = !U_IS_VOID(returnType)
        ? U_ALLOCA(returnType->ValueSize)
        : NULL;

    Invoke(retval, args, count);
    return uBoxPtr(returnType, retval, NULL, true);
}
Exemple #5
0
uObject* uDelegate::Invoke(size_t count, ...)
{
    va_list ap;
    va_start(ap, count);
    void** args = count > 0
        ? (void**)U_ALLOCA(count * sizeof(void*))
        : NULL;

    for (size_t i = 0; i < count; i++)
        args[i] = va_arg(ap, void*);

    va_end(ap);
    uType* returnType = ((uDelegateType*)__type)->ReturnType;
    void* retval = !U_IS_VOID(returnType)
        ? U_ALLOCA(returnType->ValueSize)
        : NULL;

    Invoke(retval, args, count);
    return uBoxPtr(returnType, retval, NULL, true);
}
Exemple #6
0
uObject* uFunction::Invoke(uObject* object, uArray* args)
{
    size_t count = ParameterTypes->Length();
    void* retval = !U_IS_VOID(ReturnType)
        ? U_ALLOCA(ReturnType->ValueSize)
        : NULL;

    if (!(Flags & uFunctionFlagsStatic))
        count++;
    if (Generic)
        count++;
    if (retval)
        count++;

    void** stack;
    void** ptr = stack = count > 0
            ? (void**)U_ALLOCA(count * sizeof(void*))
            : NULL;

    if (!(Flags & uFunctionFlagsStatic))
        *ptr++ = !(Flags & uFunctionFlagsVirtual) && U_IS_VALUE(DeclaringType)
            ? (uint8_t*)uPtr(object) + sizeof(uObject)
            : (void*)uPtr(object);
    if (Generic)
        *ptr++ = Generic;

    if (args)
    {
        if (args->Length() != ParameterTypes->Length())
            U_THROW_IOORE();
        if (U_IS_VALUE(((uArrayType*)args->GetType())->ElementType))
            U_THROW_ICE();

        uType** params = (uType**)ParameterTypes->Ptr();
        uObject** objects = (uObject**)args->Ptr();

        for (int i = 0; i < args->Length(); i++)
        {
            uType*& param = *params++;
            uObject*& arg = *objects++;

            switch (param->Type)
            {
            case uTypeTypeEnum:
            case uTypeTypeStruct:
                *ptr++ = (uint8_t*)arg + sizeof(uObject);
                break;
            case uTypeTypeByRef:
                *ptr++ = U_IS_VALUE(((uByRefType*)param)->ValueType)
                        ? (uint8_t*)arg + sizeof(uObject)
                        : (void*)&arg;
                break;
            case uTypeTypeClass:
            case uTypeTypeDelegate:
            case uTypeTypeInterface:
            case uTypeTypeArray:
                *ptr++ = arg;
                break;
            default:
                U_FATAL();
            }
        }
    }
    else if (ParameterTypes->Length() != 0)
        U_THROW_IOORE();

    if (retval)
        *ptr++ = retval;

    U_ASSERT(DeclaringType);
    DeclaringType->Init();
    uInvoke(Flags & uFunctionFlagsVirtual
            ? *(void**)((uint8_t*)object->GetType() + _offset)
            : _func,
        stack,
        count);
    return uBoxPtr(ReturnType, retval, NULL, true);
}
// public static T Add<T>(string descriptor, T data) :65
void PreloadedResources__Add_fn(uType* __type, uString* descriptor, void* data, uTRef __retval)
{
    uType* __types[] = {
        __type->U(0),
    };
    PreloadedResources_typeof()->Init();
    ::g::Uno::Collections::Dictionary__set_Item_fn(uPtr(PreloadedResources::resources()), descriptor, uBoxPtr(__types[0], data));
    return __retval.Store(__types[0], data), void();
}