Commit Graph

439 Commits

Author SHA1 Message Date
Felipe Magno de Almeida 8d18009419 eolian: Add -e parameter to pass export symbol to eolian generator
Summary:
Eolian generator must have a parameter so it can generate the correct
symbol export/import macro for the API generated.

This makes it possible to define the symbols as being local to a
single DSO without the need to guard the generated headers or
generated source files with #define and #undef preprocessor
statements.

=  The Rationale =

This patch is from a series of patches to rename EAPI symbols to
specific library DSOs.

EAPI was designed to be able to pass
`__attribute__ ((visibility ("default")))` for symbols with
GCC, which would mean that even if -fvisibility=hidden was used
when compiling the library, the needed symbols would get exported.

MSVC __almost__ works like GCC (or mingw) in which you can
declare everything as export and it will just work (slower, but
it will work). But there's a caveat: global variables will not
work the same way for MSVC, but works for mingw and GCC.

For global variables (as opposed to functions), MSVC requires
correct DSO visibility for MSVC: instead of declaring a symbol as
export for everything, you need to declare it as import when
importing from another DSO and export when defining it locally.

With current EAPI definitions, we get the following example
working in mingw and MSVC (observe it doesn't define any global
variables as exported symbols).

Example 1:
dll1:
```
EAPI void foo(void);

EAPI void bar()
{
  foo();
}
```
dll2:
```
EAPI void foo()
{
  printf ("foo\n");
}
```

This works fine with API defined as __declspec(dllexport) in both
cases and for gcc defining as
`__atttribute__((visibility("default")))`.

However, the following:
Example 2:

dll1:

```
EAPI extern int foo;
EAPI void foobar(void);

EAPI void bar()
{
  foo = 5;
  foobar();
}
```

dll2:

```
EAPI int foo = 0;
EAPI void foobar()
{
  printf ("foo %d\n", foo);
}
```

This will work on mingw but will not work for MSVC. And that's why
LIBAPI is the only solution that works for MSVC.

Co-authored-by: João Paulo Taylor Ienczak Zanette <jpaulotiz@gmail.com>
Co-authored-by: Lucas Cavalcante de Sousa <lucks.sousa@gmail.com>
Co-authored-by: Ricardo Campos <ricardo.campos@expertise.dev>

Reviewers: q66, vtorri, woohyun, jptiz, lucas

Reviewed By: vtorri, lucas

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D12197
2020-12-04 10:35:35 -03:00
Marcel Hollerbach a931e41823 efl: make all _class_get() functions const
please note, not the return type, but the function.
When appending __attribute__((const)) to a function, the compiler is
told that its enough to call this function once in a function.

This is quite often happening when we are efl_data_scope_get and
efl_super in a function that is different from a implemented function.

The compiler now starts to remove the calls that aggressivly that we
need to ensure that these calls are not removed, which means, the static
function calls, and the eo init are now checking the return value of
these functions, to ensure that they are called.

Please note that you now have to be carefull when your app calls
eo_shutdown, if it does so, you *must* call it at the end of a function,
or never call class_get after that anymore.

Overall this improves elm test runs 0.1s which is fair i guess, the main
thing that is faster is textrendering, where is also the point where
this is the most beneficial.

Please note, this replaces 42 occurences of double _class_get() ... THAT
is a sign!

Reviewed-by: Stefan Schmidt <stefan@datenfreihafen.org>
Reviewed-by: Daniel Kolesa <daniel@octaforge.org>
Differential Revision: https://phab.enlightenment.org/D12057
2020-07-20 11:27:53 +02:00
Daniel Kolesa b850c44653 eolian_gen: mark empty setter value params as unused 2020-04-28 19:50:45 +02:00
Daniel Kolesa 2a9d28291b eolian_gen: hack around function pointers generating unused params 2020-04-28 19:50:45 +02:00
Daniel Kolesa a7d5b089da eolian_gen: utilize c_name instead of name for generation
This will make generated output properly respect the @c_name tags.
2020-01-10 20:19:47 +01:00
Daniel Kolesa cf3ec7473b eolian_gen: fix fallback 0 default values for slices 2019-12-02 12:09:50 +01:00
Lauro Moura d4d9ecc92f eolian: Imply @no_unused if @move in return.
Summary:
This makes sure the user is warned if it ignores a return value that
could potentially be a memory leak.

