API Documentation
Environment.h
1 // Environment.h
3 //
5 
6 namespace nkScripts
7 {
13  class Environment final
14  {
15  public :
16 
20  Environment () noexcept ;
25 
26  // Getters
34  nkMemory::StringView getName () const ;
35 
36  // Setters
42  void setEnvironmentFor (INTERPRETER interpretType) ;
50  void setName (nkMemory::StringView name) ;
51 
52  // Execution
59  bool execute (const Script& script) ;
64 
65  // Manipulating memory
72  void setVar (nkMemory::StringView name, bool value) ;
79  void setVar (nkMemory::StringView name, int value) ;
86  void setVar (nkMemory::StringView name, float value) ;
93  void setVar (nkMemory::StringView name, double value) ;
100  void setVar (nkMemory::StringView name, const char* value) ;
107  void setVar (nkMemory::StringView name, nkMemory::StringView value) ;
114  void setVar (nkMemory::StringView name, const ScriptObjectReference& value) ;
122  void setObject (nkMemory::StringView name, nkMemory::StringView userTypeName, void* value) ;
123 
129  bool isVarSet (nkMemory::StringView name) ;
130 
140  bool getVar (nkMemory::StringView name, bool defaultValue) ;
150  int getVar (nkMemory::StringView name, int defaultValue) ;
160  float getVar (nkMemory::StringView name, float defaultValue) ;
170  double getVar (nkMemory::StringView name, double defaultValue) ;
180  nkMemory::StringView getVar (nkMemory::StringView name, const char* defaultValue) ;
190  nkMemory::StringView getVar (nkMemory::StringView name, nkMemory::StringView defaultValue) ;
199  ScriptObjectReference getVar (nkMemory::StringView name) ;
210  void* getObject (nkMemory::StringView name, nkMemory::StringView userTypeName = nullptr) ;
220 
229  Function* setFunc (nkMemory::StringView name) ;
236  bool isFuncSet (nkMemory::StringView name) ;
241  Function* getFunc (nkMemory::StringView name) ;
242 
251  UserType* setUserType (nkMemory::StringView name) ;
258  bool isUserTypeSet (nkMemory::StringView name) ;
263  UserType* getUserType (nkMemory::StringView name) ;
264 
272  Namespace* setNamespace (nkMemory::StringView name) ;
279  bool isNamespaceSet (nkMemory::StringView name) ;
284  Namespace* getNamespace (nkMemory::StringView name) ;
285 
286  // Call C++ -> Script
295  bool callScriptFunction (const ScriptObjectReference& reference, const DataStack& args, DataStack& expectedOutput) ;
296 
306  nkMemory::Buffer serializeScriptObject (const ScriptObjectReference& reference, bool forwardUserDataOwnership = false) ;
313  ScriptObjectReference deserializeScriptObject (nkMemory::BufferView<unsigned char> object) ;
314  } ;
315 }
316 
nkScripts::Environment::isNamespaceSet
bool isNamespaceSet(nkMemory::StringView name)
nkScripts::Environment::getUserType
UserType * getUserType(nkMemory::StringView name)
nkScripts::Environment
Defines an environment in which scripts can execute.
Definition: Environment.h:14
nkScripts
Encompasses all API of component NilkinsScripts.
Definition: Environment.h:7
nkScripts::Environment::isUserTypeSet
bool isUserTypeSet(nkMemory::StringView name)
nkScripts::Namespace
Holds information and allow control over a namespace in a scripting environment.
Definition: Namespace.h:12
nkScripts::Script
Holds all information for a script.
Definition: Script.h:14
nkScripts::Environment::setUserType
UserType * setUserType(nkMemory::StringView name)
nkMemory::BufferView
A view over data.
Definition: BufferView.h:18
nkScripts::Environment::setEnvironmentFor
void setEnvironmentFor(INTERPRETER interpretType)
nkScripts::Environment::getObject
void * getObject(nkMemory::StringView name, nkMemory::StringView userTypeName=nullptr)
nkScripts::Environment::isFuncSet
bool isFuncSet(nkMemory::StringView name)
nkScripts::Environment::getVar
bool getVar(nkMemory::StringView name, bool defaultValue)
nkScripts::UserType
Represents a user type and all the information and control related.
Definition: UserType.h:27
nkScripts::Environment::getFunc
Function * getFunc(nkMemory::StringView name)
nkScripts::Environment::isVarSet
bool isVarSet(nkMemory::StringView name)
nkScripts::ScriptObjectReference
A reference over an object in the scripting environment.
Definition: ScriptObjectReference.h:30
nkScripts::Environment::setObject
void setObject(nkMemory::StringView name, nkMemory::StringView userTypeName, void *value)
nkScripts::Environment::callScriptFunction
bool callScriptFunction(const ScriptObjectReference &reference, const DataStack &args, DataStack &expectedOutput)
nkScripts::Environment::setFunc
Function * setFunc(nkMemory::StringView name)
nkScripts::Environment::getNamespace
Namespace * getNamespace(nkMemory::StringView name)
nkScripts::ExecutionResult
Holds information about the execution result of a script in an environment.
Definition: ExecutionResult.h:26
nkScripts::INTERPRETER
INTERPRETER
Supported scripting environments.
Definition: Interpreter.h:12
nkScripts::Environment::Environment
Environment() noexcept
nkScripts::Environment::setNamespace
Namespace * setNamespace(nkMemory::StringView name)
nkScripts::Environment::requestGarbageCollection
void requestGarbageCollection()
nkScripts::Environment::getName
nkMemory::StringView getName() const
nkScripts::Environment::execute
bool execute(const Script &script)
nkScripts::Environment::deserializeScriptObject
ScriptObjectReference deserializeScriptObject(nkMemory::BufferView< unsigned char > object)
nkScripts::Environment::setVar
void setVar(nkMemory::StringView name, bool value)
nkScripts::Environment::getScriptFunction
ScriptObjectReference getScriptFunction(nkMemory::StringView name)
nkScripts::Function
Holds information, and controls, over a function in a scripting environment.
Definition: Function.h:50
nkScripts::Environment::serializeScriptObject
nkMemory::Buffer serializeScriptObject(const ScriptObjectReference &reference, bool forwardUserDataOwnership=false)
nkScripts::Environment::getLastExecutionResult
const ExecutionResult & getLastExecutionResult() const
nkScripts::Environment::setName
void setName(nkMemory::StringView name)
nkMemory
Encompasses all API of component NilkinsMemory.
Definition: Allocator.h:7