• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

src/interp/JsMethod.cpp

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 #include <spl/interp/JsArray.h>
00018 #include <spl/interp/JsMethod.h>
00019 
00020 JsMethod::JsMethod(const String& sourceCode)
00021 : m_src(sourceCode), m_prog()
00022 {
00023         throw new NotImplementedException();
00024 }
00025 
00026 JsMethod::JsMethod()
00027 : m_src("function anonymous( ) { [native code] }"), m_prog()
00028 {
00029 }
00030 
00031 JsMethod::JsMethod(const Program& prog)
00032 : m_src("function anonymous( ) { [native code] }"), m_prog(prog)
00033 {
00034 }
00035 
00036 JsMethod::JsMethod(const JsMethod& obj)
00037 : JsObject(obj), m_src(obj.m_src), m_prog(obj.m_prog)
00038 {
00039 }
00040 
00041 JsMethod::~JsMethod()
00042 {
00043 }
00044 
00045 IJsObjectPtr JsMethod::New() const
00046 {
00047         return IJsObjectPtr(new JsMethod(*this));
00048 }
00049 
00050 bool JsMethod::IsNative() const
00051 {
00052         return false;
00053 }
00054 
00055 VariantPtr JsMethod::Call(JsMethod *isthis, Vector<VariantPtr> args)
00056 {
00057         throw new Exception("Call of non native method");
00058 }
00059 
00060 VariantPtr JsMethod::GetProperty(const String& idx)
00061 {
00062         if ("arguments" == idx)
00063         {
00064         }
00065         return JsObject::GetProperty(idx);
00066 }
00067 
00068 bool JsMethod::HasProperty(const String& idx) const
00069 {
00070         return "arguments" == idx || JsObject::HasProperty(idx);
00071 }
00072 
00073 void JsMethod::SetProperty(const String& idx, VariantPtr obj)
00074 {
00075         JsObject::SetProperty(idx, obj);
00076 }
00077 
00078 bool JsMethod::Equals( const IComparable& a ) const
00079 {
00080         if (a.MajicNumber() != MajicNumber())
00081         {
00082                 return false;
00083         }
00084         
00085         return false;
00086 }
00087 
00088 int JsMethod::Compare( const IComparable& a ) const
00089 {
00090         if (a.MajicNumber() != MajicNumber())
00091         {
00092                 return -1;
00093         }
00094         
00095         return 0;
00096 }
00097 
00098 int32 JsMethod::MajicNumber() const
00099 {
00100         return JSMETHOD_MAJIC;
00101 }
00102 
00103 int32 JsMethod::HashCode() const
00104 {
00105         int32 hc = (int32)this;
00106         return hc;
00107 }
00108 
00109 StringPtr JsMethod::ToString() const
00110 {
00111         return m_src.ToString();
00112 }
00113 
00114 #if defined(DEBUG) || defined(_DEBUG)
00115 void JsMethod::CheckMem() const
00116 {
00117         JsObject::CheckMem();
00118         m_src.CheckMem();
00119         m_prog.CheckMem();
00120 }
00121 
00122 void JsMethod::ValidateMem() const
00123 {
00124         JsObject::ValidateMem();
00125         m_src.ValidateMem();
00126         m_prog.ValidateMem();
00127 }
00128 #endif
00129