This also makes possible to use `value {}` blocks with `@move` instead
of value-less properties with `@no_unused`.

Also removed the `@move` from canvas_text_async_layout as it is ignored
in the only place it is used.

Reviewers: q66

Reviewed By: q66

Subscribers: #reviewers, #committers, bu5hm4n, felipealmeida, cedric, segfaultxavi

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D10601
2019-11-05 16:54:17 -03:00
Lauro Moura 86191b02c7 eolian: Leave default text for libeolian users
Summary:
Instead of setting the default text at the library level, keep the
summary empty if nothing is provided.

The libeolian users them are free to check if the summary was actually
empty or a placeholder text was added.

ref T8309

Test Plan: Run attached tests

Reviewers: q66, segfaultxavi

Subscribers: cedric, brunobelo, #reviewers, felipealmeida, #committers

Tags: #efl

Maniphest Tasks: T8309

Differential Revision: https://phab.enlightenment.org/D10285
2019-10-09 16:18:30 +02:00
Daniel Kolesa b0ee540ec9 eolian: rename param direction enum and fields for consistency 2019-09-26 16:56:13 +02:00
Daniel Kolesa 92da64a532 eolian: remove support for globals
This was meant to happen but did not previously happen. It is not
ideal to do it now but better do it while we still can.

In short, this removes one half of the variables API (keeps
constants as they are) and repurposes the API to be only for
constants. This is also better for consistency to match errors.
2019-09-24 18:27:37 +02:00
Daniel Kolesa 72698aa6f5 eolian: always allow implementation for eot files
This is so the build system can unconditionally generate .eot.c
without worrying whether there's something to generate.
2019-09-24 18:27:37 +02:00
Daniel Kolesa 53a3326ddc eolian: rename any_value_ptr -> any_value_ref for consistency 2019-09-20 18:03:39 +02:00
Daniel Kolesa 266fd9bb36 eolian: support complex monospace syntax $[...]
This is to allow monospace bits with periods, commas and other
non-alphabetical characters. Newlines are not supported (they end
the block) and escapes are supported (for ]).

Fixes T8213.
2019-09-13 16:58:49 +02:00
Daniel Kolesa a5c7f92a52 eolian: fix default value handling for @by_ref types
We must check all pointerness first, and append NULL as default
when that applies, because @by_ref is not carried in the typedecl
info. Therefore, it would result in a false positive and try to
make a zeroed struct, which we don't want.
2019-09-10 14:25:03 +02:00
Daniel Kolesa 267c57d0f1 eolian: remove second parameter for eolian_type_c_type_get
This has been replaced by newer APIs.
2019-09-09 18:26:49 +02:00
Daniel Kolesa cb2b6d666c eolian_gen: make errors compile/work
This is not thread safe, but I don't see any better way out for
now. We'd probably need a different error API for that.

Ref T6890
2019-09-06 18:02:50 +02:00
Daniel Kolesa 04b0321bea eolian: update C generator to respect by_ref as well as tests 2019-09-05 15:19:28 +02:00
Daniel Kolesa 6751f011c1 eolian: remove the expression eval_type API
This is unnecessary because for all contexts where type is
relevant the validator already makes sure the type and expression
match correctly, so you don't ever need to re-validate it. If you
are doing a generic case and are not sure, just use MASK_ALL.
2019-09-04 18:02:47 +02:00
Daniel Kolesa 6efd0012cf eolian_gen: do not generate reflection for ref-returns 2019-09-03 16:51:57 +02:00
Daniel Kolesa 2377a2c667 eolian_gen: use new is_move APIs to check ownership transfers 2019-09-02 15:24:14 +02:00
Daniel Kolesa 2f147f2725 eolian: rename is_class api for functions to is_static
Still needs restriction to classes only etc to be done later.

