Skip to content

CR_LOAD called on first update, contrary to what the documentation states. Is this correct? #60

@danielytics

Description

@danielytics

Hi,

In the documentation for CR_LOAD, it says:

This does not happen when a plugin is loaded for the first time as there is no state to restore;

However, I'm observing that it gets called on initial call to cr_plugin_update. Is this the expected behaviour (and the documentation is wrong)?

My test code:

// main.cpp
#define CR_HOST
#include <cr.h>

int main (int argc, char* argv[])
{
    cr_plugin ctx;
    cr_plugin_open(ctx, "./test.so");
    cr_plugin_update(ctx);
    cr_plugin_close(ctx);
    return 0;
}
// test.cpp
#include <cr.h>
#include <iostream>

CR_EXPORT int cr_main(cr_plugin* ctx, cr_op operation)
{
    switch (operation) {
        case CR_STEP:
        {
            std::cout << "STEP\n";
            break;
        }
        case CR_CLOSE:
        {
            std::cout << "CLOSE\n";
            break;
        }
        case CR_LOAD:
        {
            std::cout << "LOAD\n";
            break;
        }
        case CR_UNLOAD:
        {
            std::cout << "UNLOAD\n";
            break;
        }
    }
    return 0;
}

Compiled with:

clang++ -fPIC -Icr -c test.cpp -o test.o
clang++ -shared test.o -o test.so
clang++ -Icr -c main.cpp -o main.o
clang++ -ldl main.o -o main

Running ./main gives the output:

LOAD
STEP
CLOSE

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions