示例#1
0
Boolean CursorWindow::NativePutBlob(
    /* [in] */ const ArrayOf<Byte>& value,
    /* [in] */ Int32 row,
    /* [in] */ Int32 col)
{
    NativeCursorWindow* window = mNativeWindow;
    field_slot_t* fieldSlot = window->getFieldSlotWithCheck(row, col);
    if (fieldSlot == NULL) {
        // LOG_WINDOW(" getFieldSlotWithCheck error ");
        return FALSE;
    }

    Int32 len = value.GetLength();
    Int32 offset = window->alloc(len);
    if (!offset) {
        // LOG_WINDOW("Failed allocating %u bytes", len);
        return FALSE;
    }
    Byte* bytes = value.GetPayload();
    window->copyIn(offset, (uint8_t const *)bytes, len);

    // This must be updated after the call to alloc(), since that
    // may move the field around in the window
    fieldSlot->type = FIELD_TYPE_BLOB;
    fieldSlot->data.buffer.offset = offset;
    fieldSlot->data.buffer.size = len;
    // LOG_WINDOW("%d,%d is BLOB with %u bytes @ %d", row, col, len, offset);
    return TRUE;
}
    virtual bool write(
        /* [in] */ const void* buffer,
        /* [in] */ size_t size)
    {
        ArrayOf<Byte>* storage = mByteArray;

        while (size > 0) {
            size_t requested = size;
            if (requested > (size_t)mCapacity) {
                requested = mCapacity;
            }

            memcpy(storage->GetPayload(), buffer, requested);

            ECode ec = mOutputStream->Write(storage, 0, requested);
            if (FAILED(ec)) {
                SkDebugf("------- write threw an exception\n");
                return false;
            }

            buffer = (void*)((char*)buffer + requested);
            size -= requested;
            mBytesWritten += requested;
        }
        return true;
    }
示例#3
0
ECode CStmt::Bind(
    /* [in] */ Int32 pos,
    /* [in] */ const ArrayOf<Byte>& value)
{
#if HAVE_SQLITE3 && HAVE_SQLITE_COMPILE
    hvm *v = (hvm *)mHandle;

    if (v && v->vm && v->h) {
        Int32 npar = sqlite3_bind_parameter_count((sqlite3_stmt *) v->vm);
        Int32 ret = 0;
        Int32 len = 0;

        if (pos < 1 || pos > npar) {
            return E_ILLEGAL_ARGUMENT_EXCEPTION;
        }

        if (value.GetPayload()) {
            len = value.GetLength();
            if (len > 0) {
                ret = sqlite3_bind_blob((sqlite3_stmt *) v->vm,
                            pos, value.GetPayload(), len, sqlite3_free);
            } else {
                ret = sqlite3_bind_blob((sqlite3_stmt *) v->vm,
                            pos, "", 0, SQLITE_STATIC);
            }
        } else {
            ret = sqlite3_bind_null((sqlite3_stmt *) v->vm, pos);
        }
        if (ret != SQLITE_OK) {
            mError_code = ret;
            return E_SQL_EXCEPTION;
        }
    } else {
        return E_NULL_POINTER_EXCEPTION;
    }
#else
    return E_SQL_FEATURE_NOT_SUPPORTED_EXCEPTION;
#endif
    return NOERROR;
}
示例#4
0
Int64 CDashPathEffect::NativeCreate(
    /* [in] */ const ArrayOf<Float>& intervalArray,
    /* [in] */ Float phase)
{
    int         count = intervalArray.GetLength() & ~1;  // even number
#ifdef SK_SCALAR_IS_FLOAT
    SkScalar*   intervals = intervalArray.GetPayload();
#else
    #error Need to convert float array to SkScalar array before calling the following function.
#endif
    SkPathEffect* effect = SkDashPathEffect::Create(intervals, count, phase);
    return reinterpret_cast<Int64>(effect);
}
示例#5
0
void MatrixCursor::EnsureCapacity(
    /* [in] */ Int32 size)
{
    if (size > mData->GetLength()) {
        ArrayOf< AutoPtr<IInterface> >* oldData = mData;
        Int32 newSize = mData->GetLength() * 2;
        if (newSize < size) {
            newSize = size;
        }
        mData = ArrayOf< AutoPtr<IInterface> >::Alloc(newSize);
        memcpy(mData->GetPayload(), oldData->GetPayload(),
                oldData->GetLength() * sizeof(AutoPtr<IInterface>));
        ArrayOf< AutoPtr<IInterface> >::Free(oldData);
    }
}
Int32 CDashPathEffect::NativeCreate(
    /* [in] */ const ArrayOf<Float>& intervals,
    /* [in] */ Float phase)
{
    Int32 count = intervals.GetLength() & ~1;  // even number
    Float* values = intervals.GetPayload();

    SkAutoSTMalloc<32, SkScalar> storage(count);
    SkScalar* nativeIntervals = storage.get();
    for (int i = 0; i < count; i++) {
        nativeIntervals[i] = SkFloatToScalar(values[i]);
    }
    return reinterpret_cast<Int32>(new SkDashPathEffect(
            nativeIntervals, count, SkFloatToScalar(phase)));
}
示例#7
0
ECode CursorWindow::NativeGetBlob(
    /* [in] */ Int32 row,
    /* [in] */ Int32 column,
    /* [out] */ ArrayOf<Byte>** blob)
{
    ECode ec = NOERROR;
    int32_t err;
    NativeCursorWindow * window = mNativeWindow;
    // LOG_WINDOW("Getting blob for %d,%d from %p", row, column, window);

    field_slot_t field;
    err = window->read_field_slot(row, column, &field);
    if (err != 0) {
        *blob = NULL;
        // throwExceptionWithRowCol(env, row, column);
        return E_ILLEGAL_STATE_EXCEPTION;
    }

    uint8_t type = field.type;
    if (type == FIELD_TYPE_BLOB || type == FIELD_TYPE_STRING) {
        ArrayOf<Byte>* byteArray = ArrayOf<Byte>::Alloc(field.data.buffer.size);
        // LOG_ASSERT(byteArray, "Native could not create new byte[]");
        memcpy(byteArray->GetPayload(), window->offsetToPtr(field.data.buffer.offset),
                field.data.buffer.size);
        *blob = byteArray;
        return NOERROR;
    }
    else if (type == FIELD_TYPE_INTEGER) {
        ec = throw_sqlite3_exception(NULL);
    }
    else if (type == FIELD_TYPE_FLOAT) {
        ec = throw_sqlite3_exception(NULL);
    }
    else if (type == FIELD_TYPE_NULL) {
        // do nothing
    }
    else {
        // throwUnknowTypeException(env, type);
        ec = E_ILLEGAL_STATE_EXCEPTION;
    }
    *blob = NULL;
    return ec;
}
示例#8
0
    virtual bool write(const void* buffer, size_t size)
    {
        ArrayOf<Byte>* storage = mByteArray;

        while (size > 0) {
            size_t requested = size;
            if (requested > mCapacity) {
                requested = mCapacity;
            }

            memcpy(storage->GetPayload(), buffer, requested);

            ECode ec = mOutputStream->WriteBytes(*storage, 0, requested);
            if (FAILED(ec)) {
                return FALSE;
            }

            buffer = (void*)((char*)buffer + requested);
            size -= requested;
        }
        return TRUE;
    }
示例#9
0
Handle64 StringBlock::NativeCreate(
    /* [in] */ const ArrayOf<Byte>& data,
    /* [in] */ Int32 offset,
    /* [in] */ Int32 size)
{
    Int32 len = data.GetLength();
    if (offset < 0 || offset >= len || size < 0 || size > len || (offset + size) > len) {
        assert(0);
        // jniThrowException(env, "java/lang/IndexOutOfBoundsException", NULL);
        return 0;
    }

    android::ResStringPool* osb = new android::ResStringPool(
            data.GetPayload() + offset, size, TRUE);

    if (osb == NULL || osb->getError() != android::NO_ERROR) {
        assert(0);
        // jniThrowException(env, "java/lang/IllegalArgumentException", NULL);
        return 0;
    }

    return (Handle64)osb;
}
示例#10
0
Int64 XmlBlock::NativeCreate(
    /* [in] */ const ArrayOf<Byte>& data,
    /* [in] */ Int32 offset,
    /* [in] */ Int32 size)
{
    Int32 bLen = data.GetLength();
    if (offset < 0 || offset >= bLen || size < 0 || size > bLen || (offset + size) > bLen) {
        // doThrow(env, "java/lang/IndexOutOfBoundsException");
        assert(0);
        return 0;
    }

    android::ResXMLTree* osb = new android::ResXMLTree();
    if (osb) {
        osb->setTo(data.GetPayload() + offset, size, TRUE);
    }
    if (osb == NULL || osb->getError() != android::NO_ERROR) {
        // doThrow(env, "java/lang/IllegalArgumentException");
        assert(0);
        return 0;
    }

    return (Int64)osb;
}
void CSurfaceTexture::NativeGetTransformMatrix(
    /* [in] */ const ArrayOf<Float>& mtx)
{
    android::sp<android::SurfaceTexture> surfaceTexture(SurfaceTexture_getSurfaceTexture(this));
    surfaceTexture->getTransformMatrix(mtx.GetPayload());
}