aboutsummaryrefslogtreecommitdiffstats
path: root/unpack.go
Commit message (Collapse)AuthorAgeFilesLines
* Allow mutated property structs to contain slices of non-stringsColin Cross2018-10-031-1/+3
| | | | | | | | | Property structs can now contain slices of structs and other non-strings as long as they are tagged with `blueprint:"mutated"`. Test: clone_test.go Test: unpack_test.go Change-Id: Ib77348dc6e7314a24f17caba10040f7d3ac54e54
* Support parsing int64 in Blueprint file.Nan Zhang2017-11-021-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | Support int64 number instead of int to be more fixed to bit size so that the underlying arch won't affect overflow cases. Besides, refection: func (v Value) Int() int64 always cast to int64 no matter the input is int, int16, int32. Currently we always treat "-" as negative sign to bind to next value, and "+" as plus operator to add operands together. So we allow: a = 5 + -4 + 5 or a = -4 + 5 But we don't allow: a = +5 + 4 + -4 since we don't treat "+" as a positive sign, otherwise, a = 5 + +5 would exist which looks pretty weird. In the future, we may want fully support number calculator logic eg, "+"/"-" can be positive/negative sign or operator, and "(" and ")" will be considered to group expressions with a higher precedence. int & uint properties within struct keeps unchanged, which is only allowed when tagged with 'blueprint:mutated'. We only allow *int64 property instead of int64 property within struct since it does't make sense to do prepending or appending to int64. Change-Id: I565e046dbd268af3538aee148cd7300037e56523
* Replace unpack's replace semantics with appendColin Cross2017-08-011-63/+64
| | | | | | | | | | | | | | | | | Blueprint was using "replace" semantics when unpacking properties into property structs, meaning if a module factory pre-set property values they would be overwritten by whatever was in the Blueprint file. This is different than what would happen if the same property was updated using the Append*Properties functions in proptools, which would use "append" semantics, which append strings and lists, logically ORs booleans and replaces pointers to strings and booleans. Replace unpack's semantics with append semantics for consistency. Any previous users of pre-set properties can move to using a pointer to a string or boolean if they want the old behavior. Test: unpack_test.go Test: extend_test.go Change-Id: I02eebe80916e578938142f8e76889bd985223afc
* Improve error reportingColin Cross2016-10-121-5/+5
| | | | | | Report module name and variant and property names in errors. Change-Id: I747f840402497b2c92bf8c565d7c50af33e6ab0e
* Support structures built with StructOfDan Willemsen2016-09-091-0/+9
| | | | | | | | | | | | | | | | | | | In Go 1.7, all generated types (including StructOf) are marked as unexported types. This is not a problem with regular named fields, since the whether the field is exported is based on the name, not the type. But for unnamed (anonymous) fields, there is no name, and it falls back to whether the type is exported or not. When the field isn't exported, we're unable to use reflection to set the value. Special case fields named "BlueprintEmbed" to act like exported unnamed fields during unpacking. There is no functionality lost here, since code can not directly access these runtime generated fields. Structures embedded in the source shouldn't be affected by this change, unless they happen to use the "BlueprintEmbed" field, which is not a normal field name due to the capitalization. Change-Id: I53f3b32b2286c47b2bb1918d6008d0180ad0605e
* Only instantiate nil struct pointers that are usedColin Cross2016-08-081-4/+10
| | | | | | | | | | | | | | unpackProperties was instantiating all nil struct pointers in any struct that had a property set. Check if the property is set first, and only instantiate the struct if it was set. This has a slight behavioral change, as now structures that only exist through nil pointers and are never set into will not be type-checked. This should be fixed in a later patch set that moves the type checking to be done across all property structs once per factory before blueprint files are loaded. Change-Id: I0dea34d7fff76bb4fc907516a2d996e4ea2408d6
* Support nil pointers to structs in propertiesColin Cross2016-08-051-1/+4
| | | | | | | | | | | | Allow primary builders to reduce allocations of empty structures by allowing nil pointers to concrete struct types. Property readers will not recurse into nil pointers, property writers will replace the nil pointer with a pointer to the zero value of the pointer element type. Allows a >50% primary builder time improvement with a trivial change in Soong. Change-Id: If6ad674bf7bf2a694c335378a074643a97d3c50b
* Fix error messages containing variable typesColin Cross2016-07-151-4/+4
| | | | | | | value.Type and value.Pos changed to methods, change the users that were not caught by error checking to use Type() or Pos(). Change-Id: I295a658c007fa2de68c89fb85ee367fbea5ed1aa
* Rename Pos membersColin Cross2016-06-141-5/+5
| | | | | | | Pos is going to be part of the Node interface, rename the Pos member of structs to be more specific. Change-Id: Ibd31119863b96d38bf8dac216e026200a54bbe18
* Remove blueprint/parser.IdentColin Cross2016-06-141-1/+1
| | | | | | | | It wasn't adding anything useful, and it resulted in Name.Name to get to the identifier. Replace Name Ident with Name string; NamePos scanner.Position. Change-Id: Idf9b18b31dd563a18f27c602c2d14298955af371
* Refactor blueprint parser nodes to an interfaceColin Cross2016-06-081-25/+26
| | | | | | | | | | | Refactor the blueprint parser Value object, which contained a Type enum and members to hold every possible type, into an interface (now called Expression). Rename the existing Expression object that represented a binary operator Operator. Also adds and fixes some new printer test cases with mulitline expressions. Change-Id: Icf4a20f92c8c2a27f18df8ca515a9d7f282ff133
* Support embedded anonymous property structsColin Cross2015-11-201-14/+16
| | | | | | Allow property structs to contain anonymous embedded structs and interfaces. Properties in an anonymous embedded struct or interface are treated as if they were properties in the embedding struct.
* Add property support for pointers to bools and stringsColin Cross2015-11-021-12/+27
| | | | | | | | | | | | | | | | | | | The only append semantics for bool that result in a no-op when the zero value is appended is to OR the two values together, but that is rarely the desired semantics. Add support for *bool and *string as property types, where appending a nil pointer is a no-op. For *bool, appending a non-nil pointer replaces the destination with the value. For *string, appending a non-nil pointer appends the value. This also provides a more reliable replacement for ModuleContext.ContainsProperty, as the build logic can tell that the property was set, even if it was set by a mutator and not by the blueprints file, by testing against nil. []string already provides these semantics for lists. Setting a *bool or *string property from a blueprints file is the same syntax as setting a bool or a string property.
* Fix unpacking empty listColin Cross2015-10-311-1/+1
| | | | | Add a test for unpacking empty list properties and fix a bug that resulted in nil slice instead of an empty slice.
* Add helpers for extending properties to proptoolsColin Cross2015-10-311-14/+3
| | | | | | | | | | It is common for a mutator to append or prepend property structs together. Add helper functions to append or prepend properties in property structs. The append operation is defined as appending string and slices of strings normally, OR-ing bool values, and recursing into embedded structs, pointers to structs, and interfaces containing pointers to structs. Appending or prepending the zero value of a property will always be a no-op.
* Add self-documenting supportColin Cross2015-06-261-3/+3
| | | | | | | | | | | | | | | | | | | | | The primary builder will now generate a rule to call itself with --docs=.bootstrap/docs/<name>.html to produce an automatically generated documentation file. The documentation generation process is: - Call each factory once to get empty property structs associated with the module type - Use reflection to determine the names of the type of each property struct - Use the bootstrap_go_package modules from reading the Blueprints files to find the source files for each Go package used to build the primary builder - Use the go/parser module to find the type declaration for each property struct - Extract comments for the property struct and each property declaration - Format all the comments into HTML Change-Id: Icae9307cc10549a30bfc14d6922824099de5a9b0
* Support filtering nested structures by tagColin Cross2015-06-261-15/+75
| | | | | | | | | | | Allow tagging a nested property structure with `blueprint:"filter(key:\"value\")"`, which will only allow property assignments to properites in the nested structure that are tagged with `key:"value"`. Moving the filter into Blueprint instead of the project build logic allows more reliable and consistent error messages. Change-Id: I06bc673dde647776fc5552673bdc0cdcd7216462
* Update import paths to include githubJamie Gennis2015-03-211-2/+2
|
* Add license headers and LICENSE fileColin Cross2015-01-231-0/+14
| | | | Change-Id: I6f7c7374093c0745ee4aa677480376a06648b358
* Move blueprint/* up a directoryColin Cross2015-01-231-0/+290
Make integrating with go tools easier by putting the blueprint package files in the top level directory of the git project instead of in a subdirectory called blueprint. Change-Id: I35c144c5fe7ddf34e478d0c47c50b2f6c92c2a03