Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cpp: export id #18

Open
wants to merge 1 commit into
base: continious-integration
Choose a base branch
from
Open

cpp: export id #18

wants to merge 1 commit into from

Commits on Sep 1, 2017

  1. cpp: export id

    Introduce special behavior for the id class with two features: disallow unnamed
    ids by construction, ensure that ids remain value-comparable.
    
    Generally, isl_id behaves like a reference-counted smart pointer to the name
    string and the user pointer. Additionally, it guarantees that ids with
    identical names and user pointers are pointer-comparable. An id object can have
    a "user_free" callback that is called when the reference counter reaches zero.
    Existing mechanism for callbacks does not apply to "user_free" callbacks as it
    modifies the user object passed to the callback. In particular, it creates a
    new object of a custom type in each call of the function that takes a callback
    and passes it instead of the original user pointer. Therefore, two ids
    constructed independently from the same user pointer would no longer be
    pointer-comparable. Therefore, one must pass the user pointer directly. The
    "user_free" callback must in turn remain a C function pointer. An alternative
    solution that supports std::function would require maintaining a map between
    user pointers and custom objects that were passed when constructing isl_ids;
    however, it would break direct comparability between isl_ids constructed using
    C and C++ interface.
    
    Support void and void * as return and argument types in the generator. Modify
    the generator to inject custom method declarations and definitions in the class
    based on the class name. Inject custom constructors, utility methods and
    comparison operators for isl::id. Custom constructors take either a name or a
    user pointer, or both. The "user_free" callback can be optionally provided in
    constructors or set up separately. This callback must be a C function pointer
    because it will be called from the C code. The user pointer is passed as
    void *, which can be replaced by template methods in the future, except in the
    "user_free" callback.  The "set_user_free" function is injected so as to avoid
    handling a special case in callback generation.
    
    Signed-off-by: Oleksandr Zinenko <git@ozinenko.com>
    ftynse committed Sep 1, 2017
    Configuration menu
    Copy the full SHA
    ee195ec View commit details
    Browse the repository at this point in the history