Module: Cheri::Java::Builder::Types

Defined in:
lib/cheri/java/builder/util.rb

Overview

TODO: leftover from JRBuilder, rethink for Cheri

Constant Summary collapse

BYTE_MIN =

:stopdoc:

-128
BYTE_MAX =
127
CHAR_MIN =
0
CHAR_MAX =
65535
SHORT_MIN =
-32768
SHORT_MAX =
32767
INT_MIN =
-2147483648
INT_MAX =
2147483647
LONG_MIN =
-9223372036854775808
LONG_MAX =
9223372036854775807
FLOAT_MIN =
1.401298464324817E-45
FLOAT_MAX =
3.4028234663852886E38
DOUBLE_MIN =
4.9E-324
DOUBLE_MAX =
1.7976931348623157E308

Class Method Summary collapse

Class Method Details

.can_match_type(n) ⇒ Object

call-seq:

can_match_type(type_cls_name) -> true or false

this should be called first, otherwise the response of does_type_match is ambiguous TODO: deal with subclasses of non-final types



457
458
459
# File 'lib/cheri/java/builder/util.rb', line 457

def can_match_type(n)
  @map[n] != nil
end

.does_type_match(n, v) ⇒ Object

call-seq:

does_type_match(type_cls_name, value) -> true or false

TODO: deal with subclasses of non-final types



465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
# File 'lib/cheri/java/builder/util.rb', line 465

def does_type_match(n,v)
  rtypes = @map[n]
  return false unless rtypes
  rtypes.each do |t|
    if v.kind_of?(t[0])
      range = t[1]
      if range 
        return v >= range[0] && v <= range[1]        
      else
        return true 
      end
    end
  end
  false    
end

.type_matches_arg(type, arg) ⇒ Object

type must be a JavaClass



439
440
441
442
443
444
445
446
447
448
# File 'lib/cheri/java/builder/util.rb', line 439

def type_matches_arg(type,arg)
  return type.assignable_from?(arg.java_class) if arg.respond_to?(:java_class)
  if can_match_type(type.name)      
    return does_type_match(type.name,arg)
  else
    # TODO: deal with subclasses of non-final types in TypeMap
    warn "warning: can't evaluate type #{type.name}"
    return false
  end
end