History log of /system/tools/hidl/TypeDef.h
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
368e46077eb9fbe52242e037a5b9de91693fe70f 16-Feb-2018 Steven Moreland <smoreland@google.com> Do all validation during validation phase.

When hidl-gen was originally written, validation occured
at two different times: parsing and generation.

Since then, hidl-gen was re-written to be a multi-pass compiler.
The basic phases are now (see main + AST::postParse):
parse, process, validate, generate

However, some validation still exists during the generation phase.
This validation code has been gradually cleaned up, but, here, I am
cleaning up all the rest.

By moving the code to validation, we are fixing several classes
of problems:
1. generate functions almost exclusively (except for the few exceptions
that this CL cleans up) always return status OK. We have a bunch of
data flow logic which exists solely to propagate "return OK". This
is just plain silly.
2. a large number of the returns from emit/generate functions are not
actually checked. We've had a several bugs from this and also many
CLs just to fix this when they've been discovered. This causes problems
where hidl-gen fails but nothing notices.
3. sometimes files are written before things are validated. This is
extremely frustrating and also the cause of other bugs. One common
case of this (while developing) is when updating makefiles, the hidl-gen
compiler complains something is wrong with an interface, but it has
already partially written new but invalid makefiles. This means that
they have to be manually fixed before another build can begin.
4. having status_t returns from generate functions indicates to someone
working on hidl-gen that they can return an error here, but they
should always return an error from the correct validation function.
Removing the ability to return ERROR makes sure that new errors are
caught/validated in the correct place. One instance in this CL of
this happening is that annotations are also checked on isHidlReserved
methods whereas before, these were incorrectly only checked on regular
methods.

(note, breaking text to avoid pinging these)
B ug: 65636464 (forward declarations, made this possible)
B ug: 34807779 (better tools for java compatibility, closer to being solved)
B ug: 32573681 (instance of 2 above).

Test: hidl's run_all_host_tests.sh
Change-Id: I8988e1fdf16e15b925c0a613122c41e6a41bd4dd
/system/tools/hidl/TypeDef.h
ff5e64ae0c65b80e2baa4a95b9ae9ee894b60080 11-Sep-2017 Timur Iskhakov <iskhakovt@google.com> Fix strong references

Makes strong references to deal with interface corner case explicitly.
Makes hidl-gen to detect a cycle through typedef.

Cycle example:
typedef S A;
struct S {
A foo;
};

Fixes: 65559985

Test: mma
Test: error test in follow up CL
Change-Id: I132037995c3fc99edfe3e57a1fe84d3c36ca6993
/system/tools/hidl/TypeDef.h
565b0137b2ad0e8e239d38e92c025f096de62f2d 07-Sep-2017 Timur Iskhakov <iskhakovt@google.com> Refactor AST::addScopedType.

Makes NamedType receive full name in constructor.
Adds test that defined type names are unique within one scope.

Test: mma
Test: hidl_error_test
Change-Id: If218e1febc2af9f44c5908408f67e772efdda18e
/system/tools/hidl/TypeDef.h
dbaed3317411232962d25666de60799b4dcfce98 01-Sep-2017 Timur Iskhakov <iskhakovt@google.com> Do not unwrap typedefs on lookups

TypeDefs were replaced with actual types in lookups, so package
containing typedef could be not included.

This change keeps typedef declarations and imports package with
typedef declaration.

Bug: 65266511

Test: mma
Test: manual check that include became correct
Test: /hardware/interfaces output is unchanged, however
CL changes the behavior

Change-Id: Iee78228c9acfa4dbd16c3ca4ec0d9568a927d0f6
/system/tools/hidl/TypeDef.h
542920e68eec3712d6be250eb3dcaa7907ea05ed 31-Aug-2017 Timur Iskhakov <iskhakovt@google.com> Process refence in TypeDef

Fixes failure for (ex.):
typedef int32_t[32] arr_t;

Test: mma

Change-Id: I447589b37d8c093e856ad0726e74f93b4ba3c195
/system/tools/hidl/TypeDef.h
24e605b5194d969a1558d94896d69cc554881e46 30-Aug-2017 Timur Iskhakov <iskhakovt@google.com> Make Reference::get follow const rules

Instead of having T* Reference::get() const, this change brings
const T* Reference::get() const and
T* Reference::get()

