rubex 0.1 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (197) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +3 -2
  3. data/.travis.yml +9 -1
  4. data/CONTRIBUTING.md +2 -2
  5. data/README.md +4 -1
  6. data/Rakefile +2 -2
  7. data/bin/rubex +4 -5
  8. data/lib/rubex.rb +4 -4
  9. data/lib/rubex/ast.rb +4 -1
  10. data/lib/rubex/ast/expression.rb +22 -1191
  11. data/lib/rubex/ast/expression/actual_arg_list.rb +40 -0
  12. data/lib/rubex/ast/expression/analysed_element_ref.rb +26 -0
  13. data/lib/rubex/ast/expression/analysed_element_ref/c_var_element_ref.rb +30 -0
  14. data/lib/rubex/ast/expression/analysed_element_ref/ruby_object_element_ref.rb +42 -0
  15. data/lib/rubex/ast/expression/arg_declaration.rb +43 -0
  16. data/lib/rubex/ast/expression/binary.rb +57 -0
  17. data/lib/rubex/ast/expression/binary/binary_boolean.rb +23 -0
  18. data/lib/rubex/ast/expression/binary/binary_boolean_special_op.rb +20 -0
  19. data/lib/rubex/ast/expression/binary/empty_classes.rb +62 -0
  20. data/lib/rubex/ast/expression/block_given.rb +15 -0
  21. data/lib/rubex/ast/expression/coerce_object.rb +15 -0
  22. data/lib/rubex/ast/expression/command_call.rb +74 -0
  23. data/lib/rubex/ast/expression/command_call/struct_or_union_member_call.rb +38 -0
  24. data/lib/rubex/ast/expression/element_ref.rb +64 -0
  25. data/lib/rubex/ast/expression/empty.rb +13 -0
  26. data/lib/rubex/ast/expression/from_ruby_object.rb +20 -0
  27. data/lib/rubex/ast/expression/func_ptr_arg_declaration.rb +21 -0
  28. data/lib/rubex/ast/expression/func_ptr_internal_arg_declaration.rb +13 -0
  29. data/lib/rubex/ast/expression/literal.rb +30 -0
  30. data/lib/rubex/ast/expression/literal/array_lit.rb +51 -0
  31. data/lib/rubex/ast/expression/literal/c_null.rb +15 -0
  32. data/lib/rubex/ast/expression/literal/char.rb +36 -0
  33. data/lib/rubex/ast/expression/literal/double.rb +14 -0
  34. data/lib/rubex/ast/expression/literal/false.rb +33 -0
  35. data/lib/rubex/ast/expression/literal/hash_lit.rb +45 -0
  36. data/lib/rubex/ast/expression/literal/int.rb +14 -0
  37. data/lib/rubex/ast/expression/literal/nil.rb +14 -0
  38. data/lib/rubex/ast/expression/literal/ruby_symbol.rb +22 -0
  39. data/lib/rubex/ast/expression/literal/string_lit.rb +45 -0
  40. data/lib/rubex/ast/expression/literal/true.rb +29 -0
  41. data/lib/rubex/ast/expression/method_call.rb +52 -0
  42. data/lib/rubex/ast/expression/method_call/c_function_call.rb +40 -0
  43. data/lib/rubex/ast/expression/method_call/ruby_method_call.rb +83 -0
  44. data/lib/rubex/ast/expression/name.rb +127 -0
  45. data/lib/rubex/ast/expression/ruby_constant.rb +25 -0
  46. data/lib/rubex/ast/expression/ruby_object_element_ref/ruby_array_element_ref.rb +20 -0
  47. data/lib/rubex/ast/expression/ruby_object_element_ref/ruby_hash_element_ref.rb +22 -0
  48. data/lib/rubex/ast/expression/self.rb +15 -0
  49. data/lib/rubex/ast/expression/size_of.rb +22 -0
  50. data/lib/rubex/ast/expression/struct_or_union_member_call/element_ref_member_call.rb +23 -0
  51. data/lib/rubex/ast/expression/to_ruby_object.rb +21 -0
  52. data/lib/rubex/ast/expression/typecast.rb +20 -0
  53. data/lib/rubex/ast/expression/typecast_to.rb +10 -0
  54. data/lib/rubex/ast/expression/unary.rb +37 -0
  55. data/lib/rubex/ast/expression/unary_base.rb +24 -0
  56. data/lib/rubex/ast/expression/unary_base/ampersand.rb +16 -0
  57. data/lib/rubex/ast/expression/unary_base/unary_bit_not.rb +18 -0
  58. data/lib/rubex/ast/expression/unary_base/unary_not.rb +18 -0
  59. data/lib/rubex/ast/expression/unary_base/unary_sub.rb +18 -0
  60. data/lib/rubex/ast/node.rb +111 -111
  61. data/lib/rubex/ast/statement.rb +9 -1160
  62. data/lib/rubex/ast/statement/alias.rb +43 -0
  63. data/lib/rubex/ast/statement/argument_list.rb +59 -0
  64. data/lib/rubex/ast/statement/assign.rb +35 -0
  65. data/lib/rubex/ast/statement/begin_block.rb +14 -0
  66. data/lib/rubex/ast/statement/begin_block/begin.rb +202 -0
  67. data/lib/rubex/ast/statement/begin_block/else.rb +21 -0
  68. data/lib/rubex/ast/statement/begin_block/ensure.rb +21 -0
  69. data/lib/rubex/ast/statement/begin_block/rescue.rb +34 -0
  70. data/lib/rubex/ast/statement/break.rb +18 -0
  71. data/lib/rubex/ast/statement/c_array_decl.rb +49 -0
  72. data/lib/rubex/ast/statement/c_base_type.rb +26 -0
  73. data/lib/rubex/ast/statement/c_function_decl.rb +30 -0
  74. data/lib/rubex/ast/statement/c_ptr_decl.rb +52 -0
  75. data/lib/rubex/ast/statement/c_ptr_decl/c_ptr_func_decl.rb +25 -0
  76. data/lib/rubex/ast/statement/c_struct_or_union_def.rb +49 -0
  77. data/lib/rubex/ast/statement/expression.rb +26 -0
  78. data/lib/rubex/ast/statement/for.rb +73 -0
  79. data/lib/rubex/ast/statement/forward_decl.rb +31 -0
  80. data/lib/rubex/ast/statement/if_block.rb +64 -0
  81. data/lib/rubex/ast/statement/if_block/else.rb +30 -0
  82. data/lib/rubex/ast/statement/if_block/elsif.rb +22 -0
  83. data/lib/rubex/ast/statement/if_block/helper.rb +38 -0
  84. data/lib/rubex/ast/statement/print.rb +49 -0
  85. data/lib/rubex/ast/statement/raise.rb +66 -0
  86. data/lib/rubex/ast/statement/return.rb +45 -0
  87. data/lib/rubex/ast/statement/var_decl.rb +49 -0
  88. data/lib/rubex/ast/statement/while.rb +34 -0
  89. data/lib/rubex/ast/statement/yield.rb +41 -0
  90. data/lib/rubex/ast/top_statement.rb +1 -815
  91. data/lib/rubex/ast/top_statement/c_bindings.rb +145 -0
  92. data/lib/rubex/ast/top_statement/klass.rb +125 -0
  93. data/lib/rubex/ast/top_statement/klass/attached_klass.rb +417 -0
  94. data/lib/rubex/ast/top_statement/method_def.rb +110 -0
  95. data/lib/rubex/ast/top_statement/method_def/c_function_def.rb +26 -0
  96. data/lib/rubex/ast/top_statement/method_def/ruby_method_def.rb +33 -0
  97. data/lib/rubex/cli.rb +26 -0
  98. data/lib/rubex/code_writer.rb +1 -1
  99. data/lib/rubex/compiler.rb +49 -28
  100. data/lib/rubex/compiler_config.rb +4 -2
  101. data/lib/rubex/constants.rb +71 -71
  102. data/lib/rubex/data_type.rb +9 -675
  103. data/lib/rubex/data_type/c_array.rb +33 -0
  104. data/lib/rubex/data_type/c_function.rb +23 -0
  105. data/lib/rubex/data_type/c_ptr.rb +71 -0
  106. data/lib/rubex/data_type/c_str.rb +23 -0
  107. data/lib/rubex/data_type/c_struct_or_union.rb +23 -0
  108. data/lib/rubex/data_type/char.rb +30 -0
  109. data/lib/rubex/data_type/f_32.rb +38 -0
  110. data/lib/rubex/data_type/f_64.rb +38 -0
  111. data/lib/rubex/data_type/int.rb +32 -0
  112. data/lib/rubex/data_type/int/c_boolean.rb +13 -0
  113. data/lib/rubex/data_type/int_16.rb +32 -0
  114. data/lib/rubex/data_type/int_32.rb +32 -0
  115. data/lib/rubex/data_type/int_64.rb +36 -0
  116. data/lib/rubex/data_type/int_8.rb +33 -0
  117. data/lib/rubex/data_type/l_int.rb +38 -0
  118. data/lib/rubex/data_type/l_l_int.rb +26 -0
  119. data/lib/rubex/data_type/ruby_method.rb +22 -0
  120. data/lib/rubex/data_type/ruby_object.rb +19 -0
  121. data/lib/rubex/data_type/ruby_object/boolean.rb +11 -0
  122. data/lib/rubex/data_type/ruby_object/boolean/false_type.rb +5 -0
  123. data/lib/rubex/data_type/ruby_object/boolean/true_type.rb +5 -0
  124. data/lib/rubex/data_type/ruby_object/nil_type.rb +9 -0
  125. data/lib/rubex/data_type/ruby_object/ruby_array.rb +10 -0
  126. data/lib/rubex/data_type/ruby_object/ruby_constant.rb +18 -0
  127. data/lib/rubex/data_type/ruby_object/ruby_constant/ruby_class.rb +18 -0
  128. data/lib/rubex/data_type/ruby_object/ruby_hash.rb +9 -0
  129. data/lib/rubex/data_type/ruby_object/ruby_string.rb +10 -0
  130. data/lib/rubex/data_type/ruby_object/ruby_symbol.rb +10 -0
  131. data/lib/rubex/data_type/type_def.rb +34 -0
  132. data/lib/rubex/data_type/u_char.rb +27 -0
  133. data/lib/rubex/data_type/u_int.rb +32 -0
  134. data/lib/rubex/data_type/u_int_16.rb +22 -0
  135. data/lib/rubex/data_type/u_int_32.rb +22 -0
  136. data/lib/rubex/data_type/u_int_64.rb +26 -0
  137. data/lib/rubex/data_type/u_int_8.rb +22 -0
  138. data/lib/rubex/data_type/u_l_int.rb +36 -0
  139. data/lib/rubex/data_type/u_l_int/size_t.rb +10 -0
  140. data/lib/rubex/data_type/u_l_l_int.rb +26 -0
  141. data/lib/rubex/data_type/void.rb +15 -0
  142. data/lib/rubex/data_type_helpers/float_helpers.rb +8 -0
  143. data/lib/rubex/data_type_helpers/helpers.rb +48 -0
  144. data/lib/rubex/data_type_helpers/int_helpers.rb +10 -0
  145. data/lib/rubex/data_type_helpers/u_int_helpers.rb +11 -0
  146. data/lib/rubex/helpers.rb +35 -118
  147. data/lib/rubex/helpers/node_type_methods.rb +9 -0
  148. data/lib/rubex/helpers/writers.rb +79 -0
  149. data/lib/rubex/parser.racc +83 -34
  150. data/lib/rubex/parser.racc.rb +233 -184
  151. data/lib/rubex/version.rb +2 -2
  152. data/rubex.gemspec +2 -0
  153. data/spec/basic_ruby_method_spec.rb +1 -1
  154. data/spec/binding_ptr_args_spec.rb +2 -2
  155. data/spec/bitwise_operators_spec.rb +1 -1
  156. data/spec/blocks_spec.rb +2 -2
  157. data/spec/c_bindings_spec.rb +1 -1
  158. data/spec/c_constants_spec.rb +1 -1
  159. data/spec/c_function_ptrs_spec.rb +1 -1
  160. data/spec/c_functions_spec.rb +2 -2
  161. data/spec/c_struct_interface_spec.rb +1 -1
  162. data/spec/call_by_reference_spec.rb +2 -2
  163. data/spec/class_methods_spec.rb +2 -2
  164. data/spec/class_spec.rb +4 -4
  165. data/spec/cli_spec.rb +43 -0
  166. data/spec/comments_spec.rb +2 -2
  167. data/spec/default_args_spec.rb +21 -23
  168. data/spec/error_handling_spec.rb +1 -1
  169. data/spec/examples_spec.rb +4 -4
  170. data/spec/expressions_spec.rb +1 -1
  171. data/spec/fixtures/cli/cli.rubex +3 -0
  172. data/spec/fixtures/examples/array_to_hash.rubex +1 -1
  173. data/spec/fixtures/examples/rcsv.rubex +10 -6
  174. data/spec/fixtures/loops/loops.rubex +1 -1
  175. data/spec/fixtures/ruby_strings/string_blank_bm.rb +7 -5
  176. data/spec/fixtures/struct/struct.rubex +7 -2
  177. data/spec/fixtures/temp_allocation/temp_allocation.rubex +8 -0
  178. data/spec/if_else_spec.rb +3 -7
  179. data/spec/implicit_lib_include_spec.rb +1 -1
  180. data/spec/init_ruby_objects_with_literal_syntax_spec.rb +1 -1
  181. data/spec/loops_spec.rb +1 -1
  182. data/spec/recursion_spec.rb +18 -21
  183. data/spec/ruby_constant_method_calls_spec.rb +4 -4
  184. data/spec/ruby_operators_spec.rb +1 -1
  185. data/spec/ruby_raise_spec.rb +1 -1
  186. data/spec/ruby_strings_spec.rb +3 -3
  187. data/spec/ruby_symbols_spec.rb +1 -1
  188. data/spec/ruby_types_spec.rb +2 -2
  189. data/spec/spec_helper.rb +42 -10
  190. data/spec/statement_expression_spec.rb +3 -3
  191. data/spec/static_array_spec.rb +3 -3
  192. data/spec/string_literals_spec.rb +2 -2
  193. data/spec/struct_spec.rb +4 -4
  194. data/spec/temp_allocation_spec.rb +35 -0
  195. data/spec/typecasting_spec.rb +2 -2
  196. data/spec/var_declarions_spec.rb +2 -2
  197. metadata +168 -3
