Beispiel #1
0
/* Generator0[] -> ap_generator0_array_t */
int japron_generator0_array_init_set(JNIEnv *env, ap_generator0_array_t* t, jobjectArray o)
{
  t->size = 0;
  t->p = NULL;
  check_nonnull(o,0);
  size_t i, nb = (*env)->GetArrayLength(env, o);
  *t = ap_generator0_array_make(nb);
  for (i=0; i<nb; i++) {
    jobject c = (*env)->GetObjectArrayElement(env, o, i);
    if (!c) {
      null_pointer_exception("generator is null");
      japron_generator0_array_clear(t);
      return 0;
    }
    t->p[i].gentyp = (*env)->GetIntField(env, c, japron_generator0_kind);
    jobject e = (*env)->GetObjectField(env, c, japron_generator0_coord);
    if (!e) {
      null_pointer_exception("expression is null"); 
      japron_generator0_array_clear(t);
      return 0;
    }
    t->p[i].linexpr0 = as_linexpr0(e);
  }
  return 1;
}
Beispiel #2
0
/*
 * the::graphics::directx::d2d_interop_surface::create_brush
 */
the::system::com_ptr<ID2D1Brush>
the::graphics::directx::d2d_interop_surface::create_brush(
        const D2D1::ColorF& colour) {
    THE_STACK_TRACE;

    HRESULT hr = S_OK;
    the::system::com_ptr<ID2D1Brush> retval;

    /* Sanity check: initialisation must have been completed before. */
    if (this->d2dRenderTarget.is_null()) {
        throw null_pointer_exception("d2dRenderTarget", __FILE__, __LINE__);
    }

    hr = this->d2dRenderTarget->CreateSolidColorBrush(colour,
        reinterpret_cast<ID2D1SolidColorBrush **>(&retval));
    if (FAILED(hr)) {
        THE_DIRECTX_TRACE_AND_THROW(hr, "Creating brush failed with error "
            "code %d.", hr);
    }

    return retval;
}
Beispiel #3
0
/*
 * the::graphics::directx::d2d_interop_surface::draw
 */
void the::graphics::directx::d2d_interop_surface::draw(
        const bool acquireMutex) {
    THE_STACK_TRACE;
    HRESULT hr = S_OK;

    /* Sanity check: initialisation must have been completed before. */
    if (this->d3d11ImmediateContext.is_null()) {
        throw null_pointer_exception("d3d11ImmediateContext", __FILE__, 
            __LINE__);
    }

    /* Acquire lock for rendering if requested. */
    if (acquireMutex) {
        hr = this->acquire_direct3d11_sync();
        if (FAILED(hr)) {
            THE_DIRECTX_TRACE_AND_THROW(hr, "Acquiring keyed mutex for "
                "Direct3D 11 failed with error code %d.", hr);
        }
    }

    if (this->d3d11CmdList.is_null()) {
        // Lazily create command list (preserves states).
        this->update_rendering_cmdlist();
    }

    /* Render. */
    this->d3d11ImmediateContext->ExecuteCommandList(this->d3d11CmdList, TRUE);

    /* Release mutex, if previously acquired. */
    if (acquireMutex) {
        hr = this->release_direct3d11_sync();
        if (FAILED(hr)) {
            THE_DIRECTX_TRACE_AND_THROW(hr, "Releasing keyed mutex for "
                "Direct3D 11 failed with error code %d.", hr);
        }
    }
}