Test: mma
Change-Id: I1c8834467acffd426c25aa9c0661c290a05d7a52
/system/tools/hidl/TypeDef.h
505316c499a4dbb95f6567e8531fb6f1e74c3ded 05-Aug-2017 Timur Iskhakov <iskhakovt@google.com> Revert "Revert "Add Reference type""

This reverts commit 6f2f2c026b0b6e372194794e171208a91d74f852.

Reason for revert: mac build problem could be easily fixed

Mac build failure was caused by not declaring template specialization
in header file. Unfortunately, it cannot be easily declared there,
as that would cause cyclic declaration.

The reason why Reference<T>(Reference<O>) constructor could get only
unresolved references is because there is no way to check that the
requested conversion is valid (without specialization or rtti).

However, the appeared messy solution is to be deleted with moving
lookup calls outside of the parser.

Test: builds, hidl_test
Test: builds on mac

Change-Id: Icb24e2ad52563f659e758a186d90e414ab7f1c59
/system/tools/hidl/TypeDef.h
6f2f2c026b0b6e372194794e171208a91d74f852 05-Aug-2017 Steven Moreland <smoreland@google.com> Revert "Add Reference type"

This reverts commit 4b80bc4402ec88504265e6fdbcdb8a803d67eb64.

Reason for revert: breaking mac build

Change-Id: I38b4a6e67173d87d7d78ff191aa26d4a980d2e39
/system/tools/hidl/TypeDef.h
4b80bc4402ec88504265e6fdbcdb8a803d67eb64 29-Jul-2017 Timur Iskhakov <iskhakovt@google.com> Add Reference type

Add Reference placeholder which keeps Type, FQName and Location.
This type is necessary for adding forward reference support:
it stores FQName until lookup happens, then stores resolved Type;
it stores Location, as all type-related checks are to be moved outside
of the parsing, so we need to keep Location for future error messages.

Reference type has overwritten operators to make it work as Type*,
providing additional checks that Type is resolved before being using.

Reference type is also useful for adding forward reference support as
it checks that every Type member call appears after lookup.

ConstantExpression is to support Reference (and to not be evaluated
during parsing) in future CL.

Test: links, compiles, hidl_test

Change-Id: I7a031b541e678032af1190209e9d2aaf4999bf1b
/system/tools/hidl/TypeDef.h
0ecc7b8aca24a5618512610bb6371bdb91b5fdc2 19-Jul-2017 Steven Moreland <smoreland@google.com> Add typeName() to all types.

Fixes some possible empty error messages (from
vec<unsupported type> at least). Also, will be useful
in the future to describe types.

Bug: 34807779
Test: manual
Change-Id: I52898f854e5747a65a4ca0c7a6ada0277feca761
/system/tools/hidl/TypeDef.h
cb0ba5213057de39aa164f2f9a3691370bcbfe6b 18-Jul-2017 Timur Iskhakov <iskhakovt@google.com> Moving hidl-gen parser stack outside of AST

Move compiler stack outside of AST members,
adding a parent member to NamedType to make AST
a real tree.

Add a check that interface must be declared in global scope,
that was not checked in hidl-gen.

Also move scanner outside of AST.

Test: compiles, links, boots, hidl_test
Change-Id: Ida0c192b258e40c8cfe033f00a842444df0130ad
/system/tools/hidl/TypeDef.h
a4b53d0da8c1c6889c361fd30b913adc364163bc 01-Nov-2016 Yifan Hong <elsk@google.com> Add location info to named types.

Bug: 31827278

Test: hidl_test
Change-Id: I1922d5c309c9706cef37ab34d28e1193d1e247cd
/system/tools/hidl/TypeDef.h
2a55e05a26aa8e84433eb6c3e06175ccf45d4e92 27-Sep-2016 Steven Moreland <smoreland@google.com> Output TypeDefs in C++ generated code.

Bug: 31753832
Test: visual inspection, hidl_test, building -Lc++-impl.
Change-Id: I0d49c3082d0e11937b0bfcfd27878c6feae6e7d2
/system/tools/hidl/TypeDef.h
4c865b72b320a46f326a335cfd326b66b0e10f67 15-Sep-2016 Andreas Huber <andih@google.com> [Java hidl-gen] Fix multi-dimensional arrays (used within structures, not

as method arguments).

