Arquivos
hhvm/hphp/runtime/ext/ext_simplexml.h
T
Drew Paroski 84b9d9a3a2 Separate resources from objects, part 1
In HHVM (and HPHPc before it) we've been piggybacking resources on the
KindOfObject machinery. At the language level, resource is considered to
be a different type than object, and there are a number of differences
in behavior between objects and resources (ex. resources don't allow for
dynamic properties, resources don't work with the clone operator, the
"(object)" cast behaves differently for resources vs. objects, etc).

Piggybacking resources on the KindOfObject machinery has some downsides.
Code that deals with KindOfObject values often needs to check if the value
is a resource and go down a different code path. This makes things harder
to maintain and harder to keep parity with Zend. Also, these extra branches
hurt performance a little, and they make it harder for the JIT to do a good
job in some cases when its generating machine code that operates on objects.

This diff prepares the code base for a new KindOfResource type by adding a
new "Resource" smart pointer type (currently a typedef for the Object smart
pointer type) and it updates the C++ code and the idl files appropriately.
This diff is essentially a cosmetic change and should not impact run time
behavior. In the next diff (part 2) we'll actually add a new KindOfResource
type, detach ResourceData from the ObjectData inheritence hierarchy, and
provide a real implementation for the Resource smart pointer type (instead
of just aliasing the Object smart pointer type).
2013-07-10 11:16:33 -07:00

146 linhas
5.7 KiB
C++

/*
+----------------------------------------------------------------------+
| HipHop for PHP |
+----------------------------------------------------------------------+
| Copyright (c) 2010-2013 Facebook, Inc. (http://www.facebook.com) |
| Copyright (c) 1997-2010 The PHP Group |
+----------------------------------------------------------------------+
| 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_EXT_SIMPLEXML_H_
#define incl_HPHP_EXT_SIMPLEXML_H_
// >>>>>> Generated by idl.php. Do NOT modify. <<<<<<
#include "hphp/runtime/base/base_includes.h"
#include "hphp/runtime/ext/ext_simplexml_include.h"
namespace HPHP {
///////////////////////////////////////////////////////////////////////////////
Variant f_simplexml_import_dom(CObjRef node,
CStrRef class_name = "SimpleXMLElement");
Variant f_simplexml_load_string(CStrRef data, CStrRef class_name = "SimpleXMLElement", int64_t options = 0, CStrRef ns = "", bool is_prefix = false);
Variant f_simplexml_load_file(CStrRef filename, CStrRef class_name = "SimpleXMLElement", int64_t options = 0, CStrRef ns = "", bool is_prefix = false);
Variant f_libxml_get_errors();
Variant f_libxml_get_last_error();
void f_libxml_clear_errors();
bool f_libxml_use_internal_errors(CVarRef use_errors = null_variant);
void f_libxml_set_streams_context(CResRef streams_context);
bool f_libxml_disable_entity_loader(bool disable = true);
///////////////////////////////////////////////////////////////////////////////
// class SimpleXMLElement
FORWARD_DECLARE_CLASS_BUILTIN(SimpleXMLElement);
class c_SimpleXMLElement :
public ExtObjectDataFlags<ObjectData::UseGet|
ObjectData::UseSet|
ObjectData::UseIsset|
ObjectData::UseUnset|
ObjectData::CallToImpl>,
public Sweepable {
public:
DECLARE_CLASS(SimpleXMLElement, SimpleXMLElement, ObjectData)
// need to implement
public: c_SimpleXMLElement(Class* cls = c_SimpleXMLElement::s_cls);
public: ~c_SimpleXMLElement();
public: void t___construct(CStrRef data, int64_t options = 0, bool data_is_url = false, CStrRef ns = "", bool is_prefix = false);
public: bool t_offsetexists(CVarRef index);
public: Variant t_offsetget(CVarRef index);
public: void t_offsetset(CVarRef index, CVarRef newvalue);
public: void t_offsetunset(CVarRef index);
public: Variant t_getiterator();
public: int64_t t_count();
public: Variant t_xpath(CStrRef path);
public: bool t_registerxpathnamespace(CStrRef prefix, CStrRef ns);
public: Variant t_asxml(CStrRef filename = "");
public: Array t_getnamespaces(bool recursive = false);
public: Array t_getdocnamespaces(bool recursive = false);
public: Object t_children(CStrRef ns = "", bool is_prefix = false);
public: String t_getname();
public: Object t_attributes(CStrRef ns = "", bool is_prefix = false);
public: Variant t_addchild(CStrRef qname, CStrRef value = null_string, CStrRef ns = null_string);
public: void t_addattribute(CStrRef qname, CStrRef value = null_string, CStrRef ns = null_string);
public: String t___tostring();
public: Variant t___get(Variant name);
public: Variant t___set(Variant name, Variant value);
public: bool t___isset(Variant name);
public: Variant t___unset(Variant name);
public:
Resource m_doc;
xmlNodePtr m_node;
Variant m_children;
Variant m_attributes;
bool m_is_text;
bool m_free_text;
bool m_is_attribute;
bool m_is_children;
bool m_is_property;
virtual bool o_toBooleanImpl() const noexcept;
virtual int64_t o_toInt64Impl() const noexcept;
virtual double o_toDoubleImpl() const noexcept;
virtual Array o_toArray() const;
private:
xmlXPathContextPtr m_xpath;
};
///////////////////////////////////////////////////////////////////////////////
// class LibXMLError
FORWARD_DECLARE_CLASS_BUILTIN(LibXMLError);
class c_LibXMLError : public ExtObjectData {
public:
DECLARE_CLASS(LibXMLError, LibXMLError, ObjectData)
// need to implement
public: c_LibXMLError(Class* cls = c_LibXMLError::s_cls);
public: ~c_LibXMLError();
public: void t___construct();
};
///////////////////////////////////////////////////////////////////////////////
// class SimpleXMLElementIterator
FORWARD_DECLARE_CLASS_BUILTIN(SimpleXMLElementIterator);
class c_SimpleXMLElementIterator : public ExtObjectData, public Sweepable {
public:
DECLARE_CLASS(SimpleXMLElementIterator, SimpleXMLElementIterator, ObjectData)
// need to implement
public: c_SimpleXMLElementIterator(Class* cls = c_SimpleXMLElementIterator::s_cls);
public: ~c_SimpleXMLElementIterator();
public: void t___construct();
public: Variant t_current();
public: Variant t_key();
public: Variant t_next();
public: Variant t_rewind();
public: Variant t_valid();
public:
void set_parent(c_SimpleXMLElement* parent);
void reset_iterator();
SmartPtr<c_SimpleXMLElement> m_parent;
ArrayIter *m_iter1;
ArrayIter *m_iter2;
};
///////////////////////////////////////////////////////////////////////////////
}
#endif // incl_HPHP_EXT_SIMPLEXML_H_