Comments (5)
I get the following warning when I try your code:
error: incompatible type for argument 1 of ‘color_parse_str’
GET_STR(color_get_str), PARSE_STR(color_parse_str))
Indeed, color_parse_str expects a T* instead of a T:
bool color_parse_str(color_t *ptr, const char str[], const char **endptr) {
So your association between the operator and the method in the oplist shall be defined as:
PARSE_STR(color_parse_str M_IPTR)
(Later you can use also PARSE_STR(API_2(color_parse_str)) but it is still WIP and is not working for tuple)
from mlib.
I think the warning is different because I was using clang.
I'm not sure to understand your explanation. In m-core.h I can see parse_str methods where the first argument is something like type *
. Maybe this work if type is a M-LIB container (so an array[1]-type) but I can't imagine how to manage it with a native type.
Can you give some hint how to manage this using the actual API? Thanks
from mlib.
Ok, sorry I spotted only now the note on the usage of the M_IPTR keywork in the OPLIST definition.
I'm wondering what's the aim of the API_2 mechanism.
from mlib.
The API_* mechanism is a more general mechanism to adapt the call of the operator to the needs of the methods. It defines how to call effectively the method:
void method_by_ref(type out, ...); // API_0
void method_by_addr(type *out, ...); // API_2
out = method_by_ret_value(...); // API_4
API is not the right term for this, but I wasn't able to find the right term. API CALL ?
It is a WIP as it is not supported by all the library yet.
M_IPTR is the current way of doing it. But I wasn't able to generalize the trick used for this to support the method_by_ret_value.
In your example, you just need to write:
#define COLOR_OPLIST \
M_OPEXTEND(M_DEFAULT_OPLIST, OUT_STR(color_out_str), IN_STR(color_in_str), \
GET_STR(color_get_str), PARSE_STR(color_parse_str M_IPTR))
from mlib.
Ok, many thanks.
from mlib.
Related Issues (20)
- Compiler errors HOT 3
- README example not work HOT 3
- Add EMPLACE_TYPE support for B+TREE, DICT, RB-TREE, BUFFER, CONCURRENT HOT 3
- bitset: function for getting minimum index with bit set HOT 3
- Memory leak HOT 5
- How to define REALLOC in OPLIST? HOT 1
- Bug in list? HOT 1
- Allocator customization HOT 2
- How to define a set of pointer? HOT 1
- Github actions failure HOT 1
- Non-null array get() after reset() HOT 1
- Wrong implementation for set_cstr for bounded strings HOT 16
- M_EMPTY_P(max) doesn't work HOT 4
- BPTREEI_OPLIST2_P4 missing push definition?
- Is it actually possible to create a fixed-size looping buffer? HOT 10
- BUFFER_DEF / BUFFER_THREAD_UNSAFE: performance issue HOT 1
- RB-tree _it_from on root node HOT 1
- Memory issue with _pop_at function while using 2d arrays HOT 1
- string_t: extremely confusing methods names: string_clean and string_clear HOT 5
- Change _str suffix HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mlib.