Ref https://phab.enlightenment.org/T8118
Ref https://phab.enlightenment.org/T7675
2019-08-16 16:33:37 +02:00
Daniel Kolesa 1530d0386c eolian_gen: generate freefuncs for strbuf/binbuf 2019-07-30 15:57:52 +02:00
Marcel Hollerbach 3eb7b3793b eolian: start to express ownership transfere
before @owned was not even expressed in the api definitions of the
generated APIs, this adds support for it.

@owned is now expressed with EFL_TRANSFER_OWNERSHIP in a arguments. And
that preprocessor directive is documented.

Reviewed-by: Daniel Kolesa <daniel@octaforge.org>
Differential Revision: https://phab.enlightenment.org/D9369
2019-07-23 18:09:36 +02:00
Daniel Kolesa 61f39eef49 eolian: remove API to get freefunc of type
This is not supported anymore. For now, the syntax is kept
around because of broken C++ tests, but afterwards it will
also be removed.
2019-07-08 16:06:42 +02:00
Daniel Kolesa 38223ed693 eolian_gen: remove reliance on builtin freefuncs 2019-07-08 16:06:42 +02:00
Daniel Kolesa 2a1fa5d2aa eolian_gen: introduce C generation support for error types
ref T6890
2019-07-08 16:06:42 +02:00
Daniel Kolesa 13ddc5dbc1 eolian: rename @warn_unused and its associated API
@warn_unused in syntax is now called @no_unused - this is because
"warning about unused" is a C thing (or rather, an extension to C)
and various languages might want to use stricter behavior for this.

Its associated API does the reverse now - it lets you query whether
being unused is allowed at all. This is to match future behavior
of Eolian (once it supports versioning) that will likely reverse it.

@feature
2019-05-26 17:41:22 +02:00
Daniel Kolesa d0fed247bb eolian: remove param @nonull
This has been deprecated for a while and is not strictly necessary
- as a part of an effort to stabilize Eolian, remove this. Eolian
will eventually gain support for versioning and use a reversed
behavior (i.e. no NULL by default), but the API it wlll use for
that will be very different. Features can always be added, it's
much harder to drop them.

@feature
2019-05-26 17:25:15 +02:00
Daniel Kolesa e5c9f5e76f eolian: rename eolian_event_c_name_get
This is for consistency with the new eolian_class_c_macro_get
as well as for better clarity, as c_name_get is already provided
by Object and refers to something else.
2019-05-16 15:57:39 +02:00
Daniel Kolesa b3a870c7bb eolian: rename eolian_typedecl_enum_field_c_name_get
This is to allow for better object oriented APIs, as the `c_name`
field would be inherited from Object. This also makes it more
clear in C.
2019-05-16 15:52:46 +02:00
Daniel Kolesa 4ab1f2388e eolian: add API to retrieve the C name of an object
This is to prepare for type/class renaming support. This adds
the necessary API to retrieve C-specific names. Other refactoring
is necessary elsewhere for now.

This also renames the old API eolian_class_c_name_get to
eolian_class_c_macro_get to avoid conflict as well as clarify
the intention.
2019-05-16 15:43:52 +02:00
Daniel Kolesa db57523e78 eolian: refactor parsing API and path handling
This splits the eolian_file_parse API into two, one for parsing
files already present in the database (always by filename) and
one for parsing paths.

It fixes several bugs/leaks on the way (incorrect use of
stringshare etc.) as well as adds checking for whether there
are no conflicting filenames at scan time, for free. That means
it is now no longer possible to scan two paths which have an eo
or eot file of the same name in them.

It should also be faster now.

It also fixes T7820.

@fix
2019-05-03 17:06:49 +02:00
Vincent Torri 7db4714db6 replace strndup with eina_strndup, remove strndup definition in evil and elm_test_dnd
Test Plan: compilation

Reviewers: cedric, zmike, raster

Subscribers: #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D8814
2019-05-03 13:13:57 +01:00
Daniel Kolesa 7807f7750f eolian_gen: remove support for legacy header file generation 2019-04-18 18:10:45 +02:00
Christopher Michael 62bea1701c eolian: Fix resource leak
Summary:
Small patch to fix a resource leak detected by Coverity. Coverity
reports that 'refls' going out of scope leaks the storage it points
to, so let's free it before we leave the function.

Fixes Coverity CID1399099
Depends on D8309

