Since TypedValue::operator= is dangerous, something like
tvTeleport is usually what you want to use, but it doesn't work with
temporary TypedValues (e.g. return values of things like make_tv or
cellAdd), because it took the arguments by pointer. This also means
we can change it to take parameters by value later without updating
callsites. This diff does the tvDup family and changes tvTeleport to
tvCopy. I'll gradually get the other ones done, but I just need these
for now to work with temporaries for changing SetOp to not use Variant
arithmetic.
C++11 cleanup (clean up easy enums)
This is for runtime/base/... and ended up touching a lot of files
because it turns out we have a lot of reasonably behaved enums.
example usage: genv() takes a Vector of Awaitable and creates a
Vector of WaitHandles. resize() requires a default value, reserve allows us to hint proper allocation.
I noticed that directorty structure of hphp/system was a bit scattered, so
I consolidated things to reduce the total number of folders and to put
related things together with each other.
This diff moves the contents of "hphp/system/classes_hhvm" into
"hphp/system", it moves the contents of "hphp/system/lib" into
"hphp/system", moves "hphp/idl" to "hphp/system/idl", and moves the
contents of "hphp/system/globals" into "hphp/system/idl".
Step two. Leaving the Variant::same methods as deleted for
now because I'm worried about the implicit conversion operators to
other types that support same.
Make internal iterator API return a TypedValue* instead of Variant. This
makes it possible to use the same API to update the value in-place
(except for Set, which returns const TypedValue*) and provide optimized
iterator that avoids unnecessary ref counts.
These seem on the big side to make them inline, and the conversion
from string literals to StaticString is cleaner if the ones that
use string literals are not in headers.
Currently collections define magic __get, __set, __isset, and __unset
methods which will throw exceptions if any property access is attempted
on collections (such as "isset($vec->prop)" and "$x = $vec->prop").
However, there is existing code that uses isset() to check if various
objects have a property with a certain name, and it feels like throwing
an exception here is a little harsh. This diff updates collections to
be tolerant of reading properties.
I was learning from @jdelong and he said that you should use
double quotes for local includes and angle brackets for library
includes. I asked why our code was the way it was, and he said he wanted
to clean it up. I beat him to it :)
Conflicts:
hphp/runtime/base/server/admin_request_handler.cpp
hphp/runtime/vm/named_entity.h
The current output of var_export for collections isn't very useful. It
outputs a call to __set_state like so:
Map::__set_state(array(..))
This isn't particularly useful since collections don't implement the
__set_state() method, and it is also suboptimal for the design of
collections since it relies on using PHP arrays.
This diff changes var_export to use collection literal syntax for
collections instead of generating a call to __set_state().
For cppext static methods we have a "ti_" method that takes an extra unused
parameter "const char* cls" and then a "t_" wrapper method that calls the
"ti_" method.
This makes things unnecessarily complicated when writing HipHop extensions.
Let's get rid of the extra unused parameter "cls" and the unnecessary "t_"
wrapper method.
We can't box a non-ref value for a ref param because
we could be modifying an array with refCount != 1.
zend warns, skips the call and returns null. For now, this
makes us warn, but do the call (without modifying the array).
A file scope flag controls whether to skip the call or not,
and should be changed (and eliminated) once all our tests pass.
With the flag turned on, we still dont match zend's behavior,
because its happy to go ahead and call the function with no
warning in the case of a literal array parameter
(cuf('foo', array(1))), even though it warns and skips it when
the array is in a variable ($a=array(1); cuf('foo', $a)).
This is a partial step towards merging the HPHP::VM namespace
up into its parent. To keep it reviewable/mergeable I'm not doing
everything at once here, but most of the code I've touched seems
improved. I've drawn an invisible line around the jit, Unit and
its cohort (Class, Func, PreClass, etc.); we'll get back to them
soon.
The 'r' encoding for unserialization was broken for collections because the
code was calling Variant::unserialize() on a temporary Variant, which is a
no-no. unserialize() must be called directly on the value where it resides
in the collection.
Second, there was an inconsistency between serialize and unserialize with
how id numbers worked for the 'r' and 'R' encodings. This diff fixes
serialize and unserialize to count collection keys when assigning id
numbers. I also took the opportunity to tighten up enforcement to prevent
collections keys and values from being taken by reference when during
unserialization.
Replace "collection" with "collections" in various file names since
we typically use the plural form in conversation and documentation.
Add set() and removeAt() methods needed for collection interfaces. Also
add the KeyedIterable and KeyedIterator interfaces.
Add __construct() methods for collections