00001 /* 00002 * This file is part of the Standard Portable Library (SPL). 00003 * 00004 * SPL is free software: you can redistribute it and/or modify 00005 * it under the terms of the GNU General Public License as published by 00006 * the Free Software Foundation, either version 3 of the License, or 00007 * (at your option) any later version. 00008 * 00009 * SPL 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 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with SPL. If not, see <http://www.gnu.org/licenses/>. 00016 */ 00017 #ifndef _ijsobject_h 00018 #define _ijsobject_h 00019 00020 #include <spl/types.h> 00021 #include <spl/Debug.h> 00022 #include <spl/IVariant.h> 00023 #include <spl/Memory.h> 00024 #include <spl/RefCountPtrCast.h> 00025 #include <spl/String.h> 00026 #include <spl/Undefined.h> 00027 00028 #define JSOBJECT_MAJIC 787 //< Majic number for ASSERT's in Compare and Convert 00029 #define JSNULL_MAJIC 788 //< Majic number for ASSERT's in Compare and Convert 00030 #define JSUNDEFINED_MAJIC 789 //< Majic number for ASSERT's in Compare and Convert 00031 #define JSARRAY_MAJIC 790 //< Majic number for ASSERT's in Compare and Convert 00032 #define JSMETHOD_MAJIC 791 //< Majic number for ASSERT's in Compare and Convert 00033 00034 class Variant; 00035 class IJsObject; 00036 typedef RefCountPtr<IJsObject> IJsObjectPtr; 00037 00038 class IJsObject : public IMemoryValidate, public IComparable 00039 { 00040 public: 00041 IJsObject(); 00042 virtual ~IJsObject(); 00043 00044 virtual IJsObjectPtr New() const = 0; 00045 00046 virtual RefCountPtr<Variant> GetProperty(const String& idx) = 0; 00047 virtual bool HasProperty(const String& idx) const = 0; 00048 virtual void SetProperty(const String& idx, RefCountPtr<Variant> obj) = 0; 00049 00050 virtual bool Equals( const IComparable& a ) const = 0; 00051 virtual int Compare( const IComparable& a ) const = 0; 00052 00055 virtual int32 MajicNumber() const = 0; 00056 virtual int32 HashCode() const = 0; 00057 00058 virtual StringPtr ToString() const = 0; 00059 00060 #if defined(DEBUG) || defined(_DEBUG) 00061 void CheckMem() const = 0; 00062 void ValidateMem() const = 0; 00063 #endif 00064 }; 00065 00066 //class JsNull; 00067 //typedef RefCountPtrCast<JsNull, IJsObject, IJsObjectPtr> JsNullPtr; 00068 // 00069 //class JsNull : public IJsObject 00070 //{ 00071 //protected: 00072 // IVariant* m_val; 00073 // 00074 //public: 00075 // JsNull(); 00076 // JsNull(const JsNull& obj); 00077 // virtual ~JsNull(); 00078 // 00079 // virtual RefCountPtr<Variant> GetProperty(const String& idx); 00080 // virtual bool HasProperty(const String& idx) const; 00081 // virtual void SetProperty(const String& idx, RefCountPtr<Variant> obj); 00082 // 00083 // virtual bool Equals( const IComparable& a ) const; 00084 // virtual int Compare( const IComparable& a ) const; 00085 // 00086 // ///@brief Class instances with the same majic number are of the same type (can be casted). 00087 // /// Majic numbers above 0xFFFF are available for user applications. 00088 // virtual int32 MajicNumber() const; 00089 // virtual int32 HashCode() const; 00090 // 00091 // StringPtr ToString() const; 00092 // 00093 //#if defined(DEBUG) || defined(_DEBUG) 00094 // void CheckMem() const; 00095 // void ValidateMem() const; 00096 //#endif 00097 //}; 00098 // 00099 //class JsUndefined; 00100 //typedef RefCountPtrCast<JsUndefined, IJsObject, IJsObjectPtr> JsUndefinedPtr; 00101 // 00102 //class JsUndefined : public IJsObject 00103 //{ 00104 //protected: 00105 // IVariant* m_val; 00106 // 00107 //public: 00108 // JsUndefined(); 00109 // JsUndefined(const JsUndefined& obj); 00110 // virtual ~JsUndefined(); 00111 // 00112 // virtual RefCountPtr<Variant> GetProperty(const String& idx); 00113 // virtual bool HasProperty(const String& idx) const; 00114 // virtual void SetProperty(const String& idx, RefCountPtr<Variant> obj); 00115 // 00116 // virtual bool Equals( const IComparable& a ) const; 00117 // virtual int Compare( const IComparable& a ) const; 00118 // 00119 // ///@brief Class instances with the same majic number are of the same type (can be casted). 00120 // /// Majic numbers above 0xFFFF are available for user applications. 00121 // virtual int32 MajicNumber() const; 00122 // virtual int32 HashCode() const; 00123 // 00124 // StringPtr ToString() const; 00125 // 00126 //#if defined(DEBUG) || defined(_DEBUG) 00127 // void CheckMem() const; 00128 // void ValidateMem() const; 00129 //#endif 00130 //}; 00131 00132 00133 #endif