[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Dotgnu-pnet-commits] CVS: pnetlib/JScript/Execute DefaultValueHint.cs,
From: |
Rhys Weatherley <address@hidden> |
Subject: |
[Dotgnu-pnet-commits] CVS: pnetlib/JScript/Execute DefaultValueHint.cs,NONE,1.1 ActivationObject.cs,1.1,1.2 JSObject.cs,1.1,1.2 ScriptFunction.cs,1.1,1.2 ScriptObject.cs,1.1,1.2Support.cs,1.1,1.2 |
Date: |
Tue, 14 Jan 2003 05:35:53 -0500 |
Update of /cvsroot/dotgnu-pnet/pnetlib/JScript/Execute
In directory subversions:/tmp/cvs-serv25859/JScript/Execute
Modified Files:
ActivationObject.cs JSObject.cs ScriptFunction.cs
ScriptObject.cs Support.cs
Added Files:
DefaultValueHint.cs
Log Message:
Bring the names of builtin properties and functions into alignment with
the names in ECMA-262.
--- NEW FILE ---
/*
* DefaultValueHint.cs - Hint values for "ScriptObject.DefaultValue".
*
* Copyright (C) 2003 Southern Storm Software, Pty Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
namespace Microsoft.JScript
{
using System;
internal enum DefaultValueHint
{
None,
Number,
String,
LocaleString
}; // enum DefaultValueHint
}; // namespace Microsoft.JScript
Index: ActivationObject.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/JScript/Execute/ActivationObject.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** ActivationObject.cs 13 Jan 2003 10:53:19 -0000 1.1
--- ActivationObject.cs 14 Jan 2003 10:35:49 -0000 1.2
***************
*** 61,65 ****
if(storage.HasOwnProperty(name))
{
! return
storage.GetProperty(name);
}
else if(parent != null)
--- 61,65 ----
if(storage.HasOwnProperty(name))
{
! return storage.Get(name);
}
else if(parent != null)
***************
*** 107,115 ****
if(storage.HasOwnProperty(name))
{
! return storage.GetProperty(name);
}
else
{
! storage.SetProperty(name, null,
PropertyAttributes.None);
return null;
}
--- 107,115 ----
if(storage.HasOwnProperty(name))
{
! return storage.Get(name);
}
else
{
! storage.Put(name, null);
return null;
}
***************
*** 117,121 ****
void IVariableAccess.SetVariable(String name, Object value)
{
! storage.SetProperty(name, value,
PropertyAttributes.None);
}
--- 117,121 ----
void IVariableAccess.SetVariable(String name, Object value)
{
! storage.Put(name, value);
}
Index: JSObject.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/JScript/Execute/JSObject.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** JSObject.cs 13 Jan 2003 10:53:19 -0000 1.1
--- JSObject.cs 14 Jan 2003 10:35:50 -0000 1.2
***************
*** 107,111 ****
do
{
! toStr = (temp.GetProperty("toString")
as ScriptFunction);
if(toStr != null)
{
--- 107,111 ----
do
{
! toStr = (temp.Get("toString") as
ScriptFunction);
if(toStr != null)
{
***************
*** 119,133 ****
}
- // Get the internal "[[Class]]" property for this object.
- internal virtual String ClassName
- {
- get
- {
- return "Object";
- }
- }
-
// Get a property from this object. Null if not present.
! internal override Object GetProperty(String name)
{
Property prop;
--- 119,124 ----
}
// Get a property from this object. Null if not present.
! internal override Object Get(String name)
{
Property prop;
***************
*** 143,147 ****
else
{
! return null;
}
}
--- 134,138 ----
else
{
! return base.Get(name);
}
}
***************
*** 158,163 ****
}
! // Could not find the property.
! return null;
}
--- 149,154 ----
}
! // Try looking in the prototype.
! return base.Get(name);
}
***************
*** 223,229 ****
}
! // Set a property in this object.
! internal override void SetProperty(String name, Object value,
!
PropertyAttributes attrs)
{
Property prop, prev;
--- 214,223 ----
}
! // Put a property in this object.
! internal override void Put(String name, Object value)
! {
! Put(name, value, PropertyAttributes.None);
! }
! internal void Put(String name, Object value, PropertyAttributes attrs)
{
Property prop, prev;
***************
*** 299,307 ****
}
// Add a builtin method to a prototype.
internal void AddBuiltin(EngineInstance inst, String name)
{
MethodInfo method = GetType().GetMethod(name);
! SetProperty(name, new BuiltinFunction
(inst.GetFunctionPrototype(), name,
method),
PropertyAttributes.None);
--- 293,350 ----
}
+ // Delete a property from this object.
+ internal override bool Delete(String name)
+ {
+ Property prop, prev;
+
+ // Check the overflow hash table first, if it
exists.
+ if(overflow != null)
+ {
+ prop = (Property)(overflow[name]);
+ if(prop != null)
+ {
+ if((prop.attrs &
PropertyAttributes.DontDelete) != 0)
+ {
+ return false;
+ }
+ overflow.Remove(name);
+ }
+ return true;
+ }
+
+ // Scan the property list.
+ prop = properties;
+ prev = null;
+ while(prop != null)
+ {
+ if(prop.name == name)
+ {
+ if((prop.attrs &
PropertyAttributes.DontDelete) != 0)
+ {
+ return false;
+ }
+ if(prev != null)
+ {
+ prev.next = prop.next;
+ }
+ else
+ {
+ properties = prop.next;
+ }
+ return true;
+ }
+ prev = prop;
+ prop = prop.next;
+ }
+
+ // Could not find the property, so act as
though it is deleted.
+ return true;
+ }
+
// Add a builtin method to a prototype.
internal void AddBuiltin(EngineInstance inst, String name)
{
MethodInfo method = GetType().GetMethod(name);
! Put(name, new BuiltinFunction
(inst.GetFunctionPrototype(), name,
method),
PropertyAttributes.None);
Index: ScriptFunction.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/JScript/Execute/ScriptFunction.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** ScriptFunction.cs 13 Jan 2003 10:53:19 -0000 1.1
--- ScriptFunction.cs 14 Jan 2003 10:35:50 -0000 1.2
***************
*** 76,80 ****
public Object CreateInstance(params Object[] args)
{
! return CallConstructor(args);
}
--- 76,80 ----
public Object CreateInstance(params Object[] args)
{
! return Construct(args);
}
***************
*** 148,152 ****
// Perform a constructor call on this object.
! internal virtual Object CallConstructor(Object[] args)
{
JSObject obj = new
JSObject(GetPrototypeForConstructedObject());
--- 148,152 ----
// Perform a constructor call on this object.
! internal virtual Object Construct(Object[] args)
{
JSObject obj = new
JSObject(GetPrototypeForConstructedObject());
***************
*** 163,167 ****
// Get the internal "[[Class]]" property for this object.
! internal override String ClassName
{
get
--- 163,167 ----
// Get the internal "[[Class]]" property for this object.
! internal override String Class
{
get
Index: ScriptObject.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/JScript/Execute/ScriptObject.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** ScriptObject.cs 13 Jan 2003 10:53:19 -0000 1.1
--- ScriptObject.cs 14 Jan 2003 10:35:50 -0000 1.2
***************
*** 180,188 ****
if(index >= 0)
{
! value =
GetPropertyByIndex(index);
}
else
{
! value =
GetProperty(Convert.ToString(index));
}
if(!(value is Missing))
--- 180,188 ----
if(index >= 0)
{
! value = GetIndex(index);
}
else
{
! value =
Get(Convert.ToString(index));
}
if(!(value is Missing))
***************
*** 199,208 ****
if(index >= 0)
{
! SetPropertyByIndex(index,
value);
}
else
{
!
SetProperty(Convert.ToString(index), value,
!
PropertyAttributes.None);
}
}
--- 199,207 ----
if(index >= 0)
{
! PutIndex(index, value);
}
else
{
! Put(Convert.ToString(index),
value);
}
}
***************
*** 216,224 ****
Math.Round(index) == index)
{
! value =
GetPropertyByIndex((int)index);
}
else
{
! value =
GetProperty(Convert.ToString(index));
}
if(!(value is Missing))
--- 215,223 ----
Math.Round(index) == index)
{
! value = GetIndex((int)index);
}
else
{
! value =
Get(Convert.ToString(index));
}
if(!(value is Missing))
***************
*** 236,245 ****
Math.Round(index) == index)
{
! SetPropertyByIndex((int)index,
value);
}
else
{
!
SetProperty(Convert.ToString(index), value,
!
PropertyAttributes.None);
}
}
--- 235,243 ----
Math.Round(index) == index)
{
! PutIndex((int)index, value);
}
else
{
! Put(Convert.ToString(index),
value);
}
}
***************
*** 249,253 ****
get
{
! Object value = GetProperty(name);
if(!(value is Missing))
{
--- 247,251 ----
get
{
! Object value = Get(name);
if(!(value is Missing))
{
***************
*** 261,265 ****
set
{
! SetProperty(name, value,
PropertyAttributes.None);
}
}
--- 259,263 ----
set
{
! Put(name, value);
}
}
***************
*** 345,360 ****
}
// Get a property from this object. Null if not present.
! internal virtual Object GetProperty(String name)
{
! // TODO
! return null;
}
! // Set a property in this object.
! internal virtual void SetProperty(String name, Object value,
!
PropertyAttributes attrs)
{
! // TODO
}
--- 343,399 ----
}
+ // Get the internal "[[Class]]" property for this object.
+ internal virtual String Class
+ {
+ get
+ {
+ return "Object";
+ }
+ }
+
// Get a property from this object. Null if not present.
! internal virtual Object Get(String name)
{
! // The base class only needs to check the
prototype.
! if(parent != null)
! {
! return parent.Get(name);
! }
! else
! {
! return null;
! }
}
! // Get a property from this object by numeric index.
! internal virtual Object GetIndex(int index)
{
! return Get(Convert.ToString(index));
! }
!
! // Put a property to this object.
! internal virtual void Put(String name, Object value)
! {
! // Normally overridden in subclasses.
! }
!
! // Put a property to this object by numeric index.
! internal virtual void PutIndex(int index, Object value)
! {
! Put(Convert.ToString(index), value);
! }
!
! // Determine if we can put a property to this object.
! internal virtual bool CanPut(String name)
! {
! // The base class only needs to check the
prototype.
! if(parent != null)
! {
! return parent.CanPut(name);
! }
! else
! {
! return true;
! }
}
***************
*** 362,380 ****
internal virtual bool HasOwnProperty(String name)
{
! // TODO
return false;
}
! // Get a property from this object by numeric index.
! internal virtual Object GetPropertyByIndex(int index)
{
! return GetProperty(Convert.ToString(index));
}
! // Get a property from this object by numeric index.
! internal virtual void SetPropertyByIndex(int index, Object value)
{
! SetProperty(Convert.ToString(index), value,
!
PropertyAttributes.None);
}
--- 401,437 ----
internal virtual bool HasOwnProperty(String name)
{
! // Normally overridden in subclasses.
return false;
}
! // Determine if this object or one of its prototypes has a property.
! internal virtual bool HasProperty(String name)
! {
! if(HasOwnProperty(name))
! {
! return true;
! }
! else if(parent != null)
! {
! return parent.HasProperty(name);
! }
! else
! {
! return false;
! }
! }
!
! // Delete a property from this object.
! internal virtual bool Delete(String name)
{
! // Normally overridden in subclasses.
! return true;
}
! // Get the default value for this object.
! internal virtual Object DefaultValue(DefaultValueHint hint)
{
! // TODO
! return null;
}
Index: Support.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/JScript/Execute/Support.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** Support.cs 13 Jan 2003 10:53:19 -0000 1.1
--- Support.cs 14 Jan 2003 10:35:50 -0000 1.2
***************
*** 135,139 ****
else if(value is JSObject)
{
! return
((JSObject)value).ClassName.ToLower();
}
else
--- 135,139 ----
else if(value is JSObject)
{
! return
((JSObject)value).Class.ToLower();
}
else
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Dotgnu-pnet-commits] CVS: pnetlib/JScript/Execute DefaultValueHint.cs,NONE,1.1 ActivationObject.cs,1.1,1.2 JSObject.cs,1.1,1.2 ScriptFunction.cs,1.1,1.2 ScriptObject.cs,1.1,1.2Support.cs,1.1,1.2,
Rhys Weatherley <address@hidden> <=