Remove StringOffset and String.lval() overloaded functions.

These are dead code, except for a few tests.
Esse commit está contido em:
Edwin Smith
2013-06-12 21:44:53 -07:00
commit de Sara Golemon
commit d3601af2ac
11 arquivos alterados com 12 adições e 167 exclusões
+2 -10
Ver Arquivo
@@ -21,7 +21,6 @@
#include "hphp/runtime/base/types.h"
#include "hphp/runtime/base/complex_types.h"
#include "hphp/runtime/base/binary_operations.h"
#include "hphp/runtime/base/string_offset.h"
#include "hphp/runtime/base/intercept.h"
#include "hphp/runtime/base/runtime_error.h"
#include "hphp/runtime/base/runtime_option.h"
@@ -29,6 +28,7 @@
#include "hphp/runtime/base/util/request_local.h"
#include "hphp/runtime/base/strings.h"
#include "hphp/util/case_insensitive.h"
#include "hphp/runtime/base/type_conversions.h"
#if defined(__APPLE__) || defined(__USE_BSD)
/**
@@ -166,19 +166,11 @@ inline Variant &concat_assign(Variant &v1, CStrRef s2) {
return v1;
}
inline String &concat_assign(const StringOffset &s1, litstr s2) {
return concat_assign(s1.lval(), s2);
}
inline String &concat_assign(const StringOffset &s1, CStrRef s2) {
return concat_assign(s1.lval(), s2);
}
template <class K, class V>
const V &String::set(K key, const V &value) {
StringData *s = StringData::Escalate(m_px);
SmartPtr<StringData>::operator=(s);
m_px->setChar(toInt32(key), toString(value));
m_px->setChar(HPHP::toInt32(key), toString(value));
return value;
}
-1
Ver Arquivo
@@ -29,7 +29,6 @@
#include "hphp/runtime/base/type_conversions.h"
#include "hphp/runtime/base/builtin_functions.h"
#include "hphp/runtime/base/comparisons.h"
#include "hphp/runtime/base/string_offset.h"
#include "hphp/runtime/base/util/smart_object.h"
#include "hphp/runtime/base/list_assignment.h"
#include "hphp/runtime/base/resource_data.h"
+3 -4
Ver Arquivo
@@ -76,10 +76,9 @@ enum ReserveStringMode { ReserveString };
enum CopyMallocMode { CopyMalloc };
/**
* Inner data class for String type. As a coding guideline, String and
* StringOffset classes should delegate real string work to this class,
* although both String and StringOffset classes are more than welcome to test
* nullability to avoid calling this class.
* Inner data class for String type. As a coding guideline, String
* should delegate real string work to this class, although String is
* more than welcome to test nullability to avoid calling this class.
*
* A StringData can be in two formats, small or big. Small format
* stores the string inline by overlapping with some fields, as follows:
-36
Ver Arquivo
@@ -1,36 +0,0 @@
/*
+----------------------------------------------------------------------+
| HipHop for PHP |
+----------------------------------------------------------------------+
| Copyright (c) 2010-2013 Facebook, Inc. (http://www.facebook.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
*/
#include "hphp/runtime/base/string_offset.h"
#include "hphp/runtime/base/complex_types.h"
namespace HPHP {
///////////////////////////////////////////////////////////////////////////////
StringOffset::operator String() const {
return m_data->getChar(m_offset);
}
StringOffset &StringOffset::operator=(CVarRef v) {
if (v.isArray()) {
raise_notice("Array to string conversion");
}
m_data->setChar(m_offset, v.toString());
return *this;
}
///////////////////////////////////////////////////////////////////////////////
}
-67
Ver Arquivo
@@ -1,67 +0,0 @@
/*
+----------------------------------------------------------------------+
| HipHop for PHP |
+----------------------------------------------------------------------+
| Copyright (c) 2010-2013 Facebook, Inc. (http://www.facebook.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
*/
#ifndef incl_HPHP_STRING_OFFSET_H_
#define incl_HPHP_STRING_OFFSET_H_
#include "hphp/runtime/base/types.h"
#include "hphp/runtime/base/string_data.h"
#include "hphp/runtime/base/util/exceptions.h"
namespace HPHP {
///////////////////////////////////////////////////////////////////////////////
/**
* Handles sub-string expressions. This class should delegate all real work to
* StringData.
*/
class StringOffset {
public:
/**
* Constructor. "offset" is where we are at in the string.
*/
StringOffset(StringData *data, int offset)
: m_data(data), m_offset(offset) {
assert(m_data);
}
/**
* Get r-value of this offset object.
*/
operator String() const;
/**
* Get l-value of this offset object. Well, not quite, since this is illegal.
*/
String &lval() const {
throw InvalidOperandException("taking l-value of a string offset");
}
/**
* Assignement operator. Almost the whole purpose for having this offset
* class.
*/
StringOffset &operator=(CVarRef v);
private:
StringData *m_data;
int m_offset;
};
///////////////////////////////////////////////////////////////////////////////
}
#endif // incl_HPHP_STRING_OFFSET_H_
-13
Ver Arquivo
@@ -15,7 +15,6 @@
*/
#include "hphp/runtime/base/complex_types.h"
#include "hphp/runtime/base/string_offset.h"
#include "hphp/runtime/base/type_conversions.h"
#include "hphp/runtime/base/builtin_functions.h"
#include "hphp/runtime/base/comparisons.h"
@@ -260,18 +259,6 @@ String String::rvalAt(CVarRef key) const {
return rvalAtImpl(key.toInt32());
}
StringOffset String::lvalAt(CArrRef key) {
return lvalAtImpl(key.toInt32());
}
StringOffset String::lvalAt(CObjRef key) {
return lvalAtImpl(key.toInt32());
}
StringOffset String::lvalAt(CVarRef key) {
return lvalAtImpl(key.toInt32());
}
char String::charAt(int pos) const {
assert(pos >= 0 && pos <= size());
const char *s = data();
-23
Ver Arquivo
@@ -25,7 +25,6 @@
#include "hphp/util/assertions.h"
#include "hphp/runtime/base/util/smart_ptr.h"
#include "hphp/runtime/base/string_data.h"
#include "hphp/runtime/base/string_offset.h"
#include "hphp/runtime/base/types.h"
#include "hphp/runtime/base/hphp_value.h"
@@ -407,22 +406,6 @@ public:
String rvalAt(CObjRef key) const;
String rvalAt(CVarRef key) const;
StringOffset lvalAt(bool key) { return lvalAtImpl(key ? 1 : 0);}
StringOffset lvalAt(char key) { return lvalAtImpl(key);}
StringOffset lvalAt(short key) { return lvalAtImpl(key);}
StringOffset lvalAt(int key) { return lvalAtImpl(key);}
StringOffset lvalAt(int64_t key) { return lvalAtImpl(key);}
StringOffset lvalAt(double key) { return lvalAtImpl((int64_t)key);}
StringOffset lvalAt(litstr key) { return lvalAtImpl(String(key).toInt32());}
StringOffset lvalAt(const StringData *key) {
not_reached();
return lvalAtImpl(key ? key->toInt32() : 0);
}
StringOffset lvalAt(CStrRef key) { return lvalAtImpl(key.toInt32());}
StringOffset lvalAt(CArrRef key);
StringOffset lvalAt(CObjRef key);
StringOffset lvalAt(CVarRef key);
template <class K, class V>
inline const V &set(K key, const V &value);
@@ -446,12 +429,6 @@ public:
private:
StringOffset lvalAtImpl(int key) {
StringData *s = StringData::Escalate(m_px);
StringBase::operator=(s);
return StringOffset(m_px, key);
}
String rvalAtImpl(int key) const {
if (m_px) {
return m_px->getChar(key);
-6
Ver Arquivo
@@ -94,12 +94,6 @@ class ArrayData;
class ObjectData;
class ResourceData;
/**
* Arrays, strings and objects can take offsets or array elements. These offset
* objects will help to store temporary information to make the task easier.
*/
class StringOffset;
/**
* Miscellaneous objects to help arrays to construct or to iterate.
*/
+4 -4
Ver Arquivo
@@ -200,15 +200,15 @@ bool TestCppBase::TestString() {
{
VS(String("test").rvalAt(2).c_str(), "s");
String s = "test";
s.lvalAt(2) = "";
s.set(2, String(""));
VS(s, String("te\0t", 4, AttachLiteral));
s.lvalAt(2) = "zz";
s.set(2, String("zz"));
VS(s, "tezt");
s.lvalAt(5) = "q";
s.set(5, String("q"));
VS(s, "tezt q");
String s2 = s; // test copy-on-write
s.lvalAt(1) = "3";
s.set(1, String("3"));
VS(s, "t3zt q");
VS(s2, "tezt q");
}
+2 -2
Ver Arquivo
@@ -42,8 +42,8 @@ class TestCppBase : public TestBase {
bool TestIpBlockMap();
/**
* Date types. This in turn tests StringData, ArrayData, StringOffset,
* ArrayOffset, VariantOffset, ArrayIter, ArrayElement and other classes.
* Date types. This in turn tests StringData, ArrayData, String,
* ArrayIter, and other classes.
*
* Some of the classes are not tested here, including Object/ObjectData/
* SmartObject<T>. They are a lot more covered in TestCodeRun with better
+1 -1
Ver Arquivo
@@ -143,7 +143,7 @@ bool TestExtApc::test_apc_store() {
String tsFetched = f_apc_fetch("ts");
VS(tsFetched, "NewValue");
String sharedString = tsFetched;
tsFetched.lvalAt(0) = "M";
tsFetched.set(0, String("M"));
VS(tsFetched, "MewValue");
VS(sharedString, "NewValue");
VERIFY(tsFetched.get() != sharedString.get());