Bug: 31438033
Change-Id: I8e29ae8eca2a9ef8a320e37ca0bb79dcfa8a9b9a
/system/tools/hidl/TypeDef.h
d537ab02e1707597d70665fd8c75ca1ec9f57326 12-Sep-2016 Steven Moreland <smoreland@google.com> Remove dependency on libutils.

As part of this, TypeDef has also been converted to a NamedType. This is
because originally, Scope contained just a KeyedVector<localname, idx> of
types which it contained, and an std::vector<type> which idx indexes into
(KeyedVector<localname, type> alone would have also worked). However, now
it contains a std::map<localname, idx> instead. Because of this, we have lost
the ability to iterate over the keys (localnames) in O(n). By converting
TypeDef to a NamedType, name => idx => type such that name == type->name.
This also means that in function hierarchy calling Scope::addType, we no
longer have to pass around the tuple (name, type) since type->name == name,
and we can pass around only type.

Change-Id: I8f85afe0e389979a2fd98ff5eeccf47e3fcc8307
/system/tools/hidl/TypeDef.h
979e099f1163ff75beed5776cd01fb409b90a0cd 07-Sep-2016 Steven Moreland <smoreland@google.com> Added knowledge of namespacing into generation.

This is the first step in making code aware of namespacing. Currently,
the solution to generate symbols which are properly namespaced is to
post-process text after it is being outputed by a Formatter. Ideally
objects will know what namespace they are in and be able to print
themselves out accordingly. This change specifically will allow
generated code to remove namespaces from symbols that don't need
to be qualified entirely without relying on post-processing to remove
the namespace.

Change-Id: Ie535d05a64eb3d6c7d3b5451abdaa289c574170f
/system/tools/hidl/TypeDef.h
1aec397b1fdea7db4120dbe55b6995bb2a9d9138 26-Aug-2016 Andreas Huber <andih@google.com> Adds (C)opyright headers everywhere.

Change-Id: I453af702f80aa4159ef6c3d29d9514b4897adc0a
/system/tools/hidl/TypeDef.h
39fa71827738f6c1340e4523946fe9bf704eef3a 19-Aug-2016 Andreas Huber <andih@google.com> Improved name lookup in order to allow partial names to refer to external

(imported) packages.

Bug: 30977424
Change-Id: I0a3757d6c3b10229627e2c1d6bc6176f88e13151
/system/tools/hidl/TypeDef.h
2831d5145675ead9f2fb767bf5fe4ae56b88349f 15-Aug-2016 Andreas Huber <andih@google.com> Initial commit of Java backend to hidl-gen.

Change-Id: I38b62637df74d3e5daf702a8996502d0d5726033
/system/tools/hidl/TypeDef.h
8d3ac0c6112e02e3a705fd4f9d82e523f10b4287 04-Aug-2016 Andreas Huber <andih@google.com> Be a little smarter about dealing with TypeDefs, resolve to the typedef'd

target at lookup time, so all code ever sees is anything _but_ TypeDefs.
Also verify that the optional Enum storage type is valid (i.e. an enum
or an integer type) and re-emit enum values for derived enum types.
/system/tools/hidl/TypeDef.h
bb797e4ba03e95cd0b20aa77b83717dcf8cc6287 03-Aug-2016 Andreas Huber <andih@google.com> properly deref RefType and TypeDef to find boolean attributes of a Type.
/system/tools/hidl/TypeDef.h
5a545440766886a1bbd09ed7221bb337705e5d14 03-Aug-2016 Andreas Huber <andih@google.com> Better validation. Check that unions contain no fixup types and structs

contain no references to interfaces (hwBinders).
/system/tools/hidl/TypeDef.h
31629bcd51ab30bc0aadc69f3fc8ce4893eca900 03-Aug-2016 Andreas Huber <andih@google.com> Saner determination of a declared type's name (now short + full name)

