Beispiel #1
0
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);

        Name label = as_int(list_get(action, 0));
        ca_assert(label != name_None);

        switch (label) {
        case name_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 name_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");
        }
    }
}
Beispiel #2
0
NativePatch* insert_native_patch(World* world, Value* name)
{
    NativePatch* patch = find_existing_native_patch(world, name);

    if (patch != NULL)
        return patch;

    patch = add_native_patch(world);
    set_value(&patch->name, name);

    // Make sure this module is loaded by a global name. The native patch won't
    // work if the module has only been loaded by filename or relative name.
    load_module(world, NULL, name);

    return patch;
}
Beispiel #3
0
CIRCA_EXPORT caNativePatch* circa_create_native_patch(caWorld* world, const char* name)
{
    return add_native_patch(world, name);
}