Skip to content

Conversation

@ftynse
Copy link
Member

@ftynse ftynse commented Sep 1, 2017

Implement iterators for lists. All iterator code is in isl.h.top. Generator only needs to inject a typedef and begin/end methods.

Not sure if we can use C++11 range-based for in the tests so did not do this.

Depends on #18 #19. Addresses #5.

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 <[email protected]>
@ftynse ftynse changed the title List iterators [WIP] List iterators Sep 1, 2017
@tobiasgrosser
Copy link
Member

First, yes you can use C++11. The bindings are C++11 and later.

@ftynse
Copy link
Member Author

ftynse commented Sep 1, 2017 via email

@tobiasgrosser
Copy link
Member

Maybe describe this in doc/interface

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants