Commit Graph

264 Commits

Author SHA1 Message Date
Daniel Kolesa a1cb493d4f eolian: fix memory leak when using error objects 2019-11-15 13:36:57 +01:00
Daniel Kolesa cdff7852e0 eolian: loosen the requirements on API (don't return stringshare) 2019-09-26 16:47:22 +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 4ce7444dd1 efl: use new eolian error functionality instead of globals
Also enable referencing errors in docs.
2019-09-24 16:29:55 +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 4c6a9520ef eolian: fix use after free in eolian_database
'toscan' is actually a view to 'mpath' memory, so freeing it first
would result in use-after-free. This is obviously only in the error
branch so it usually does not happen, but fix anyway.

CID1403022
2019-08-05 15:43:39 +02:00
Mike Blumenkrantz 3853f75696 eolian: fix leak in eolian_state_file_path_parse
Summary:
this fixes a trivial leak where a string is leaked at the end of the function.
it is not significant, but it still appears in leak detections.

Reviewers: q66

Reviewed By: q66

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D9124
2019-07-08 16:17:58 +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 7dcbdef56d eolian: add API to query unit version 2019-05-26 18:19:20 +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 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 aa1db12c00 eolian: fail on scan file conflict
If two files of the same name are found in the include paths,
the scan should fail.
2019-05-06 17:05:22 +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
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
Daniel Kolesa c4640d6f40 eolian: add API to get full file path of a unit
This is necessary for easy dependency generation, as it is needed
to retrieve a full list of paths that each generated file depends
on.
2018-10-24 12:01:05 +02:00
Daniel Kolesa a923a94f85 eolian: always validate entire staging area
This is necessary even when parsing a single file because there
may be parsed results directly in the staging area introduced by
doc references, those wouldn't get correctly validated and would
be left in an inconsistent and unusable state.
2018-05-13 17:06:12 +02:00
Daniel Kolesa e50aa5e1c9 eolian: check does no changes, so take a const state 2018-05-13 17:06:12 +02:00
Daniel Kolesa 0a399be7b0 eolian: add source file for the future static checker 2018-05-03 17:14:39 +02:00
Daniel Kolesa f5c85daca7 eolian: add API that will allow for additional static analysis
Currently this API does nothing.
2018-05-03 17:14:39 +02:00
Daniel Kolesa a2ccdb7b21 eolian: re-enable non-dependencied parsing
The issue was that standalone-parsed files (outside of dependencies
of some other unit) were not being included in that dependency tree
(obviously) which resulted in their own dependency tree being
excluded from merging, causing the database hashes to lack the
necessary elements.

To fix this, I trigger merging of the "standalone" dependency trees
separately, by calling _merge_units from defer parsing cb.
2018-04-19 13:44:14 +02:00
Daniel Kolesa 974fa323a1 eolian: disable non-dependencied parsing for the time being
As 543902f2ba breaks build,
disable parsing with state as a parent for now, until the issue
is figured out.
2018-04-18 21:17:31 +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 311fada0d2 eolian: simpler and more efficient defer parsing 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 3bddb2b6c4 eolian: commit all changes into staging area first 2018-03-22 18:01:31 +01:00
Daniel Kolesa 806c30ec34 eolian: complete staging area merge logic 2018-03-22 17:56:52 +01: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 3ae67b24b3 eolian: validate staging unit when parsing all 2018-03-22 16:27:35 +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 bc182e69d7 eolian: flush defer table before parsing 2018-03-22 15:37:25 +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 bf1e3a702f eolian: event/function_get_by_name -> by_name_get 2018-03-16 14:26:15 +01:00
Daniel Kolesa 6c0180d7f8 eolian: more stringent and fine-grained validation 2018-03-16 00:14:13 +01:00
Daniel Kolesa fed326a3ef eolian: fix unit child management
Also pass correct unit to validation for performance.
2018-03-16 00:10:13 +01:00
Daniel Kolesa 2760f047d3 eolian: merge objects in units 2018-03-15 23:32:20 +01:00
Daniel Kolesa 2c59abc878 eolian: fix minor memory leaks 2018-03-15 16:45:23 +01:00
Daniel Kolesa ab43e61ef6 eolian: turn some state APIs into inlines over unit APIs 2018-03-14 17:20:49 +01:00
Daniel Kolesa 2d0a25c995 eolian: refactor doc ref resolution API 2018-03-14 16:51:11 +01:00
Daniel Kolesa 0f0009cb4f eolian: expose short_name/namespaces via object 2018-03-12 13:55:21 +01:00
Daniel Kolesa 5cc3abb425 eolian: only merge units on success when parsing all files 2018-03-12 11:37:02 +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 342974977f eolian: resolve to Eolian_Objects instead of voids 2018-03-09 15:25:36 +01:00
Daniel Kolesa c7fd43ad4e eolian: return Eolian_Object_Type from ref resolver
This needs only one enum and allows for better interop.
2018-03-09 15:25:36 +01:00