00001
00002
00003
00004
00005
00006 #ifndef __BS_OBJECTDEFINITION_H__
00007 #define __BS_OBJECTDEFINITION_H__
00008
00009 #include <vector>
00010 #include "bsPrerequisites.h"
00011 #include "bsCore.h"
00012 #include "bsBytecode.h"
00013
00014 namespace BS_NMSP
00015 {
00016 class ScriptMachine;
00017
00020 class _BSAPI ObjectDefinition
00021 {
00022
00023 public:
00024
00027 struct MemberVariable
00028 {
00030 String name;
00032 bool readonly;
00034 bstype value;
00035 };
00036
00039 struct State
00040 {
00042 String name;
00043 };
00044
00045 public:
00046
00052 ObjectDefinition(const String& name, const String& type);
00053
00056 virtual ~ObjectDefinition();
00057
00062 const String& getName() const;
00063
00068 const String& getType() const;
00069
00075 void appendConstructionCode(const BytecodeBlock& code);
00076
00079 void finaliseConstructor();
00080
00085 void setMaxLocalVariables(int count);
00086
00091 int getMaxLocalVariables() const;
00092
00100 int addMemberVariable(const String& name, bool readOnly, bstype initialValue = bsvalue0);
00101
00109 MemberVariable& getMemberVariable(int index);
00110
00116 int getMemberVariableIndex(const String& name) const;
00117
00122 int getNumMemberVariables() const;
00123
00128 void setNumUserMembers(int count);
00129
00134 int getNumUserMembers() const;
00135
00143 State& addState(const String& name);
00144
00152 State &getState(int index);
00153
00159 int getStateIndex(const String& name) const;
00160
00165 int getNumStates() const;
00166
00171 void setInitialState(int state);
00172
00178 ScriptRecord* createScriptRecord(ScriptMachine* machine);
00179
00180 private:
00181
00182 String mName;
00183
00184 String mType;
00185
00186 protected:
00187
00189 int mMaxLocals;
00190
00192 BytecodeBlock mConstructor;
00193
00195 uint32* mConstructCode;
00196
00198 size_t mConstructSize;
00199
00201 std::vector<MemberVariable> mMemberVariables;
00202
00204 int mNumUserMembers;
00205
00207 std::vector<State> mStates;
00208
00210 int mInitialState;
00211
00212 };
00213
00214 }
00215
00216 #endif