summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2016-03-01 18:09:48 +0100
committerRémi Verschelde <rverschelde@gmail.com>2016-03-01 18:09:48 +0100
commit002ff3cc9a6479695034b556f15ef4d9fa4bc6fe (patch)
treef1423d79df9873e7601d1c765310d961f9173f60 /core
parent46bfcd350745d3053a0cab2985d73baae0a4a88d (diff)
Revert "Merge pull request #3814 from est31/iterators_for_for"
This reverts commit adf50568890cefb5fc354dbc1b21c4140bb410f9, reversing changes made to ee2bc87c0ef3cc1a432655ff935e60f32977904d.
Diffstat (limited to 'core')
-rw-r--r--core/range_iterator.cpp169
-rw-r--r--core/range_iterator.h72
-rw-r--r--core/register_core_types.cpp3
3 files changed, 0 insertions, 244 deletions
diff --git a/core/range_iterator.cpp b/core/range_iterator.cpp
deleted file mode 100644
index 9534e011d7..0000000000
--- a/core/range_iterator.cpp
+++ /dev/null
@@ -1,169 +0,0 @@
-/*************************************************************************/
-/* range_iterator.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-
-#include "range_iterator.h"
-#include "object_type_db.h"
-
-void RangeIterator::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("_iter_init","arg"),&RangeIterator::_iter_init);
- ObjectTypeDB::bind_method(_MD("_iter_next","arg"),&RangeIterator::_iter_next);
- ObjectTypeDB::bind_method(_MD("_iter_get","arg"),&RangeIterator::_iter_get);
- ObjectTypeDB::bind_method(_MD("is_finished"),&RangeIterator::is_finished);
- ObjectTypeDB::bind_method(_MD("to_array"),&RangeIterator::to_array);
- ObjectTypeDB::bind_method(_MD("set_range","arg1","arg2","arg3"),&RangeIterator::_set_range,DEFVAL(Variant()),DEFVAL(Variant()));
-}
-
-bool RangeIterator::_iter_init(Variant arg) {
- return !is_finished();
-}
-
-bool RangeIterator::_iter_next(Variant arg) {
- current += step;
- return !is_finished();
-}
-
-Variant RangeIterator::_iter_get(Variant arg) {
- return Variant(current);
-}
-
-bool RangeIterator::is_finished() {
- if(step > 0)
- {
- return current >= stop;
- }
- else
- {
- return current <= stop;
- }
-}
-
-Array RangeIterator::to_array() {
- if (step==0) {
- ERR_EXPLAIN("step is zero!");
- ERR_FAIL_V(Array());
- }
-
- Array arr(true);
- if (current >= stop && step > 0) {
- return arr;
- }
- if (current <= stop && step < 0) {
- return arr;
- }
-
- //calculate how many
- int count=0;
- if (step > 0) {
- count=((stop-current-1)/step)+1;
- } else {
- count=((current-stop-1)/-step)+1;
- }
-
- arr.resize(count);
-
- if (step > 0) {
- int idx=0;
- for(int i=current;i<stop;i+=step) {
- arr[idx++]=i;
- }
- } else {
- int idx=0;
- for(int i=current;i>stop;i+=step) {
- arr[idx++]=i;
- }
- }
-
- return arr;
-}
-
-void RangeIterator::set_range(int stop) {
- this->current = 0;
- this->stop = stop;
- this->step = (stop > 0)?(1):(-1);
-}
-
-void RangeIterator::set_range(int start, int stop) {
- this->current = start;
- this->stop = stop;
- this->step = (stop > start)?(1):(-1);
-}
-
-void RangeIterator::set_range(int start, int stop, int step) {
- if(step == 0)
- {
- ERR_EXPLAIN("step is zero!");
- ERR_FAIL();
- }
-
- this->current = start;
- this->stop = stop;
- this->step = step;
-}
-
-Ref<RangeIterator> RangeIterator::_set_range(Variant arg1, Variant arg2, Variant arg3)
-{
- bool valid = true;
- if(arg1.get_type() == Variant::INT)
- {
- if(arg2.get_type() == Variant::INT)
- {
- if(arg3.get_type() == Variant::INT) set_range((int)arg1, (int)arg2, (int)arg3); // (start, end, step)
- else if(arg3.get_type() == Variant::NIL) set_range((int)arg1, (int)arg2); // (start, end)
- else valid = false;
- }
- else if(arg2.get_type() == Variant::NIL) set_range((int)arg1); // (end)
- else valid = false;
- }
- else valid = false;
-
- if(!valid)
- {
- ERR_EXPLAIN("Invalid type in function 'set_range' in base 'RangeIterator'. Expected 1, 2, or 3 ints.");
- ERR_FAIL_V(Ref<RangeIterator>());
- }
- return Ref<RangeIterator>(this);
-}
-
-RangeIterator::RangeIterator() {
- current = 0;
- stop = 0;
- step = 0;
-}
-
-RangeIterator::RangeIterator(int stop) {
- set_range(stop);
-}
-
-RangeIterator::RangeIterator(int start, int stop) {
- set_range(start, stop);
-}
-
-RangeIterator::RangeIterator(int start, int stop, int step) {
- set_range(start, stop, step);
-}
diff --git a/core/range_iterator.h b/core/range_iterator.h
deleted file mode 100644
index c3e38a9094..0000000000
--- a/core/range_iterator.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/*************************************************************************/
-/* range_iterator.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-#ifndef RANGE_ITERATOR_H
-#define RANGE_ITERATOR_H
-
-#include "reference.h"
-#include "variant.h"
-#include "array.h"
-
-class RangeIterator : public Reference
-{
-protected:
- OBJ_TYPE( RangeIterator, Reference );
-
- static void _bind_methods();
-
-private:
- int current;
- int stop;
- int step;
-
- bool _iter_init(Variant arg);
- bool _iter_next(Variant arg);
- Variant _iter_get(Variant arg);
-
-public:
-
- bool is_finished();
-
- Array to_array();
-
- void set_range(int stop);
- void set_range(int start, int stop);
- void set_range(int start, int stop, int step);
-
- Ref<RangeIterator> _set_range(Variant arg1, Variant arg2 = Variant(), Variant arg3 = Variant());
-
- void _init(Variant arg1, Variant arg2, Variant arg3);
-
- RangeIterator();
- RangeIterator(int stop);
- RangeIterator(int start, int stop);
- RangeIterator(int start, int stop, int step);
-};
-
-#endif // RANGE_ITERATOR_H
diff --git a/core/register_core_types.cpp b/core/register_core_types.cpp
index c516059cfb..54431cf381 100644
--- a/core/register_core_types.cpp
+++ b/core/register_core_types.cpp
@@ -52,7 +52,6 @@
#include "func_ref.h"
#include "input_map.h"
#include "undo_redo.h"
-#include "range_iterator.h"
#ifdef XML_ENABLED
static ResourceFormatSaverXML *resource_saver_xml=NULL;
@@ -131,8 +130,6 @@ void register_core_types() {
ObjectTypeDB::register_type<Translation>();
ObjectTypeDB::register_type<PHashTranslation>();
ObjectTypeDB::register_type<UndoRedo>();
- ObjectTypeDB::register_type<RangeIterator>();
-
ObjectTypeDB::register_type<HTTPClient>();
ObjectTypeDB::register_virtual_type<ResourceInteractiveLoader>();