[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog server/as_environment.cpp serve...
From: |
Sandro Santilli |
Subject: |
[Gnash-commit] gnash ChangeLog server/as_environment.cpp serve... |
Date: |
Tue, 19 Dec 2006 12:01:03 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 06/12/19 12:01:02
Modified files:
. : ChangeLog
server : as_environment.cpp as_environment.h
Log message:
* server/as_environment.{cpp,h}: ScopeStack typedef, improved
dox on variable setters/getters.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.1968&r2=1.1969
http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_environment.cpp?cvsroot=gnash&r1=1.44&r2=1.45
http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_environment.h?cvsroot=gnash&r1=1.33&r2=1.34
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.1968
retrieving revision 1.1969
diff -u -b -r1.1968 -r1.1969
--- ChangeLog 19 Dec 2006 11:07:41 -0000 1.1968
+++ ChangeLog 19 Dec 2006 12:01:02 -0000 1.1969
@@ -1,5 +1,7 @@
2006-12-19 Sandro Santilli <address@hidden>
+ * server/as_environment.{cpp,h}: ScopeStack typedef, improved
+ dox on variable setters/getters.
* server/asobj/Makefile.am: added libltdl include dir.
* server/as_environment.{cpp,h} (get_version):
simplified and clarified dox.
Index: server/as_environment.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/as_environment.cpp,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -b -r1.44 -r1.45
--- server/as_environment.cpp 19 Dec 2006 10:57:32 -0000 1.44
+++ server/as_environment.cpp 19 Dec 2006 12:01:02 -0000 1.45
@@ -16,7 +16,7 @@
//
-/* $Id: as_environment.cpp,v 1.44 2006/12/19 10:57:32 strk Exp $ */
+/* $Id: as_environment.cpp,v 1.45 2006/12/19 12:01:02 strk Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -41,7 +41,7 @@
// Return the value of the given var, if it's defined.
as_value
as_environment::get_variable(const std::string& varname,
- const std::vector<with_stack_entry>& with_stack) const
+ const ScopeStack& with_stack) const
{
// Path lookup rigamarole.
character* target = m_target;
@@ -66,14 +66,14 @@
as_value
as_environment::get_variable(const std::string& varname) const
{
- static std::vector<with_stack_entry> empty_with_stack;
+ static ScopeStack empty_with_stack;
return get_variable(varname, empty_with_stack);
}
as_value
as_environment::get_variable_raw(
const std::string& varname,
- const std::vector<with_stack_entry>& with_stack) const
+ const ScopeStack& with_stack) const
// varname must be a plain variable name; no path parsing.
{
assert(strchr(varname.c_str(), ':') == NULL);
@@ -84,7 +84,8 @@
// Check the with-stack.
for (size_t i = with_stack.size(); i > 0; --i) {
- as_object* obj = with_stack[i-1].m_object.get();
+ // const_cast needed due to non-const as_object::get_member
+ as_object* obj = const_cast<as_object*>(with_stack[i-1].object());
if (obj && obj->get_member(varname.c_str(), &val)) {
// Found the var in this context.
return val;
@@ -135,7 +136,7 @@
bool
as_environment::del_variable_raw(
const std::string& varname,
- const std::vector<with_stack_entry>& with_stack)
+ const ScopeStack& with_stack)
// varname must be a plain variable name; no path parsing.
{
assert(strchr(varname.c_str(), ':') == NULL);
@@ -147,7 +148,8 @@
// Check the with-stack.
for (size_t i = with_stack.size(); i > 0; --i)
{
- as_object* obj = with_stack[i-1].m_object.get();
+ // const_cast needed due to non-const as_object::get_member
+ as_object* obj =
const_cast<as_object*>(with_stack[i-1].object());
if (obj)
{
std::pair<bool,bool> ret = obj->delProperty(varname);
@@ -184,7 +186,7 @@
as_value
as_environment::get_variable_raw(const std::string& varname) const
{
- static std::vector<with_stack_entry> empty_with_stack;
+ static ScopeStack empty_with_stack;
return get_variable_raw(varname, empty_with_stack);
}
@@ -193,7 +195,7 @@
as_environment::set_variable(
const std::string& varname,
const as_value& val,
- const std::vector<with_stack_entry>& with_stack)
+ const ScopeStack& with_stack)
{
IF_VERBOSE_ACTION (
log_action("-------------- %s = %s",
@@ -207,9 +209,17 @@
//log_msg("set_variable(%s, %s)", varname.c_str(), val.to_string());
if (parse_path(varname, path, var)) {
target = find_target(path);
- if (target) {
+ if (target)
+ {
target->set_member(var.c_str(), val);
}
+ else
+ {
+ IF_VERBOSE_ASCODING_ERRORS(
+ log_warning("Path target '%s' not found while setting %s=%s",
+ path.c_str(), varname.c_str(), val.to_string());
+ );
+ }
} else {
set_variable_raw(varname, val, with_stack);
}
@@ -220,7 +230,7 @@
const std::string& varname,
const as_value& val)
{
- static std::vector<with_stack_entry> empty_with_stack;
+ static ScopeStack empty_with_stack;
set_variable(varname, val, empty_with_stack);
}
@@ -229,12 +239,13 @@
as_environment::set_variable_raw(
const std::string& varname,
const as_value& val,
- const std::vector<with_stack_entry>& with_stack)
+ const ScopeStack& with_stack)
{
// Check the with-stack.
- for (int i = with_stack.size() - 1; i >= 0; i--)
+ for (size_t i = with_stack.size(); i > 0; --i)
{
- as_object* obj = with_stack[i].m_object.get();
+ // const_cast needed due to non-const as_object::get_member
+ as_object* obj =
const_cast<as_object*>(with_stack[i-1].object());
as_value dummy;
if (obj && obj->get_member(varname.c_str(), &dummy)) {
// This object has the member; so set it here.
@@ -261,7 +272,7 @@
const std::string& varname,
const as_value& val)
{
- static std::vector<with_stack_entry> empty_with_stack;
+ static ScopeStack empty_with_stack;
set_variable_raw(varname, val, empty_with_stack);
}
Index: server/as_environment.h
===================================================================
RCS file: /sources/gnash/gnash/server/as_environment.h,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -b -r1.33 -r1.34
--- server/as_environment.h 19 Dec 2006 10:57:32 -0000 1.33
+++ server/as_environment.h 19 Dec 2006 12:01:02 -0000 1.34
@@ -18,7 +18,7 @@
//
//
-/* $Id: as_environment.h,v 1.33 2006/12/19 10:57:32 strk Exp $ */
+/* $Id: as_environment.h,v 1.34 2006/12/19 12:01:02 strk Exp $ */
#ifndef GNASH_AS_ENVIRONMENT_H
#define GNASH_AS_ENVIRONMENT_H
@@ -45,6 +45,10 @@
class as_environment
{
public:
+
+ /// A stack of objects used for variables/members lookup
+ typedef std::vector<with_stack_entry> ScopeStack;
+
/// Stack of as_values in this environment
std::vector<as_value> m_stack;
@@ -129,48 +133,111 @@
size_t stack_size() const { return m_stack.size(); }
/// \brief
- /// Return the (possibly UNDEFINED) value of the named var.
- /// Variable name can contain path elements.
+ /// Return the (possibly UNDEFINED) value of the named variable
+ //
+ /// @param varname
+ /// Variable name. Can contain path elements.
+ /// TODO: should be case-insensitive up to SWF6.
///
as_value get_variable(const std::string& varname) const;
- /// Same of the above, but no support for path.
+ /// Return the (possibly UNDEFINED) value of the named variable.
+ //
+ /// @param varname
+ /// Variable name. Can not contain path elements.
+ /// TODO: should be case-insensitive up to SWF6.
+ ///
as_value get_variable_raw(const std::string& varname) const;
/// \brief
- /// Delete a variable, w/out support for the path, seeking
- /// in the given 'with' stack.
+ /// Delete a variable, w/out support for the path, using
+ /// a ScopeStack.
//
- /// TODO: varname should be likely case-insensitive up to SWF6
- /// and case-SENSITIVE from SWF7 on
+ /// @param varname
+ /// Variable name. Can not contain path elements.
+ /// TODO: should be case-insensitive up to SWF6.
+ ///
+ /// @param with_stack
+ /// The Scope stack to use for lookups.
///
bool del_variable_raw(const std::string& varname,
- const std::vector<with_stack_entry>& with_stack);
+ const ScopeStack& with_stack);
- /// \brief
/// Return the (possibly UNDEFINED) value of the named var.
- /// Variable name can contain path elements.
- /// Uses the with_stack ActionContext
+ //
+ /// @param varname
+ /// Variable name. Can contain path elements.
+ /// TODO: should be case-insensitive up to SWF6.
+ ///
+ /// @param with_stack
+ /// The Scope stack to use for lookups.
///
as_value get_variable(const std::string& varname,
- const std::vector<with_stack_entry>& with_stack) const;
+ const ScopeStack& with_stack) const;
/// \brief
/// Given a path to variable, set its value.
/// Variable name can contain path elements.
+ //
+ /// @param path
+ /// Variable path.
+ /// TODO: should be case-insensitive up to SWF6.
+ ///
+ /// @param val
+ /// The value to assign to the variable, if found.
+ ///
+ /// TODO: make this function return some info about the
+ /// variable being found and set ?
///
void set_variable(const std::string& path, const as_value& val);
/// Given a variable name, set its value (no support for path)
- void set_variable_raw(const std::string& path, const as_value& val);
+ //
+ /// If no variable with that name is found, a new one
+ /// will be created as a member of current target.
+ ///
+ /// @param var
+ /// Variable name. Can not contain path elements.
+ /// TODO: should be case-insensitive up to SWF6.
+ ///
+ /// @param val
+ /// The value to assign to the variable, if found.
+ ///
+ void set_variable_raw(const std::string& var, const as_value& val);
/// \brief
- /// Given a path to variable, set its value,
- /// using the with_stack ActionContext
+ /// Given a path to variable, set its value.
+ //
+ /// If no variable with that name is found, a new one is created.
+ ///
+ /// For path-less variables, this would act as a proxy for
+ /// set_variable_raw.
+ ///
+ /// @param path
+ /// Variable path.
+ /// TODO: should be case-insensitive up to SWF6.
+ ///
+ /// @param val
+ /// The value to assign to the variable.
+ ///
+ /// @param with_stack
+ /// The Scope stack to use for lookups.
+ ///
void set_variable(const std::string& path, const as_value& val,
- const std::vector<with_stack_entry>& with_stack);
+ const ScopeStack& with_stack);
/// Set/initialize the value of the local variable.
+ //
+ /// If no *local* variable with that name is found, a new one
+ /// will be created.
+ ///
+ /// @param varname
+ /// Variable name. Can not contain path elements.
+ /// TODO: should be case-insensitive up to SWF6.
+ ///
+ /// @param val
+ /// The value to assign to the variable.
+ ///
void set_local(const std::string& varname, const as_value& val);
/// \brief
@@ -319,11 +386,11 @@
/// Given a variable name, set its value (no support for path)
void set_variable_raw(const std::string& path, const as_value& val,
- const std::vector<with_stack_entry>& with_stack);
+ const ScopeStack& with_stack);
/// Same of the above, but no support for path.
as_value get_variable_raw(const std::string& varname,
- const std::vector<with_stack_entry>& with_stack) const;
+ const ScopeStack& with_stack) const;
/// \brief
- [Gnash-commit] gnash ChangeLog server/as_environment.cpp serve..., Sandro Santilli, 2006/12/07
- [Gnash-commit] gnash ChangeLog server/as_environment.cpp serve..., Sandro Santilli, 2006/12/07
- [Gnash-commit] gnash ChangeLog server/as_environment.cpp serve..., Sandro Santilli, 2006/12/08
- [Gnash-commit] gnash ChangeLog server/as_environment.cpp serve..., Sandro Santilli, 2006/12/14
- [Gnash-commit] gnash ChangeLog server/as_environment.cpp serve..., Sandro Santilli, 2006/12/14
- [Gnash-commit] gnash ChangeLog server/as_environment.cpp serve..., Sandro Santilli, 2006/12/18
- [Gnash-commit] gnash ChangeLog server/as_environment.cpp serve..., Sandro Santilli, 2006/12/19
- [Gnash-commit] gnash ChangeLog server/as_environment.cpp serve...,
Sandro Santilli <=