当前位置: 首页>>代码示例>>C++>>正文


C++ ca_assert函数代码示例

本文整理汇总了C++中ca_assert函数的典型用法代码示例。如果您正苦于以下问题:C++ ca_assert函数的具体用法?C++ ca_assert怎么用?C++ ca_assert使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了ca_assert函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: find_block_that_exit_point_will_reach

Block* find_block_that_exit_point_will_reach(Term* term)
{
    ca_assert(is_exit_point(term));

    Block* block = term->owningBlock;

    // 'return' exits to nearest major block.
    if (term->function == FUNCS.return_func) {
        while (is_minor_block(block)) {
            Block* parent = get_parent_block(block);
            if (parent == NULL)
                return block;

            block = parent;
        }
        return block;
    }

    // 'case_condition_bool' exits the current if-block.
    if (term->function == FUNCS.case_condition_bool)
        return get_parent_block(term->owningBlock);

    // Otherwise, exit to nearest for-loop.
    while (!is_for_loop(block) && !is_while_loop(block)) {
        Block* parent = get_parent_block(block);
        if (parent == NULL)
            return block;

        block = parent;
    }
    return block;
}
开发者ID:andyfischer,项目名称:circa,代码行数:32,代码来源:control_flow.cpp

示例2: list_remove_index

void list_remove_index(caValue* list, int index)
{
    ca_assert(list->value_type->storageType == name_StorageTypeList);
    ListData* data = (ListData*) list->value_data.ptr;
    list_remove_index(data, index);
    list->value_data.ptr = data;
}
开发者ID:RickMoynihan,项目名称:circa,代码行数:7,代码来源:list.cpp

示例3: migrate_block

void migrate_block(Block* target, Migration* migration)
{
    ca_assert(target != migration->oldBlock);

    if (target == migration->newBlock)
        return;

    // Store a cache of lookups that we've made in this call.
    TermMap cache;

    for (BlockIterator it(target); it; ++it) {

        Term* term = *it;

        // Iterate through each "dependency", which includes the function & inputs.
        for (int i=0; i < term->numDependencies(); i++) {
            Term* ref = term->dependency(i);
            Term* newRef = NULL;

            if (cache.contains(ref)) {
                newRef = cache[ref];
            } else {

                // Lookup and save result in cache
                newRef = migrate_term_pointer(ref, migration);
                cache[ref] = newRef;
            }

            // Possibly rebind
            if (newRef != ref)
                term->setDependency(i, newRef);
        }
    }
}
开发者ID:ShenTensen,项目名称:circa,代码行数:34,代码来源:migration.cpp

示例4: handle_release

void handle_release(caValue* value)
{
    HandleData* container = as_handle(value);
    ca_assert(container != NULL);

    container->refcount--;

    // Release data, if this is the last reference.
    if (container->refcount <= 0) {

        // Find the type's release function (if any), and call it.
        Term* releaseMethod = find_method(NULL, value->value_type, "release");
        if (releaseMethod != NULL) {
            Stack stack;
            push_frame(&stack, function_contents(releaseMethod));
            caValue* inputSlot = get_input(&stack, 0);

            // Don't copy this value, otherwise we'll get in trouble when the copy
            // needs to be released.
            swap(value, inputSlot);

            run_interpreter(&stack);

            swap(value, inputSlot);
        }

        free(container);
    }
}
开发者ID:arn-e,项目名称:circa,代码行数:29,代码来源:handle.cpp

示例5: log_finish

void log_finish()
{
    ca_assert(g_logInProgress);
    fprintf(g_logFile, ")\n");
    g_logInProgress = false;
    g_logArgCount = 0;
}
开发者ID:ShenTensen,项目名称:circa,代码行数:7,代码来源:debug.cpp

示例6: modify_branch_so_that_state_access_is_indexed

void modify_branch_so_that_state_access_is_indexed(Branch* branch, int index)
{
    Term* stateInput = find_state_input(branch);
    if (stateInput == NULL)
        return;

    // If the state output is connected directly to state input, then do nothing.
    Term* stateOutput = find_state_output(branch);

    if (stateOutput->input(0) == stateInput)
        return;

    Term* unpackList = apply(branch, FUNCS.unpack_state_from_list, TermList(stateInput));
    unpackList->setIntProp("index", index);
    move_after_inputs(unpackList);

    for (int i=0; i < stateInput->users.length(); i++) {
        Term* term = stateInput->users[i];
        if (term == unpackList)
            continue;
        remap_pointers_quick(term, stateInput, unpackList);
    }

    Term* stateResult = stateOutput->input(0);
    ca_assert(stateResult != NULL);

    Term* packList = apply(branch, FUNCS.pack_state_to_list,
                           TermList(stateInput, stateResult));
    packList->setIntProp("index", index);
    packList->setBoolProp("final", true);
    set_input(stateOutput, 0, packList);
    move_after(packList, stateResult);
}
开发者ID:levelplane,项目名称:circa,代码行数:33,代码来源:if_block.cpp

示例7: find_output_term_for_state_field

// For the given field name
static Term* find_output_term_for_state_field(Branch* branch, const char* fieldName, int position)
{
    Term* result = find_from_unique_name(branch, fieldName);

    // For declared state, the result is the last term with the given name
    if (result->function == FUNCS.declared_state) {
        return find_local_name(branch, result->name.c_str(), position);
    }

    ca_assert(result != NULL);

    // This term might be the actual state result, or the state result might be
    // found in an extra output. Look around and see if this term has a stateful
    // extra output.
    for (int outputIndex=0;; outputIndex++) {
        Term* extraOutput = get_extra_output(result, outputIndex);
        if (extraOutput == NULL)
            break;

        if (is_state_output(extraOutput))
            return extraOutput;
    }

    return result;
}
开发者ID:levelplane,项目名称:circa,代码行数:26,代码来源:stateful_code.cpp

