Class: RubyQt6::QtCore::Private::MetaMethod
- Inherits:
-
Object
- Object
- RubyQt6::QtCore::Private::MetaMethod
- Defined in:
- lib/qt6/qtcore/private/metamethod.rb
Constant Summary collapse
- RE =
/(\w+ )?(\w+)\((.*)\)/
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#parameters ⇒ Object
readonly
Returns the value of attribute parameters.
-
#return_type ⇒ Object
readonly
Returns the value of attribute return_type.
-
#signature ⇒ Object
readonly
Returns the value of attribute signature.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
- .normalized_name(name) ⇒ Object
- .normalized_parameters(parameters) ⇒ Object
- .normalized_return_type(return_type) ⇒ Object
- .normalized_signature(normalized_name, normalized_parameters) ⇒ Object
Instance Method Summary collapse
-
#initialize(signature, type, underlying) ⇒ MetaMethod
constructor
A new instance of MetaMethod.
- #qsignature ⇒ Object
- #qsignature_name ⇒ Object
- #signal? ⇒ Boolean
- #slot? ⇒ Boolean
Constructor Details
#initialize(signature, type, underlying) ⇒ MetaMethod
Returns a new instance of MetaMethod.
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/qt6/qtcore/private/metamethod.rb', line 32 def initialize(signature, type, ) matched = signature.match(RE) raise "Invalid metamethod signature: #{signature}" if matched.nil? @name = self.class.normalized_name(matched[2]) @parameters = self.class.normalized_parameters(matched[3].split(",")) @signature = self.class.normalized_signature(@name, @parameters) @return_type = self.class.normalized_return_type(matched[1]) @type = type.to_sym = .to_sym end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
9 10 11 |
# File 'lib/qt6/qtcore/private/metamethod.rb', line 9 def name @name end |
#parameters ⇒ Object (readonly)
Returns the value of attribute parameters.
10 11 12 |
# File 'lib/qt6/qtcore/private/metamethod.rb', line 10 def parameters @parameters end |
#return_type ⇒ Object (readonly)
Returns the value of attribute return_type.
12 13 14 |
# File 'lib/qt6/qtcore/private/metamethod.rb', line 12 def return_type @return_type end |
#signature ⇒ Object (readonly)
Returns the value of attribute signature.
11 12 13 |
# File 'lib/qt6/qtcore/private/metamethod.rb', line 11 def signature @signature end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
13 14 15 |
# File 'lib/qt6/qtcore/private/metamethod.rb', line 13 def type @type end |
Class Method Details
.normalized_name(name) ⇒ Object
15 16 17 |
# File 'lib/qt6/qtcore/private/metamethod.rb', line 15 def self.normalized_name(name) QtCore::Private.inflector.underscore(name) end |
.normalized_parameters(parameters) ⇒ Object
19 20 21 |
# File 'lib/qt6/qtcore/private/metamethod.rb', line 19 def self.normalized_parameters(parameters) parameters.map(&->(param) { param.delete(" ") }) end |
.normalized_return_type(return_type) ⇒ Object
27 28 29 30 |
# File 'lib/qt6/qtcore/private/metamethod.rb', line 27 def self.normalized_return_type(return_type) return nil if return_type.nil? return_type.delete(" ") end |
.normalized_signature(normalized_name, normalized_parameters) ⇒ Object
23 24 25 |
# File 'lib/qt6/qtcore/private/metamethod.rb', line 23 def self.normalized_signature(normalized_name, normalized_parameters) normalized_name + "(" + normalized_parameters.join(",") + ")" end |
Instance Method Details
#qsignature ⇒ Object
52 53 54 55 |
# File 'lib/qt6/qtcore/private/metamethod.rb', line 52 def qsignature signature = self.class.normalized_signature(qsignature_name, @parameters) signal? ? "2#{signature}" : "1#{signature}" end |
#qsignature_name ⇒ Object
57 58 59 60 61 62 63 |
# File 'lib/qt6/qtcore/private/metamethod.rb', line 57 def qsignature_name case when :libQt6 then QtCore::Private.inflector.camelize(@name) when :ruby then "_rubyqt6_#{QtCore::Private.inflector.underscore(@name)}" else raise "Unknown underlying type: #{@underlying}" end end |
#signal? ⇒ Boolean
44 45 46 |
# File 'lib/qt6/qtcore/private/metamethod.rb', line 44 def signal? @type == :signal end |
#slot? ⇒ Boolean
48 49 50 |
# File 'lib/qt6/qtcore/private/metamethod.rb', line 48 def slot? @type == :slot end |