summaryrefslogtreecommitdiffstats
path: root/core/variant.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Display error messages in console when vformat is calledAndrii Doroshenko (Xrayez)2019-10-241-1/+1
|
* Optimized variant reference function.Valentin Zagura2019-09-091-1/+9
| | | | Optimized critical execution path in Variant::reference by removing expensive and unnecessary call to clear for atomic types.
* Replace 'ERR_EXPLAIN' with 'ERR_FAIL_*_MSG' in 'core/' and 'editor/'Braden Bodily2019-08-171-4/+1
| | | | | | | | | Condensed some if and ERR statements. Added dots to end of error messages Couldn't figure out EXPLAINC. These files gave me trouble: core/error_macros.h, core/io/file_access_buffered_fa.h (where is it?), core/os/memory.cpp, drivers/png/png_driver_common.cpp, drivers/xaudio2/audio_driver_xaudio2.cpp (where is it?)
* Changed some code showed in LGTM and Coverageqarmin2019-07-201-3/+1
|
* Added release function to PoolVector::Access.Ibrahn Sahir2019-07-061-3/+0
| | | | | | For clarity, assign-to-release idiom for PoolVector::Read/Write replaced with a function call. Existing uses replaced (or removed if already handled by scope)
* Remove unnecessary code and add some error explanationsqarmin2019-07-011-20/+0
|
* Some code changed with Clang-Tidyqarmin2019-06-261-1/+1
|
* Merge pull request #27886 from LeonardMeagher2/obj_to_stringRémi Verschelde2019-05-201-1/+1
|\ | | | | Allow overriding how scripted objects are converted to strings
| * Allow overriding how scripted objects are converted to stringsLeonard Meagher2019-05-031-1/+1
| | | | | | | | | | | | | | | | | | | | solves #26796 - ADD `String to_string()` method to Object which can be overriden by `String _to_string()` in scripts - ADD `String to_string(r_valid)` method to ScriptInstance to allow langauges to control how scripted objects are converted to strings - IMPLEMENT to_string for GDScriptInstance, VisualScriptInstance, and NativeScriptInstance - ADD Documentation about `Object.to_string` and `Object._to_string` - Changed `Variant::operator String` to use `obj->to_string()`
* | Don't crash on printing nested typesHein-Pieter van Braam-Stewart2019-04-201-4/+23
|/ | | | | | | | | | When adding an Array or Dictionary to itself operator String() got in an infinite loop. This commit adds a stack to operator String() (Through the use of a new 'stringify method'). This stack keeps track of all unique Arrays and Dictionaries it has seen. When a duplicate is found only a static string is printed '[...]' or '{...}'. This mirror Python's behavior in a similar case.
* Style: Apply new changes from clang-format 8.0Rémi Verschelde2019-04-091-12/+26
| | | | | | It seems to stay compatible with formatting done by clang-format 6.0 and 7.0, so contributors can keep using those versions for now (they will not undo those changes).
* Fix many asan and ubsan reported issuesHein-Pieter van Braam2019-01-301-29/+48
| | | | | | | | | This allows most demos to run without any ubsan or asan errors. There are still some things in thirdpart/ and some things in AudioServer that needs a look but this fixes a lot of issues. This should help debug less obvious issues, hopefully. This fixes #25217 and fixes #25218
* Warn of invalid pointer when converting object to RID, closes #19023Juan Linietsky2019-01-261-0/+8
|
* Update copyright statements to 2019Rémi Verschelde2019-01-011-2/+2
| | | | Happy new year to the wonderful Godot community!
* construct transform from transform2d bugclayjohn2018-11-281-1/+11
|
* Remove redundant "== true" codeAaron Franke2018-10-061-1/+1
| | | If it can be compared to a boolean, it can be evaluated as one in-place.
* Make core/ includes absolute, remove subfolders from include pathRémi Verschelde2018-09-121-6/+6
| | | | | | This allows more consistency in the manner we include core headers, where previously there would be a mix of absolute, relative and include path-dependent includes.
* Merge pull request #20856 from KoBeWi/pretty-dictionary-printRémi Verschelde2018-08-141-2/+3
|\ | | | | Add some curly braces to make dictionary printing less ambiguous
| * Add some curly braces to make dictionary printing less ambiguousTomasz Chabora2018-08-091-2/+3
| |
* | Fix int(String) != int(int) conversionChaosus2018-08-141-1/+1
|/
* Reduce unnecessary COW on Vector by make writing explicitHein-Pieter van Braam2018-07-261-11/+11
| | | | | | | | | | | | | | | | | | | | | | | This commit makes operator[] on Vector const and adds a write proxy to it. From now on writes to Vectors need to happen through the .write proxy. So for instance: Vector<int> vec; vec.push_back(10); std::cout << vec[0] << std::endl; vec.write[0] = 20; Failing to use the .write proxy will cause a compilation error. In addition COWable datatypes can now embed a CowData pointer to their data. This means that String, CharString, and VMap no longer use or derive from Vector. _ALWAYS_INLINE_ and _FORCE_INLINE_ are now equivalent for debug and non-debug builds. This is a lot faster for Vector in the editor and while running tests. The reason why this difference used to exist is because force-inlined methods used to give a bad debugging experience. After extensive testing with modern compilers this is no longer the case.
* State machine animation nodeJuan Linietsky2018-06-251-0/+24
|
* Handle missing arg pointer in get_call_error_textGary Oberbrunner2018-04-301-1/+5
| | | | | | | | | | I had a situation coming from godot-python where the caller of Variant::get_call_error_text() passed null for `p_argptrs`. In addition to fixing that in the caller, seems like good practice to defend against that situation in the callee to prevent a crash. So this patch just substitutes some semi-useful text for the source type name and keeps going so the user's actual error gets emitted.
* Add base support for 2D meshes in Godot, including Sprite -> Mesh2D conversion.Juan Linietsky2018-02-211-0/+2
|
* Add missing copyright headers and fix formattingRémi Verschelde2018-01-051-0/+1
| | | | | | Using `misc/scripts/fix_headers.py` on all Godot files. Some missing header guards were added, and the header inclusion order was fixed in the Bullet module.
* Update copyright statements to 2018Rémi Verschelde2018-01-011-2/+2
| | | | Happy new year to the wonderful Godot community!
* Style: Apply new clang-format 5.0 style to all filesRémi Verschelde2017-12-071-5/+1
|
* Properly implement Basis constructor using Vector3 of Euler anglesRémi Verschelde2017-11-211-6/+9
| | | | Fixes #13104.
* Basis accepts Vector3 as constructor argument.Chip Collier2017-11-201-0/+1
|
* Rename Rect3 to AABB.Ferenc Arn2017-11-171-29/+29
| | | | Fixes #12973.
* Implement Linux-style likely()/unlikely() macrosHein-Pieter van Braam2017-09-211-2/+2
| | | | | | | | | | | | | | This implement branch prediction macros likely() and unlikely() like in Linux. When using these macros please ensure that when you use them the condition in the branch really is very, very likely or unlikely. Think 90+% of the time. Primarily useful for error checking. (And I implement these macros for all our error checking macros now) See this article for more information: https://kernelnewbies.org/FAQ/LikelyUnlikely There are more places where these macros may make sense in renderer and physics engine. Placing them will come in another commit down the line.
* Don't call Variant::reference() unnecessarilyHein-Pieter van Braam2017-09-191-30/+131
| | | | | | operator= does not need to call reference() if the new value is of the same type as the old. This saves us zeroing the Variant, This speeds up reuse of a Variant in a loop by roughly 50%.
* Construct Variants from Reference properly in GDNativeRuslan Mustakov2017-09-141-2/+2
| | | | | | | | | | Previously godot_variant_new_object constructed Variant without accounting for the fact that the Object can be a Reference, so refcount was not increased and References were destructed prematurely. Also, Reference::init_ref did not propagate refcount increment to the script instance, which led to desync of refcount info on the script side and Godot side.
* Use HTTPS URL for Godot's website in the headersRémi Verschelde2017-08-271-1/+1
|
* Convert Object::cast_to() to the static versionHein-Pieter van Braam2017-08-241-2/+2
| | | | | | | | | | | | Currently we rely on some undefined behavior when Object->cast_to() gets called with a Null pointer. This used to work fine with GCC < 6 but newer versions of GCC remove all codepaths in which the this pointer is Null. However, the non-static cast_to() was supposed to be null safe. This patch makes cast_to() Null safe and removes the now redundant Null checks where they existed. It is explained in this article: https://www.viva64.com/en/b/0226/
* Makes all Godot API's methods Lower CaseIndah Sylvia2017-08-071-1/+1
|
* renamed all Rect3.pos to Rect3.positionalexholly2017-06-091-2/+2
|
* renamed all Rect2.pos to Rect2.positionalexholly2017-06-041-3/+3
|
* Removal of InputEvent as built-in Variant type..Juan Linietsky2017-05-201-41/+0
| | | | this might cause bugs I haven't found yet..
* Removal of Image from Variant, converted to a Resource.Juan Linietsky2017-05-171-38/+0
|
* Correct Variant::hash_compare()Hein-Pieter van Braam2017-04-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There was a logic error in #7815 which made Variant.hash_compare() == Variant.hash_compare() always true. In an attempt to short-circuit the NaN check I made an (in hindsight) obvious error: 10 == 12 || is_nan(10) == is_nan(12) This will be true for all inputs, except for the NaN, not-NaN case. The macro has been updated to now generate: (10 == 12) || (is_nan(10) && is_nan(10)) so: (10 == 12) || (is_nan(10) && is_nan(12)) = false False or (False and False) is False (10 == 10) || (is_nan(10) && is_nan(10)) = true True or (False and False) is True (Nan == 10) || (is_nan(NaN) && is_nan(10)) = false False or (True and False) is False (Nan == Nan) || (is_nan(NaN) && is_nan(NaN)) = true False or (True and True) is True Which is correct for all cases. This bug was triggered because the hash function for floating point numbers can very easily generate collisions for the tested Vector3(). I've also added an extra hashing step to the float hash function to make this less likely to occur. This fixes #8081 and probably many more random weirdness.
* Add "Godot Engine contributors" copyright lineRémi Verschelde2017-04-081-0/+1
|
* fixed ClassDB inconsistenciesKarroffel2017-03-131-1/+1
| | | | fixes #7960
* A Whole New World (clang-format edition)Rémi Verschelde2017-03-051-966/+867
| | | | | | | | | | | | | | | | | | | | | | | | I can show you the code Pretty, with proper whitespace Tell me, coder, now when did You last write readable code? I can open your eyes Make you see your bad indent Force you to respect the style The core devs agreed upon A whole new world A new fantastic code format A de facto standard With some sugar Enforced with clang-format A whole new world A dazzling style we all dreamed of And when we read it through It's crystal clear That now we're in a whole new world of code
* really fixed PTRCALL nowKarroffel2017-03-051-5/+1
|
* Added PowerState casting operator to VariantKarroffel2017-03-051-0/+5
| | | | Without it Godot does not build with PTRCALL_ENABLED
* Various fixes detected using PVS-Studio static analyzer.Thaer Razeq2017-02-281-2/+2
| | | | | | | - Add FIXME tags comments to some unfixed potential bugs - Remove some checks (always false: unsigned never < 0) - Fix some if statements based on reviews. - Bunch of missing `else` statements
* Correct hash behavior for floating point numbersHein-Pieter van Braam2017-02-161-5/+182
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes HashMap where a key or part of a key is a floating point number. To fix this the following has been done: * HashMap now takes an extra template argument Comparator. This class gets used to compare keys. The default Comperator now works correctly for common types and floating point numbets. * Variant implements ::hash_compare() now. This function implements nan-safe comparison for all types with components that contain floating point numbers. * Variant now has a VariantComparator which uses Variant::hash_compare() safely compare floating point components of variant's types. * The hash functions for floating point numbers will now normalize NaN values so that all floating point numbers that are NaN hash to the same value. C++ module writers that want to use HashMap internally in their modules can now also safeguard against this crash by defining their on Comperator class that safely compares their types. GDScript users, or writers of modules that don't use HashMap internally in their modules don't need to do anything. This fixes #7354 and fixes #6947.
* Style: Fix statements ending with ';;'Rémi Verschelde2017-01-161-1/+1
|
* Style: Cleanups, added headers, renamed filesRémi Verschelde2017-01-161-0/+1
| | | | | | | | | Made sure files in core/ and tools/ have a proper Godot license header when written by us. Also renamed aabb.{cpp,h} and object_type_db.{cpp,h} to rect3.{cpp,h} and class_db.{cpp,h} respectively. Also added a proper header to core/io/base64.{c,h} after clarifying the licensing with the original author (public domain).