Leviathan  0.8.0.0
Leviathan game engine
Leviathan::ScriptRunResult< ReturnT > Struct Template Reference

Holds a result of the new script run method. More...

#include <ScriptRunningSetup.h>

Public Member Functions

 ScriptRunResult (SCRIPT_RUN_RESULT result, ReturnT &&value)
 
 ScriptRunResult (const ScriptRunResult< ReturnT > &other)
 
 ScriptRunResult (ScriptRunResult< ReturnT > &&other)
 
 ScriptRunResult (SCRIPT_RUN_RESULT result)
 Only set result code. More...
 
 ~ScriptRunResult ()
 
ScriptRunResultoperator= (const ScriptRunResult< ReturnT > &other)
 Assign other. More...
 

Public Attributes

SCRIPT_RUN_RESULT Result
 Result code of the script running. More...
 
ReturnT Value
 

Protected Member Functions

void ReleasePointerReference ()
 Helper for the multiple places that do pointer reference decrease. More...
 
void IncreasePointerReference ()
 Helper for the multiple places that do pointer reference increase. More...
 

Detailed Description

template<typename ReturnT>
struct Leviathan::ScriptRunResult< ReturnT >

Holds a result of the new script run method.

Note
If the return type is reference counted this automatically releases it, so if you want to keep the object around you must increase the reference count (and then for safety wrap it into intrusive_ptr)

Definition at line 73 of file ScriptRunningSetup.h.

Constructor & Destructor Documentation

◆ ScriptRunResult() [1/4]

template<typename ReturnT>
Leviathan::ScriptRunResult< ReturnT >::ScriptRunResult ( SCRIPT_RUN_RESULT  result,
ReturnT &&  value 
)
inline

Definition at line 75 of file ScriptRunningSetup.h.

75  :
76  Result(result), Value(std::move(value))
77  {
78  // We need to take a reference as the script context is reset
79  // before we are returned to the caller
81  }
void IncreasePointerReference()
Helper for the multiple places that do pointer reference increase.
SCRIPT_RUN_RESULT Result
Result code of the script running.

◆ ScriptRunResult() [2/4]

template<typename ReturnT>
Leviathan::ScriptRunResult< ReturnT >::ScriptRunResult ( const ScriptRunResult< ReturnT > &  other)
inline

Definition at line 83 of file ScriptRunningSetup.h.

83  :
84  Result(other.Result), Value(other.Value)
85  {
86  // We need to take a reference as the other instance will release its pointer
88  }
void IncreasePointerReference()
Helper for the multiple places that do pointer reference increase.
SCRIPT_RUN_RESULT Result
Result code of the script running.

◆ ScriptRunResult() [3/4]

template<typename ReturnT>
Leviathan::ScriptRunResult< ReturnT >::ScriptRunResult ( ScriptRunResult< ReturnT > &&  other)
inline

Definition at line 90 of file ScriptRunningSetup.h.

90  :
91  Result(other.Result), Value(std::move(other.Value))
92  {
93  }
SCRIPT_RUN_RESULT Result
Result code of the script running.

◆ ScriptRunResult() [4/4]

template<typename ReturnT>
Leviathan::ScriptRunResult< ReturnT >::ScriptRunResult ( SCRIPT_RUN_RESULT  result)
inline

Only set result code.

Definition at line 96 of file ScriptRunningSetup.h.

96  : Result(result)
97  {
98  if constexpr(std::is_pointer_v<ReturnT>)
99  Value = nullptr;
100  }
SCRIPT_RUN_RESULT Result
Result code of the script running.

◆ ~ScriptRunResult()

template<typename ReturnT>
Leviathan::ScriptRunResult< ReturnT >::~ScriptRunResult ( )
inline

Definition at line 102 of file ScriptRunningSetup.h.

103  {
105  }
void ReleasePointerReference()
Helper for the multiple places that do pointer reference decrease.

Member Function Documentation

◆ IncreasePointerReference()

template<typename ReturnT>
void Leviathan::ScriptRunResult< ReturnT >::IncreasePointerReference ( )
inlineprotected

Helper for the multiple places that do pointer reference increase.

Definition at line 132 of file ScriptRunningSetup.h.

133  {
134  if constexpr(std::is_pointer_v<ReturnT>) {
135 
137  }
138  }
static void IncrementRefCountIfRefCountedType(T *current)
Increments refcount of obj if it is derived from ReferenceCounted or an angelscript type.

◆ operator=()

template<typename ReturnT>
ScriptRunResult& Leviathan::ScriptRunResult< ReturnT >::operator= ( const ScriptRunResult< ReturnT > &  other)
inline

Assign other.

Definition at line 108 of file ScriptRunningSetup.h.

109  {
110  // Release our old pointer if it was reference counted
112 
113  Value = other.Value;
114  Result = other.Result;
115 
116  // We need to take a reference as the other instance will release its pointer
118 
119  return *this;
120  }
void ReleasePointerReference()
Helper for the multiple places that do pointer reference decrease.
void IncreasePointerReference()
Helper for the multiple places that do pointer reference increase.
SCRIPT_RUN_RESULT Result
Result code of the script running.

◆ ReleasePointerReference()

template<typename ReturnT>
void Leviathan::ScriptRunResult< ReturnT >::ReleasePointerReference ( )
inlineprotected

Helper for the multiple places that do pointer reference decrease.

Definition at line 124 of file ScriptRunningSetup.h.

125  {
126  if constexpr(std::is_pointer_v<ReturnT>) {
128  }
129  }
static void DecrementRefCountIfRefCountedType(T *current)
Increments refcount of obj if it is derived from ReferenceCounted or an angelscript type.

Member Data Documentation

◆ Result

template<typename ReturnT>
SCRIPT_RUN_RESULT Leviathan::ScriptRunResult< ReturnT >::Result

Result code of the script running.

Definition at line 142 of file ScriptRunningSetup.h.

◆ Value

template<typename ReturnT>
ReturnT Leviathan::ScriptRunResult< ReturnT >::Value

Return value received from the script. Only valid of Result == SCRIPT_RUN_RESULT::Success

Definition at line 146 of file ScriptRunningSetup.h.


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