Skip to content

Commit

Permalink
Display BitField[Enum] in docs to distinguish from Enum
Browse files Browse the repository at this point in the history
  • Loading branch information
dalexeev committed Jun 15, 2023
1 parent 824820d commit eb391d3
Show file tree
Hide file tree
Showing 52 changed files with 191 additions and 129 deletions.
2 changes: 2 additions & 0 deletions core/doc_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ void DocData::return_doc_from_retinfo(DocData::MethodDoc &p_method, const Proper
if (p_method.return_enum.begins_with("_")) { //proxy class
p_method.return_enum = p_method.return_enum.substr(1, p_method.return_enum.length());
}
p_method.return_is_bitfield = p_retinfo.usage & PROPERTY_USAGE_CLASS_IS_BITFIELD;
p_method.return_type = "int";
} else if (p_retinfo.class_name != StringName()) {
p_method.return_type = p_retinfo.class_name;
Expand Down Expand Up @@ -82,6 +83,7 @@ void DocData::argument_doc_from_arginfo(DocData::ArgumentDoc &p_argument, const
if (p_argument.enumeration.begins_with("_")) { //proxy class
p_argument.enumeration = p_argument.enumeration.substr(1, p_argument.enumeration.length());
}
p_argument.is_bitfield = p_arginfo.usage & PROPERTY_USAGE_CLASS_IS_BITFIELD;
p_argument.type = "int";
} else if (p_arginfo.class_name != StringName()) {
p_argument.type = p_arginfo.class_name;
Expand Down
25 changes: 19 additions & 6 deletions core/doc_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class DocData {
String name;
String type;
String enumeration;
bool is_bitfield = false;
String default_value;
bool operator<(const ArgumentDoc &p_arg) const {
if (name == p_arg.name) {
Expand All @@ -70,6 +71,9 @@ class DocData {

if (p_dict.has("enumeration")) {
doc.enumeration = p_dict["enumeration"];
if (p_dict.has("is_bitfield")) {
doc.is_bitfield = p_dict["is_bitfield"];
}
}

if (p_dict.has("default_value")) {
Expand All @@ -91,6 +95,7 @@ class DocData {

if (!p_doc.enumeration.is_empty()) {
dict["enumeration"] = p_doc.enumeration;
dict["is_bitfield"] = p_doc.is_bitfield;
}

if (!p_doc.default_value.is_empty()) {
Expand All @@ -105,6 +110,7 @@ class DocData {
String name;
String return_type;
String return_enum;
bool return_is_bitfield = false;
String qualifiers;
String description;
bool is_deprecated = false;
Expand Down Expand Up @@ -152,6 +158,9 @@ class DocData {

if (p_dict.has("return_enum")) {
doc.return_enum = p_dict["return_enum"];
if (p_dict.has("return_is_bitfield")) {
doc.return_is_bitfield = p_dict["return_is_bitfield"];
}
}

if (p_dict.has("qualifiers")) {
Expand Down Expand Up @@ -201,6 +210,7 @@ class DocData {

if (!p_doc.return_enum.is_empty()) {
dict["return_enum"] = p_doc.return_enum;
dict["return_is_bitfield"] = p_doc.return_is_bitfield;
}

if (!p_doc.qualifiers.is_empty()) {
Expand Down Expand Up @@ -264,10 +274,9 @@ class DocData {

if (p_dict.has("enumeration")) {
doc.enumeration = p_dict["enumeration"];
}

if (p_dict.has("is_bitfield")) {
doc.is_bitfield = p_dict["is_bitfield"];
if (p_dict.has("is_bitfield")) {
doc.is_bitfield = p_dict["is_bitfield"];
}
}

if (p_dict.has("description")) {
Expand Down Expand Up @@ -299,10 +308,9 @@ class DocData {

if (!p_doc.enumeration.is_empty()) {
dict["enumeration"] = p_doc.enumeration;
dict["is_bitfield"] = p_doc.is_bitfield;
}

dict["is_bitfield"] = p_doc.is_bitfield;

if (!p_doc.description.is_empty()) {
dict["description"] = p_doc.description;
}
Expand All @@ -319,6 +327,7 @@ class DocData {
String name;
String type;
String enumeration;
bool is_bitfield = false;
String description;
String setter, getter;
String default_value;
Expand All @@ -342,6 +351,9 @@ class DocData {

if (p_dict.has("enumeration")) {
doc.enumeration = p_dict["enumeration"];
if (p_dict.has("is_bitfield")) {
doc.is_bitfield = p_dict["is_bitfield"];
}
}

if (p_dict.has("description")) {
Expand Down Expand Up @@ -391,6 +403,7 @@ class DocData {

if (!p_doc.enumeration.is_empty()) {
dict["enumeration"] = p_doc.enumeration;
dict["is_bitfield"] = p_doc.is_bitfield;
}

if (!p_doc.description.is_empty()) {
Expand Down
2 changes: 0 additions & 2 deletions core/io/ip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@
#include "core/templates/hash_map.h"
#include "core/variant/typed_array.h"

VARIANT_ENUM_CAST(IP::ResolverStatus);

/************* RESOLVER ******************/

struct _IP_ResolverPrivate {
Expand Down
1 change: 1 addition & 0 deletions core/io/ip.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,5 +109,6 @@ class IP : public Object {
};

VARIANT_ENUM_CAST(IP::Type);
VARIANT_ENUM_CAST(IP::ResolverStatus);

#endif // IP_H
2 changes: 0 additions & 2 deletions core/io/xml_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@

//#define DEBUG_XML

VARIANT_ENUM_CAST(XMLParser::NodeType);

static inline bool _is_white_space(char c) {
return (c == ' ' || c == '\t' || c == '\n' || c == '\r');
}
Expand Down
2 changes: 2 additions & 0 deletions core/io/xml_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,6 @@ class XMLParser : public RefCounted {
~XMLParser();
};

VARIANT_ENUM_CAST(XMLParser::NodeType);

#endif // XML_PARSER_H
3 changes: 0 additions & 3 deletions core/os/time.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@ static const uint8_t MONTH_DAYS_TABLE[2][12] = {
{ 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
};

VARIANT_ENUM_CAST(Month);
VARIANT_ENUM_CAST(Weekday);

#define UNIX_TIME_TO_HMS \
uint8_t hour, minute, second; \
{ \
Expand Down
3 changes: 3 additions & 0 deletions core/os/time.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,7 @@ class Time : public Object {
virtual ~Time();
};

VARIANT_ENUM_CAST(Month);
VARIANT_ENUM_CAST(Weekday);

#endif // TIME_H
9 changes: 9 additions & 0 deletions doc/class.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
</xs:sequence>
<xs:attribute type="xs:string" name="type" />
<xs:attribute type="xs:string" name="enum" use="optional" />
<xs:attribute type="xs:boolean" name="is_bitfield" use="optional" />
</xs:complexType>
</xs:element>
<xs:element name="param" maxOccurs="unbounded" minOccurs="0">
Expand All @@ -44,6 +45,7 @@
<xs:attribute type="xs:string" name="name" />
<xs:attribute type="xs:string" name="type" />
<xs:attribute type="xs:string" name="enum" use="optional" />
<xs:attribute type="xs:boolean" name="is_bitfield" use="optional" />
<xs:attribute type="xs:string" name="default" use="optional" />
</xs:complexType>
</xs:element>
Expand All @@ -69,6 +71,7 @@
</xs:sequence>
<xs:attribute type="xs:string" name="type" />
<xs:attribute type="xs:string" name="enum" use="optional" />
<xs:attribute type="xs:boolean" name="is_bitfield" use="optional" />
</xs:complexType>
</xs:element>
<xs:element name="returns_error" maxOccurs="unbounded" minOccurs="0">
Expand All @@ -88,6 +91,7 @@
<xs:attribute type="xs:string" name="name" />
<xs:attribute type="xs:string" name="type" />
<xs:attribute type="xs:string" name="enum" use="optional" />
<xs:attribute type="xs:boolean" name="is_bitfield" use="optional" />
<xs:attribute type="xs:string" name="default" use="optional" />
</xs:complexType>
</xs:element>
Expand Down Expand Up @@ -115,6 +119,7 @@
<xs:attribute type="xs:string" name="getter" />
<xs:attribute type="xs:string" name="overrides" use="optional" />
<xs:attribute type="xs:string" name="enum" use="optional" />
<xs:attribute type="xs:boolean" name="is_bitfield" use="optional" />
<xs:attribute type="xs:string" name="default" use="optional" />
<xs:attribute type="xs:boolean" name="is_deprecated" use="optional" />
<xs:attribute type="xs:boolean" name="is_experimental" use="optional" />
Expand Down Expand Up @@ -182,6 +187,7 @@
</xs:sequence>
<xs:attribute type="xs:string" name="type" />
<xs:attribute type="xs:string" name="enum" use="optional" />
<xs:attribute type="xs:boolean" name="is_bitfield" use="optional" />
</xs:complexType>
</xs:element>
<xs:element name="param" maxOccurs="unbounded" minOccurs="0">
Expand All @@ -193,6 +199,7 @@
<xs:attribute type="xs:string" name="name" />
<xs:attribute type="xs:string" name="type" />
<xs:attribute type="xs:string" name="enum" use="optional" />
<xs:attribute type="xs:boolean" name="is_bitfield" use="optional" />
<xs:attribute type="xs:string" name="default" use="optional" />
</xs:complexType>
</xs:element>
Expand Down Expand Up @@ -236,6 +243,7 @@
</xs:sequence>
<xs:attribute type="xs:string" name="type" />
<xs:attribute type="xs:string" name="enum" use="optional" />
<xs:attribute type="xs:boolean" name="is_bitfield" use="optional" />
</xs:complexType>
</xs:element>
<xs:element name="param" maxOccurs="unbounded" minOccurs="0">
Expand All @@ -247,6 +255,7 @@
<xs:attribute type="xs:string" name="name" />
<xs:attribute type="xs:string" name="type" />
<xs:attribute type="xs:string" name="enum" use="optional" />
<xs:attribute type="xs:boolean" name="is_bitfield" use="optional" />
<xs:attribute type="xs:string" name="default" use="optional" />
</xs:complexType>
</xs:element>
Expand Down
4 changes: 2 additions & 2 deletions doc/classes/ArrayMesh.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
<param index="1" name="arrays" type="Array" />
<param index="2" name="blend_shapes" type="Array[]" default="[]" />
<param index="3" name="lods" type="Dictionary" default="{}" />
<param index="4" name="flags" type="int" enum="Mesh.ArrayFormat" default="0" />
<param index="4" name="flags" type="int" enum="Mesh.ArrayFormat" is_bitfield="true" default="0" />
<description>
Creates a new surface. [method Mesh.get_surface_count] will become the [code]surf_idx[/code] for this new surface.
Surfaces are created to be rendered using a [param primitive], which may be any of the values defined in [enum Mesh.PrimitiveType].
Expand Down Expand Up @@ -145,7 +145,7 @@
</description>
</method>
<method name="surface_get_format" qualifiers="const">
<return type="int" enum="Mesh.ArrayFormat" />
<return type="int" enum="Mesh.ArrayFormat" is_bitfield="true" />
<param index="0" name="surf_idx" type="int" />
<description>
Returns the format mask of the requested surface (see [method add_surface_from_arrays]).
Expand Down
2 changes: 1 addition & 1 deletion doc/classes/BaseButton.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
The [ButtonGroup] associated with the button. Not to be confused with node groups.
[b]Note:[/b] The button will be configured as a radio button if a [ButtonGroup] is assigned to it.
</member>
<member name="button_mask" type="int" setter="set_button_mask" getter="get_button_mask" enum="MouseButtonMask" default="1">
<member name="button_mask" type="int" setter="set_button_mask" getter="get_button_mask" enum="MouseButtonMask" is_bitfield="true" default="1">
Binary mask to choose which mouse buttons this button will respond to.
To allow both left-click and right-click, use [code]MOUSE_BUTTON_MASK_LEFT | MOUSE_BUTTON_MASK_RIGHT[/code].
</member>
Expand Down
12 changes: 6 additions & 6 deletions doc/classes/CanvasItem.xml
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@
<param index="5" name="font_size" type="int" default="16" />
<param index="6" name="max_lines" type="int" default="-1" />
<param index="7" name="modulate" type="Color" default="Color(1, 1, 1, 1)" />
<param index="8" name="brk_flags" type="int" enum="TextServer.LineBreakFlag" default="3" />
<param index="9" name="justification_flags" type="int" enum="TextServer.JustificationFlag" default="3" />
<param index="8" name="brk_flags" type="int" enum="TextServer.LineBreakFlag" is_bitfield="true" default="3" />
<param index="9" name="justification_flags" type="int" enum="TextServer.JustificationFlag" is_bitfield="true" default="3" />
<param index="10" name="direction" type="int" enum="TextServer.Direction" default="0" />
<param index="11" name="orientation" type="int" enum="TextServer.Orientation" default="0" />
<description>
Expand All @@ -212,8 +212,8 @@
<param index="6" name="max_lines" type="int" default="-1" />
<param index="7" name="size" type="int" default="1" />
<param index="8" name="modulate" type="Color" default="Color(1, 1, 1, 1)" />
<param index="9" name="brk_flags" type="int" enum="TextServer.LineBreakFlag" default="3" />
<param index="10" name="justification_flags" type="int" enum="TextServer.JustificationFlag" default="3" />
<param index="9" name="brk_flags" type="int" enum="TextServer.LineBreakFlag" is_bitfield="true" default="3" />
<param index="10" name="justification_flags" type="int" enum="TextServer.JustificationFlag" is_bitfield="true" default="3" />
<param index="11" name="direction" type="int" enum="TextServer.Direction" default="0" />
<param index="12" name="orientation" type="int" enum="TextServer.Orientation" default="0" />
<description>
Expand Down Expand Up @@ -309,7 +309,7 @@
<param index="4" name="width" type="float" default="-1" />
<param index="5" name="font_size" type="int" default="16" />
<param index="6" name="modulate" type="Color" default="Color(1, 1, 1, 1)" />
<param index="7" name="justification_flags" type="int" enum="TextServer.JustificationFlag" default="3" />
<param index="7" name="justification_flags" type="int" enum="TextServer.JustificationFlag" is_bitfield="true" default="3" />
<param index="8" name="direction" type="int" enum="TextServer.Direction" default="0" />
<param index="9" name="orientation" type="int" enum="TextServer.Orientation" default="0" />
<description>
Expand Down Expand Up @@ -346,7 +346,7 @@
<param index="5" name="font_size" type="int" default="16" />
<param index="6" name="size" type="int" default="1" />
<param index="7" name="modulate" type="Color" default="Color(1, 1, 1, 1)" />
<param index="8" name="justification_flags" type="int" enum="TextServer.JustificationFlag" default="3" />
<param index="8" name="justification_flags" type="int" enum="TextServer.JustificationFlag" is_bitfield="true" default="3" />
<param index="9" name="direction" type="int" enum="TextServer.Direction" default="0" />
<param index="10" name="orientation" type="int" enum="TextServer.Orientation" default="0" />
<description>
Expand Down
4 changes: 2 additions & 2 deletions doc/classes/Control.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1028,13 +1028,13 @@
<member name="size" type="Vector2" setter="_set_size" getter="get_size" default="Vector2(0, 0)">
The size of the node's bounding rectangle, in the node's coordinate system. [Container] nodes update this property automatically.
</member>
<member name="size_flags_horizontal" type="int" setter="set_h_size_flags" getter="get_h_size_flags" enum="Control.SizeFlags" default="1">
<member name="size_flags_horizontal" type="int" setter="set_h_size_flags" getter="get_h_size_flags" enum="Control.SizeFlags" is_bitfield="true" default="1">
Tells the parent [Container] nodes how they should resize and place the node on the X axis. Use a combination of the [enum SizeFlags] constants to change the flags. See the constants to learn what each does.
</member>
<member name="size_flags_stretch_ratio" type="float" setter="set_stretch_ratio" getter="get_stretch_ratio" default="1.0">
If the node and at least one of its neighbors uses the [constant SIZE_EXPAND] size flag, the parent [Container] will let it take more or less space depending on this property. If this node has a stretch ratio of 2 and its neighbor a ratio of 1, this node will take two thirds of the available space.
</member>
<member name="size_flags_vertical" type="int" setter="set_v_size_flags" getter="get_v_size_flags" enum="Control.SizeFlags" default="1">
<member name="size_flags_vertical" type="int" setter="set_v_size_flags" getter="get_v_size_flags" enum="Control.SizeFlags" is_bitfield="true" default="1">
Tells the parent [Container] nodes how they should resize and place the node on the Y axis. Use a combination of the [enum SizeFlags] constants to change the flags. See the constants to learn what each does.
</member>
<member name="theme" type="Theme" setter="set_theme" getter="get_theme">
Expand Down
2 changes: 1 addition & 1 deletion doc/classes/DisplayServer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -807,7 +807,7 @@
</description>
</method>
<method name="mouse_get_button_state" qualifiers="const">
<return type="int" enum="MouseButtonMask" />
<return type="int" enum="MouseButtonMask" is_bitfield="true" />
<description>
Returns the current state of mouse buttons (whether each button is pressed) as a bitmask. If multiple mouse buttons are pressed at the same time, the bits are added together. Equivalent to [method Input.get_mouse_button_mask].
</description>
Expand Down
2 changes: 1 addition & 1 deletion doc/classes/EditorInspectorPlugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
<param index="2" name="name" type="String" />
<param index="3" name="hint_type" type="int" enum="PropertyHint" />
<param index="4" name="hint_string" type="String" />
<param index="5" name="usage_flags" type="int" enum="PropertyUsageFlags" />
<param index="5" name="usage_flags" type="int" enum="PropertyUsageFlags" is_bitfield="true" />
<param index="6" name="wide" type="bool" />
<description>
Called to allow adding property-specific editors to the property list for [param object]. The added editor control must extend [EditorProperty]. Returning [code]true[/code] removes the built-in editor for this property, otherwise allows to insert a custom editor before the built-in one.
Expand Down
2 changes: 1 addition & 1 deletion doc/classes/EditorSpinSlider.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<member name="read_only" type="bool" setter="set_read_only" getter="is_read_only" default="false">
If [code]true[/code], the slider can't be interacted with.
</member>
<member name="size_flags_vertical" type="int" setter="set_v_size_flags" getter="get_v_size_flags" overrides="Control" enum="Control.SizeFlags" default="1" />
<member name="size_flags_vertical" type="int" setter="set_v_size_flags" getter="get_v_size_flags" overrides="Control" enum="Control.SizeFlags" is_bitfield="true" default="1" />
<member name="step" type="float" setter="set_step" getter="get_step" overrides="Range" default="1.0" />
<member name="suffix" type="String" setter="set_suffix" getter="get_suffix" default="&quot;&quot;">
The suffix to display after the value (in a faded color). This should generally be a plural word. You may have to use an abbreviation if the suffix is too long to be displayed.
Expand Down
Loading

0 comments on commit eb391d3

Please sign in to comment.