static int fun_add (env_t * env, int args_nr, val_t * result, val_t * args) { if (TY (0) == TY_INT && TY (1) == TY_INT) { /* Integer addition */ RESULTINT = ARGINT (0) + ARGINT (1); result->ty = TY_INT; } else if (ARG_MAY_BE_AREA (0) && ARG_MAY_BE_AREA (1)) { /* Area union */ make_area (&args[0]); make_area (&args[1]); RESULTAREA = area_union (ARGAREA (0), ARGAREA (1)); ARGAREA (0) = NULL; ARGAREA (1) = NULL; result->ty = TY_AREA; } else { /* Anything else -> string concatenation */ stringify (&args[0], 1); stringify (&args[1], 1); /* Yes, we could speed this up. */ RESULTSTR = (char *) malloc (1 + strlen (ARGSTR (0)) + strlen (ARGSTR (1))); strcpy (RESULTSTR, ARGSTR (0)); strcat (RESULTSTR, ARGSTR (1)); result->ty = TY_STRING; } return 0; }
/* Add curve to path. */ static void glyphCurve(abfGlyphCallbacks *cb, float x1, float y1, float x2, float y2, float x3, float y3) { abfMetricsCtx h = cb->direct_ctx; Rect ep; /* End-point bounds */ Rect cp; /* Control-point bounds */ float x0 = h->x; float y0 = h->y; if (h->flags & ABF_MTX_TRANSFORM) { /* Transform curve */ float xt; xt = x0; x0 = TX(xt, y0); y0 = TY(xt, y0); xt = x1; x1 = TX(xt, y1); y1 = TY(xt, y1); xt = x2; x2 = TX(xt, y2); y2 = TY(xt, y2); xt = x3; x3 = TX(xt, y3); y3 = TY(xt, y3); } setLineBounds(&ep, x0, y0, x3, y3); setLineBounds(&cp, x1, y1, x2, y2); if (ep.left < h->real_mtx.left || ep.bottom < h->real_mtx.bottom || ep.right > h->real_mtx.right || ep.top > h->real_mtx.top || cp.left < h->real_mtx.left || cp.bottom < h->real_mtx.bottom || cp.right > h->real_mtx.right || cp.top > h->real_mtx.top) { /* Curve may extend bounds */ if (cp.left < ep.left || cp.right > ep.right) /* Grow left and/or right bounds */ setBezLimits(x0, x1, x2, x3, &ep.left, &ep.right); if (cp.bottom < ep.bottom || cp.top > ep.top) /* Grow top and/or bottom bounds */ setBezLimits(y0, y1, y2, y3, &ep.bottom, &ep.top); boundPoint(h, ep.left, ep.bottom); boundPoint(h, ep.right, ep.top); } h->x = x3; h->y = y3; }
static echld_bool_t parent_get_hello(echld_msg_type_t type, enc_msg_t* ba, void* data) { echld_t* c = (echld_t*)data; int err_id; char* err = NULL; switch (type) { case ECHLD_HELLO: PARENT_DBG((1,"Child[%d]: =>IDLE",c->chld_id)); c->state = IDLE; break; case ECHLD_ERROR: parent.dec->error(ba,&err_id,&err); break; case ECHLD_TIMED_OUT: err = g_strdup("timedout"); break; default: err = g_strdup_printf("Wrong MSG 'HELLO' expected, got '%s",TY(type)); break; } if (c->cb) c->cb(c->data,err); if (err) g_free(err); return TRUE; }
static echld_state_t reqh_snd(echld_t* c, echld_msg_type_t t, GByteArray* ba, echld_msg_cb_t resp_cb, void* cb_data) { int idx; reqh_t* r; int reqh_id = reqh_ids++; if (!c) { PARENT_DBG((1,"REQH_SND: No such child")); return 1; } idx = reqh_id_idx(c,-1); if (idx < 0) { reqh_t req; idx = c->reqs->len; g_array_append_val(c->reqs,req); } r = &(((reqh_t*)c->reqs->data)[idx]); r->reqh_id = reqh_id; r->cb = resp_cb; r->cb_data = cb_data; gettimeofday(&(r->tv),NULL); PARENT_DBG((4,"reqh_add: idx='%d'",idx)); PARENT_DBG((3,"REQH_SND: type='%s' chld_id=%d reqh_id=%d",TY(t), c->chld_id,reqh_id)); PARENT_SEND(ba,c->chld_id,t,reqh_id); if (ba) g_byte_array_free(ba,TRUE); /* do we? */ return reqh_id; }
static echld_bool_t hello_cb(echld_msg_type_t type, enc_msg_t* msg_buff, void* ud) { echld_init_t* init = (echld_init_t*)ud; char* err = NULL; int errnum = 0; if (init && init->dispatcher_hello_cb) { switch(type) { case ECHLD_ERROR: parent.dec->error(msg_buff, &errnum ,&err); break; case ECHLD_TIMED_OUT: err = g_strdup("timedout"); break; default: err = g_strdup_printf("Wrong MSG 'HELLO' expected, got '%s",TY(type)); break; case ECHLD_HELLO: break; } init->dispatcher_hello_cb(ud,err); if (err) g_free(err); } return TRUE; }
static int fun_gt (env_t * env, int args_nr, val_t * result, val_t * args) { if (TY (0) == TY_STRING || TY (1) == TY_STRING) { stringify (&args[0], 1); stringify (&args[1], 1); RESULTINT = strcmp (ARGSTR (0), ARGSTR (1)) > 0; } else { intify (&args[0]); intify (&args[1]); RESULTINT = ARGINT (0) > ARGINT (1); } return 0; }
/* Add move to path. */ static void glyphMove(abfGlyphCallbacks *cb, float x0, float y0) { abfMetricsCtx h = cb->direct_ctx; float x; float y; if (h->flags & ABF_MTX_TRANSFORM) { x = TX(x0, y0); y = TY(x0, y0); } else { x = x0; y = y0; } if (h->flags & SEEN_MOVE) boundPoint(h, x, y); else { /* Set bounds to first point */ h->real_mtx.left = h->real_mtx.right = x; h->real_mtx.bottom = h->real_mtx.top = y; } h->x = x0; h->y = y0; h->flags |= SEEN_MOVE; }
template <typename F> GpuFFTPlanCl<F>::GpuFFTPlanCl (const OpenCL::StubPool& pool, const cl::Device& device, csize_t size, csize_t batchCount, bool inPlace, bool outOfPlace, bool forward, bool backward, OpenCL::VectorAccounting& accounting) : GpuFFTPlan<F> (pool.context (), device, size, batchCount, inPlace, outOfPlace, forward, backward), tmp (pool, supportNonZeroOffsets ? this->batchSize () : 0, accounting, "GpuFFTPlanCl tmp") { TY(Dim3) dim; dim.x = Core::checked_cast<unsigned int> (size); dim.y = 1; dim.z = 1; cl_int error = CL_SUCCESS; plan = static_cast<void*> (VAL(CreatePlan) (this->context () (), dim, VAL(1D), VAL(InterleavedComplexFormat), &error)); cl::detail::errHandler (error, VAL(CreatePlanStr)); ASSERT (plan != NULL); }
/* Add line to path. */ static void glyphLine(abfGlyphCallbacks *cb, float x1, float y1) { abfMetricsCtx h = cb->direct_ctx; if (h->flags & ABF_MTX_TRANSFORM) boundPoint(h, TX(x1, y1), TY(x1, y1)); else boundPoint(h, x1, y1); h->x = x1; h->y = y1; }
for (;(*cookie)<imax;(*cookie)++) { if (((hdlr_t*)(c->handlers->data))[*cookie].type == t) { r = &( ((hdlr_t*)(c->handlers->data))[*cookie] ); (*cookie)++; break; } } return r; } static long parent_read_frame(guint8* b, size_t len, echld_chld_id_t chld_id, echld_msg_type_t t, echld_reqh_id_t reqh_id, void* data _U_) { echld_t* c = get_child(chld_id); GByteArray* ba = g_byte_array_new(); PARENT_DBG((1,"MSG_IN<- ch=%d t='%s' rh=%d",chld_id,TY(t),reqh_id)); g_byte_array_append(ba,b, (guint)len); if (c) { reqh_t* r = get_req(c, reqh_id); int i; hdlr_t* h; gboolean go_ahead = TRUE; if (r) { /* got that reqh_id */ if (r->cb) { go_ahead = r->cb(t,ba,r->cb_data); } r->reqh_id = -1; r->cb = NULL;
static int fun_eq (env_t * env, int args_nr, val_t * result, val_t * args) { if (TY (0) == TY_STRING || TY (1) == TY_STRING) { stringify (&args[0], 1); stringify (&args[1], 1); RESULTINT = strcmp (ARGSTR (0), ARGSTR (1)) == 0; } else if (TY (0) == TY_DIR && TY (1) == TY_DIR) RESULTINT = ARGDIR (0) == ARGDIR (1); else if (TY (0) == TY_ENTITY && TY (1) == TY_ENTITY) RESULTINT = ARGENTITY (0) == ARGENTITY (1); else if (TY (0) == TY_LOCATION && TY (1) == TY_LOCATION) RESULTINT = (ARGLOCATION (0).x == ARGLOCATION (1).x && ARGLOCATION (0).y == ARGLOCATION (1).y && ARGLOCATION (0).m == ARGLOCATION (1).m); else if (TY (0) == TY_AREA && TY (1) == TY_AREA) RESULTINT = ARGAREA (0) == ARGAREA (1); /* Probably not that great an idea... */ else if (TY (0) == TY_SPELL && TY (1) == TY_SPELL) RESULTINT = ARGSPELL (0) == ARGSPELL (1); else if (TY (0) == TY_INVOCATION && TY (1) == TY_INVOCATION) RESULTINT = ARGINVOCATION (0) == ARGINVOCATION (1); else { intify (&args[0]); intify (&args[1]); RESULTINT = ARGINT (0) == ARGINT (1); } return 0; }