示例8: list_resize

void list_resize(caValue* list, int size)
{
    ca_assert(list->value_type->storageType == name_StorageTypeList);
    ListData* data = (ListData*) list->value_data.ptr;
    data = list_resize(data, size);
    list->value_data.ptr = data;
}
开发者ID:RickMoynihan,项目名称:circa,代码行数:7,代码来源:list.cpp

示例9: file_watch_trigger_actions

void file_watch_trigger_actions(World* world, FileWatch* watch)
{
    // Walk through each action and execute it.
    for (int i = 0; i < list_length(&watch->onChangeActions); i++) {
        caValue* action = list_get(&watch->onChangeActions, i);

        Symbol label = first_symbol(action);
        ca_assert(label != sym_None);

        switch (label) {
        case sym_NativePatch: {
            caValue* moduleName = list_get(action, 1);

            NativePatch* nativeModule = add_native_patch(world, as_cstring(moduleName));
            native_patch_load_from_file(nativeModule, as_cstring(&watch->filename));
            native_patch_finish_change(nativeModule);
            break;
        }
        case sym_PatchBlock: {
            // Reload this code block.
            caValue* moduleName = list_get(action, 1);
            load_module_file(world, as_cstring(moduleName), as_cstring(&watch->filename));
            break;
        }
        default:
            internal_error("unrecognized file watch action");
        }
    }
}
开发者ID:arn-e,项目名称:circa,代码行数:29,代码来源:file_watch.cpp

示例10: if_block_create_input_placeholders_for_outer_pointers

void if_block_create_input_placeholders_for_outer_pointers(Term* ifCall)
{
    Branch* contents = nested_contents(ifCall);
    TermList outerTerms;

    // Find outer pointers across each case
    for (CaseIterator it(contents); it.unfinished(); it.advance()) {
        list_outer_pointers(nested_contents(it.current()), &outerTerms);
    }

    ca_assert(ifCall->numInputs() == 0);

    // Create input placeholders and add inputs for all outer pointers
    for (int i=0; i < outerTerms.length(); i++) {
        Term* outer = outerTerms[i];

        set_input(ifCall, i, outer);
        Term* placeholder = append_input_placeholder(nested_contents(ifCall));
        rename(placeholder, outer->name);

        // Go through each case and repoint to this new placeholder
        for (CaseIterator it(contents); it.unfinished(); it.advance()) {
            remap_pointers_quick(nested_contents(it.current()), outer, placeholder);
        }
    }
}
开发者ID:levelplane,项目名称:circa,代码行数:26,代码来源:if_block.cpp

示例11: ca_context_cache_full

/**
 * ca_context_cache_full:
 * @c: The context to use for uploading.
 * @p: The property list for this event sound.
 *
 * Upload the specified sample into the server and attach the
 * specified properties to it. Similar to ca_context_cache() but takes
 * a ca_proplist instead of a variable number of arguments.
 *
 * If the backend doesn't support caching sound samples this function
 * will return CA_ERROR_NOTSUPPORTED.
 *
 * Returns: 0 on success, negative error code on error.
 */
int ca_context_cache_full(ca_context *c, ca_proplist *p) {
    int ret;

    ca_return_val_if_fail(!ca_detect_fork(), CA_ERROR_FORKED);
    ca_return_val_if_fail(c, CA_ERROR_INVALID);
    ca_return_val_if_fail(p, CA_ERROR_INVALID);

    ca_mutex_lock(c->mutex);

    ca_return_val_if_fail_unlock(ca_proplist_contains(p, CA_PROP_EVENT_ID) ||
                                 ca_proplist_contains(c->props, CA_PROP_EVENT_ID), CA_ERROR_INVALID, c->mutex);

    if ((ret = context_open_unlocked(c)) < 0)
        goto finish;

    ca_assert(c->opened);

    ret = driver_cache(c, p);

finish:

    ca_mutex_unlock(c->mutex);

    return ret;
}
开发者ID:Ecstalionos,项目名称:libcanberra-vizaudio,代码行数:39,代码来源:common.c

示例12: as_cstring

const char* as_cstring(caValue* value)
{
    ca_assert(value->value_type->storageType == sym_StorageTypeString);
    StringData* data = (StringData*) value->value_data.ptr;
    if (data == NULL)
        return "";
    return data->str;
}
开发者ID:arn-e,项目名称:circa,代码行数:8,代码来源:string_type.cpp

示例13: list_insert

caValue* list_insert(caValue* list, int index)
{
    ca_assert(list->value_type->storageType == name_StorageTypeList);
    ListData* data = (ListData*) list->value_data.ptr;
    caValue* result = list_insert(&data, index);
    list->value_data.ptr = data;
    return result;
}
开发者ID:RickMoynihan,项目名称:circa,代码行数:8,代码来源:list.cpp

示例14: ca_vorbis_get_rate

unsigned ca_vorbis_get_rate(ca_vorbis *v) {
        const vorbis_info *vi;
        ca_assert(v);

        ca_assert_se(vi = ov_info(&v->ovf, -1));

        return (unsigned) vi->rate;
}
开发者ID:5Ecur1ty,项目名称:libcanberra,代码行数:8,代码来源:read-vorbis.c

示例15: test_handle_find_free_slot

int test_handle_find_free_slot()
{
    for (int i=0; i < g_testHandleSlots; i++)
        if (!g_testHandleAllocated[i])
            return i;
    ca_assert(false);
    return 0;
}
开发者ID:arn-e,项目名称:circa,代码行数:8,代码来源:internal_debug.cpp


注:本文中的ca_assert函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。