Esempio n. 1
0
void find_dll_for_script(Branch* branch, caValue* resultOut)
{
    String* filename = (String*) branch_get_source_filename(branch);

    if (!is_string(filename)) {
        set_name(resultOut, name_Failure);
        return;
    }

    String dllFilename;
    copy(filename, &dllFilename);

    if (string_ends_with(&dllFilename, ".ca"))
        string_resize(&dllFilename, -3);

    //string_append(&dllFilename, DLL_SUFFIX);
    swap(&dllFilename, resultOut);
}
Esempio n. 2
0
Branch* find_module_from_filename(const char* filename)
{
    // O(n) search for a module with this filename. Could stand to be more efficient.
    for (int i=0; i < kernel()->length(); i++) {
        Term* term = kernel()->get(i);
        if (term->nestedContents == NULL)
            continue;

        caValue* branchFilename = branch_get_source_filename(nested_contents(term));
        if (branchFilename == NULL)
            continue;

        if (string_eq(branchFilename, filename))
            return nested_contents(term);
    }

    return NULL;
}