Arquivos
hhvm/hphp/runtime/ext/ext_variable.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

90 linhas
3.2 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_VARIABLE_H_
#define incl_HPHP_VARIABLE_H_
#include "hphp/runtime/base/base_includes.h"
namespace HPHP {
///////////////////////////////////////////////////////////////////////////////
// type testing
bool f_is_bool(CVarRef v);
bool f_is_int(CVarRef v);
bool f_is_integer(CVarRef v);
bool f_is_long(CVarRef v);
bool f_is_double(CVarRef v);
bool f_is_float(CVarRef v);
bool f_is_numeric(CVarRef v);
bool f_is_real(CVarRef v);
bool f_is_string(CVarRef v);
bool f_is_scalar(CVarRef v);
bool f_is_array(CVarRef v);
bool f_is_object(CVarRef v);
bool f_is_resource(CVarRef v);
bool f_is_null(CVarRef v);
String f_gettype(CVarRef v);
String f_get_resource_type(CResRef handle);
///////////////////////////////////////////////////////////////////////////////
// type conversion
int64_t f_intval(CVarRef v, int64_t base = 10);
double f_doubleval(CVarRef v);
double f_floatval(CVarRef v);
String f_strval(CVarRef v);
bool f_settype(VRefParam var, CStrRef type);
///////////////////////////////////////////////////////////////////////////////
// input/output
Variant f_print_r(CVarRef expression, bool ret = false);
Variant f_var_export(CVarRef expression, bool ret = false);
void f_var_dump(CVarRef v);
void f_var_dump(int _argc, CVarRef expression, CArrRef _argv = null_array);
void f_debug_zval_dump(CVarRef variable);
String f_serialize(CVarRef value);
Variant f_unserialize(CStrRef str,
CArrRef class_whitelist = empty_array);
///////////////////////////////////////////////////////////////////////////////
// variable table
Array f_get_defined_vars();
bool f_import_request_variables(CStrRef types, CStrRef prefix = "");
#define EXTR_OVERWRITE 0
#define EXTR_SKIP 1
#define EXTR_PREFIX_SAME 2
#define EXTR_PREFIX_ALL 3
#define EXTR_PREFIX_INVALID 4
#define EXTR_PREFIX_IF_EXISTS 5
#define EXTR_IF_EXISTS 6
#define EXTR_REFS 0x100
int64_t f_extract(CArrRef var_array, int extract_type = EXTR_OVERWRITE,
CStrRef prefix = "");
///////////////////////////////////////////////////////////////////////////////
}
#endif // incl_HPHP_VARIABLE_H_