C++: Document sixtyfps::interpreter::Value::Type

This commit is contained in:
Simon Hausmann 2021-06-21 13:29:07 +02:00 committed by Simon Hausmann
parent f7ff3ba0db
commit f377b5db6c
2 changed files with 33 additions and 3 deletions

View file

@ -279,8 +279,36 @@ public:
/// Destroys the value. /// Destroys the value.
~Value() { cbindgen_private::sixtyfps_interpreter_value_destructor(&inner); } ~Value() { cbindgen_private::sixtyfps_interpreter_value_destructor(&inner); }
/// \private #if !defined(DOXYGEN)
using Type = cbindgen_private::ValueType; using Type = cbindgen_private::ValueType;
#else
/// This enum describes the different types the Value class can represent.
enum Type {
/// The variant that expresses the non-type. This is the default.
Void,
/// An `int` or a `float` (this is also used for unit based type such as `length` or
/// `angle`)
Number,
/// Correspond to the `string` type in .60
String,
/// Correspond to the `bool` type in .60
Bool,
/// An Array in the .60 language.
Array,
/// A more complex model which is not created by the interpreter itself (Type::Array can
/// also be used for models)
Model,
/// An object
Struct,
/// Correspond to `brush` or `color` type in .60. For color, this is then a
/// sixtyfps::Brush with just a color.
Brush,
/// Correspond to `image` type in .60.
Image,
/// The type is not a public type but something internal.
Other = -1,
};
#endif // else !defined(DOXYGEN)
// optional<int> to_int() const; // optional<int> to_int() const;
// optional<float> to_float() const; // optional<float> to_float() const;

View file

@ -22,6 +22,8 @@ pub use sixtyfps_compilerlib::diagnostics::{Diagnostic, DiagnosticLevel};
/// This enum represents the different public variants of the [`Value`] enum, without /// This enum represents the different public variants of the [`Value`] enum, without
/// the contained values. /// the contained values.
// NOTE: The docs for ValueType are duplicated in sixtyfps_interpreter.h, for extraction by
// Doxygen. Keep in sync!
#[derive(Debug, Copy, Clone, PartialEq)] #[derive(Debug, Copy, Clone, PartialEq)]
#[repr(i8)] #[repr(i8)]
pub enum ValueType { pub enum ValueType {
@ -35,7 +37,7 @@ pub enum ValueType {
Bool, Bool,
/// An Array in the .60 language. /// An Array in the .60 language.
Array, Array,
/// A more complex model which is not created by the interpreter itself (Value::Array can also be used for model) /// A more complex model which is not created by the interpreter itself (ValueType::Array can also be used for models)
Model, Model,
/// An object /// An object
Struct, Struct,
@ -98,7 +100,7 @@ pub enum Value {
Image(Image), Image(Image),
/// An Array in the .60 language. /// An Array in the .60 language.
Array(SharedVector<Value>), Array(SharedVector<Value>),
/// A more complex model which is not created by the interpreter itself (Value::Array can also be used for model) /// A more complex model which is not created by the interpreter itself (Value::Array can also be used for models)
Model(Rc<dyn sixtyfps_corelib::model::Model<Data = Value>>), Model(Rc<dyn sixtyfps_corelib::model::Model<Data = Value>>),
/// An object /// An object
Struct(Struct), Struct(Struct),