Reviewers: raster, cedric, q66, zmike, bu5hm4n, stefan

Reviewed By: q66

Subscribers: #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D8310
2019-03-12 11:31:51 -04:00
Marcel Hollerbach 1c62ed5349 efl: ensure legacy is only relying on stable types
Summary:
This commit changes the beta ness of a few types, those types are
looking quite stable. Edje types will likely not change. The
Efl.Gfx.Join types are actaully already stable since the last release,
since evas_vg was stable back then and those enums have been in there.

The elementary stuff looks a bit unthought, and we have the chance to
change the API in the backend, so maybe we want to not declare it
stable, but rather reintroduce the legacy types.

With this we can enable eolian generation of beta tags for types.

ref T7726

Depends on D8276

Reviewers: cedric, segfaultxavi, zmike, stefan_schmidt, q66

Reviewed By: segfaultxavi, q66

Subscribers: #reviewers, #committers

Tags: #efl

Maniphest Tasks: T7726

Differential Revision: https://phab.enlightenment.org/D8277
2019-03-09 16:39:06 +01:00
Cedric BAIL bc12d9feb5 eo: make reflection getter const function.
Getter are usually not modifying there object. This is going to put a strong
limit on what a getter property for MVVM is, as it will prevent any side
effect on getting a property from a View.

Reviewed-by: Xavi Artigas <xavierartigas@yahoo.es>
Differential Revision: https://phab.enlightenment.org/D7969
2019-03-08 14:31:08 -08:00
Daniel Kolesa cf200a7d28 eolian: remove legacy handling API and most of generation
Summary:
This removes all Eolian API that deals with handling of legacy
code. It also removes the code using it in the generator as well
as bindings, but for now keeps generation of .eo.legacy.h types,
as there are still instances in our codebase where things are
otherwise broken. We can remove the rest once that is resolved.

Reviewers: zmike, cedric

Subscribers: #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D8255
2019-03-08 10:12:09 -05:00
Daniel Kolesa 1a17aff85f eolian: add support for marking type declarations beta
Summary:
This also simplifies the beta checking API by unifying it under
objects (makes much more sense that way) and reworks the validator
to have betaness support within its context state, allowing checks
to be done easily in any place.

The betaness checks are disabled for types for the time being,
because otherwise there are too many errors (types are assumed
to be stable as they are not tagged beta, but they reference beta
classes all over the place). Set EOLIAN_TYPEDECL_BETA_WARN to 1
in your environment to force enable the checks.

Reviewers: zmike, bu5hm4n, stefan_schmidt, lauromoura, cedric

Reviewed By: zmike

Subscribers: #reviewers, #committers

Tags: #efl, #eolian

Differential Revision: https://phab.enlightenment.org/D8102
2019-03-08 08:17:01 -05:00
Daniel Kolesa 4b1622b5fc eolian: remove support for inlist/inarray
This feature was kind of ill-conceived and never worked properly.
Since there isn't enough time to make it work right at this point
and there are no users of it in the API, remove it for now.

It might get added in the next release cycle, in a proper form.

@feature
2019-02-28 20:28:24 +01:00
Marcel Hollerbach 3555029f9f eolian_gen: fix generation of legacy class functions
we forgot to generate the legacy function. This no now added back.

ref D8029

Reviewed-by: YeongJong Lee <yj34.lee@samsung.com>
Differential Revision: https://phab.enlightenment.org/D8037
2019-02-28 16:11:52 +01:00
Cedric BAIL b23f65291f eo: make reflection setter able to return an error code in case of failure.
Reviewed-by: Marcel Hollerbach <marcel-hollerbach@t-online.de>
Differential Revision: https://phab.enlightenment.org/D7935
2019-02-21 11:54:09 -08:00
Daniel Kolesa b6b7317f4e eolian gen: generate a separate file with legacy implementations
If legacy implementations are generated, eolian_gen now creates
a separate file for them and includes it. The file name convention
for that is <.c file name without ext>.legacy.<.c file name ext>
or <.c file name>.legacy.c if it has no ext, so for example
foo.eo.c becomes foo.eo.legacy.c and foo becomes foo.legacy.c.

