expressir 1.2.4 → 1.2.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (310) hide show
  1. checksums.yaml +4 -4
  2. data/.cross_rubies +0 -6
  3. data/.github/workflows/rake.yml +200 -9
  4. data/.gitignore +7 -2
  5. data/.gitmodules +3 -0
  6. data/.rubocop.yml +13 -4
  7. data/Rakefile +4 -1
  8. data/bin/console +0 -1
  9. data/bin/rspec +3 -3
  10. data/exe/expressir +4 -2
  11. data/exe/format +1 -1
  12. data/exe/format-test +25 -25
  13. data/exe/generate-parser +16 -13
  14. data/expressir.gemspec +11 -9
  15. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/CMakeLists.txt +44 -34
  16. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2013.vcxproj +11 -5
  17. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2013.vcxproj.filters +0 -3
  18. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2015.vcxproj +11 -4
  19. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2015.vcxproj.filters +0 -3
  20. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2017.vcxproj +11 -4
  21. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2017.vcxproj.filters +0 -3
  22. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2019.vcxproj +11 -4
  23. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2019.vcxproj.filters +0 -3
  24. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlrcpp.xcodeproj/project.pbxproj +20 -20
  25. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRFileStream.cpp +0 -6
  26. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRInputStream.cpp +30 -19
  27. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRInputStream.h +13 -10
  28. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/CommonToken.cpp +2 -4
  29. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/DefaultErrorStrategy.cpp +16 -13
  30. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Exceptions.cpp +2 -2
  31. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Exceptions.h +2 -2
  32. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/FailedPredicateException.cpp +5 -4
  33. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/FailedPredicateException.h +1 -1
  34. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/IntStream.h +0 -6
  35. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Lexer.cpp +0 -1
  36. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Lexer.h +0 -13
  37. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/LexerInterpreter.cpp +0 -15
  38. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/LexerInterpreter.h +1 -7
  39. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Parser.cpp +47 -27
  40. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Parser.h +0 -6
  41. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserInterpreter.cpp +27 -39
  42. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserInterpreter.h +1 -7
  43. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserRuleContext.cpp +19 -22
  44. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserRuleContext.h +20 -20
  45. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RecognitionException.cpp +0 -1
  46. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Recognizer.cpp +16 -27
  47. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Recognizer.h +10 -21
  48. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RuleContext.cpp +4 -3
  49. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RuleContext.h +5 -1
  50. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RuntimeMetaData.cpp +2 -1
  51. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Token.h +0 -32
  52. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenStreamRewriter.cpp +1 -1
  53. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenStreamRewriter.h +2 -7
  54. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/UnbufferedCharStream.cpp +15 -18
  55. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/UnbufferedCharStream.h +12 -18
  56. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Version.h +42 -0
  57. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Vocabulary.cpp +13 -45
  58. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Vocabulary.h +11 -26
  59. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/antlr4-common.h +19 -61
  60. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/antlr4-runtime.h +7 -5
  61. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATN.cpp +4 -55
  62. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATN.h +34 -20
  63. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfig.cpp +30 -35
  64. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfig.h +35 -32
  65. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfigSet.cpp +58 -54
  66. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfigSet.h +77 -31
  67. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializationOptions.cpp +22 -32
  68. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializationOptions.h +22 -24
  69. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializer.cpp +335 -462
  70. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializer.h +9 -68
  71. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSimulator.cpp +9 -39
  72. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSimulator.h +6 -22
  73. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNState.cpp +10 -26
  74. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNState.h +41 -42
  75. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNStateType.cpp +33 -0
  76. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNStateType.h +36 -0
  77. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ActionTransition.cpp +2 -6
  78. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ActionTransition.h +4 -2
  79. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ArrayPredictionContext.cpp +49 -22
  80. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ArrayPredictionContext.h +20 -12
  81. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AtomTransition.cpp +1 -5
  82. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AtomTransition.h +5 -2
  83. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicBlockStartState.h +4 -2
  84. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicState.h +4 -2
  85. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockEndState.h +5 -3
  86. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockStartState.h +10 -1
  87. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionInfo.h +1 -1
  88. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionState.cpp +0 -5
  89. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionState.h +12 -8
  90. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EpsilonTransition.cpp +2 -6
  91. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EpsilonTransition.h +6 -3
  92. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LL1Analyzer.cpp +139 -106
  93. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LL1Analyzer.h +9 -48
  94. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNConfig.cpp +16 -33
  95. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNConfig.h +12 -12
  96. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNSimulator.cpp +69 -82
  97. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNSimulator.h +15 -33
  98. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerAction.cpp +12 -6
  99. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerAction.h +45 -11
  100. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerActionExecutor.cpp +48 -44
  101. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerActionExecutor.h +31 -18
  102. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerActionType.h +3 -1
  103. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerChannelAction.cpp +14 -26
  104. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerChannelAction.h +12 -16
  105. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerCustomAction.cpp +15 -32
  106. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerCustomAction.h +12 -24
  107. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerIndexedCustomAction.cpp +23 -29
  108. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerIndexedCustomAction.h +13 -19
  109. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerModeAction.cpp +13 -26
  110. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerModeAction.h +12 -16
  111. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerMoreAction.cpp +6 -17
  112. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerMoreAction.h +12 -16
  113. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPopModeAction.cpp +6 -17
  114. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPopModeAction.h +12 -16
  115. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPushModeAction.cpp +13 -26
  116. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPushModeAction.h +12 -16
  117. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerSkipAction.cpp +6 -17
  118. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerSkipAction.h +11 -15
  119. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerTypeAction.cpp +13 -26
  120. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerTypeAction.h +13 -17
  121. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LoopEndState.h +5 -1
  122. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/NotSetTransition.cpp +1 -6
  123. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/NotSetTransition.h +4 -2
  124. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/OrderedATNConfigSet.cpp +6 -2
  125. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/OrderedATNConfigSet.h +8 -3
  126. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParserATNSimulator.cpp +164 -151
  127. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParserATNSimulator.h +26 -19
  128. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParserATNSimulatorOptions.h +50 -0
  129. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusBlockStartState.h +5 -1
  130. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusLoopbackState.h +5 -2
  131. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PrecedencePredicateTransition.cpp +2 -11
  132. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PrecedencePredicateTransition.h +15 -9
  133. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateEvalInfo.cpp +2 -2
  134. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateEvalInfo.h +2 -2
  135. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateTransition.cpp +4 -14
  136. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateTransition.h +22 -11
  137. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContext.cpp +255 -338
  138. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContext.h +86 -127
  139. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextCache.cpp +56 -0
  140. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextCache.h +64 -0
  141. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextMergeCache.cpp +167 -0
  142. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextMergeCache.h +101 -0
  143. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextMergeCacheOptions.h +71 -0
  144. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextType.h +21 -0
  145. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionMode.cpp +18 -17
  146. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionMode.h +1 -1
  147. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ProfilingATNSimulator.cpp +2 -2
  148. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ProfilingATNSimulator.h +2 -2
  149. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RangeTransition.cpp +1 -5
  150. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RangeTransition.h +4 -2
  151. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStartState.h +4 -3
  152. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStopState.h +4 -2
  153. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleTransition.cpp +1 -5
  154. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleTransition.h +5 -3
  155. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SemanticContext.cpp +197 -156
  156. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SemanticContext.h +92 -81
  157. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SemanticContextType.h +23 -0
  158. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SerializedATNView.h +101 -0
  159. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SetTransition.cpp +2 -6
  160. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SetTransition.h +11 -3
  161. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SingletonPredictionContext.cpp +39 -34
  162. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SingletonPredictionContext.h +17 -10
  163. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarBlockStartState.h +5 -2
  164. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopEntryState.h +4 -2
  165. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopbackState.cpp +6 -6
  166. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopbackState.h +6 -2
  167. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/TokensStartState.h +5 -2
  168. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/Transition.cpp +1 -9
  169. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/Transition.h +11 -22
  170. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/TransitionType.cpp +27 -0
  171. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/TransitionType.h +33 -0
  172. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/WildcardTransition.cpp +1 -5
  173. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/WildcardTransition.h +4 -2
  174. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFA.cpp +9 -21
  175. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFA.h +20 -15
  176. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFASerializer.cpp +1 -8
  177. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFASerializer.h +4 -4
  178. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFAState.cpp +9 -50
  179. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFAState.h +57 -48
  180. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/LexerDFASerializer.cpp +1 -4
  181. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/LexerDFASerializer.h +3 -4
  182. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/InterpreterDataReader.cpp +2 -2
  183. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/InterpreterDataReader.h +3 -1
  184. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/Interval.cpp +1 -29
  185. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/Interval.h +10 -10
  186. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/IntervalSet.cpp +7 -20
  187. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/IntervalSet.h +1 -9
  188. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/MurmurHash.cpp +54 -68
  189. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/MurmurHash.h +34 -14
  190. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Any.cpp +0 -5
  191. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Any.h +1 -155
  192. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Arrays.h +39 -0
  193. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/BitSet.h +1 -1
  194. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/CPPUtils.cpp +12 -53
  195. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/CPPUtils.h +16 -29
  196. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Casts.h +34 -0
  197. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Declarations.h +0 -2
  198. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/StringUtils.cpp +25 -33
  199. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/StringUtils.h +2 -62
  200. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Unicode.h +28 -0
  201. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Utf8.cpp +242 -0
  202. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Utf8.h +54 -0
  203. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/AbstractParseTreeVisitor.h +13 -12
  204. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNode.h +7 -2
  205. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNodeImpl.cpp +36 -5
  206. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNodeImpl.h +14 -4
  207. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/IterativeParseTreeWalker.cpp +14 -19
  208. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTree.cpp +0 -3
  209. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTree.h +13 -4
  210. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeType.h +22 -0
  211. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeVisitor.h +4 -4
  212. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeWalker.cpp +8 -9
  213. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeWalker.h +4 -4
  214. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNode.h +10 -2
  215. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNodeImpl.cpp +2 -5
  216. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNodeImpl.h +4 -5
  217. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/ParseTreePatternMatcher.cpp +1 -2
  218. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathLexer.cpp +128 -119
  219. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathLexer.h +18 -27
  220. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/tests/Utf8Test.cpp +110 -0
  221. data/ext/express-parser/antlrgen/Express.interp +1 -1
  222. data/ext/express-parser/antlrgen/ExpressBaseListener.cpp +1 -1
  223. data/ext/express-parser/antlrgen/ExpressBaseListener.h +1 -1
  224. data/ext/express-parser/antlrgen/ExpressBaseVisitor.cpp +1 -1
  225. data/ext/express-parser/antlrgen/ExpressBaseVisitor.h +200 -200
  226. data/ext/express-parser/antlrgen/ExpressLexer.cpp +645 -1129
  227. data/ext/express-parser/antlrgen/ExpressLexer.h +20 -27
  228. data/ext/express-parser/antlrgen/ExpressLexer.interp +1 -1
  229. data/ext/express-parser/antlrgen/ExpressListener.cpp +1 -1
  230. data/ext/express-parser/antlrgen/ExpressListener.h +1 -1
  231. data/ext/express-parser/antlrgen/ExpressParser.cpp +1754 -1447
  232. data/ext/express-parser/antlrgen/ExpressParser.h +219 -223
  233. data/ext/express-parser/antlrgen/ExpressVisitor.cpp +1 -1
  234. data/ext/express-parser/antlrgen/ExpressVisitor.h +200 -200
  235. data/ext/express-parser/express_parser.cpp +207 -75
  236. data/ext/express-parser/extconf.rb +10 -9
  237. data/lib/expressir/config.rb +1 -1
  238. data/lib/expressir/express/parser.rb +2 -2
  239. data/lib/expressir/express/visitor.rb +7 -5
  240. data/lib/expressir/model.rb +78 -78
  241. data/lib/expressir/version.rb +1 -1
  242. data/rakelib/antlr4-native.rake +63 -0
  243. data/rakelib/cross-ruby.rake +213 -162
  244. data/spec/acceptance/version_spec.rb +7 -2
  245. data/spec/expressir/express/cache_spec.rb +8 -5
  246. data/spec/expressir/express/formatter_spec.rb +16 -8
  247. data/spec/expressir/express/parser_spec.rb +17 -11
  248. data/spec/expressir/model/model_element_spec.rb +154 -146
  249. metadata +79 -91
  250. data/demo.rb +0 -18
  251. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSerializer.cpp +0 -621
  252. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSerializer.h +0 -61
  253. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AbstractPredicateTransition.cpp +0 -14
  254. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AbstractPredicateTransition.h +0 -24
  255. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicBlockStartState.cpp +0 -12
  256. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicState.cpp +0 -12
  257. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockEndState.cpp +0 -15
  258. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockStartState.cpp +0 -9
  259. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EmptyPredictionContext.cpp +0 -35
  260. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EmptyPredictionContext.h +0 -27
  261. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LoopEndState.cpp +0 -12
  262. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/Makefile +0 -67
  263. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusBlockStartState.cpp +0 -12
  264. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusLoopbackState.cpp +0 -12
  265. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStartState.cpp +0 -16
  266. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStopState.cpp +0 -12
  267. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarBlockStartState.cpp +0 -12
  268. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopEntryState.cpp +0 -15
  269. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/TokensStartState.cpp +0 -12
  270. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/guid.cpp +0 -303
  271. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/guid.h +0 -112
  272. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNode.cpp +0 -9
  273. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNode.cpp +0 -9
  274. data/original/examples/ap233/ap233e1_arm_lf_stepmod-2010-11-12.exp +0 -9589
  275. data/original/examples/ap233/ap233e1_arm_lf_stepmod-2010-11-12.owl +0 -36619
  276. data/original/examples/ap233/ap233e1_arm_lf_stepmod-2010-11-12.xml +0 -13294
  277. data/original/examples/employment/eclipse/.project +0 -17
  278. data/original/examples/employment/eclipse/Export/Employment.png +0 -0
  279. data/original/examples/employment/eclipse/Express/employment_schema.exp +0 -33
  280. data/original/examples/employment/eclipse/Express/employment_schema.xmi +0 -77
  281. data/original/examples/employment/eclipse/Express/employment_schema.xml +0 -93
  282. data/original/examples/employment/eclipse/Models/Employment.uml +0 -4
  283. data/original/examples/employment/eclipse/Models/Employment.umldi +0 -240
  284. data/original/examples/employment/eclipse/readme.txt +0 -7
  285. data/original/examples/employment/employment_schema.exp +0 -33
  286. data/original/examples/employment/employment_schema.rb +0 -232
  287. data/original/examples/employment/employment_schema.xml +0 -93
  288. data/original/examples/employment/employment_schema___module.rb +0 -46
  289. data/original/examples/employment/employment_schema___p28attr.rb +0 -126
  290. data/original/examples/employment/employment_schema___p28inst.rb +0 -26
  291. data/original/examples/employment/example_employment_data.xml +0 -1
  292. data/original/examples/employment/example_employment_data_copy.xml +0 -1
  293. data/original/examples/employment/example_employment_reader.rb +0 -30
  294. data/original/examples/employment/example_employment_writer.rb +0 -51
  295. data/original/examples/plcs/ap239e1_arm_lf_dexlib_2010-01-06.exp +0 -3710
  296. data/original/examples/plcs/ap239e1_arm_lf_dexlib_2010-01-06.owl +0 -35880
  297. data/original/examples/plcs/ap239e1_arm_lf_dexlib_2010-01-06.xmi +0 -15357
  298. data/original/examples/plcs/ap239e1_arm_lf_dexlib_2010-01-06.xml +0 -9468
  299. data/original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.exp +0 -8404
  300. data/original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.owl +0 -43147
  301. data/original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.xmi +0 -18341
  302. data/original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.xml +0 -11632
  303. data/original/exp2ruby.rb +0 -525
  304. data/original/expsm.rb +0 -34
  305. data/original/mapping_owl.rb +0 -1018
  306. data/original/mapping_sysml.rb +0 -2281
  307. data/original/mapping_uml2.rb +0 -599
  308. data/original/mapping_uml2_eclipse.rb +0 -433
  309. data/original/reeper.rb +0 -134
  310. data/spec/expressr_spec.rb +0 -5