at the time the type is introduced to a scope.
/system/tools/hidl/TypeDef.h
867fcb63af8c3ac96ed1b3f3950525aa70393bdf 03-Aug-2016 Andreas Huber <andih@google.com> bye bye, dump(), RefType no longer gets a name.
/system/tools/hidl/TypeDef.h
737080baf85882c45bb322ee2191ae5fd9e1283a 03-Aug-2016 Andreas Huber <andih@google.com> Keeping track of imported names, resolve enum storage types, some finetuning.
/system/tools/hidl/TypeDef.h
881227d860c59471eee31d39946e96ce2daa35d6 02-Aug-2016 Andreas Huber <andih@google.com> generate C++ interface header, proxy and stub headers and sources.
/system/tools/hidl/TypeDef.h
c9410c7e62a33fd7599b2f3e025093a2d171577e 28-Jul-2016 Andreas Huber <andih@google.com> initial commit of reimplementation of hidl-gen

commit 56da787631c17276bc987f19649c6c1ea92200c3
Author: Andreas Huber <andih@google.com>
Date: Thu Jul 28 12:18:57 2016 -0700

ast.cpp => AST.cpp

commit 095552aba072152d9c87475895cd2e97c43b7b03
Author: Andreas Huber <andih@google.com>
Date: Thu Jul 28 10:43:04 2016 -0700

TypeContainer => Scope, since it now also holds constants.

commit 89ec1c511e7806037a53e43333c37fdf1b7aa39e
Author: Andreas Huber <andih@google.com>
Date: Thu Jul 28 10:41:05 2016 -0700

initial support for constants

commit b60b7ae588654b634bfdc5c283a25dd6378e1df7
Author: Andreas Huber <andih@google.com>
Date: Thu Jul 28 10:01:46 2016 -0700

Support for typedef, maintain ordering inside TypeContainer

commit 8e83034a077ce2309deeb0e2094079cf6f11d8b4
Author: Andreas Huber <andih@google.com>
Date: Thu Jul 28 09:36:29 2016 -0700

support for optional super interface

commit 9d44b022adb4a68dfca67ba2a6d845b7c8f27b88
Author: Andreas Huber <andih@google.com>
Date: Thu Jul 28 09:28:18 2016 -0700

ast => AST

commit 48fd7f8a4e8ecf230cfc416aec6c8f6115e410af
Author: Andreas Huber <andih@google.com>
Date: Thu Jul 28 09:26:44 2016 -0700

Each type in its own source/header file pair.

commit ca1285ecbcbbb1340eec476e3fd4d1334908d8c1
Author: Andreas Huber <andih@google.com>
Date: Thu Jul 28 08:52:24 2016 -0700

added scalar types "char", "bool" and "opaque"

commit fbb351e5f4392fcbbce77402dfe059a1c8d79fb2
Author: Andreas Huber <andih@google.com>
Date: Wed Jul 27 13:47:32 2016 -0700

some fixes to the parser and ast.

commit 78288216b101349e9364c2d4470ecb5b9a942f5c
Author: Andreas Huber <andih@google.com>
Date: Wed Jul 27 12:34:21 2016 -0700

Formatter, AST::dump(), NamedType

commit 4b8cc5d0a8ff5f70cb53e21b56138124259b8bcb
Author: Andreas Huber <andih@google.com>
Date: Wed Jul 27 11:45:10 2016 -0700

revamp of the parser, scoped type containers

commit 0193fbfa5c7ac3ac1ce306dfb9c55d879f8c02b5
Author: Andreas Huber <andih@google.com>
Date: Wed Jul 27 10:13:35 2016 -0700

store output in AST.

commit 7f53022123978cc7c2a05b0c4aba7a4c5deea93b
Author: Andreas Huber <andih@google.com>
Date: Wed Jul 27 10:06:54 2016 -0700

reentrant lexer/parser

commit 3d3e343d6cea2fb127b203071e8aff08a5715011
Author: Andreas Huber <andih@google.com>
Date: Tue Jul 26 15:27:02 2016 -0700

better typename lookup, comments.

commit 39f13ae860dbd9ffd163a5c99f150170525457ef
Author: Andreas Huber <andih@google.com>
Date: Tue Jul 26 14:29:33 2016 -0700

an actual AST.

commit b1f3f1d94a8d1257426da35ace5bc2af04c433b6
Author: Andreas Huber <andih@google.com>
Date: Tue Jul 26 12:51:34 2016 -0700

initial commit

Change-Id: I44d1d928a5f3dcb908e264d53af09bbe25d8c464
/system/tools/hidl/TypeDef.h