On 10 November 2016 at 18:49, Carsten Haitzler <ras...@rasterman.com> wrote:
> On Wed, 9 Nov 2016 12:14:36 -0200 Gustavo Sverzut Barbieri < > barbi...@gmail.com> > said: > > > Hi all, > > > > I'm using Eo extensively and its Eolian works well, great work. > > > > But one thing that I struggle in my examples is to translate > > enumerations to string and back. I have to repeat that similar code in > > my examples and I wonder if Eolian should generate them for me... I > > guess so, what's your take on that? > > > > Also, please add another marker for "enum" that informs it's a > > bitwise, we just document that, but would be nice to have a formal way > > to inform. Maybe also something in the pass/return of values, to > > specify if it takes a single or multiple. Like this: > > > > enum @bitwise Mode { > > read, [[ being bitwise, no values means (1 << 0)]] > > write, [[ 1<<1 is automatic]] > > } > > > > generates: > > const char *mode_str_to(enum Mode); // for single entry > > enum Mode mode_str_from(const char *Mode); // for single entry > > > > const char *mode_bitmask_str_to(unsigned Mode); // for many entry > > this one above is going to suck for bitwise. you'd have to generate a > biffer - > you couldn't sanely generate "all combinations" and compile theme except > for > very trivial examples. then the q is - what buffer is this? a single one > isnt > very usable. :( > > jpeg brought this up today. he might expand on this. :) > Yes. Based on raster's eina_freeq, we could create a temporary string API. An API that, unlike eina_tmpstr, does not require any manual free. By definition, a string would be valid only for the current scope. (with a small gotcha if ecore_main_loop_iterate is called). At the moment, eina_freeq is used for "safety" but I think some kind of garbage collected objects API could be useful, especially for strings. That way we could simply return const char* in many places without having to worry about static allocation, or requiring the user to free each string. > > > unsigned mode_bitmask_str_from (const char *Mode); // for many entry > > > > > > the bitmask_str_to() as 'const char*' may be painful since we'd have > > to generate all combinations as static const char, but it's easier to > > use. Allocating and returning a value could be an alternative. > and this is pretty "UGH" unless we have a sane way of dealing with returns > - > freeing is posible but makes usage a pain. :( > > printf("have: %s\n", bitmask_str_from(x)); > > :( cant do. need to store and free every time. :( > > > For methods we could use: > > > > class C () { > > methods { > > open { > > params { > > mode: bitmask<Mode>; > > } > > } > > mode_get { > > return: bitmask<Mode>; > > } > > } > > } > > > > This would generate functions that hints about mode to use but will > > take/return unsigned integers to avoid compilers saying the value > > doesn't exist in enum. > > > > > > -- > > Gustavo Sverzut Barbieri > > -------------------------------------- > > Mobile: +55 (16) 99354-9890 > > > > ------------------------------------------------------------ > ------------------ > > Developer Access Program for Intel Xeon Phi Processors > > Access to Intel Xeon Phi processor-based developer platforms. > > With one year of Intel Parallel Studio XE. > > Training and support from Colfax. > > Order your platform today. http://sdm.link/xeonphi > > _______________________________________________ > > enlightenment-devel mailing list > > enlightenment-devel@lists.sourceforge.net > > https://lists.sourceforge.net/lists/listinfo/enlightenment-devel > > > > > -- > ------------- Codito, ergo sum - "I code, therefore I am" -------------- > The Rasterman (Carsten Haitzler) ras...@rasterman.com > > > ------------------------------------------------------------ > ------------------ > Developer Access Program for Intel Xeon Phi Processors > Access to Intel Xeon Phi processor-based developer platforms. > With one year of Intel Parallel Studio XE. > Training and support from Colfax. > Order your platform today. http://sdm.link/xeonphi > _______________________________________________ > enlightenment-devel mailing list > enlightenment-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/enlightenment-devel > > -- Jean-Philippe André ------------------------------------------------------------------------------ Developer Access Program for Intel Xeon Phi Processors Access to Intel Xeon Phi processor-based developer platforms. With one year of Intel Parallel Studio XE. Training and support from Colfax. Order your platform today. http://sdm.link/xeonphi _______________________________________________ enlightenment-devel mailing list enlightenment-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-devel