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 _jsmethod_h 00018 #define _jsmethod_h 00019 00020 #include <spl/interp/JsObject.h> 00021 #include <spl/interp/Program.h> 00022 00023 class JsMethod; 00024 typedef RefCountPtrCast<JsMethod, JsObject, JsObjectPtr> JsMethodPtr; 00025 00026 class JsMethod : public JsObject 00027 { 00028 protected: 00029 String m_src; 00030 Program m_prog; 00031 00032 public: 00033 JsMethod(); 00034 JsMethod(const String& sourceCode); 00035 JsMethod(const Program& prog); 00036 JsMethod(const JsMethod& obj); 00037 virtual ~JsMethod(); 00038 00039 virtual IJsObjectPtr New() const; 00040 00041 virtual bool IsNative() const; 00042 virtual VariantPtr Call(JsMethod *isthis, Vector<VariantPtr> args); 00043 00044 virtual VariantPtr GetProperty(const String& idx); 00045 virtual bool HasProperty(const String& idx) const; 00046 virtual void SetProperty(const String& idx, VariantPtr obj); 00047 00048 virtual bool Equals( const IComparable& a ) const; 00049 virtual int Compare( const IComparable& a ) const; 00050 00051 virtual int32 MajicNumber() const; 00052 virtual int32 HashCode() const; 00053 00054 StringPtr ToString() const; 00055 00056 inline const Program& GetProgram() { return m_prog; } 00057 inline const Program *GetProgramPtr() { return &m_prog; } 00058 00059 #if defined(DEBUG) || defined(_DEBUG) 00060 void CheckMem() const; 00061 void ValidateMem() const; 00062 #endif 00063 }; 00064 00065 #endif