Commit Graph

266 Commits

Author SHA1 Message Date
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 0275ef0f33 eolian: add APIs to get full C types of parameters/returns/fields
These are needed because the type itself does not carry all the
information it needs to carry (particularly by_ref).
2019-09-04 16:27:54 +02:00
Daniel Kolesa 242bad209b eolian: add API to check if an inner type of complex type is @move
This complements the equivalent APIs of parameters and so on.
It is not the same as the older type_is_owned API, which applied
to everything.
2019-08-31 02:13:59 +02:00
Daniel Kolesa fbcad90fec eolian: add parsing for @move and @by_ref
The @by_ref qualifier is now allowed on parameters, returns and
struct fields in the usual qualifier section. It will mean that
this type is passed around by reference, and will only be allowed
on types that are not already pointer-like.

The @move qualifier will replace @owned as one with a clearer
meaning. It means "transfer of ownership". It has the same semantics
as the current @owned, i.e. on return values it transfers ownership
of the value to the caller, on parameters it transfers ownership
to the callee (the inverse is the default when not specified).
On struct fields, it means the field will transfer together with
the struct that contains it.
2019-08-30 16:22:20 +02:00
Daniel Kolesa 8a8a833837 eolian: rename @class on methods to @static
Ref https://phab.enlightenment.org/T8118
Ref https://phab.enlightenment.org/T7675
2019-08-16 16:27:00 +02:00
Daniel Kolesa 65b4782682 eolian: remove support for old free() syntax
Now freefuncs can only be specified on type declarations but not
on types themselves. Also remove transitiveness of freefuncs.
2019-07-17 20:15:35 +02:00
Daniel Kolesa 2bfa55582c eolian: remove builtin freefuncs
For now this does not alter API behavior, so freefuncs are still
transitive to aliases etc., this will get removed later.
2019-07-08 16:06:42 +02:00
Daniel Kolesa 1bbf4380ab eolian: add library support for declaring and using errors
You can now declare errors like this:

error Foo = "message"; [[documentation]]

Then you can use them as types like this:

foo {
    return: error(Error1, Error2, ...);
}

They have a separate type category and storage. They are checked
for redefinitions the same as anything else though. This does
not add any generator support nor it adds any advanced checking.

Ref T6890
2019-06-24 15:15:30 +02:00
Daniel Kolesa db1b637fae eolian: initial versioning implementation
This implements initial support for specifying unit versions.
The default version is 1, specifying the basic feature level.

If you want to specify another version, you need to specify
something like `#version 2` at the beginning of the .eo or
.eot file; the version number must be higher than 0 and lower
than USHRT_MAX (typically 65536).

The beginning of the file is now called the "header section";
other things may be added into the header section later.
Version cannot be specified twice, and it cannot be specified
once other contents (like types or class definition) appear.
Comments do not count as other contents, so those are fine
to appear before #version.

@feature
2019-05-26 18:16:01 +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 5ea0195661 eolian: remove @nullable keyword
This was an experiment that never properly took off and was never
used by any generator. Its use was highly variable, so it could
not be relied upon. We will still want to reverse the current
behavior eventually (no null by default), but that will be
done with eo file versioning in the future.

@feature
2019-05-21 16:04:35 +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 6312cafe20 eolian: move from eo_prefix to c_prefix 2019-05-09 16:17:44 +02: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
Daniel Kolesa a9360222b0 eolian: add support for inlist structs
This adds support for inlist structs, a special type of struct
that can only be used with inlists. This differs from regular
structs in a couple ways:

1) They are stored separately. Just like structs, enums, aliases
   have their own storage, so do inlist structs.
2) They can't be @extern, nor they can be opaque.
3) They are their own type of typedecl.
4) When they contain only one field, this field must be a value
   type always, cannot be a pointer.

Like regular structs, they can have arbitrary fields, and they
can have a pre-set free function via @free().

In C, the inlist structs will be generated exactly like ordinary
ones, except they will have EINA_INLIST before the first field.
Other binding generators can deal with them as they wish, for
example to provide high level interfaces to them.

This does not yet do the plumbing necessary to hook these into
the type system, nor it adds generator support.

