00001
00002
00003
00004
00005
00006 #ifndef __BS_MACHINE_H__
00007 #define __BS_MACHINE_H__
00008
00009 #include "bsPrerequisites.h"
00010 #include "bsScriptMachine.h"
00011 #include "bsTypeManager.h"
00012 #include "bsLog.h"
00013
00014 namespace BS_NMSP
00015 {
00016
00023 class _BSAPI Machine
00024 {
00025 Log mLog;
00026
00027 ScriptMachine* mScriptMachine;
00028
00029 TypeManager* mTypeManager;
00030
00031 private:
00032
00033 ScriptMachine* getScriptMachine() const
00034 {
00035 return mScriptMachine;
00036 }
00037
00038 public:
00039
00042 Machine();
00043
00046 ~Machine();
00047
00052 const Log& getLog() const;
00053
00061 int registerGlobalVariable(const String& name, bool readOnly, bstype initialValue);
00062
00070 void setGlobalVariableValue(const String& name, bstype value);
00071
00079 int compileScript(const uint8* buffer, size_t bufferSize);
00080
00085 void preUpdate(float frameTime);
00086
00091 void postUpdate(float frameTime);
00092
00099 void createType(const String& name);
00100
00108 int getTypeId(const String& name) const;
00109
00116 void releaseType(UserTypeBase* object);
00117
00118 #ifdef BS_Z_DIMENSION
00119
00131 void updateType(UserTypeBase* object, bstype x, bstype y, bstype z, bstype angle, float frameTime);
00132 #else
00133
00144 void updateType(UserTypeBase* object, bstype x, bstype y, bstype angle, float frameTime);
00145 #endif
00146
00156 int registerEmitFunction(const String& type, const String& name, int numArgs, EmitFunction func);
00157
00165 void setDieFunction(const String& type, DieFunction func);
00166
00176 int setAnchorX(const String& type, SetFunction set, GetFunction get);
00177
00187 int setAnchorY(const String& type, SetFunction set, GetFunction get);
00188
00189 #ifdef BS_Z_DIMENSION
00190
00199 int setAnchorZ(const String& type, SetFunction set, GetFunction get);
00200 #endif
00201
00211 int setAnchorAngle(const String& type, SetFunction set, GetFunction get);
00212
00225 int registerProperty(const String& type, const String& name, SetFunction set, GetFunction get);
00226
00237 int registerAffector(const String& type, const String& name, AffectorFunction func);
00238
00239 #ifdef BS_ENABLEJIT
00240
00249 int registerNativeFunction(const String& name, bool returnsValue, int numArguments,
00250 NativeFunction func, void* jitFunc);
00251 #else
00252
00260 int registerNativeFunction(const String& name, bool returnsValue, int numArguments,
00261 NativeFunction func);
00262 #endif
00263
00271 int declareControllerMemberVariable(const String& ctrl, const String& var, bstype value);
00272
00273
00274 #ifndef BS_Z_DIMENSION
00275
00286 Emitter* createEmitter(const String& definition, bstype x, bstype y, bstype angle,
00287 void* userObject = 0);
00288 #else
00289
00301 Emitter* createEmitter(const String& definition, bstype x, bstype y, bstype z,
00302 bstype angle, void* userObject = 0);
00303 #endif
00304
00309 void destroyEmitter(Emitter* emit);
00310
00317 bool emitterDefinitionExists(const String& name) const;
00318
00319 #ifndef BS_Z_DIMENSION
00320
00330 Controller* createController(const String& definition, bstype x, bstype y, bstype angle,
00331 void* userObject = 0);
00332 #else
00333
00344 Controller* createController(const String& definition, bstype x, bstype y, bstype z, bstype angle,
00345 void* userObject = 0);
00346 #endif
00347
00352 void destroyController(Controller* ctrl);
00353
00360 bool controllerDefinitionExists(const String& name) const;
00361
00362 #ifdef BS_ENABLEJIT
00363
00373 bool enableJIT(const char* object);
00374 #endif
00375
00376 };
00377
00378 }
00379
00380 #endif