csplugincommon/script/scriptcommon.h Source File (Crystal Space 2.0 Public API Reference)

| ## Public API Reference

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

csplugincommon/script/scriptcommon.h

    00001 /*
    00002     Copyright (C) 2007 by Mat Sutcliffe <oktal@gmx.co.uk>
    00003
    00004     This library is free software; you can redistribute it and/or
    00005     modify it under the terms of the GNU Library General Public
    00006     License as published by the Free Software Foundation; either
    00007     version 2 of the License, or (at your option) any later version.
    00008
    00009     This library is distributed in the hope that it will be useful,
    00010     but WITHOUT ANY WARRANTY; without even the implied warranty of
    00011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00012     Library General Public License for more details.
    00013
    00014     You should have received a copy of the GNU Library General Public
    00015     License along with this library; if not, write to the Free
    00016     Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    00017 */
    00018
    00019 #ifndef __CS_PLUGINCOMMON_SCRIPT_SCRIPTCOMMON_H__
    00020 #define __CS_PLUGINCOMMON_SCRIPT_SCRIPTCOMMON_H__
    00021
    00022 #include "csutil/scf_implementation.h"
    00023 #include "csutil/array.h"
    00024 #include "csutil/ref.h"
    00025 #include "csutil/refarr.h"
    00026 #include "csutil/weakref.h"
    00027 #include "ivaria/script.h"
    00028
    00029 #include "csutil/deprecated_warn_off.h"
    00030
    00038 class CS_CRYSTALSPACE_EXPORT csScriptObjectCommon :
    00039   public scfImplementation1<csScriptObjectCommon, iScriptObject>
    00040 {
    00041   void CallCommon (const char *name, csRef<iScriptValue> &retval,
    00042     va_list var_args, const char *format);
    00043
    00044 protected:
    00045   csScriptObjectCommon() : scfImplementationType (this) {}
    00046   csScriptObjectCommon(iBase *parent) : scfImplementationType (this, parent) {}
    00047
    00048 public:
    00049   virtual ~csScriptObjectCommon() {}
    00050
    00051   virtual bool IsType (const char *t) const { return IsA (t); }
    00052
    00053   virtual bool SetPointer (void*) { return false; }
    00054
    00055   virtual bool Call (const char *name, const char *format, ...);
    00056   virtual bool Call (const char *name, int &ret, const char *fmt, ...);
    00057   virtual bool Call (const char *name, float &ret, const char *fmt, ...);
    00058   virtual bool Call (const char *name, double &ret, const char *fmt, ...);
    00059   virtual bool Call (const char *name, csRef<iString>&, const char *fmt, ...);
    00060   virtual bool Call (const char *name, csRef<iScriptObject>&,
    00061     const char *fmt, ...);
    00062
    00063   virtual bool Set (const char *name, int data);
    00064   virtual bool Set (const char *name, float data);
    00065   virtual bool Set (const char *name, double data);
    00066   virtual bool Set (const char *name, char const *data);
    00067   virtual bool Set (const char *name, iScriptObject *data);
    00068   virtual bool SetTruth (const char *name, bool isTrue);
    00069
    00070   virtual bool Get (const char *name, int &data) const;
    00071   virtual bool Get (const char *name, float &data) const;
    00072   virtual bool Get (const char *name, double &data) const;
    00073   virtual bool Get (const char *name, csRef<iString>&) const;
    00074   virtual bool Get (const char *name, csRef<iScriptObject>&) const;
    00075   virtual bool GetTruth (const char *name, bool &isTrue) const;
    00076
    00077   virtual csPtr<iScriptValue> Call (const char*,
    00078     const csRefArray<iScriptValue>& = csRefArray<iScriptValue> ()) = 0;
    00079   virtual bool Set (const char *name, iScriptValue*) = 0;
    00080   virtual csPtr<iScriptValue> Get (const char*) = 0;
    00081 };
    00082
    00090 class CS_CRYSTALSPACE_EXPORT csScriptCommon :
    00091   public scfImplementation1<csScriptCommon, iScript>
    00092 {
    00093   void CallCommon (const char *name, csRef<iScriptValue> &retval,
    00094     va_list var_args, const char *format);
    00095
    00096 protected:
    00097   csScriptCommon() : scfImplementationType (this) {}
    00098   csScriptCommon(iBase *parent) : scfImplementationType (this, parent) {}
    00099
    00100 public:
    00101   virtual ~csScriptCommon() {}
    00102
    00103   virtual csRef<iScriptObject> NewObject (const char *type,
    00104     const char *ctorFormat, ...);
    00105
    00106   virtual bool Call (const char *name, const char *format, ...);
    00107   virtual bool Call (const char *name, int &ret, const char *fmt, ...);
    00108   virtual bool Call (const char *name, float &ret, const char *fmt, ...);
    00109   virtual bool Call (const char *name, double &ret, const char *fmt, ...);
    00110   virtual bool Call (const char *name, csRef<iString>&, const char *fmt, ...);
    00111   virtual bool Call (const char *name, csRef<iScriptObject> &ret,
    00112     const char *fmt, ...);
    00113
    00114   virtual bool Store (const char *name, int data);
    00115   virtual bool Store (const char *name, float data);
    00116   virtual bool Store (const char *name, double data);
    00117   virtual bool Store (const char *name, char const *data);
    00118   virtual bool Store (const char *name, iScriptObject *data);
    00119   virtual bool SetTruth (const char *name, bool isTrue);
    00120
    00121   virtual bool Retrieve (const char *name, int &data) const;
    00122   virtual bool Retrieve (const char *name, float &data) const;
    00123   virtual bool Retrieve (const char *name, double &data) const;
    00124   virtual bool Retrieve (const char *name, csRef<iString>&) const;
    00125   virtual bool Retrieve (const char *name, csRef<iScriptObject>&) const;
    00126   virtual bool GetTruth (const char *name, bool &isTrue) const;
    00127
    00128   virtual csPtr<iScriptValue> Call (const char*,
    00129     const csRefArray<iScriptValue>& = csRefArray<iScriptValue> ()) = 0;
    00130   virtual bool Store (const char *name, iScriptValue*) = 0;
    00131   virtual csPtr<iScriptValue> Retrieve (const char*) = 0;
    00132 };
    00133
    00134 #include "csutil/deprecated_warn_on.h"
    00135
    00136 #endif // __CS_PLUGINCOMMON_SCRIPT_SCRIPTCOMMON_H__