Collaboration diagram for Objects:

Macros

#define DECLARE_FSTR_OBJECT(name, ObjectType)   extern const ObjectType& name;
 Declare a global Object reference. More...
 
#define DEFINE_FSTR_REF(name, ObjectType, object)   const ObjectType& name PROGMEM = object.template as<ObjectType>();
 Define a reference to an object. More...
 
#define DEFINE_FSTR_REF_NAMED(name, ObjectType)   DEFINE_FSTR_REF(name, ObjectType, FSTR_DATA_NAME(name).object);
 
#define FSTR_DATA_NAME(name)   __fstr__##name
 Provide internal name for generated flash string structures. More...
 
#define FSTR_PTR(objref)   static_cast<std::remove_reference<decltype(objref)>::type*>(&FSTR_DATA_NAME(objref).object)
 Given an Object& reference, return a pointer to the actual object. More...
 
#define FSTR_CHECK_STRUCT(name)
 Check structure is POD-compliant and correctly aligned. More...
 
#define IMPORT_FSTR_OBJECT(name, ObjectType, file)
 Import an object from an external file with reference. More...
 
#define IMPORT_FSTR_OBJECT_LOCAL(name, ObjectType, file)
 Like IMPORT_FSTR_OBJECT except reference is declared static constexpr. More...
 

Detailed Description

Macro Definition Documentation

◆ DECLARE_FSTR_OBJECT

#define DECLARE_FSTR_OBJECT (   name,
  ObjectType 
)    extern const ObjectType& name;

Declare a global Object reference.

Parameters
name
ObjectType

◆ DEFINE_FSTR_REF

#define DEFINE_FSTR_REF (   name,
  ObjectType,
  object 
)    const ObjectType& name PROGMEM = object.template as<ObjectType>();

Define a reference to an object.

Parameters
nameName for reference
ObjectTypeFully qualified typename of object required, e.g. FSTR::String, FlashString, FSTR::Vector<int>, etc.
objectObject instance to cast

◆ DEFINE_FSTR_REF_NAMED

#define DEFINE_FSTR_REF_NAMED (   name,
  ObjectType 
)    DEFINE_FSTR_REF(name, ObjectType, FSTR_DATA_NAME(name).object);

◆ FSTR_CHECK_STRUCT

#define FSTR_CHECK_STRUCT (   name)
Value:
static_assert(std::is_pod<decltype(name)>::value, "FSTR structure not POD"); \
static_assert(offsetof(decltype(name), data) == sizeof(uint32_t), "FSTR structure alignment error");

Check structure is POD-compliant and correctly aligned.

◆ FSTR_DATA_NAME

#define FSTR_DATA_NAME (   name)    __fstr__##name

Provide internal name for generated flash string structures.

◆ FSTR_PTR

#define FSTR_PTR (   objref)    static_cast<std::remove_reference<decltype(objref)>::type*>(&FSTR_DATA_NAME(objref).object)

Given an Object& reference, return a pointer to the actual object.

Parameters
objrefWhen an Object pointer is required, such when defining entries for a Vector or Map, it is usually sufficient to use &objref.

However, some older compilers such as GCC 4.8.5 requires such references to be declared constexpr. For example, this fails with FSTR structure not POD:

    DEFINE_FSTR(globalStringRef, "This creates a global reference");
    DEFINE_VECTOR(myVector, FSTR::String, &globalStringRef);
                                       ^^^

Global references cannot be declared constexpr, so changing DEFINE_FSTR to DEFINE_FSTR_LOCAL will fix the problem.

Another solution is to get a direct pointer to the actual data structure:

    DEFINE_VECTOR(myVector, FSTR::String, FSTR_PTR(globalStringRef));

We can only do this of course if the data structure is in scope.

◆ IMPORT_FSTR_OBJECT

#define IMPORT_FSTR_OBJECT (   name,
  ObjectType,
  file 
)
Value:
extern "C" __attribute__((visibility("hidden"))) const FSTR::ObjectBase FSTR_DATA_NAME(name); \
#define FSTR_DATA_NAME(name)
Provide internal name for generated flash string structures.
Definition: Object.hpp:56
#define DEFINE_FSTR_REF(name, ObjectType, object)
Define a reference to an object.
Definition: Object.hpp:49
#define IMPORT_FSTR_DATA(name, file)
Link the contents of a file.
Definition: Utility.hpp:107
Definition: Array.hpp:108
ObjectType
Definition: Libraries/jerryscript/src/include/Jerryscript/Types.h:34

Import an object from an external file with reference.

Parameters
nameName for the object
ObjectTypeObject type for reference
fileAbsolute path to the file containing the content
See also
See also IMPORT_FSTR_DATA
Note
Can only be used at file scope

◆ IMPORT_FSTR_OBJECT_LOCAL

#define IMPORT_FSTR_OBJECT_LOCAL (   name,
  ObjectType,
  file 
)
Value:
extern "C" __attribute__((visibility("hidden"))) const FSTR::ObjectBase FSTR_DATA_NAME(name); \
static constexpr DEFINE_FSTR_REF(name, ObjectType, FSTR_DATA_NAME(name));

Like IMPORT_FSTR_OBJECT except reference is declared static constexpr.