@feature
2019-02-28 00:52:14 +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
Daniel Kolesa 7feeda0410 eolian: add support for composite section into regular classes
Each regular class can now have a section called 'composite',
which can contain interfaces and interfaces only. This defines
a list of interfaces that are allowed to be unimplemented on the
class, as it is assumed the class will be composited with some
other class implementing those interfaces.

Only regular classes can have this, as only regular classes can
be instantiated.

It will also be necessary to check whether the classes in the
section appear somewhere within the inheritance tree. For now,
this testing is not being done.

Example of usage:

composite {
    Some.Magic.Interface;
    Another.Magic.Interface;
}

directly in the class body.
2019-01-21 17:19:14 +01:00
Daniel Kolesa 2110641131 eolian: add validation to make sure all methods are implemented
The checks are only done for regular classes. It's also disabled
by default as too many methods would be unimplemented.

Use EOLIAN_CLASS_UNIMPLEMENTED_WARN=1 to enable the errors.
2019-01-16 19:41:40 +01:00
Marcel Hollerbach 455dedd49d eolian: introduce the keyword required
This introduces a new keyword called required. It only works on mixins.
You can specify a list of regular/abstract classes in there.
Classes specified after the required keyword are later used to verify
the usage of the mixin. With this feature a mixin can define a list of
types that the inheriting object (the object that inherits from a mixin)
needs to fullfill, if one class that is required is not in the
implemented classes, then eolian will bail out.

Differential Revision: https://phab.enlightenment.org/D7584
2019-01-11 12:37:27 +01:00
Daniel Kolesa 14ce54c303 eolian: implement new inherit behavior
Eolian now separates 'parent' and 'extensions'. For regular
classes, parent is the first item in the inherits list and
extesions is the rest. For interfaces and mixins, parent is
NULL and extends is the inherits list.

The reason for this is the separation of them in syntax in near
future. It also slightly changes the behavior; since for interfaces
and mixins, parent is always NULL now, you can freely inherit from
all types of classes without needing to manually put an interface
type as the first item of the inherits list.
2018-11-23 13:57:07 +01:00
Daniel Kolesa d0c96539f2 eolian: add eolian_implement_implementing_class_get
This will make it easier for generators and utilities to retrieve
the class that implemented a method/property/etc rather than the
class the implement was originally defined for. Thanks to this
it will no longer be necessary to carry the class pointer around
the place.
2018-11-04 16:12:53 +01:00
Felipe Magno de Almeida 1933735635 eolian: Add @ctor_param parameter to constructors
Summary:
This tagging keyword explicitly asks, for bindings that support it,
that the constructor's parameters are added to the class constructor.

Allowing the user to instantiate the class and call the constructor in
a straightforward way.

Reviewers: q66, woohyun, bu5hm4n, Jaehyun_Cho, segfaultxavi

Reviewed By: q66

Subscribers: cedric, #reviewers, #committers, lauromoura

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D7221
2018-10-31 02:47:58 +01:00
Daniel Kolesa 3a55fe0bbf eolian: allow void and non-ownable types in future 2018-05-03 17:14:39 +02:00
Daniel Kolesa 0a399be7b0 eolian: add source file for the future static checker 2018-05-03 17:14:39 +02:00
Daniel Kolesa dd90488b69 eolian: add capturing of variables/typedecls in expr eval
This will be used from validation to properly count actual
dependencies of a unit.
2018-04-20 16:10:55 +02:00
Daniel Kolesa 543902f2ba eolian: make doc ref resolution global
Doc refs no longer introduce new dependencies into files. Instead,
they're parsed globally, and any doc ref lookup is also made
globally. This allows unit based dependencies to correspond more
to what files actually really need at compile time/runtime, with
docs being irrelevant to that; it also simplifies the API.

The doc resolution API now takes Eolian_State instead of
Eolian_Unit, too.
2018-04-18 16:38:14 +02:00
Daniel Kolesa 28b1dd25c7 eolian: add internal api for dep deferring + parsing without dep
This is cleaner than adding into a hash manually. Additionally, it
is now possible to request that the file be parsed not as a dep,
but rather standalone, which will be useful later.
2018-04-18 16:38:14 +02:00
Daniel Kolesa 2defb32214 eolian: correct line/column number during doc reference validation
Eolian doc objects now bundle debug information necessary to
provide correct line/column numbers. It is not possible to get
this information cirectly from the text, as it's reformatted and
contains no extra whitespace or newlines beyond paragraph
separators.

