History | View | Annotate | Download (51.2 kB)
Fix whitespace and typos in comments
Signed-off-by: Jose A. Lopes <jabolopes@google.com>Reviewed-by: Hrvoje Ribicic <riba@google.com>
Another workaround for GHC linking error "unknown symbol"
This error appears after adding the dependency to lifted-base.See also #683 and ee7caf27.
I surmise that something like this is happening: Some code, that usesthe library, is only referenced through Template Haskell. A probable bug...
Assert correct usage of AndRestArguments fields
The special field andRestArguments is intended to be only usedas the last field of an object, catching all remaining keys.Add a compile-time check to verify that it is used correctly.
Signed-off-by: Klaus Aehlig <aehlig@google.com>...
Merge branch 'stable-2.11' into master
Add function providing the canonical andRestArguments
The field catching the remaining fields will always be of the sameshape, so add a function for this to make usage simple.
Signed-off-by: Klaus Aehlig <aehlig@google.com>Reviewed-by: Petr Pudlak <pudlak@google.com>
Add additional constructor AndRestArguments to OptionalType
A field of this type will capture all the remaining fieldsof an object as JSValues. Obviously, the intended use isto have precisely one such field. This mechanism will allowto pass opaque values trough, as it is, e.g., required for...
Replace duplicated code with readJSONWithDesc
JSON errors were annotated at other places, so use the function there aswell.
Signed-off-by: Petr Pudlak <pudlak@google.com>Reviewed-by: Klaus Aehlig <aehlig@google.com>
When parsing fields, annotate JSON errors with names
This allows better debugging of failed JSON conversions.
Use ClockTime instead of Double in fields in Objects.hs
This affects "mtime" and "ctime" fields in all data types.
This also forces explicit declaration of how the fields are serializedin Query.
A function for creating time fields that serialize as Double
The function creates fields with custom read/show methods based onTimeAsDoubleJSON, with the default value of 0 seconds since the epoch.
Document Field data type used in TH code generation
Describe what types of fields are currently possible and allowed andwhat what are the types of their "Q Exp" expressions.
Prohibit fields that are optional with a default value
For fields marked optional we need to keep the information that a valueisn't available. Therefore having a default value for an optional fieldwould not work.
Signed-off-by: Petr Pudlak <pudlak@google.com>...
A workaround for GHC linking problem "unknown symbol ..."
GHC 7.4 on Debian Wheezy fails to compile after some TH related changes,reporting
ghc: src/Ganeti/JSON.o: unknown symbol `attoparseczm0zi11zi1zi0_DataziAttoparsecziText_zdwf_info`
This doesn't happen on Squeeze. Explicitly importing attoparsec in THH...
Fix saveObjectField to work properly with custom fieldShow
Before it only worked for non-optional fields. For optional fieldswith custom fieldShow functions, the generated code didn't use it.
Fix typing problems in TH that generates field code
See #677: The code generated by TH had different types depending on ifa field had a default value and/or custom reader. Simple cases worked byaccident, but more complex ones failed.
This patch distinguishes properly between optional fields and mandatory...
Use a data type when generating Python types of OpCodes
Currently they are generated only as Strings.
Signed-off-by: Petr Pudlak <pudlak@google.com>Reviewed-by: Jose A. Lopes <jabolopes@google.com>
Refactor OpCodeDescriptor from a tuple to a data type
This greatly enhances code readability.
Also fix monadic types "Q ExpQ" [which is "Q (Q Exp)"] to "Q Exp".
Rename PyValueInstances.hs to PyValue.hs
Now the file contains the type class declaration as well.
Move PyValue into PyValueInstances.hs, import it in THH.hs
This puts all PyValue code into one module, getting rid of orphaninstances.
Support fieldRead in partial params
While from parameters both full and partial versions are generated,with in the partial version all types mapped to Maybe, the fieldReadparameter of the field was not wrapped accordingly. So far, that didn'tmatter, as it was always Nothing in this case, but for supporting special...
Add a field-transformer for accepting parser
Add a transformer for numerical fields, to also acceptstrings instead of numbers if they can be parsed by thegiven parser.
Signed-off-by: Klaus Aehlig <aehlig@google.com>Reviewed-by: Hrvoje Ribicic <riba@google.com>
Hs2Py constants: add 'becDefaults'
Add constant 'becDefaults' to the Haskell to Python constantgeneration. An instance of 'PyValue' is added to the type 'PyValueEx'in order to allow polymorphic types, namely, 'Map's.
Signed-off-by: Jose A. Lopes <jabolopes@google.com>...
Remove 'Show' from 'PyValue' class
Remove 'Show' constraint from the 'PyValue' class which, even thoughit allowed to simplify the definition of instances of this class forprimitive types, it made it more complicated to define instances forother types....
Add 'declareILADT' to declare integer literal datatypes
Add 'declareILADT' to declare integer literal datatypes.
Signed-off-by: Jose A. Lopes <jabolopes@google.com>Reviewed-by: Thomas Thrainer <thomasth@google.com>
Add Template Haskell 'declareLADT'
Add 'declareLADT' in Template Haskell module to declare Haskelldatatypes using 'String's directly as values for the JSONserialization, as opposed to 'Name's which is what the current'declareADT' allows. To achieve this, 'genFromRaw' must be...
Wrap 'Set' in 'ListSet' for the opcodes
In what Haskell to Python opcodes are concerned, a Haskell 'Set' istranslated into a Python 'list'. In other words, currently, opcodesthat handle sets of parameters are actually handling lists becausethis is how sets are currently encoded. This patch introduces a new...
Haskell to Python opcodes: fix Unit
Fix how Haskell to Python opcode generation handles unit. It seemsthat, in 'template-haskell-2.7.0', unit is represented by TemplateHaskell as a constructor of the form '(ConT name)', where 'name' isthe constructor name for 'Unit'. However, in 'template-haskell-2.8.0'...
Add Template Haskell code for constant generation
Add Template Haskell functions that generate a list in Haskellcontaining all the constants to be generated in Python. This list isan association list mapping the constant name to its Python value,which is stored as a string....
Add Python opcode generation
Merge stable-2.7 into stable-2.8
Conflicts: INSTALL NEWS configure.ac src/Ganeti/Query/Group.hs test/hs/Test/Ganeti/Objects.hs test/hs/Test/Ganeti/Query/Query.hs
Signed-off-by: Michele Tartara <mtartara@google.com>Reviewed-by: Helga Velroyen <helgav@google.com>
Fix typo in documentation string
Signed-off-by: Klaus Aehlig <aehlig@google.com>Reviewed-by: Helga Velroyen <helgav@google.com>
Improve TemplateHaskell code to support empty objects
Currently, an empty objects will generate warnings as the arguments ofvarious functions are unused. By adding conditional code for this, wecan support generation of empty objects, e.g. like needed in Rpc code....
Rename htools/ to src/
Per offline discussions, this is the first patch of therenames. Tested with "make distcheck", seems to work fine.
The only change outside of the renaming is a bit of simplification inthe .gitignore rules; otherwise, simply s/htools/src/....