Comments (4)
Should Ok() also fail if the value of the field is not the default/fixed value? In the case of commands with op codes, the view should be invalid if it is not the specified value.
from emboss.
Ok()
falls under the (existing) feature, [requires]
.
However, ideally, [default_value]
(or whatever it gets called) would be inferred from annotations like [requires: this == 10]
, without a human having to explicitly add it.
from emboss.
Just to make sure, I think we can infer the default value from the requires
annotation if it's there and only a scalar value. AFAIK, the requires
annotation allows for ranges as well and we can't infer much there. We also need to be able to set a default value which can be overridden to something else if necessary. Just want to make sure the implementation captures all these use cases.
from emboss.
That is correct. The exact rules I am thinking are:
- If the field is a structure (
struct
orbits
type), its default value is the compound of the default values of its fields. - Otherwise, if there is a
[default_value: n]
annotation on the field, the default value isn
. - Otherwise, if there is a
[requires]
annotation of the form[requires: this == n]
or[requires: n == this]
, wheren
is a compile-time constant (including an expression that evaluates to a compile-time constant, like2 * Type.some_constant
), then the default value isn
. - Otherwise, if the field is a boolean and there is a
[requires]
annotation of the form[requires: this]
, the default value istrue
. - Otherwise, use the default default value for the field's type, which should be
0
for numeric types andfalse
for booleans.
I am open to other inference forms, but I cannot think of any that would be useful and seem likely in real code.
from emboss.
Related Issues (20)
- Support `bits` wider than 64 bits HOT 1
- Support Integer Division and Modulus in the Emboss Expression Sublanguage
- Support High-Bit-Zero Numbering on `bits`
- Support Variable-Length/Offset fields within `bits`
- Support Variable-Length `bits`
- Support Sign-Magnitude Integers
- Support Lists of Variable-Length Structures. HOT 1
- Migrate to c++17 HOT 1
- `requires` attribute on struct/bits has no effect HOT 2
- Support kCamelCase names for enum values HOT 1
- Implicit narrowing conversion in OffsetBitBlock HOT 1
- `ContiguousBuffer` should have `memcpy()` equivalents.
- Documentation blocks should be placed on top of the entity they describe HOT 4
- Support using `requires` with open enums.
- Support using enum values in requires HOT 1
- Support generating an import depfile (.d) like GCC & Clang -MD option HOT 2
- Clang Wunused-parameter warning HOT 1
- Example of `$size_in_bits` from documentation fails to compile HOT 4
- Support `Int` and `UInt` wider than 64 bits.
- PEP8-ify Emboss Code
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from emboss.