@@ -0,0 +1,38 @@
1
+ module Rubex
2
+ module DataType
3
+ class LInt
4
+ include IntHelpers
5
+ def to_s
6
+ 'long int'
7
+ end
8
+
9
+ def to_ruby_object(arg)
10
+ "LONG2NUM(#{arg})"
11
+ end
12
+
13
+ def from_ruby_object(arg)
14
+ "NUM2LONG(#{arg})"
15
+ end
16
+
17
+ def lint?
18
+ true
19
+ end
20
+
21
+ def p_formatter
22
+ '%ld'
23
+ end
24
+
25
+ def <=>(other)
26
+ if other.char? || other.int8? || other.int16? || other.int32? ||
27
+ other .int64? || other.uint8? || other.uint16? || other.uint32? ||
28
+ other.int?
29
+ 1
30
+ elsif other.lint?
31
+ 0
32
+ else
33
+ -1
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,26 @@
1
+ module Rubex
2
+ module DataType
3
+ class LLInt
4
+ include IntHelpers
5
+ def to_s
6
+ 'long long int'
7
+ end
8
+
9
+ def to_ruby_object(arg)
10
+ "LL2NUM(#{arg})"
11
+ end
12
+
13
+ def from_ruby_object(arg)
14
+ "NUM2LL(#{arg})"
15
+ end
16
+
17
+ def llint?
18
+ true
19
+ end
20
+
21
+ def p_formatter
22
+ '%ll'
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,22 @@
1
+ module Rubex
2
+ module DataType
3
+ class RubyMethod
4
+ include Helpers
5
+
6
+ attr_reader :name, :c_name, :type
7
+ attr_accessor :scope, :arg_list
8
+
9
+ def initialize(name, c_name, scope, arg_list)
10
+ @name = name
11
+ @c_name = c_name
12
+ @scope = scope
13
+ @arg_list = arg_list
14
+ @type = RubyObject.new
15
+ end
16
+
17
+ def ruby_method?
18
+ true
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,19 @@
1
+ module Rubex
2
+ module DataType
3
+ class RubyObject
4
+ include Helpers
5
+ def to_s
6
+ 'VALUE'
7
+ end
8
+
9
+ def object?
10
+ true
11
+ end
12
+
13
+ def p_formatter
14
+ '%s'
15
+ end
16
+ end
17
+
18
+ end
19
+ end
@@ -0,0 +1,11 @@
1
+ module Rubex
2
+ module DataType
3
+ class Boolean < RubyObject
4
+ include Helpers
5
+
6
+ def bool?
7
+ true
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,5 @@
1
+ module Rubex
2
+ module DataType
3
+ class FalseType < Boolean; end
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module Rubex
2
+ module DataType
3
+ class TrueType < Boolean; end
4
+ end
5
+ end
@@ -0,0 +1,9 @@
1
+ module Rubex
2
+ module DataType
3
+ class NilType < RubyObject
4
+ def nil_type?
5
+ true
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,10 @@
1
+ module Rubex
2
+ module DataType
3
+ class RubyArray < RubyObject
4
+ def ruby_array?
5
+ true
6
+ end
7
+ end
8
+
9
+ end
10
+ end
@@ -0,0 +1,18 @@
1
+ module Rubex
2
+ module DataType
3
+ class RubyConstant < RubyObject
4
+ attr_reader :name, :type
5
+
6
+ def initialize(name)
7
+ @name = name
8
+ # FIXME: make this flexible so that consts set to primitive types can be
9
+ # easily converted to C types.
10
+ @type = RubyObject.new
11
+ end
12
+
13
+ def ruby_constant?
14
+ true
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ module Rubex
2
+ module DataType
3
+ class RubyClass < RubyConstant
4
+ attr_reader :name, :c_name, :scope, :ancestor
5
+
6
+ def initialize(name, c_name, scope, ancestor)
7
+ @name = name
8
+ @c_name = c_name
9
+ @scope = scope
10
+ @ancestor = ancestor
11
+ end
12
+
13
+ def ruby_class?
14
+ true
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,9 @@
1
+ module Rubex
2
+ module DataType
3
+ class RubyHash < RubyObject
4
+ def ruby_hash?
5
+ true
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,10 @@
1
+ module Rubex
2
+ module DataType
3
+ class RubyString < RubyObject
4
+ def ruby_string?
5
+ true
6
+ end
7
+ end
8
+
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ module Rubex
2
+ module DataType
3
+ class RubySymbol < RubyObject
4
+ def ruby_symbol?
5
+ true
6
+ end
7
+ end
8
+
9
+ end
10
+ end
@@ -0,0 +1,34 @@
1
+ module Rubex
2
+ module DataType
3
+ # FIXME: Find out a better way to generically find the old type of a typedef
4
+ # when the new type is encountered. Should cover cases where the new type
5
+ # is aliased with some other name too. In other words, reach the actual
6
+ # type in the most generic way possible without too many checks.
7
+ class TypeDef
8
+ # include Helpers
9
+ attr_reader :type, :old_type, :new_type
10
+
11
+ def initialize(old_type, new_type, type)
12
+ @old_type = old_type
13
+ @new_type = new_type
14
+ @type = type
15
+ end
16
+
17
+ def alias_type?
18
+ true
19
+ end
20
+
21
+ def to_s
22
+ @new_type.to_s
23
+ end
24
+
25
+ def base_type
26
+ @old_type
27
+ end
28
+
29
+ def method_missing(meth, *args, &block)
30
+ @old_type.send(meth, *args, &block)
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,27 @@
1
+ module Rubex
2
+ module DataType
3
+ class UChar
4
+ include Helpers
5
+
6
+ def to_s
7
+ 'unsigned char'
8
+ end
9
+
10
+ def from_ruby_object(arg)
11
+ "(unsigned char)NUM2INT(#{arg})"
12
+ end
13
+
14
+ def p_formatter
15
+ '%d'
16
+ end
17
+
18
+ def uchar?
19
+ true
20
+ end
21
+
22
+ def <=>(other)
23
+ (other.char? || other.uchar?) ? 0 : 1
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,32 @@
1
+ module Rubex
2
+ module DataType
3
+ class UInt
4
+ include UIntHelpers
5
+ def to_s
6
+ 'unsigned int'
7
+ end
8
+
9
+ def from_ruby_object(arg)
10
+ "(unsigned int)NUM2UINT(#{arg})"
11
+ end
12
+
13
+ def uint?
14
+ true
15
+ end
16
+
17
+ def p_formatter
18
+ '%u'
19
+ end
20
+
21
+ def <=>(other)
22
+ if other.char? || other.int8? || other.int16? || other.uint8? || other.uint16?
23
+ 1
24
+ elsif other.uint? || other.int? || other.int32? || other.uint32?
25
+ 0
26
+ else
27
+ -1
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,22 @@
1
+ module Rubex
2
+ module DataType
3
+ class UInt16
4
+ include UIntHelpers
5
+ def to_s
6
+ 'uint16_t'
7
+ end
8
+
9
+ def from_ruby_object(arg)
10
+ "(uint16_t)NUM2UINT(#{arg})"
11
+ end
12
+
13
+ def uint16?
14
+ true
15
+ end
16
+
17
+ def p_formatter
18
+ '%u'
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,22 @@
1
+ module Rubex
2
+ module DataType
3
+ class UInt32
4
+ include UIntHelpers
5
+ def to_s
6
+ 'uint32_t'
7
+ end
8
+
9
+ def from_ruby_object(arg)
10
+ "(int32_t)NUM2UINT(#{arg})"
11
+ end
12
+
13
+ def uint32?
14
+ true
15
+ end
16
+
17
+ def p_formatter
18
+ '%u'
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,26 @@
1
+ module Rubex
2
+ module DataType
3
+ class UInt64
4
+ include UIntHelpers
5
+ def to_s
6
+ 'uint64_t'
7
+ end
8
+
9
+ def to_ruby_object(arg)
10
+ "ULONG2NUM(#{arg})"
11
+ end
12
+
13
+ def from_ruby_object(arg)
14
+ "(int64_t)NUM2UINT(#{arg})"
15
+ end
16
+
17
+ def uint64?
18
+ true
19
+ end
20
+
21
+ def p_formatter
22
+ '%lu'
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,22 @@
1
+ module Rubex
2
+ module DataType
3
+ class UInt8
4
+ include UIntHelpers
5
+ def to_s
6
+ 'uint8_t'
7
+ end
8
+
9
+ def from_ruby_object(arg)
10
+ "(uint8_t)NUM2UINT(#{arg})"
11
+ end
12
+
13
+ def uint8?
14
+ true
15
+ end
16
+
17
+ def p_formatter
18
+ '%u'
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,36 @@
1
+ module Rubex
2
+ module DataType
3
+ class ULInt
4
+ include UIntHelpers
5
+ def to_s
6
+ 'unsigned long int'
7
+ end
8
+
9
+ def to_ruby_object(arg)
10
+ "ULONG2NUM(#{arg})"
11
+ end
12
+
13
+ def from_ruby_object(arg)
14
+ "NUM2ULONG(#{arg})"
15
+ end
16
+
17
+ def ulint?
18
+ true
19
+ end
20
+
21
+ def p_formatter
22
+ '%lu'
23
+ end
24
+
25
+ def <=>(other)
26
+ if other.char? || other.int8? || other.int16? || other.int32? || other .int64? || other.uint8? || other.uint16? || other.uint32? || other.int?
27
+ 1
28
+ elsif other.ulint?
29
+ 0
30
+ else
31
+ -1
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end