The file is generated assuming there are any legacy APIs contained
inside the .eo file.
2019-02-21 16:52:40 +01:00
Daniel Kolesa e335663da0 eolian gen: emit doxygen references to constants in uppercase
Since these are made into macros in C, they get uppercase names.
Reflect this in documentation generation.

Fixes T7691.
2019-02-21 12:14:33 +01:00
Daniel Kolesa 8952c05ddd eolian gen: initial support for reflection api
This adds support for generating reflection functions for
properties. This support is basic for now, supporting only
primitive types and string(shares), it will be expanded later
as required.

@feature
2019-02-15 17:17:15 +01:00
Xavi Artigas 19fcd6e60f eolian: allow tagging complete classes as BETA
Summary:
This allows using the @beta tag in classes, like this:
class @beta Efl.Foo extends Efl.Bar { ... }

This will surround the class definition in the .eo.h file with an
EFL_BETA_API_SUPPORT #define, equivalent to tag every method and
event with @beta.

Test Plan: Nothing changes since no class uses this tag yet

Reviewers: q66, bu5hm4n, zmike

Reviewed By: q66

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D7933
2019-02-13 18:48:02 +01:00
Xavi Artigas 6b7346b7b2 Remove individual class BETA guards
Summary:
Eolian adds a per-class BETA guard (like EFL_UI_WIN_BETA) to any method tagged
as @beta. This means that any app (and the EFL code) wanting to use BETA features
has to enable them class by class, which is cumbersome.
This commit replaces the individual guards with the global EFL_BETA_API_SUPPORT
guard, so apps only need to define one symbol to access BETA features.

Any usage of the per-class guards has been removed from the EFL code and examples.
When building EFL the global guard is defined by configure, so all EFL methods
already have access to BETA API.
Efl_Core.h and Efl_Ui.h no longer define EFL_BETA_API_SUPPORT. Apps wanting to
use BETA API have to define this symbol before including any EFL header
(It has been added to the examples requiring it).

Test Plan:
make && make check && make examples still work, but there's a lot less #defines
in the code

Reviewers: zmike, bu5hm4n, q66

Reviewed By: q66

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Maniphest Tasks: T6788

Differential Revision: https://phab.enlightenment.org/D7924
2019-02-13 18:09:17 +01:00
Marcel Hollerbach 46885653bc eo: remove class functions from eo
As in the previous commit explained, we want to get rid of class
functions in eo, and make them just c functions right away.

This commit removes the class parameter from the eo_class_function_set
call, and adjusts the tests to not depend on class functions anymore.
Class functions are now not tested anymore, tests that used them as a
way to test *things* are adjusted to test them now with object
functions, tests that just tested the working of class functions are
dropped.

This fixes T7675.

Reviewed-by: Cedric BAIL <cedric.bail@free.fr>
Differential Revision: https://phab.enlightenment.org/D7902
2019-02-13 16:59:59 +01:00
Marcel Hollerbach 37d2d378ec eolian: drop class function overriding
Until this commit eo did class functions as part of the vtable, which
enabled those functions to be overwritten in classes inheriting another
class. However in task T7675 we decided that this is not really good for
bindings, as most OOP languages do not support this sort of feature.

After this commit eolian realizes class function completly outside of
the vtable, the c-symbol that is the class funciton is now just directly
redirecting to a implementation, without the involvement of the vtable.

This also means a change to the syntax created by eo:

Calling before:
  class_function(CLASS_A);
Calling after:
   class_function();

Implementation before:
   class_function(const Eo *obj, void *pd) { ... }
Implementation after:
   class_function(void) { ... }

This fixes T7675.

Co-authored-by: lauromauro <lauromoura@expertisesolutions.com.br>

Reviewed-by: Daniel Kolesa <daniel@octaforge.org>
Differential Revision: https://phab.enlightenment.org/D7901
2019-02-13 16:59:58 +01:00
Marcel Hollerbach 0709bdea6f eo: change API call of efl_class_functions_set
The next commit will bring support for something like reflection. This
commit prepares the whole tree for getting another argument in
efl_class_functions_set.

ref T7681

Differential Revision: https://phab.enlightenment.org/D7882
2019-02-07 14:43:25 +01:00