ecs_opaque_init

Function ecs_opaque_init 

Source
pub unsafe extern "C" fn ecs_opaque_init(
    world: *mut ecs_world_t,
    desc: *const ecs_opaque_desc_t,
) -> u64
Expand description

Create a new opaque type. Opaque types are types of which the layout doesn’t match what can be modelled with the primitives of the meta framework, but which have a structure that can be described with meta primitives. Typical examples are STL types such as std::string or std::vector, types with a nontrivial layout, and types that only expose getter/setter methods.

An opaque type is a combination of a serialization function, and a handle to a meta type which describes the structure of the serialized output. For example, an opaque type for std::string would have a serializer function that accesses .c_str(), and with type ecs_string_t.

The serializer callback accepts a serializer object and a pointer to the value of the opaque type to be serialized. The serializer has two methods:

  • value, which serializes a value (such as .c_str())
  • member, which specifies a member to be serialized (in the case of a struct)