ivaria/script.h
Go to the documentation of this file.00001 /* 00002 Copyright (C) 1999 by Brandon Ehle <azverkan@yahoo.com> 00003 (C) 2003-2007 by Mat Sutcliffe <oktal@gmx.co.uk> 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License as published by the Free Software Foundation; either 00008 version 2 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public 00016 License along with this library; if not, write to the Free 00017 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00018 */ 00019 00020 #ifndef __CS_IVARIA_SCRIPT_H__ 00021 #define __CS_IVARIA_SCRIPT_H__ 00022 00027 #include "csutil/scf.h" 00028 #include "csutil/ref.h" 00029 #include "csutil/array.h" 00030 #include "csutil/refarr.h" 00031 #include "iutil/string.h" 00032 00033 struct iScript; 00034 struct iScriptObject; 00035 00054 struct iScriptValue : public virtual iBase 00055 { 00056 SCF_INTERFACE (iScriptValue, 2, 0, 0); 00057 00059 enum 00060 { 00061 tInt = 0x01, 00062 tFloat = 0x02, 00063 tDouble = 0x04, 00064 tString = 0x08, 00065 tBool = 0x10, 00066 tObject = 0x20 00067 }; 00068 00070 virtual iScript* GetScript () = 0; 00071 00073 virtual unsigned GetTypes () const = 0; 00074 00076 virtual int GetInt () const = 0; 00077 00079 virtual float GetFloat () const = 0; 00080 00082 virtual double GetDouble () const = 0; 00083 00085 virtual const csRef<iString> GetString () const = 0; 00086 00088 virtual bool GetBool () const = 0; 00089 00091 virtual csRef<iScriptObject> GetObject () const = 0; 00092 }; 00093 00102 struct iScriptObject : public virtual iBase 00103 { 00104 SCF_INTERFACE (iScriptObject, 2, 0, 0); 00105 00109 virtual iScript* GetScript () = 0; 00110 00117 virtual const csRef<iString> GetClass () const = 0; 00118 00126 virtual bool IsA (const char *) const = 0; 00127 00129 CS_DEPRECATED_METHOD_MSG("use IsA() instead") 00130 virtual bool IsType (const char *) const = 0; 00131 00141 virtual void* GetPointer () = 0; 00142 00149 CS_DEPRECATED_METHOD 00150 virtual bool SetPointer (void*) = 0; 00151 00162 virtual csPtr<iScriptValue> Call (const char *name, 00163 const csRefArray<iScriptValue> &args = csRefArray<iScriptValue> ()) = 0; 00164 00175 virtual bool Set (const char *name, iScriptValue *value) = 0; 00176 00186 virtual csPtr<iScriptValue> Get (const char *name) = 0; 00187 00189 //@@@ Lots more deprecated methods below 00190 00191 #define CS_DEPRECATED_METHOD_MSG_CALL CS_DEPRECATED_METHOD_MSG \ 00192 ("use Call(const char*, const csRefArray<iScriptValue>&) instead") 00193 #define CS_DEPRECATED_METHOD_MSG_SET(NEW_METHOD) CS_DEPRECATED_METHOD_MSG \ 00194 ("use " NEW_METHOD "(const char*, iScriptValue*) instead") 00195 #define CS_DEPRECATED_METHOD_MSG_GET(NEW_METHOD) CS_DEPRECATED_METHOD_MSG \ 00196 ("use " NEW_METHOD "(const char*) instead") 00197 00198 CS_DEPRECATED_METHOD_MSG_CALL 00199 virtual bool Call (const char *name, const char *format, ...) 00200 CS_GNUC_PRINTF(3, 4) = 0; 00201 CS_DEPRECATED_METHOD_MSG_CALL 00202 virtual bool Call (const char *name, int &ret, const char *fmt, ...) 00203 CS_GNUC_PRINTF(4, 5) = 0; 00204 CS_DEPRECATED_METHOD_MSG_CALL 00205 virtual bool Call (const char *name, float &ret, const char *fmt, ...) 00206 CS_GNUC_PRINTF(4, 5) = 0; 00207 CS_DEPRECATED_METHOD_MSG_CALL 00208 virtual bool Call (const char *name, double &ret, const char *fmt, ...) 00209 CS_GNUC_PRINTF(4, 5) = 0; 00210 CS_DEPRECATED_METHOD_MSG_CALL 00211 virtual bool Call (const char *name, csRef<iString>&, const char *fmt, ...) 00212 CS_GNUC_PRINTF(4, 5) = 0; 00213 CS_DEPRECATED_METHOD_MSG_CALL 00214 virtual bool Call (const char *name, csRef<iScriptObject>&, 00215 const char *fmt, ...) CS_GNUC_PRINTF(4, 5) = 0; 00216 00217 CS_DEPRECATED_METHOD_MSG_SET("Set") 00218 virtual bool Set (const char *name, int data) = 0; 00219 CS_DEPRECATED_METHOD_MSG_SET("Set") 00220 virtual bool Set (const char *name, float data) = 0; 00221 CS_DEPRECATED_METHOD_MSG_SET("Set") 00222 virtual bool Set (const char *name, double data) = 0; 00223 CS_DEPRECATED_METHOD_MSG_SET("Set") 00224 virtual bool Set (const char *name, char const *data) = 0; 00225 CS_DEPRECATED_METHOD_MSG_SET("Set") 00226 virtual bool Set (const char *name, iScriptObject *data) = 0; 00227 CS_DEPRECATED_METHOD_MSG_SET("Set") 00228 virtual bool SetTruth (const char *name, bool isTrue) = 0; 00229 00230 CS_DEPRECATED_METHOD_MSG_GET("Get") 00231 virtual bool Get (const char *name, int &data) const = 0; 00232 CS_DEPRECATED_METHOD_MSG_GET("Get") 00233 virtual bool Get (const char *name, float &data) const = 0; 00234 CS_DEPRECATED_METHOD_MSG_GET("Get") 00235 virtual bool Get (const char *name, double &data) const = 0; 00236 CS_DEPRECATED_METHOD_MSG_GET("Get") 00237 virtual bool Get (const char *name, csRef<iString>&) const = 0; 00238 CS_DEPRECATED_METHOD_MSG_GET("Get") 00239 virtual bool Get (const char *name, csRef<iScriptObject>&) const = 0; 00240 CS_DEPRECATED_METHOD_MSG_GET("Get") 00241 virtual bool GetTruth (const char *name, bool &isTrue) const = 0; 00242 }; 00243 00249 struct iScript : public virtual iBase 00250 { 00251 SCF_INTERFACE (iScript, 2, 0, 0); 00252 00258 virtual bool RunText (const char *text) = 0; 00259 00265 virtual bool LoadModule (const char *name) = 0; 00266 00273 virtual bool LoadModule (const char *path, const char *filename) = 0; 00274 00281 virtual bool LoadModuleNative (const char *path, const char *filename) = 0; 00282 00293 virtual csPtr<iScriptValue> Call (const char *name, 00294 const csRefArray<iScriptValue> &args = csRefArray<iScriptValue> ()) = 0; 00295 00297 virtual csPtr<iScriptValue> RValue (int value) = 0; 00298 00300 virtual csPtr<iScriptValue> RValue (float value) = 0; 00301 00303 virtual csPtr<iScriptValue> RValue (double value) = 0; 00304 00306 virtual csPtr<iScriptValue> RValue (const char *value) = 0; 00307 00309 virtual csPtr<iScriptValue> RValue (bool value) = 0; 00310 00312 virtual csPtr<iScriptValue> RValue (iScriptObject *value) = 0; 00313 00322 virtual csPtr<iScriptObject> New (const char *type, 00323 const csRefArray<iScriptValue> &args = csRefArray<iScriptValue> ()) = 0; 00324 00334 virtual bool Store (const char *name, iScriptValue *value) = 0; 00335 00343 virtual csPtr<iScriptValue> Retrieve (const char *name) = 0; 00344 00352 virtual bool Remove (const char *name) = 0; 00353 00355 //@@@ Lots more deprecated methods below. 00356 00357 CS_DEPRECATED_METHOD_MSG("use New() instead") 00358 virtual csRef<iScriptObject> NewObject (const char *type, 00359 const char *ctorFormat, ...) CS_GNUC_PRINTF(3, 4) = 0; 00360 00361 CS_DEPRECATED_METHOD_MSG_CALL 00362 virtual bool Call (const char *name, const char *format, ...) 00363 CS_GNUC_PRINTF(3, 4) = 0; 00364 CS_DEPRECATED_METHOD_MSG_CALL 00365 virtual bool Call (const char *name, int &ret, const char *fmt, ...) 00366 CS_GNUC_PRINTF(4, 5) = 0; 00367 CS_DEPRECATED_METHOD_MSG_CALL 00368 virtual bool Call (const char *name, float &ret, const char *fmt, ...) 00369 CS_GNUC_PRINTF(4, 5) = 0; 00370 CS_DEPRECATED_METHOD_MSG_CALL 00371 virtual bool Call (const char *name, double &ret, const char *fmt, ...) 00372 CS_GNUC_PRINTF(4, 5) = 0; 00373 CS_DEPRECATED_METHOD_MSG_CALL 00374 virtual bool Call (const char *name, csRef<iString>&, const char *fmt, ...) 00375 CS_GNUC_PRINTF(4, 5) = 0; 00376 CS_DEPRECATED_METHOD_MSG_CALL 00377 virtual bool Call (const char *name, csRef<iScriptObject> &ret, 00378 const char *fmt, ...) CS_GNUC_PRINTF(4, 5) = 0; 00379 00380 CS_DEPRECATED_METHOD_MSG_SET("Store") 00381 virtual bool Store (const char *name, int data) = 0; 00382 CS_DEPRECATED_METHOD_MSG_SET("Store") 00383 virtual bool Store (const char *name, float data) = 0; 00384 CS_DEPRECATED_METHOD_MSG_SET("Store") 00385 virtual bool Store (const char *name, double data) = 0; 00386 CS_DEPRECATED_METHOD_MSG_SET("Store") 00387 virtual bool Store (const char *name, char const *data) = 0; 00388 CS_DEPRECATED_METHOD_MSG_SET("Store") 00389 virtual bool Store (const char *name, iScriptObject *data) = 0; 00390 CS_DEPRECATED_METHOD_MSG_SET("Store") 00391 virtual bool SetTruth (const char *name, bool isTrue) = 0; 00392 00393 CS_DEPRECATED_METHOD_MSG_GET("Retrieve") 00394 virtual bool Retrieve (const char *name, int &data) const = 0; 00395 CS_DEPRECATED_METHOD_MSG_GET("Retrieve") 00396 virtual bool Retrieve (const char *name, float &data) const = 0; 00397 CS_DEPRECATED_METHOD_MSG_GET("Retrieve") 00398 virtual bool Retrieve (const char *name, double &data) const = 0; 00399 CS_DEPRECATED_METHOD_MSG_GET("Retrieve") 00400 virtual bool Retrieve (const char *name, csRef<iString>&) const = 0; 00401 CS_DEPRECATED_METHOD_MSG_GET("Retrieve") 00402 virtual bool Retrieve (const char *name, csRef<iScriptObject>&) const = 0; 00403 CS_DEPRECATED_METHOD_MSG_GET("Retrieve") 00404 virtual bool GetTruth (const char *name, bool &isTrue) const = 0; 00405 00406 #undef CS_DEPRECATED_METHOD_MSG_CALL 00407 #undef CS_DEPRECATED_METHOD_MSG_SET 00408 #undef CS_DEPRECATED_METHOD_MSG_GET 00409 }; 00410 00411 #endif // __CS_IVARIA_SCRIPT_H__
Generated for Crystal Space 2.0 by doxygen 1.6.1