Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 23 additions & 25 deletions lib/syskit/actions/interface_model_extension.rb
Original file line number Diff line number Diff line change
Expand Up @@ -185,20 +185,6 @@ def use_profile_object(
register_action_from_profile(definition.to_action_model)
end
end

include MetaRuby::DSLs::FindThroughMethodMissing

def has_through_method_missing?(name)
MetaRuby::DSLs.has_through_method_missing?(
profile, name, "_tag" => :has_tag?
) || super
end

def find_through_method_missing(name, args)
MetaRuby::DSLs.find_through_method_missing(
profile, name, args, "_tag" => :find_tag
) || super
end
end

# @api private
Expand All @@ -217,32 +203,44 @@ def setup_main_profile(profile)
end
end

Roby::Actions::Models::Library.include LibraryExtension
Roby::Actions::Interface.extend LibraryExtension
Roby::Actions::Interface.extend InterfaceModelExtension

# @api private
#
# Module injected in {Roby::Actions::Interface}, i.e. instance-level methods
module InterfaceExtension
def profile
self.class.profile
end
# Definition of the delegation of the `_tag` methods to `profile`
module FindTag
HAS_THROUGH_METHOD_MISSING = { "_tag" => :has_tag? }.freeze
FIND_THROUGH_METHOD_MISSING = { "_tag" => :find_tag }.freeze

def has_through_method_missing?(name)
MetaRuby::DSLs.has_through_method_missing?(
profile, name, "_tag" => :has_tag?
profile, name, HAS_THROUGH_METHOD_MISSING
) || super
end

def find_through_method_missing(name, args)
MetaRuby::DSLs.find_through_method_missing(
profile, name, args, "_tag" => :find_tag
profile, name, args, FIND_THROUGH_METHOD_MISSING
) || super
end

include MetaRuby::DSLs::FindThroughMethodMissing
end

# @api private
#
# Module injected in {Roby::Actions::Interface}, i.e. instance-level methods
module InterfaceExtension
def profile
self.class.profile
end
end

Roby::Actions::Models::Library.include LibraryExtension
Roby::Actions::Models::Library.include FindTag
Roby::Actions::Interface.extend LibraryExtension
Roby::Actions::Interface.extend InterfaceModelExtension
Roby::Actions::Interface.extend FindTag

Roby::Actions::Interface.include InterfaceExtension
Roby::Actions::Interface.include FindTag
end
end
30 changes: 18 additions & 12 deletions lib/syskit/actions/profile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -701,25 +701,31 @@ def find_device_requirements_by_name(name)
end
end

HAS_THROUGH_METHOD_MISSING = {
"_tag" => :has_tag?,
"_def" => :has_definition?,
"_dev" => :has_device?,
"_task" => :has_deployed_task?,
"_deployment_group" => :has_deployment_group?
}.freeze

def has_through_method_missing?(m)
MetaRuby::DSLs.has_through_method_missing?(
self, m,
"_tag" => :has_tag?,
"_def" => :has_definition?,
"_dev" => :has_device?,
"_task" => :has_deployed_task?,
"_deployment_group" => :has_deployment_group?
self, m, HAS_THROUGH_METHOD_MISSING
) || super
end

FIND_THROUGH_METHOD_MISSING = {
"_tag" => :find_tag,
"_def" => :find_definition_by_name,
"_dev" => :find_device_requirements_by_name,
"_task" => :find_deployed_task_by_name,
"_deployment_group" => :find_deployment_group_by_name
}.freeze

def find_through_method_missing(m, args)
MetaRuby::DSLs.find_through_method_missing(
self, m, args,
"_tag" => :find_tag,
"_def" => :find_definition_by_name,
"_dev" => :find_device_requirements_by_name,
"_task" => :find_deployed_task_by_name,
"_deployment_group" => :find_deployment_group_by_name
self, m, args, FIND_THROUGH_METHOD_MISSING
) || super
end

Expand Down
16 changes: 3 additions & 13 deletions lib/syskit/bound_data_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -159,19 +159,9 @@ def to_instance_requirements
req
end

def has_through_method_missing?(m)
MetaRuby::DSLs.has_through_method_missing?(
self, m,
"_srv" => :has_data_service?
) || super
end

def find_through_method_missing(m, args)
MetaRuby::DSLs.find_through_method_missing(
self, m, args,
"_srv" => :find_data_service
) || super
end
MetaRuby::DSLs::FindThroughMethodMissing.standard(
self, { "_srv" => "data_service" }
)

DRoby = Struct.new :component, :model do
def proxy(peer)
Expand Down
22 changes: 14 additions & 8 deletions lib/syskit/component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -700,21 +700,27 @@ def deregister_data_reader(name)
@data_readers.each(&:disconnect)
end

HAS_THROUGH_METHOD_MISSING = {
"_srv" => :has_data_service?,
"_writer" => :find_registered_data_writer,
"_reader" => :find_registered_data_reader
}.freeze

FIND_THROUGH_METHOD_MISSING = {
"_srv" => :find_data_service,
"_writer" => :find_registered_data_writer,
"_reader" => :find_registered_data_reader
}.freeze

def has_through_method_missing?(m)
MetaRuby::DSLs.has_through_method_missing?(
self, m,
"_srv" => :has_data_service?,
"_writer" => :find_registered_data_writer,
"_reader" => :find_registered_data_reader
self, m, HAS_THROUGH_METHOD_MISSING
) || super
end

def find_through_method_missing(m, args)
MetaRuby::DSLs.find_through_method_missing(
self, m, args,
"_srv" => :find_data_service,
"_writer" => :find_registered_data_writer,
"_reader" => :find_registered_data_reader
self, m, args, FIND_THROUGH_METHOD_MISSING
) || super
end

Expand Down
7 changes: 5 additions & 2 deletions lib/syskit/coordination/models/data_monitoring_table.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,18 @@ def attach_to(query)
attachment_points << query
end

HAS_THROUGH_METHOD_MISSING = { "_port" => :has_port? }.freeze
FIND_THROUGH_METHOD_MISSING = { "_port" => :find_port }.freeze

def has_through_method_missing?(m)
MetaRuby::DSLs.has_through_method_missing?(
root, m, "_port" => :has_port?
root, m, HAS_THROUGH_METHOD_MISSING
) || super
end

def find_through_method_missing(m, args)
MetaRuby::DSLs.find_through_method_missing(
root, m, args, "_port" => :find_port
root, m, args, FIND_THROUGH_METHOD_MISSING
) || super
end

Expand Down
18 changes: 3 additions & 15 deletions lib/syskit/coordination/models/fault_response_table_extension.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,26 +77,14 @@ def find_monitor(name)
nil
end

def has_through_method_missing?(m)
MetaRuby::DSLs.has_through_method_missing?(
self, m, "_monitor" => :find_monitor
) || super
end

def find_through_method_missing(m, args)
MetaRuby::DSLs.find_through_method_missing(
self, m, args, "_monitor" => :find_monitor
) || super
end

include MetaRuby::DSLs::FindThroughMethodMissing
MetaRuby::DSLs::FindThroughMethodMissing.standard(self, %w[monitor])

def respond_to_missing?(m, include_private)
arguments[m] || super
arguments.key?(m) || super
end

def method_missing(m, *args, &block)
if arg = arguments[m]
if (arg = arguments[m])
Roby::Coordination::Models::Variable.new(m)
else
super
Expand Down
8 changes: 1 addition & 7 deletions lib/syskit/coordination/models/port_handling.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,7 @@ def self_port_to_component_port(port)
model.self_port_to_component_port(port)
end

def has_through_method_missing?(m)
MetaRuby::DSLs.has_through_method_missing?(self, m, "_port" => :has_port?) || super
end

def find_through_method_missing(m, args)
MetaRuby::DSLs.find_through_method_missing(self, m, args, "_port" => :find_port) || super
end
MetaRuby::DSLs::FindThroughMethodMissing.standard(self, %w[port])
end
end
end
Expand Down
8 changes: 1 addition & 7 deletions lib/syskit/coordination/port_handling.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,7 @@ def self_port_to_component_port(port)
end
end

def has_through_method_missing?(m)
MetaRuby::DSLs.has_through_method_missing?(self, m, "_port" => :has_port?) || super
end

def find_through_method_missing(m, args)
MetaRuby::DSLs.find_through_method_missing(self, m, args, "_port" => :find_port) || super
end
MetaRuby::DSLs::FindThroughMethodMissing.standard(self, %w[port])
end

class OutputPort < Syskit::OutputPort
Expand Down
8 changes: 5 additions & 3 deletions lib/syskit/deployment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ def logger_name
#
# @return [TaskContext,nil] either the logging task, or nil if this
# deployment has none
def logger_task
def logger_task(create: true)
return unless logging_enabled?

if arguments[:logger_task]
Expand All @@ -371,14 +371,16 @@ def logger_task
@logger_task =
if logger_task&.fullfills?(LoggerService)
logger_task
else
elsif create
instanciate_default_logger_task(logger_name)
end

@logger_task&.default_logger = true
end

@logger_task ||= process_server_config.default_logger_task(plan)
return @logger_task if @logger_task

@logger_task = process_server_config.default_logger_task(plan, create: create)
end

# Instanciates a new default logger
Expand Down
25 changes: 6 additions & 19 deletions lib/syskit/instance_requirements.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1349,25 +1349,12 @@ def each_child
end
end

def has_through_method_missing?(name)
MetaRuby::DSLs.has_through_method_missing?(
self, name,
"_srv" => :has_data_service?,
"_child" => :has_child?,
"_port" => :has_port?
) || super
end

def find_through_method_missing(name, args)
MetaRuby::DSLs.find_through_method_missing(
self, name, args,
"_srv" => :find_data_service,
"_child" => :find_child,
"_port" => :find_port
) || super
end

include MetaRuby::DSLs::FindThroughMethodMissing
MetaRuby::DSLs::FindThroughMethodMissing.standard(
self,
"_srv" => "data_service",
"_child" => "child",
"_port" => "port"
)

# Generates the InstanceRequirements object that represents +self+
# best
Expand Down
14 changes: 2 additions & 12 deletions lib/syskit/models/bound_data_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -398,18 +398,8 @@ def find_data_service(name)
nil
end

def has_through_method_missing?(m)
MetaRuby::DSLs.has_through_method_missing?(
self, m, "_srv" => :has_data_service?
) || super
end

def find_through_method_missing(m, args)
MetaRuby::DSLs.find_through_method_missing(
self, m, args,
"_srv" => :find_data_service
) || super
end
MetaRuby::DSLs::FindThroughMethodMissing
.standard(self, { "_srv" => "data_service" })

# Whether two services are the same service bound to two different interfaces
#
Expand Down
27 changes: 8 additions & 19 deletions lib/syskit/models/component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1399,25 +1399,14 @@ def data_writer(port, as:, **policy)
data_writers[as] = port.to_bound_data_accessor(as, self, **policy)
end

def has_through_method_missing?(name)
MetaRuby::DSLs.has_through_method_missing?(
self, name,
"_srv" => :find_data_service,
"_reader" => :find_data_reader,
"_writer" => :find_data_writer
) || super
end

def find_through_method_missing(name, args)
MetaRuby::DSLs.find_through_method_missing(
self, name, args,
"_srv" => :find_data_service,
"_reader" => :find_data_reader,
"_writer" => :find_data_writer
) || super
end

include MetaRuby::DSLs::FindThroughMethodMissing
MetaRuby::DSLs::FindThroughMethodMissing.standard(
self,
{
"_srv" => :data_service,
"_reader" => :data_reader,
"_writer" => :data_writer
}
)

ruby2_keywords def method_missing(name, *args, &block) # rubocop:disable Style/MissingRespondToMissing
if name == :orogen_model
Expand Down
12 changes: 1 addition & 11 deletions lib/syskit/models/composition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1254,17 +1254,7 @@ def setup_submodel(submodel, register_specializations: true,
submodel
end

def has_through_method_missing?(m)
MetaRuby::DSLs.has_through_method_missing?(
self, m, "_child" => :find_child
) || super
end

def find_through_method_missing(m, args)
MetaRuby::DSLs.find_through_method_missing(
self, m, args, "_child" => :find_child
) || super
end
MetaRuby::DSLs::FindThroughMethodMissing.standard(self, %w[child])

# Helper method for {#promote_exported_output} and
# {#promote_exported_input}
Expand Down
Loading