Fixes T6701.
2018-04-12 15:24:15 +02:00
Daniel Kolesa 710748c551 eolian: better/more robust class inheritance list replacement 2018-04-11 14:31:03 +02:00
Daniel Kolesa db04d3f670 eolian: introduce main and staging areas properly
The state is now correctly divided. No merging is performed yet,
which is to be done next.
2018-03-22 17:56:52 +01:00
Daniel Kolesa 93a64c5eab eolian: clean rollback support
Previously, when an error happened in Eolian, the state was left
in a presumably unusable and inconsistent condition. This work
aims to change that, as all changes are committed into a staging
area before being validated and merged back into main state.

This is not yet complete, as units and by-file lookups are not
currently involved in the rollback. This will change in the
subsequent commits.

@feature
2018-03-22 15:37:25 +01:00
Daniel Kolesa d9a8fe0fca eolian: add state staging area
This will be used for clean rollbacks on errors.
2018-03-22 15:37:25 +01:00
Daniel Kolesa 2db8e8e914 eolian: make use of panics for certain alloc errors 2018-03-20 17:34:51 +01:00
Daniel Kolesa a1ae5cd918 eolian: use new error logging for all recoverable errors 2018-03-20 17:34:51 +01:00
Daniel Kolesa 9610459502 eolian: add APIs to get unit from object and state from unit 2018-03-16 16:16:16 +01:00
Daniel Kolesa 60c733670d eolian: intial API for a new error mechanism
Unlike panic, this will be used to handle regular errors
such as parse errors. There will be no jumps and you
will be able to pass in a pointer to get the error
data into some local memory. That way you will be
able to override printing error messages.
2018-03-16 16:07:12 +01:00
Daniel Kolesa 927bcfd60a eolian: initial API for a new panic mechanism
This will be used to handle unrecoverable errors.
For robustness, you will be able to set a custom
panic callback, jump and try to recover manually.
2018-03-16 15:41:57 +01:00
Daniel Kolesa 6c0180d7f8 eolian: more stringent and fine-grained validation 2018-03-16 00:14:13 +01:00
Daniel Kolesa 978ba5052d eolian: reduce the number of database traversals during validation
This significantly improves performance by not iterating certain
paths multiple times.
2018-03-15 23:25:35 +01:00
Daniel Kolesa 0f0009cb4f eolian: expose short_name/namespaces via object 2018-03-12 13:55:21 +01:00
Daniel Kolesa 665fc62916 eolian: simplify namespace handling
This is mostly a preparation for rework of name(space) APIs.
2018-03-11 17:35:13 +01:00
Daniel Kolesa 7a4669b1b7 eolian: remove old declaration APIs 2018-03-08 23:59:40 +01:00
Daniel Kolesa 2248131295 eolian: give objects names, and reduce duplication 2018-03-08 19:47:28 +01:00
Daniel Kolesa 917a5216f8 eolian: add APIs to retrieve declarations as objects
This will replace the old declarations API.
2018-03-08 19:00:32 +01:00
Daniel Kolesa 9594f09156 eolian: add API to query information about Objects
As nearly every Eolian handle is backed by an Eolian_Object,
this information is now publicly exposed and has an API. This
opens up an array of new possibilities for tooling, as you
can now externally query file names, line numbers etc.,
as well as cast arbitrary handles to Eolian_Object pointers
and back.

This will be expanded later and it will replace the Declaration
system, as it's cleaner, better integrated and more versatile.

@feature
2018-03-08 17:32:38 +01:00
Daniel Kolesa 436f2d3363 eolian: add API to get file name of a unit 2018-02-27 16:12:35 +01:00
Daniel Kolesa 6a284e48c9 eolian: eolian_* -> eolian_state_*, Eolian -> Eolian_State 2018-02-27 16:12:35 +01:00