Blender  V2.93
Classes | Namespaces | Macros
FN_cpp_type.hh File Reference
#include "BLI_hash.hh"
#include "BLI_index_mask.hh"
#include "BLI_math_base.h"
#include "BLI_string_ref.hh"
#include "BLI_utility_mixins.hh"

Go to the source code of this file.

Classes

class  blender::fn::CPPType
 

Namespaces

 blender
 
 blender::fn
 

Macros

#define BUFFER_FOR_CPP_TYPE_VALUE(type, variable_name)
 

Detailed Description

The CPPType class is the core of the runtime-type-system used by the functions system. It can represent C++ types that are default-constructible, destructible, movable, copyable, equality comparable and hashable. In the future we might want to make some of these properties optional.

Every type has a size and an alignment. Every function dealing with C++ types in a generic way, has to make sure that alignment rules are followed. The methods provided by a CPPType instance will check for correct alignment as well.

Every type has a name that is for debugging purposes only. It should not be used as identifier.

To check if two instances of CPPType represent the same type, only their pointers have to be compared. Any C++ type has at most one corresponding CPPType instance.

A CPPType instance comes with many methods that allow dealing with types in a generic way. Most methods come in three variants. Using the construct-default methods as example:

In some cases default-construction does nothing (e.g. for trivial types like int). The default_value method provides some default value anyway that can be copied instead. What the default value is, depends on the type. Usually it is something like 0 or an empty string.

Implementation Considerations

Concepts like inheritance are currently not captured by this system. This is not because it is not possible, but because it was not necessary to add this complexity yet.

One could also implement CPPType itself using virtual inheritance. However, I found the approach used now with explicit function pointers to work better. Here are some reasons:

Definition in file FN_cpp_type.hh.

Macro Definition Documentation

◆ BUFFER_FOR_CPP_TYPE_VALUE

#define BUFFER_FOR_CPP_TYPE_VALUE (   type,
  variable_name 
)
Value:
blender::DynamicStackBuffer<64, 64> stack_buffer_for_##variable_name((type).size(), \
(type).alignment()); \
void *variable_name = stack_buffer_for_##variable_name.buffer();
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition: btDbvt.cpp:52

Definition at line 676 of file FN_cpp_type.hh.