Module: Contrast::Api::Decorators::TraceEventSignature::ClassMethods

Defined in:
lib/contrast/api/decorators/trace_event_signature.rb

Overview

Class methods for TraceEventSignature

Instance Method Summary collapse

Instance Method Details

#build(ret_obj, policy_node, args) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/contrast/api/decorators/trace_event_signature.rb', line 20

def build ret_obj, policy_node, args
  signature = new
  return_type = ret_obj ? ret_obj.cs__class.name : Contrast::Utils::ObjectShare::NIL_STRING
  signature.return_type = Contrast::Utils::StringUtils.force_utf8(return_type)
  signature.class_name = Contrast::Utils::StringUtils.force_utf8(policy_node.class_name)
  signature.method_name = Contrast::Utils::StringUtils.force_utf8(policy_node.method_name)
  if args
    args&.each do |arg|
      arg_type = arg ? arg.cs__class.name : Contrast::Utils::ObjectShare::NIL_STRING
      signature.arg_types << Contrast::Utils::StringUtils.force_utf8(arg_type)
    end
  end
  signature.constructor = policy_node.method_name == :new
  # if there's a ret, then this method isn't nil. not 100% full proof since you can
  # return nil, but this is the best we've got currently.
  signature.void_method = ret_obj.nil?
  # 8 is STATIC in Java... we have to placate them for now
  # it has been requested that flags be removed since it isn't used
  signature.flags = 8 unless policy_node.instance_method?
  signature
end