本文整理汇总了C++中CX_ASSERT函数的典型用法代码示例。如果您正苦于以下问题:C++ CX_ASSERT函数的具体用法?C++ CX_ASSERT怎么用?C++ CX_ASSERT使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CX_ASSERT函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cx_str_explode
cxu32 cx_str_explode (char **dst, cxu32 dstSize, const char *src, char delimiter)
{
CX_ASSERT (dst);
CX_ASSERT (src);
cxu32 count = 0;
const char *start = src;
const char *found = strchr (start, delimiter);
while (found)
{
CX_ASSERT (count < dstSize);
dst [count++] = cx_strdup (start, found - start);
start = found + 1;
found = strchr (start, delimiter);
}
CX_ASSERT (count < dstSize);
if (*start != '\0')
{
dst [count++] = cx_strdup (start, strlen (start));
}
return count;
}
示例2: CX_ASSERT
cxAtlas *cxAtlas::SetCoords(const cxArray *coords,const cxFrames *frames)
{
CX_ASSERT(!Size().IsZero(), "size not set");
cxInt size = frames->Num();
SetCapacity(size);
const cxInt *map = frames->Map();
for(cxInt i = 0;i < size;i++){
cxInt mapIdx = map[i];
CX_ASSERT(mapIdx < coords->Size(), "map idx error");
//get map tex
cxTexCoord *coord = coords->At(mapIdx)->To<cxTexCoord>();
if(coord->IsEmpty()){
continue;
}
//trimmed box
cxBoxPoint3F bp = coord->Trimmed(BoxPoint(), Size(), FlipX(), FlipY());
if(bp.Size().IsZero()){
continue;
}
//add render
cxBoxRender &render = renders.Inc();
render.SetVertices(bp);
render.SetColor(Color());
//get coord box
const cxBoxCoord2F &tbox = coord->BoxCoord(Pixel(), FlipX(), FlipY());
render.SetCoords(tbox);
}
return this;
}
示例3: CX_ASSERT
//support key.key key.0.0.1, max 8 level
static json_t *jsonGetJson(json_t *json,cxConstChars key)
{
CX_ASSERT(cxConstCharsOK(key), "key error");
json_t *rv = json_object_get(json, key);
if(rv != NULL){
return rv;
}
cxChars ckey = allocator->strdup(key);
cxInt num = 0;
cxChars ckeys[16];
cxChars src = ckey;
ckeys[num++] = src;
while (*src++ != '\0') {
if(*src != '.')continue;
CX_ASSERT(num < 16, ". opt too more");
ckeys[num++] = src + 1;
*src++ = '\0';
}
json_t *pv = json;
cxInt index = 0;
for(cxInt i=0; i < num;i ++){
cxConstChars ckey = ckeys[i];
if(cxKeyIsNumber(ckey, &index)){
rv = json_array_get(pv, index);
}else{
rv = json_object_get(pv, ckey);
}
if(rv == NULL)break;
pv = rv;
}
allocator->free(ckey);
return rv;
}
示例4: CX_ASSERT
const cx_colour *_ui_intrinsic_colour_get (const ui_intrinsic_t *intr, ui_widget_state_t wstate)
{
CX_ASSERT (intr);
CX_ASSERT ((wstate >= UI_WIDGET_STATE_NORMAL) && (wstate < NUM_UI_WIDGET_STATES));
return &intr->colour [wstate];
}
示例5: cx_str_utf8_to_unicode
cxu32 cx_str_utf8_to_unicode (cxu32 *dst, cxu32 dstSize, const char *utf8src)
{
cxu32 dstLen = 0;
cxu32 srcSize = strlen (utf8src); // data length
CX_ASSERT ((srcSize < dstSize) && "dstSize too small");
const cxu8 *src = (const cxu8 *) utf8src;
cxi32 ss = srcSize;
#if CX_DEBUG
cxi32 srcCount = 0;
#endif
while ((ss > 0) && (dstLen < (dstSize - 1)))
{
cxu32 ch = 0;
cxu32 offset = cx_str_utf8_decode (&ch, src);
CX_ASSERT (dstLen < dstSize);
dst [dstLen++] = ch;
src += offset;
ss -= offset;
#if CX_DEBUG
srcCount += offset;
#endif
}
dst [dstLen] = 0;
return dstLen;
}
示例6: _ui_intrinsic_colour_set
void _ui_intrinsic_colour_set (ui_intrinsic_t *intr, ui_widget_state_t wstate, const cx_colour *colour)
{
CX_ASSERT (intr);
CX_ASSERT (colour);
CX_ASSERT ((wstate >= UI_WIDGET_STATE_NORMAL) && (wstate < NUM_UI_WIDGET_STATES));
intr->colour [wstate] = *colour;
}
示例7: _ui_intrinsic_texture_set
void _ui_intrinsic_texture_set (ui_intrinsic_t *intr, ui_widget_state_t wstate, cx_texture *texture)
{
CX_ASSERT (intr);
CX_ASSERT (texture);
CX_ASSERT ((wstate >= UI_WIDGET_STATE_NORMAL) && (wstate < NUM_UI_WIDGET_STATES));
intr->texture [wstate] = texture;
}
示例8: CX_ASSERT
cxArray *cxArray::Swap(cxInt src,cxInt dst)
{
CX_ASSERT(src >= 0 && src < Size(), "src out bound");
CX_ASSERT(dst >= 0 && dst < Size(), "dst out bound");
cxObject **ptr = (cxObject **)mv.data();
CX_SWAP_VAR(ptr[src], ptr[dst]);
return this;
}
示例9: input_register_gesture_event_callback
void input_register_gesture_event_callback (input_gesture_type type, input_gesture_event_callback fn)
{
CX_ASSERT (g_initialised);
CX_ASSERT ((type > INPUT_GESTURE_TYPE_INVALID) && (type < NUM_INPUT_GESTURE_TYPES));
CX_ASSERT (!cx_list2_exists (&g_gestureEventCallbacks [type], fn));
cx_list2_insert_back (&g_gestureEventCallbacks [type], fn);
}
示例10: input_register_touch_event_callback
void input_register_touch_event_callback (input_touch_type type, input_touch_event_callback fn)
{
CX_ASSERT (g_initialised);
CX_ASSERT ((type > INPUT_TOUCH_TYPE_INVALID) && (type < NUM_INPUT_TOUCH_TYPES));
CX_ASSERT (!cx_list2_exists (&g_touchEventCallbacks [type], fn));
cx_list2_insert_back (&g_touchEventCallbacks [type], fn);
}
示例11: cx_str_utf8_decode
cxu32 cx_str_utf8_decode (cxu32 *dst, const cxu8 *src)
{
CX_ASSERT (dst);
CX_ASSERT (src);
cxu32 ch = 0;
cxu32 offset = 0;
if ((src [0] & UTF8_BYTE6) == UTF8_BYTE6)
{
offset = 6;
}
else if ((src [0] & UTF8_BYTE5) == UTF8_BYTE5)
{
offset = 5;
}
else if ((src [0] & UTF8_BYTE4) == UTF8_BYTE4)
{
ch = ((src [0] & 0x07) << 18) |
((src [1] & 0x3f) << 12) |
((src [2] & 0x3f) << 6) |
((src [3] & 0x3f));
offset = 4;
}
else if ((src [0] & UTF8_BYTE3) == UTF8_BYTE3)
{
ch = ((src [0] & 0x0f) << 12) |
((src [1] & 0x3f) << 6) |
((src [2] & 0x3f));
offset = 3;
}
else if ((src [0] & UTF8_BYTE2) == UTF8_BYTE2)
{
ch = ((src [0] & 0x1f) << 6) |
((src [1] & 0x3f));
offset = 2;
}
else if (src [0] < UTF8_BYTE1)
{
ch = (src [0]);
offset = 1;
}
else
{
offset = strlen ((const char *) src);
CX_ERROR ("Invalid UTF8 character");
}
*dst = ch;
return offset;
}
示例12: ui_do_button
bool ui_do_button (ui_context_t *context, const ui_button_t *button)
{
CX_ASSERT (context);
CX_ASSERT (button);
bool ret = false;
bool isHot = (button->elem == context->hover);
bool isActive = (button->elem == context->active);
if (isHot)
{
// is touch event end, return true;
if (context->event.type == INPUT_TOUCH_TYPE_END)
{
bool isInside = ui_touch_hit (context, button->elem);
if (isInside)
{
context->active = button->elem;
ret = true;
}
}
// render hover skin
ui_render_element (button->elem);
}
else if (isActive)
{
// render active skin
ui_render_element (button->elem);
}
else
{
// is touch event begin, return true;
if (context->event.type == INPUT_TOUCH_TYPE_BEGIN)
{
// if touch event inside, set hover
bool isInside = ui_touch_hit (context, button->elem);
if (isInside)
{
context->hover = button->elem;
}
}
// render normal skin
ui_render_element (button->elem);
}
return ret;
}
示例13: input_process_cached_events
static void input_process_cached_events (void)
{
CX_ASSERT (g_initialised);
if (g_gestureEventsCount > 0)
{
g_touchEventsCount = 0;
}
// gesture events
for (unsigned i = 0, c = g_gestureEventsCount; i < c; ++i)
{
const input_gesture_event *gestureEvent = &g_gestureEventsCache [i];
cx_list2 *list = &g_gestureEventCallbacks [gestureEvent->type];
cx_list2_node *cb = list->head;
while (cb)
{
CX_ASSERT (cb->data);
input_gesture_event_callback fn = (input_gesture_event_callback) cb->data;
fn (gestureEvent);
cb = cb->next;
}
}
// touch events
for (unsigned i = 0, c = g_touchEventsCount; i < c; ++i)
{
const input_touch_event *touchEvent = &g_touchEventsCache [i];
cx_list2 *list = &g_touchEventCallbacks [touchEvent->type];
cx_list2_node *cb = list->head;
while (cb)
{
CX_ASSERT (cb->data);
input_touch_event_callback fn = (input_touch_event_callback) cb->data;
fn (touchEvent);
cb = cb->next;
}
}
}
示例14: cxJsonCreate
cxJson cxJsonCreate(cxString json)
{
CX_ASSERT(json != NULL, "args error");
cxJson this = CX_CREATE(cxJson);
json_error_t error = {0};
if(cxStringLength(json) <= 0){
return this;
}
this->json = json_loadb(cxStringBody(json), cxStringLength(json), JSON_DECODE_ANY, &error);
CX_ASSERT(this->json != NULL, "cxJson load error (%d:%d) %s:%s",error.line,error.column,error.source,error.text);
return this;
}
示例15: CX_FATAL_ASSERT
static ui_intrinsic_t *ui_ctx_input_hit (ui_context_t *ctx, const cx_vec2 *point, bool ext)
{
CX_FATAL_ASSERT (ctx);
CX_ASSERT (point);
ui_intrinsic_t *hit = NULL;
cx_list2_node *intrNode = ctx->intrList.tail;
float tx = ctx->canvasWidth * point->x;
float ty = ctx->canvasHeight * point->y;
while (intrNode)
{
ui_intrinsic_t *intr = (ui_intrinsic_t *) intrNode->data;
CX_ASSERT (intr);
if (intr->enable)
{
float w = intr->dimension.x;
float h = intr->dimension.y;
float x = intr->position.x;
float y = intr->position.y;
if (ext && (ctx->hover == intr))
{
const float ex = 4.0f;
const float ey = 6.0f;
w += ex;
h += ey;
x -= (ex * 0.5f);
y -= (ey * 0.5f);
}
if ((tx >= x) && (tx <= (x + w)))
{
if ((ty >= y) && (ty <= (y + h)))
{
hit = intr;
break;
}
}
}
intrNode = intrNode->prev;
}
return hit;
}