[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog libbase/string_table.cpp libbas...
From: |
Chad Musick |
Subject: |
[Gnash-commit] gnash ChangeLog libbase/string_table.cpp libbas... |
Date: |
Thu, 24 Jan 2008 03:41:59 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Chad Musick <cmusick> 08/01/24 03:41:59
Modified files:
. : ChangeLog
libbase : string_table.cpp string_table.h
server : asClass.cpp asClass.h
Log message:
Add case-insensitive support for string_table. More work is needed to
enable it where appropriate.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.5482&r2=1.5483
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/string_table.cpp?cvsroot=gnash&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/string_table.h?cvsroot=gnash&r1=1.7&r2=1.8
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asClass.cpp?cvsroot=gnash&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asClass.h?cvsroot=gnash&r1=1.5&r2=1.6
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.5482
retrieving revision 1.5483
diff -u -b -r1.5482 -r1.5483
--- ChangeLog 23 Jan 2008 20:33:37 -0000 1.5482
+++ ChangeLog 24 Jan 2008 03:41:58 -0000 1.5483
@@ -1,3 +1,10 @@
+2008-01-24 Chad Musick <address@hidden>
+
+ * libbase/string_table.cpp,.h: Add a case insensitive option to
+ find and value
+ * server/asClass.h,.cpp: Change code to compile with new string
+ table key type (keys cannot be converted in one step to as_value)
+
2008-01-23 Sandro Santilli <address@hidden>
* gui/kde_glue_agg.cpp: keep rendering no matter what HAVE_QTOPIA says
Index: libbase/string_table.cpp
===================================================================
RCS file: /sources/gnash/gnash/libbase/string_table.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- libbase/string_table.cpp 21 Jan 2008 20:55:45 -0000 1.4
+++ libbase/string_table.cpp 24 Jan 2008 03:41:58 -0000 1.5
@@ -24,12 +24,24 @@
std::string string_table::mEmpty = "";
string_table::key
-string_table::find(const std::string& to_find, bool insert_unfound)
+string_table::find(const std::string& to_find, bool insert_unfound,
+ bool case_insensitive)
{
+ std::size_t ckey = 0;
+
// Empty strings all map to 0
if (to_find.empty())
return 0;
+ if (case_insensitive)
+ {
+ std::string caseless = boost::to_lower_copy(to_find);
+ if (caseless != to_find) // Only do this if cased/caseless
differs.
+ {
+ ckey = find(caseless, insert_unfound, false).caseless;
+ }
+ }
+
table::nth_index<0>::type::iterator i = mTable.get<0>().find(to_find);
if (i == mTable.end() && insert_unfound)
@@ -44,17 +56,18 @@
i = mTable.get<0>().find(to_find);
// If they did, use that value.
if (i != mTable.end())
- return i->mId;
+ return case_key(i->mId, &i->mValue);
// Otherwise, insert it.
theSvt.mValue = to_find;
theSvt.mId = ++mHighestKey;
- return mTable.insert(theSvt).first->mId;
+ mTable.insert(theSvt);
+ return case_key(ckey ? ckey : theSvt.mId,
&(theSvt.mValue));
}
else
return 0;
}
- return i->mId;
+ return case_key(ckey ? ckey : i->mId, &(i->mValue));
}
string_table::key
Index: libbase/string_table.h
===================================================================
RCS file: /sources/gnash/gnash/libbase/string_table.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- libbase/string_table.h 21 Jan 2008 20:55:45 -0000 1.7
+++ libbase/string_table.h 24 Jan 2008 03:41:59 -0000 1.8
@@ -41,6 +41,19 @@
/// A general use string table.
class string_table
{
+private:
+ struct case_key
+ {
+ std::size_t caseless;
+ const std::string *cased;
+ case_key() : caseless(0), cased(NULL) {}
+ case_key(std::size_t k) : caseless(k), cased(NULL) {}
+ case_key(std::size_t k, const std::string *c) :
+ caseless(k), cased(c) {}
+ operator std::size_t() const { return caseless; }
+ bool operator<(const case_key &o) { return caseless <
o.caseless; }
+ };
+
public:
/// A little helper for indexing.
struct svt
@@ -54,11 +67,11 @@
boost::multi_index::indexed_by<
boost::multi_index::hashed_non_unique<
boost::multi_index::member<svt, std::string,
&svt::mValue> >,
- boost::multi_index::hashed_non_unique<
+ boost::multi_index::hashed_non_unique< // caseless
boost::multi_index::member<svt, std::size_t,
&svt::mId> >
> > table;
- typedef std::size_t key;
+ typedef case_key key;
/// \brief
/// Find a string. If insert_unfound is true, the string will
@@ -70,10 +83,16 @@
/// If this is set to false, a search is performed, but no update.
/// By update, any unfound string is added to the table.
///
+ /// @param case_insensitive
+ /// If true, find a case-insensitive match to this.
+ /// N.B.: Will not necessarily match a string which was not inserted
+ /// as case_insensitive.
+ ///
/// @return
/// A key which can be used in value or 0 if the string is
/// not yet in the table and insert_unfound was false.
- key find(const std::string& to_find, bool insert_unfound = true);
+ key find(const std::string& to_find, bool insert_unfound = true,
+ bool case_insensitive = false);
/// \brief
/// Find a string which is the concatentation of two known strings
@@ -81,6 +100,21 @@
/// Otherwise, just like find.
key find_dot_pair(key left, key right, bool insert_unfound = true);
+ /// Find a string by its key, exactly.
+ ///
+ /// @param to_find
+ /// The string key whose value should be found.
+ ///
+ /// @param (unnamed)
+ /// Used to distinguish from value(key to_find)
+ const std::string& value(key &to_find, bool)
+ {
+ if (to_find.cased != NULL)
+ return *to_find.cased;
+ to_find.cased = &(value(to_find));
+ return *to_find.cased;
+ }
+
/// Find a string by its key.
///
/// @return
@@ -89,7 +123,8 @@
{
if (mTable.empty() || !to_find)
return mEmpty;
- table::nth_index<1>::type::iterator r =
mTable.get<1>().find(to_find);
+ table::nth_index<1>::type::iterator r =
+ mTable.get<1>().find(to_find.caseless);
return (r == mTable.get<1>().end()) ? mEmpty : r->mValue;
}
@@ -141,7 +176,7 @@
table mTable;
static std::string mEmpty; // The empty string, universally.
boost::mutex mLock;
- key mHighestKey;
+ std::size_t mHighestKey;
bool mSetToLower; // If true, affects the next group addition.
};
Index: server/asClass.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asClass.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- server/asClass.cpp 21 Jan 2008 20:55:48 -0000 1.4
+++ server/asClass.cpp 24 Jan 2008 03:41:59 -0000 1.5
@@ -47,9 +47,10 @@
asClass *type, as_value& val, bool isconst)
{
if (val.is_object())
- val.to_object()->set_member(NSV::INTERNAL_TYPE,
type->getName());
+
val.to_object()->set_member(string_table::key(NSV::INTERNAL_TYPE),
+ std::size_t(type->getName()));
- string_table::key nsname = ns ? ns->getURI() : 0;
+ string_table::key nsname = ns ? ns->getURI() : string_table::key(0);
int flags = as_prop_flags::dontDelete;
@@ -65,9 +66,10 @@
asClass *type, as_value& val, bool isconst, bool isstatic)
{
if (val.is_object())
- val.to_object()->set_member(NSV::INTERNAL_TYPE,
type->getName());
+ val.to_object()->set_member(NSV::INTERNAL_TYPE,
+ std::size_t(type->getName()));
- string_table::key nsname = ns ? ns->getURI() : 0;
+ string_table::key nsname = ns ? ns->getURI() : string_table::key(0);
int flags = as_prop_flags::dontDelete;
if (isconst)
@@ -97,7 +99,7 @@
asMethod::addSlot(string_table::key name, asNamespace* ns, boost::uint32_t
slotId,
asClass */*type*/)
{
- string_table::key nsname = ns ? ns->getURI() : 0;
+ string_table::key nsname = ns ? ns->getURI() : string_table::key(0);
int flags = as_prop_flags::dontDelete;
mPrototype->init_member(name, as_value(), flags, nsname, slotId);
@@ -128,7 +130,7 @@
asClass::addSlot(string_table::key name, asNamespace* ns, boost::uint32_t
slotId,
asClass */*type*/, bool isstatic)
{
- string_table::key nsname = ns ? ns->getURI() : 0;
+ string_table::key nsname = ns ? ns->getURI() : string_table::key(0);
int flags = as_prop_flags::dontDelete;
if (isstatic)
flags |= as_prop_flags::staticProp;
@@ -140,7 +142,7 @@
bool
asMethod::addMethod(string_table::key name, asNamespace* ns, asMethod* method)
{
- string_table::key nsname = ns ? ns->getURI() : 0;
+ string_table::key nsname = ns ? ns->getURI() : string_table::key(0);
as_value val(method->getPrototype());
mPrototype->init_member(name, val, as_prop_flags::readOnly |
@@ -152,7 +154,7 @@
asClass::addMethod(string_table::key name, asNamespace* ns, asMethod* method,
bool isstatic)
{
- string_table::key nsname = ns ? ns->getURI() : 0;
+ string_table::key nsname = ns ? ns->getURI() : string_table::key(0);
as_value val(method->getPrototype());
int flags = as_prop_flags::readOnly | as_prop_flags::dontDelete
| as_prop_flags::dontEnum;
@@ -167,7 +169,7 @@
asClass::addGetter(string_table::key name, asNamespace *ns, asMethod *method,
bool isstatic)
{
- string_table::key nsname = ns ? ns->getURI() : 0;
+ string_table::key nsname = ns ? ns->getURI() : string_table::key(0);
Property *getset = mPrototype->getOwnProperty(name, nsname);
@@ -188,7 +190,7 @@
asClass::addSetter(string_table::key name, asNamespace *ns, asMethod *method,
bool isstatic)
{
- string_table::key nsname = ns ? ns->getURI() : 0;
+ string_table::key nsname = ns ? ns->getURI() : string_table::key(0);
Property *getset = mPrototype->getOwnProperty(name, nsname);
@@ -208,7 +210,7 @@
bool
asMethod::addGetter(string_table::key name, asNamespace *ns, asMethod *method)
{
- string_table::key nsname = ns ? ns->getURI() : 0;
+ string_table::key nsname = ns ? ns->getURI() : string_table::key(0);
Property *getset = mPrototype->getOwnProperty(name, nsname);
@@ -226,7 +228,7 @@
bool
asMethod::addSetter(string_table::key name, asNamespace *ns, asMethod *method)
{
- string_table::key nsname = ns ? ns->getURI() : 0;
+ string_table::key nsname = ns ? ns->getURI() : string_table::key(0);
Property *getset = mPrototype->getOwnProperty(name, nsname);
Index: server/asClass.h
===================================================================
RCS file: /sources/gnash/gnash/server/asClass.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- server/asClass.h 21 Jan 2008 20:55:48 -0000 1.5
+++ server/asClass.h 24 Jan 2008 03:41:59 -0000 1.6
@@ -217,7 +217,7 @@
{
if (getClassInternal(name))
return false;
- mClasses[name] = a;
+ mClasses[static_cast<std::size_t>(name)] = a;
return true;
}
- [Gnash-commit] gnash ChangeLog libbase/string_table.cpp libbas...,
Chad Musick <=