@@ -1,24 +0,0 @@
1
- /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
2
- * Use of this file is governed by the BSD 3-clause license that
3
- * can be found in the LICENSE.txt file in the project root.
4
- */
5
-
6
- #pragma once
7
-
8
- #include "atn/Transition.h"
9
-
10
- namespace antlr4 {
11
- namespace atn {
12
-
13
- class ANTState;
14
-
15
- class ANTLR4CPP_PUBLIC AbstractPredicateTransition : public Transition {
16
-
17
- public:
18
- AbstractPredicateTransition(ATNState *target);
19
- ~AbstractPredicateTransition();
20
-
21
- };
22
-
23
- } // namespace atn
24
- } // namespace antlr4
@@ -1,12 +0,0 @@
1
- /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
2
- * Use of this file is governed by the BSD 3-clause license that
3
- * can be found in the LICENSE.txt file in the project root.
4
- */
5
-
6
- #include "atn/BasicBlockStartState.h"
7
-
8
- using namespace antlr4::atn;
9
-
10
- size_t BasicBlockStartState::getStateType() {
11
- return BLOCK_START;
12
- }
@@ -1,12 +0,0 @@
1
- /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
2
- * Use of this file is governed by the BSD 3-clause license that
3
- * can be found in the LICENSE.txt file in the project root.
4
- */
5
-
6
- #include "atn/BasicState.h"
7
-
8
- using namespace antlr4::atn;
9
-
10
- size_t BasicState::getStateType() {
11
- return BASIC;
12
- }
@@ -1,15 +0,0 @@
1
- /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
2
- * Use of this file is governed by the BSD 3-clause license that
3
- * can be found in the LICENSE.txt file in the project root.
4
- */
5
-
6
- #include "atn/BlockEndState.h"
7
-
8
- using namespace antlr4::atn;
9
-
10
- BlockEndState::BlockEndState() : startState(nullptr) {
11
- }
12
-
13
- size_t BlockEndState::getStateType() {
14
- return BLOCK_END;
15
- }
@@ -1,9 +0,0 @@
1
- /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
2
- * Use of this file is governed by the BSD 3-clause license that
3
- * can be found in the LICENSE.txt file in the project root.
4
- */
5
-
6
- #include "BlockStartState.h"
7
-
8
- antlr4::atn::BlockStartState::~BlockStartState() {
9
- }
@@ -1,35 +0,0 @@
1
- /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
2
- * Use of this file is governed by the BSD 3-clause license that
3
- * can be found in the LICENSE.txt file in the project root.
4
- */
5
-
6
- #include "atn/EmptyPredictionContext.h"
7
-
8
- using namespace antlr4::atn;
9
-
10
- EmptyPredictionContext::EmptyPredictionContext() : SingletonPredictionContext(nullptr, EMPTY_RETURN_STATE) {
11
- }
12
-
13
- bool EmptyPredictionContext::isEmpty() const {
14
- return true;
15
- }
16
-
17
- size_t EmptyPredictionContext::size() const {
18
- return 1;
19
- }
20
-
21
- Ref<PredictionContext> EmptyPredictionContext::getParent(size_t /*index*/) const {
22
- return nullptr;
23
- }
24
-
25
- size_t EmptyPredictionContext::getReturnState(size_t /*index*/) const {
26
- return returnState;
27
- }
28
-
29
- bool EmptyPredictionContext::operator == (const PredictionContext &o) const {
30
- return this == &o;
31
- }
32
-
33
- std::string EmptyPredictionContext::toString() const {
34
- return "$";
35
- }
@@ -1,27 +0,0 @@
1
- /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
2
- * Use of this file is governed by the BSD 3-clause license that
3
- * can be found in the LICENSE.txt file in the project root.
4
- */
5
-
6
- #pragma once
7
-
8
- #include "atn/SingletonPredictionContext.h"
9
-
10
- namespace antlr4 {
11
- namespace atn {
12
-
13
- class ANTLR4CPP_PUBLIC EmptyPredictionContext : public SingletonPredictionContext {
14
- public:
15
- EmptyPredictionContext();
16
-
17
- virtual bool isEmpty() const override;
18
- virtual size_t size() const override;
19
- virtual Ref<PredictionContext> getParent(size_t index) const override;
20
- virtual size_t getReturnState(size_t index) const override;
21
- virtual std::string toString() const override;
22
-
23
- virtual bool operator == (const PredictionContext &o) const override;
24
- };
25
-
26
- } // namespace atn
27
- } // namespace antlr4
@@ -1,12 +0,0 @@
1
- /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
2
- * Use of this file is governed by the BSD 3-clause license that
3
- * can be found in the LICENSE.txt file in the project root.
4
- */
5
-
6
- #include "atn/LoopEndState.h"
7
-
8
- using namespace antlr4::atn;
9
-
10
- size_t LoopEndState::getStateType() {
11
- return LOOP_END;
12
- }
@@ -1,67 +0,0 @@
1
-
2
- CXXFLAGS += -g -std=c++0x -Wall #-Wextra
3
- CXXFLAGS += -I. -I../ -I../misc/ -I../tree/ -I../dfa/ \
4
- -I../../../../../antlrcpp/
5
-
6
- #TODO LDFLAGS += ?
7
-
8
- ALL_CXXFLAGS = $(CPPFLAGS) $(CXXFLAGS)
9
- ALL_LDFLAGS = $(LDFLAGS)
10
-
11
- # Escote's files
12
- SRCS = \
13
- AbstractPredicateTransition.cpp \
14
- ActionTransition.cpp \
15
- ArrayPredictionContext.cpp \
16
- ATNDeserializationOptions.cpp \
17
- ATNDeserializer.cpp \
18
- ATNState.cpp \
19
- ATNType.cpp \
20
- AtomTransition.cpp \
21
- BasicBlockStartState.cpp \
22
- BasicState.cpp \
23
- BlockEndState.cpp \
24
- BlockStartState.cpp \
25
- DecisionState.cpp \
26
- EmptyPredictionContext.cpp \
27
- EpsilonTransition.cpp \
28
- LexerATNConfig.cpp \
29
- LoopEndState.cpp
30
- # Escote's TODO: LL1Analyzer.cpp LexerATNSimulator.cpp ATNSimulator.cpp \
31
- ATNSerializer.cpp ATNConfigSet.cpp ATNConfig.cpp \
32
- ATN.cpp
33
-
34
- # Alejandro's files
35
- SRCS += \
36
- NotSetTransition.cpp \
37
- OrderedATNConfigSet.cpp \
38
- PlusBlockStartState.cpp \
39
- PlusLoopbackState.cpp \
40
- PredicateTransition.cpp \
41
- PredictionMode.cpp \
42
- RangeTransition.cpp \
43
- RuleStartState.cpp \
44
- RuleStopState.cpp \
45
- RuleTransition.cpp \
46
- SemanticContext.cpp \
47
- SetTransition.cpp \
48
- SingletonPredictionContext.cpp \
49
- StarBlockStartState.cpp \
50
- StarLoopbackState.cpp \
51
- StarLoopEntryState.cpp \
52
- TokensStartState.cpp \
53
- Transition.cpp \
54
- WildcardTransition.cpp
55
- # Alejandro's TODO: PredictionContext.cpp PredictionContextCache.cpp \
56
- PrecedencePredicateTransition.cpp ParserATNSimulator.cpp
57
-
58
- OBJS = $(SRCS:.cpp=.o)
59
-
60
- all: $(OBJS)
61
-
62
- %.o: %.cpp
63
- $(CXX) -c $(ALL_CXXFLAGS) $< -o $@
64
-
65
- clean:
66
- $(RM) $(OBJS)
67
-
@@ -1,12 +0,0 @@
1
- /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
2
- * Use of this file is governed by the BSD 3-clause license that
3
- * can be found in the LICENSE.txt file in the project root.
4
- */
5
-
6
- #include "atn/PlusBlockStartState.h"
7
-
8
- using namespace antlr4::atn;
9
-
10
- size_t PlusBlockStartState::getStateType() {
11
- return PLUS_BLOCK_START;
12
- }
@@ -1,12 +0,0 @@
1
- /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
2
- * Use of this file is governed by the BSD 3-clause license that
3
- * can be found in the LICENSE.txt file in the project root.
4
- */
5
-
6
- #include "atn/PlusLoopbackState.h"
7
-
8
- using namespace antlr4::atn;
9
-
10
- size_t PlusLoopbackState::getStateType() {
11
- return PLUS_LOOP_BACK;
12
- }
@@ -1,16 +0,0 @@
1
- /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
2
- * Use of this file is governed by the BSD 3-clause license that
3
- * can be found in the LICENSE.txt file in the project root.
4
- */
5
-
6
- #include "atn/RuleStartState.h"
7
-
8
- using namespace antlr4::atn;
9
-
10
- RuleStartState::RuleStartState() {
11
- isLeftRecursiveRule = false;
12
- }
13
-
14
- size_t RuleStartState::getStateType() {
15
- return RULE_START;
16
- }
@@ -1,12 +0,0 @@
1
- /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
2
- * Use of this file is governed by the BSD 3-clause license that
3
- * can be found in the LICENSE.txt file in the project root.
4
- */
5
-
6
- #include "atn/RuleStopState.h"
7
-
8
- using namespace antlr4::atn;
9
-
10
- size_t RuleStopState::getStateType() {
11
- return RULE_STOP;
12
- }
@@ -1,12 +0,0 @@
1
- /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
2
- * Use of this file is governed by the BSD 3-clause license that
3
- * can be found in the LICENSE.txt file in the project root.
4
- */
5
-
6
- #include "atn/StarBlockStartState.h"
7
-
8
- using namespace antlr4::atn;
9
-
10
- size_t StarBlockStartState::getStateType() {
11
- return STAR_BLOCK_START;
12
- }
@@ -1,15 +0,0 @@
1
- /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
2
- * Use of this file is governed by the BSD 3-clause license that
3
- * can be found in the LICENSE.txt file in the project root.
4
- */
5
-
6
- #include "atn/StarLoopEntryState.h"
7
-
8
- using namespace antlr4::atn;
9
-
10
- StarLoopEntryState::StarLoopEntryState() : DecisionState(), isPrecedenceDecision(false) {
11
- }
12
-
13
- size_t StarLoopEntryState::getStateType() {
14
- return STAR_LOOP_ENTRY;
15
- }
@@ -1,12 +0,0 @@
1
- /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
2
- * Use of this file is governed by the BSD 3-clause license that
3
- * can be found in the LICENSE.txt file in the project root.
4
- */
5
-
6
- #include "atn/TokensStartState.h"
7
-
8
- using namespace antlr4::atn;
9
-
10
- size_t TokensStartState::getStateType() {
11
- return TOKEN_START;
12
- }
@@ -1,303 +0,0 @@
1
- /*
2
- The MIT License (MIT)
3
-
4
- Copyright (c) 2014 Graeme Hill (http://graemehill.ca)
5
-
6
- Permission is hereby granted, free of charge, to any person obtaining a copy
7
- of this software and associated documentation files (the "Software"), to deal
8
- in the Software without restriction, including without limitation the rights
9
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- copies of the Software, and to permit persons to whom the Software is
11
- furnished to do so, subject to the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be included in
14
- all copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
- THE SOFTWARE.
23
- */
24
-
25
- #include "guid.h"
26
-
27
- #ifdef GUID_LIBUUID
28
- #include <uuid/uuid.h>
29
- #endif
30
-
31
- #ifdef GUID_CFUUID
32
- #include <CoreFoundation/CFUUID.h>
33
- #endif
34
-
35
- #ifdef GUID_WINDOWS
36
- #include <objbase.h>
37
- #endif
38
-
39
- #ifdef GUID_ANDROID
40
- #include <jni.h>
41
- #endif
42
-
43
- using namespace std;
44
-
45
- // overload << so that it's easy to convert to a string
46
- ostream &operator<<(ostream &s, const Guid &guid)
47
- {
48
- return s << hex << setfill('0')
49
- << setw(2) << (int)guid._bytes[0]
50
- << setw(2) << (int)guid._bytes[1]
51
- << setw(2) << (int)guid._bytes[2]
52
- << setw(2) << (int)guid._bytes[3]
53
- << "-"
54
- << setw(2) << (int)guid._bytes[4]
55
- << setw(2) << (int)guid._bytes[5]
56
- << "-"
57
- << setw(2) << (int)guid._bytes[6]
58
- << setw(2) << (int)guid._bytes[7]
59
- << "-"
60
- << setw(2) << (int)guid._bytes[8]
61
- << setw(2) << (int)guid._bytes[9]
62
- << "-"
63
- << setw(2) << (int)guid._bytes[10]
64
- << setw(2) << (int)guid._bytes[11]
65
- << setw(2) << (int)guid._bytes[12]
66
- << setw(2) << (int)guid._bytes[13]
67
- << setw(2) << (int)guid._bytes[14]
68
- << setw(2) << (int)guid._bytes[15];
69
- }
70
-
71
- // create a guid from vector of bytes
72
- Guid::Guid(const vector<unsigned char> &bytes)
73
- {
74
- _bytes = bytes;
75
- }
76
-
77
- // create a guid from array of bytes
78
- Guid::Guid(const unsigned char *bytes)
79
- {
80
- _bytes.assign(bytes, bytes + 16);
81
- }
82
-
83
- // create a guid from array of words
84
- Guid::Guid(const uint16_t *bytes, bool reverse)
85
- {
86
- if (reverse) {
87
- for (size_t i = 8; i > 0; --i)
88
- {
89
- _bytes.push_back(bytes[i - 1] >> 8);
90
- _bytes.push_back(bytes[i - 1] & 0xFF);
91
- }
92
- } else {
93
- for (size_t i = 0; i < 8; ++i)
94
- {
95
- _bytes.push_back(bytes[i] & 0xFF);
96
- _bytes.push_back(bytes[i] >> 8);
97
- }
98
- }
99
- }
100
-
101
- // converts a single hex char to a number (0 - 15)
102
- static unsigned char hexDigitToChar(char ch)
103
- {
104
- if (ch > 47 && ch < 58)
105
- return (unsigned char)(ch - 48);
106
-
107
- if (ch > 96 && ch < 103)
108
- return (unsigned char)(ch - 87);
109
-
110
- if (ch > 64 && ch < 71)
111
- return (unsigned char)(ch - 55);
112
-
113
- return 0;
114
- }
115
-
116
- // converts the two hexadecimal characters to an unsigned char (a byte)
117
- static unsigned char hexPairToChar(char a, char b)
118
- {
119
- return hexDigitToChar(a) * 16 + hexDigitToChar(b);
120
- }
121
-
122
- // create a guid from string
123
- Guid::Guid(const string &fromString)
124
- {
125
- _bytes.clear();
126
-
127
- char charOne = 0, charTwo;
128
- bool lookingForFirstChar = true;
129
-
130
- for (const char &ch : fromString)
131
- {
132
- if (ch == '-')
133
- continue;
134
-
135
- if (lookingForFirstChar)
136
- {
137
- charOne = ch;
138
- lookingForFirstChar = false;
139
- }
140
- else
141
- {
142
- charTwo = ch;
143
- auto byte = hexPairToChar(charOne, charTwo);
144
- _bytes.push_back(byte);
145
- lookingForFirstChar = true;
146
- }
147
- }
148
-
149
- }
150
-
151
- // create empty guid
152
- Guid::Guid()
153
- {
154
- _bytes = vector<unsigned char>(16, 0);
155
- }
156
-
157
- // copy constructor
158
- Guid::Guid(const Guid &other)
159
- {
160
- _bytes = other._bytes;
161
- }
162
-
163
- // overload assignment operator
164
- Guid &Guid::operator=(const Guid &other)
165
- {
166
- _bytes = other._bytes;
167
- return *this;
168
- }
169
-
170
- // overload equality operator
171
- bool Guid::operator==(const Guid &other) const
172
- {
173
- return _bytes == other._bytes;
174
- }
175
-
176
- // overload inequality operator
177
- bool Guid::operator!=(const Guid &other) const
178
- {
179
- return !((*this) == other);
180
- }
181
-
182
- const std::string Guid::toString() const
183
- {
184
- std::stringstream os;
185
- os << *this;
186
- return os.str();
187
- }
188
-
189
- // This is the linux friendly implementation, but it could work on other
190
- // systems that have libuuid available
191
- #ifdef GUID_LIBUUID
192
- Guid GuidGenerator::newGuid()
193
- {
194
- uuid_t id;
195
- uuid_generate(id);
196
- return id;
197
- }
198
- #endif
199
-
200
- // this is the mac and ios version
201
- #ifdef GUID_CFUUID
202
- Guid GuidGenerator::newGuid()
203
- {
204
- auto newId = CFUUIDCreate(NULL);
205
- auto bytes = CFUUIDGetUUIDBytes(newId);
206
- CFRelease(newId);
207
-
208
- const unsigned char byteArray[16] =
209
- {
210
- bytes.byte0,
211
- bytes.byte1,
212
- bytes.byte2,
213
- bytes.byte3,
214
- bytes.byte4,
215
- bytes.byte5,
216
- bytes.byte6,
217
- bytes.byte7,
218
- bytes.byte8,
219
- bytes.byte9,
220
- bytes.byte10,
221
- bytes.byte11,
222
- bytes.byte12,
223
- bytes.byte13,
224
- bytes.byte14,
225
- bytes.byte15
226
- };
227
- return byteArray;
228
- }
229
- #endif
230
-
231
- // obviously this is the windows version
232
- #ifdef GUID_WINDOWS
233
- Guid GuidGenerator::newGuid()
234
- {
235
- GUID newId;
236
- CoCreateGuid(&newId);
237
-
238
- const unsigned char bytes[16] =
239
- {
240
- (newId.Data1 >> 24) & 0xFF,
241
- (newId.Data1 >> 16) & 0xFF,
242
- (newId.Data1 >> 8) & 0xFF,
243
- (newId.Data1) & 0xff,
244
-
245
- (newId.Data2 >> 8) & 0xFF,
246
- (newId.Data2) & 0xff,
247
-
248
- (newId.Data3 >> 8) & 0xFF,
249
- (newId.Data3) & 0xFF,
250
-
251
- newId.Data4[0],
252
- newId.Data4[1],
253
- newId.Data4[2],
254
- newId.Data4[3],
255
- newId.Data4[4],
256
- newId.Data4[5],
257
- newId.Data4[6],
258
- newId.Data4[7]
259
- };
260
-
261
- return bytes;
262
- }
263
- #endif
264
-
265
- // android version that uses a call to a java api
266
- #ifdef GUID_ANDROID
267
- GuidGenerator::GuidGenerator(JNIEnv *env)
268
- {
269
- _env = env;
270
- _uuidClass = env->FindClass("java/util/UUID");
271
- _newGuidMethod = env->GetStaticMethodID(_uuidClass, "randomUUID", "()Ljava/util/UUID;");
272
- _mostSignificantBitsMethod = env->GetMethodID(_uuidClass, "getMostSignificantBits", "()J");
273
- _leastSignificantBitsMethod = env->GetMethodID(_uuidClass, "getLeastSignificantBits", "()J");
274
- }
275
-
276
- Guid GuidGenerator::newGuid()
277
- {
278
- jobject javaUuid = _env->CallStaticObjectMethod(_uuidClass, _newGuidMethod);
279
- jlong mostSignificant = _env->CallLongMethod(javaUuid, _mostSignificantBitsMethod);
280
- jlong leastSignificant = _env->CallLongMethod(javaUuid, _leastSignificantBitsMethod);
281
-
282
- unsigned char bytes[16] =
283
- {
284
- (mostSignificant >> 56) & 0xFF,
285
- (mostSignificant >> 48) & 0xFF,
286
- (mostSignificant >> 40) & 0xFF,
287
- (mostSignificant >> 32) & 0xFF,
288
- (mostSignificant >> 24) & 0xFF,
289
- (mostSignificant >> 16) & 0xFF,
290
- (mostSignificant >> 8) & 0xFF,
291
- (mostSignificant) & 0xFF,
292
- (leastSignificant >> 56) & 0xFF,
293
- (leastSignificant >> 48) & 0xFF,
294
- (leastSignificant >> 40) & 0xFF,
295
- (leastSignificant >> 32) & 0xFF,
296
- (leastSignificant >> 24) & 0xFF,
297
- (leastSignificant >> 16) & 0xFF,
298
- (leastSignificant >> 8) & 0xFF,
299
- (leastSignificant) & 0xFF,
300
- };
301
- return bytes;
302
- }
303
- #endif