Browse Source

Merge pull request #419 from StraToN/403-extends-is

Separate `extends` keyword from `is` keyword.
Rémi Verschelde 8 years ago
parent
commit
c74cce5865

+ 1 - 3
classes/class_editorplugin.rst

@@ -162,7 +162,7 @@ Add a custom type, which will appear in the list of nodes or resources. An icon
 
 
 When given node or resource is selected, the base type will be instanced (ie, "Spatial", "Control", "Resource"), then the script will be loaded and set to this object.
 When given node or resource is selected, the base type will be instanced (ie, "Spatial", "Control", "Resource"), then the script will be loaded and set to this object.
 
 
-You can use the :ref:`EditorPlugin.handles<class_EditorPlugin_handles>` to check if your custom object is being edited by checking the script or using 'extends' keyword.
+You can use the :ref:`EditorPlugin.handles<class_EditorPlugin_handles>` to check if your custom object is being edited by checking the script or using 'is' keyword.
 
 
 During run-time, this will be a simple object with a script so this function does not need to be called then.
 During run-time, this will be a simple object with a script so this function does not need to be called then.
 
 
@@ -369,5 +369,3 @@ Restore the plugin GUI layout saved by :ref:`EditorPlugin.get_window_layout<clas
 - void  **update_canvas**  **(** **)**
 - void  **update_canvas**  **(** **)**
 
 
 Updates the control used to draw the edited scene over the 2D canvas. This is used together with :ref:`forward_canvas_input_event<class_EditorPlugin_forward_canvas_input_event>`.
 Updates the control used to draw the edited scene over the 2D canvas. This is used together with :ref:`forward_canvas_input_event<class_EditorPlugin_forward_canvas_input_event>`.
-
-

+ 1 - 1
extensions/gdscript.py

@@ -87,7 +87,7 @@ class GDScriptLexer(RegexLexer):
         ],
         ],
         'keywords': [
         'keywords': [
             (words((
             (words((
-                'do', 'var', 'const', 'extends', 'export', 'onready', 'tool',
+                'do', 'var', 'const', 'extends', 'is', 'export', 'onready', 'tool',
                 'static', 'setget', 'signal', 'breakpoint', 'switch', 'case',
                 'static', 'setget', 'signal', 'breakpoint', 'switch', 'case',
                 'assert', 'break', 'continue', 'elif', 'else', 'for', 'if',
                 'assert', 'break', 'continue', 'elif', 'else', 'for', 'if',
                 'pass', 'return', 'while', 'match'), suffix=r'\b'),
                 'pass', 'return', 'while', 'match'), suffix=r'\b'),

+ 4 - 4
files/resource_queue.gd

@@ -46,7 +46,7 @@ func queue_resource(path, p_in_front = false):
 func cancel_resource(path):
 func cancel_resource(path):
 	_lock("cancel_resource")
 	_lock("cancel_resource")
 	if path in pending:
 	if path in pending:
-		if pending[path] extends ResourceInteractiveLoader:
+		if pending[path] is ResourceInteractiveLoader:
 			queue.erase(pending[path])
 			queue.erase(pending[path])
 		pending.erase(path)
 		pending.erase(path)
 	_unlock("cancel_resource")
 	_unlock("cancel_resource")
@@ -55,7 +55,7 @@ func get_progress(path):
 	_lock("get_progress")
 	_lock("get_progress")
 	var ret = -1
 	var ret = -1
 	if path in pending:
 	if path in pending:
-		if pending[path] extends ResourceInteractiveLoader:
+		if pending[path] is ResourceInteractiveLoader:
 			ret = float(pending[path].get_stage()) / float(pending[path].get_stage_count())
 			ret = float(pending[path].get_stage()) / float(pending[path].get_stage_count())
 		else:
 		else:
 			ret = 1.0
 			ret = 1.0
@@ -67,7 +67,7 @@ func is_ready(path):
 	var ret
 	var ret
 	_lock("is_ready")
 	_lock("is_ready")
 	if path in pending:
 	if path in pending:
-		ret = !(pending[path] extends ResourceInteractiveLoader)
+		ret = !(pending[path] is ResourceInteractiveLoader)
 	else:
 	else:
 		ret = false
 		ret = false
 
 
@@ -89,7 +89,7 @@ func _wait_for_resource(res, path):
 func get_resource(path):
 func get_resource(path):
 	_lock("get_resource")
 	_lock("get_resource")
 	if path in pending:
 	if path in pending:
-		if pending[path] extends ResourceInteractiveLoader:
+		if pending[path] is ResourceInteractiveLoader:
 			var res = pending[path]
 			var res = pending[path]
 			if res != queue[0]:
 			if res != queue[0]:
 				var pos = queue.find(res)
 				var pos = queue.find(res)

+ 7 - 5
learning/scripting/gdscript/gdscript_basics.rst

@@ -175,7 +175,9 @@ keywords are reserved words (tokens), they can't be used as identifiers.
 +------------+---------------------------------------------------------------------------------------------------------------+
 +------------+---------------------------------------------------------------------------------------------------------------+
 | class      | Defines a class.                                                                                              |
 | class      | Defines a class.                                                                                              |
 +------------+---------------------------------------------------------------------------------------------------------------+
 +------------+---------------------------------------------------------------------------------------------------------------+
-| extends    | Defines what class to extend with the current class. Also tests whether a variable extends a given class.     |
+| extends    | Defines what class to extend with the current class.                                                          |
++------------+---------------------------------------------------------------------------------------------------------------+
+| is         | Tests whether a variable extends a given class.                                                               |
 +------------+---------------------------------------------------------------------------------------------------------------+
 +------------+---------------------------------------------------------------------------------------------------------------+
 | tool       | Executes the script in the editor.                                                                            |
 | tool       | Executes the script in the editor.                                                                            |
 +------------+---------------------------------------------------------------------------------------------------------------+
 +------------+---------------------------------------------------------------------------------------------------------------+
@@ -213,7 +215,7 @@ The following is the list of supported operators and their precedence
 +---------------------------------------------------------------+-----------------------------------------+
 +---------------------------------------------------------------+-----------------------------------------+
 | ``x.attribute``                                               | Attribute Reference                     |
 | ``x.attribute``                                               | Attribute Reference                     |
 +---------------------------------------------------------------+-----------------------------------------+
 +---------------------------------------------------------------+-----------------------------------------+
-| ``extends``                                                   | Instance Type Checker                   |
+| ``is``                                                        | Instance Type Checker                   |
 +---------------------------------------------------------------+-----------------------------------------+
 +---------------------------------------------------------------+-----------------------------------------+
 | ``~``                                                         | Bitwise NOT                             |
 | ``~``                                                         | Bitwise NOT                             |
 +---------------------------------------------------------------+-----------------------------------------+
 +---------------------------------------------------------------+-----------------------------------------+
@@ -865,7 +867,7 @@ Inheritance uses the ``extends`` keyword:
 
 
 
 
 To check if a given instance inherits from a given class
 To check if a given instance inherits from a given class
-the ``extends`` keyword can be used as an operator instead:
+the ``is`` keyword can be used:
 
 
 ::
 ::
 
 
@@ -874,8 +876,8 @@ the ``extends`` keyword can be used as an operator instead:
 
 
     # [...]
     # [...]
 
 
-    # use 'extends' to check inheritance
-    if (entity extends enemy_class):
+    # use 'is' to check inheritance
+    if (entity is enemy_class):
         entity.apply_damage()
         entity.apply_damage()
 
 
 Class Constructor
 Class Constructor