ALib C++ Library
Library Version: 2402 R1
Documentation generated by doxygen
No Matches
Calculus::AutoCastEntry Struct Reference


An entry of field AutoCasts. Defines auto-casts for custom types.

Definition at line 788 of file calculus.hpp.

#include <calculus.hpp>

Collaboration diagram for Calculus::AutoCastEntry:

Public Field Index:

CallbackDecl Callback
const char * DbgCallbackName
std::vector< String > * OperatorsAccepted
std::vector< String > * OperatorsDeclined
Box ResultType
String ReverseCastFunctionName
Box Type

Field Details:

◆ Callback

CallbackDecl Callback

Callback function to add to the program that performs the auto-cast.

If nullptr is given, then an internal, predefined callback is used, which returns a value of type Types::Integer which is generated by taking the raw value of the argument box. This is especially useful for any boxed enum type that is to be made compatible with bitwise boolean operators (and other integral calculations and functions).

Definition at line 817 of file calculus.hpp.

◆ DbgCallbackName

const char* DbgCallbackName

The C++ name of the callback function (only available with debug builds of the library. Use preprocessor macro CALCULUS_CALLBACK to provide this field together with field Callback. The macro selects to prune the name string in release compilations.

If Callback is set to nullptr, the name of the internal function ("any2int") is inserted automatically. Instead of aforementioned macro CALCULUS_CALLBACK use macro CALCULUS_DEFAULT_AUTOCAST instead.

Definition at line 831 of file calculus.hpp.

◆ OperatorsAccepted

std::vector<String>* OperatorsAccepted

List of operators that the auto-cast accepts. If nulled, then just any operator that is not in OperatorsDeclined is accepted.

Definition at line 797 of file calculus.hpp.

◆ OperatorsDeclined

std::vector<String>* OperatorsDeclined

List of operators that the auto-cast does not accept. An operator should not appear in both lists, this one and list OperatorsAccepted. However, it is does, then the operator is not accepted.

A value of nullptr is allowed to indicate no declined operators.

Definition at line 806 of file calculus.hpp.

◆ ResultType

Box ResultType

The result type given a sample box.

If field Callback is nullptr to specify the use of the internal, default cast function, this field will be ignored and Types::Integer , will be set instead. Hence, in this case, this field can be specified as nullptr.

Definition at line 841 of file calculus.hpp.

◆ ReverseCastFunctionName

String ReverseCastFunctionName

This is the name of the function that reverses the cast. The function is used when an expression with an auto-cast functions is decompiled to generate compilable, optimized expression strings.

This method is needed only if "normalized, optimized expression strings" are to be generated. For more information on this topic consult manual section 11.5.6 Normalized, Optimized Expression Strings.
Note that, if the aforementioned feature is used, then this function name has to be provided together with the implementation of the expression function itself, even if the internal default cast implementation (activated by setting field Callback to nullptr) is used. The rationale is, that this library can not automatically convert integral types back to a custom type. This is even true for simple enumeration types.

Definition at line 861 of file calculus.hpp.

◆ Type

The type that is to be automatically casted.

Definition at line 791 of file calculus.hpp.

The documentation for this struct was generated from the following file: