rhodes 5.5.15 → 5.5.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (458) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +48 -13
  3. data/doc/oss/WM_CE_Installation_And_Build_Guidelines.md +1 -1
  4. data/lib/commonAPI/barcode/ext.yml +6 -2
  5. data/lib/commonAPI/barcode/ext/barcode.xml +1 -1
  6. data/lib/commonAPI/barcode/ext/build.bat +8 -0
  7. data/lib/commonAPI/barcode/ext/platform/qt/Barcode.pro +90 -0
  8. data/lib/commonAPI/barcode/ext/platform/qt/Rakefile +35 -0
  9. data/lib/commonAPI/barcode/ext/platform/qt/resources/barcode.qrc +10 -0
  10. data/lib/commonAPI/barcode/ext/platform/qt/resources/buttonBack.png +0 -0
  11. data/lib/commonAPI/barcode/ext/platform/qt/resources/buttonRetry.png +0 -0
  12. data/lib/commonAPI/barcode/ext/platform/qt/resources/buttonSave.png +0 -0
  13. data/lib/commonAPI/barcode/ext/platform/qt/resources/scanner_sound.wav +0 -0
  14. data/lib/commonAPI/barcode/ext/platform/qt/src/BarcodeController.cpp +40 -0
  15. data/lib/commonAPI/barcode/ext/platform/qt/src/BarcodeController.h +57 -0
  16. data/lib/commonAPI/barcode/ext/platform/qt/src/BarcodeDialogBuilder.h +52 -0
  17. data/lib/commonAPI/barcode/ext/platform/qt/src/BarcodeDialogView.cpp +175 -0
  18. data/lib/commonAPI/barcode/ext/platform/qt/src/BarcodeDialogView.h +68 -0
  19. data/lib/commonAPI/barcode/ext/platform/qt/src/Barcode_impl.cpp +109 -0
  20. data/lib/commonAPI/barcode/ext/platform/qt/src/decoderthread.cpp +39 -0
  21. data/lib/commonAPI/barcode/ext/platform/qt/src/decoderthread.h +29 -0
  22. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/CameraImageWrapper.cpp +131 -0
  23. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/CameraImageWrapper.h +39 -0
  24. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/QZXing.h +173 -0
  25. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/QZXing.pri +277 -0
  26. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/QZXing_global.h +13 -0
  27. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/imagehandler.cpp +45 -0
  28. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/imagehandler.h +23 -0
  29. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/qzxing.cpp +303 -0
  30. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/bigint/BigInteger.cc +405 -0
  31. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/bigint/BigInteger.hh +215 -0
  32. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/bigint/BigIntegerAlgorithms.cc +70 -0
  33. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/bigint/BigIntegerAlgorithms.hh +25 -0
  34. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/bigint/BigIntegerLibrary.hh +8 -0
  35. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/bigint/BigIntegerUtils.cc +50 -0
  36. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/bigint/BigIntegerUtils.hh +72 -0
  37. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/bigint/BigUnsigned.cc +697 -0
  38. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/bigint/BigUnsigned.hh +418 -0
  39. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/bigint/BigUnsignedInABase.cc +125 -0
  40. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/bigint/BigUnsignedInABase.hh +122 -0
  41. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/bigint/ChangeLog +146 -0
  42. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/bigint/NumberlikeArray.hh +177 -0
  43. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/bigint/README +71 -0
  44. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/win32/zxing/iconv.h +14 -0
  45. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/win32/zxing/msvc/stdint.h +247 -0
  46. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/win32/zxing/win_iconv.c +2035 -0
  47. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/BarcodeFormat.cpp +40 -0
  48. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/BarcodeFormat.h +60 -0
  49. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/Binarizer.cpp +45 -0
  50. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/Binarizer.h +50 -0
  51. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/BinaryBitmap.cpp +70 -0
  52. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/BinaryBitmap.h +56 -0
  53. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/ChecksumException.cpp +28 -0
  54. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/ChecksumException.h +34 -0
  55. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/DecodeHints.cpp +148 -0
  56. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/DecodeHints.h +85 -0
  57. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/Exception.cpp +43 -0
  58. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/Exception.h +51 -0
  59. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/FormatException.cpp +41 -0
  60. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/FormatException.h +37 -0
  61. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/IllegalStateException.h +35 -0
  62. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/InvertedLuminanceSource.cpp +68 -0
  63. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/InvertedLuminanceSource.h +48 -0
  64. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/LuminanceSource.cpp +86 -0
  65. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/LuminanceSource.h +59 -0
  66. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/MultiFormatReader.cpp +124 -0
  67. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/MultiFormatReader.h +48 -0
  68. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/NotFoundException.h +35 -0
  69. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/Reader.cpp +31 -0
  70. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/Reader.h +40 -0
  71. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/ReaderException.h +37 -0
  72. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/Result.cpp +66 -0
  73. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/Result.h +57 -0
  74. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/ResultIO.cpp +34 -0
  75. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/ResultPoint.cpp +108 -0
  76. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/ResultPoint.h +55 -0
  77. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/ResultPointCallback.cpp +26 -0
  78. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/ResultPointCallback.h +39 -0
  79. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/WriterException.h +17 -0
  80. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/ZXing.h +140 -0
  81. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/aztec/AztecDetectorResult.cpp +54 -0
  82. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/aztec/AztecDetectorResult.h +48 -0
  83. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/aztec/AztecReader.cpp +68 -0
  84. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/aztec/AztecReader.h +49 -0
  85. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/aztec/decoder/AztecDecoder.cpp +495 -0
  86. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/aztec/decoder/Decoder.h +69 -0
  87. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/aztec/detector/AztecDetector.cpp +548 -0
  88. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/aztec/detector/Detector.h +92 -0
  89. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/Array.h +173 -0
  90. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/BitArray.cpp +237 -0
  91. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/BitArray.h +97 -0
  92. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/BitArrayIO.cpp +31 -0
  93. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/BitMatrix.cpp +143 -0
  94. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/BitMatrix.h +91 -0
  95. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/BitSource.cpp +76 -0
  96. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/BitSource.h +74 -0
  97. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/CharacterSetECI.cpp +104 -0
  98. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/CharacterSetECI.h +53 -0
  99. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/Counted.h +140 -0
  100. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/DecoderResult.cpp +51 -0
  101. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/DecoderResult.h +54 -0
  102. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/DetectorResult.cpp +39 -0
  103. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/DetectorResult.h +43 -0
  104. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/GlobalHistogramBinarizer.cpp +212 -0
  105. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/GlobalHistogramBinarizer.h +48 -0
  106. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/GreyscaleLuminanceSource.cpp +80 -0
  107. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/GreyscaleLuminanceSource.h +53 -0
  108. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/GreyscaleRotatedLuminanceSource.cpp +81 -0
  109. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/GreyscaleRotatedLuminanceSource.h +46 -0
  110. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/GridSampler.cpp +122 -0
  111. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/GridSampler.h +45 -0
  112. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/HybridBinarizer.cpp +226 -0
  113. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/HybridBinarizer.h +67 -0
  114. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/IllegalArgumentException.cpp +27 -0
  115. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/IllegalArgumentException.h +36 -0
  116. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/PerspectiveTransform.cpp +107 -0
  117. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/PerspectiveTransform.h +49 -0
  118. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/Point.h +47 -0
  119. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/Str.cpp +61 -0
  120. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/Str.h +51 -0
  121. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/StringUtils.cpp +198 -0
  122. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/StringUtils.h +52 -0
  123. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/detector/JavaMath.h +43 -0
  124. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/detector/MathUtils.h +57 -0
  125. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/detector/MonochromeRectangleDetector.cpp +175 -0
  126. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/detector/MonochromeRectangleDetector.h +62 -0
  127. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/detector/WhiteRectangleDetector.cpp +330 -0
  128. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/detector/WhiteRectangleDetector.h +59 -0
  129. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/reedsolomon/GenericGF.cpp +150 -0
  130. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/reedsolomon/GenericGF.h +73 -0
  131. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/reedsolomon/GenericGFPoly.cpp +218 -0
  132. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/reedsolomon/GenericGFPoly.h +56 -0
  133. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/reedsolomon/ReedSolomonDecoder.cpp +174 -0
  134. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/reedsolomon/ReedSolomonDecoder.h +49 -0
  135. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/reedsolomon/ReedSolomonException.cpp +30 -0
  136. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/reedsolomon/ReedSolomonException.h +33 -0
  137. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/datamatrix/DataMatrixReader.cpp +54 -0
  138. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/datamatrix/DataMatrixReader.h +45 -0
  139. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/datamatrix/DataMatrixVersion.cpp +199 -0
  140. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/datamatrix/Version.h +87 -0
  141. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/datamatrix/decoder/BitMatrixParser.h +59 -0
  142. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/datamatrix/decoder/DataBlock.h +49 -0
  143. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/datamatrix/decoder/DataMatrixBitMatrixParser.cpp +361 -0
  144. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/datamatrix/decoder/DataMatrixDataBlock.cpp +113 -0
  145. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/datamatrix/decoder/DataMatrixDecodedBitStreamParser.cpp +416 -0
  146. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/datamatrix/decoder/DataMatrixDecoder.cpp +93 -0
  147. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/datamatrix/decoder/DecodedBitStreamParser.h +104 -0
  148. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/datamatrix/decoder/Decoder.h +49 -0
  149. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/datamatrix/detector/CornerPoint.h +43 -0
  150. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/datamatrix/detector/DataMatrixCornerPoint.cpp +46 -0
  151. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/datamatrix/detector/DataMatrixDetector.cpp +447 -0
  152. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/datamatrix/detector/DataMatrixDetectorException.cpp +23 -0
  153. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/datamatrix/detector/Detector.h +94 -0
  154. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/datamatrix/detector/DetectorException.h +23 -0
  155. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/multi/ByQuadrantReader.cpp +75 -0
  156. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/multi/ByQuadrantReader.h +42 -0
  157. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/multi/GenericMultipleBarcodeReader.cpp +137 -0
  158. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/multi/GenericMultipleBarcodeReader.h +51 -0
  159. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/multi/MultipleBarcodeReader.cpp +29 -0
  160. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/multi/MultipleBarcodeReader.h +41 -0
  161. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/multi/qrcode/QRCodeMultiReader.cpp +58 -0
  162. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/multi/qrcode/QRCodeMultiReader.h +36 -0
  163. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/multi/qrcode/detector/MultiDetector.cpp +47 -0
  164. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/multi/qrcode/detector/MultiDetector.h +37 -0
  165. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/multi/qrcode/detector/MultiFinderPatternFinder.cpp +236 -0
  166. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/multi/qrcode/detector/MultiFinderPatternFinder.h +47 -0
  167. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/oned/CodaBarReader.cpp +340 -0
  168. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/oned/CodaBarReader.h +57 -0
  169. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/oned/Code128Reader.cpp +497 -0
  170. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/oned/Code128Reader.h +48 -0
  171. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/oned/Code39Reader.cpp +329 -0
  172. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/oned/Code39Reader.h +63 -0
  173. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/oned/Code93Reader.cpp +293 -0
  174. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/oned/Code93Reader.h +58 -0
  175. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/oned/EAN13Reader.cpp +85 -0
  176. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/oned/EAN13Reader.h +49 -0
  177. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/oned/EAN8Reader.cpp +65 -0
  178. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/oned/EAN8Reader.h +47 -0
  179. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/oned/ITFReader.cpp +337 -0
  180. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/oned/ITFReader.h +54 -0
  181. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/oned/MultiFormatOneDReader.cpp +96 -0
  182. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/oned/MultiFormatOneDReader.h +38 -0
  183. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/oned/MultiFormatUPCEANReader.cpp +110 -0
  184. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/oned/MultiFormatUPCEANReader.h +41 -0
  185. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/oned/OneDReader.cpp +228 -0
  186. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/oned/OneDReader.h +81 -0
  187. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/oned/OneDResultPoint.cpp +28 -0
  188. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/oned/OneDResultPoint.h +35 -0
  189. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/oned/UPCAReader.cpp +71 -0
  190. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/oned/UPCAReader.h +50 -0
  191. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/oned/UPCEANReader.cpp +309 -0
  192. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/oned/UPCEANReader.h +88 -0
  193. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/oned/UPCEReader.cpp +146 -0
  194. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/oned/UPCEReader.h +47 -0
  195. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/pdf417/PDF417Reader.cpp +170 -0
  196. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/pdf417/PDF417Reader.h +49 -0
  197. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/pdf417/decoder/BitMatrixParser.h +84 -0
  198. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/pdf417/decoder/DecodedBitStreamParser.h +84 -0
  199. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/pdf417/decoder/Decoder.h +62 -0
  200. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/pdf417/decoder/PDF417BitMatrixParser.cpp +997 -0
  201. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/pdf417/decoder/PDF417DecodedBitStreamParser.cpp +563 -0
  202. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/pdf417/decoder/PDF417Decoder.cpp +118 -0
  203. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/pdf417/decoder/ec/ErrorCorrection.cpp +214 -0
  204. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/pdf417/decoder/ec/ErrorCorrection.h +71 -0
  205. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/pdf417/decoder/ec/ModulusGF.cpp +120 -0
  206. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/pdf417/decoder/ec/ModulusGF.h +72 -0
  207. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/pdf417/decoder/ec/ModulusPoly.cpp +284 -0
  208. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/pdf417/decoder/ec/ModulusPoly.h +68 -0
  209. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/pdf417/detector/Detector.h +106 -0
  210. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/pdf417/detector/LinesSampler.cpp +719 -0
  211. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/pdf417/detector/LinesSampler.h +122 -0
  212. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/pdf417/detector/PDF417Detector.cpp +664 -0
  213. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/qrcode/ErrorCorrectionLevel.h +55 -0
  214. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/qrcode/FormatInformation.h +54 -0
  215. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/qrcode/QRCodeReader.cpp +52 -0
  216. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/qrcode/QRCodeReader.h +48 -0
  217. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/qrcode/QRErrorCorrectionLevel.cpp +70 -0
  218. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/qrcode/QRFormatInformation.cpp +117 -0
  219. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/qrcode/QRVersion.cpp +566 -0
  220. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/qrcode/Version.h +86 -0
  221. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/qrcode/decoder/BitMatrixParser.h +56 -0
  222. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/qrcode/decoder/DataBlock.h +50 -0
  223. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/qrcode/decoder/DataMask.h +50 -0
  224. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/qrcode/decoder/DecodedBitStreamParser.h +72 -0
  225. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/qrcode/decoder/Decoder.h +46 -0
  226. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/qrcode/decoder/Mode.h +68 -0
  227. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/qrcode/decoder/QRBitMatrixParser.cpp +183 -0
  228. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/qrcode/decoder/QRDataBlock.cpp +118 -0
  229. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/qrcode/decoder/QRDataMask.cpp +159 -0
  230. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/qrcode/decoder/QRDecodedBitStreamParser.cpp +433 -0
  231. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/qrcode/decoder/QRDecoder.cpp +107 -0
  232. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/qrcode/decoder/QRMode.cpp +118 -0
  233. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/qrcode/detector/AlignmentPattern.h +45 -0
  234. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/qrcode/detector/AlignmentPatternFinder.h +68 -0
  235. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/qrcode/detector/Detector.h +69 -0
  236. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/qrcode/detector/FinderPattern.h +48 -0
  237. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/qrcode/detector/FinderPatternFinder.h +80 -0
  238. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/qrcode/detector/FinderPatternInfo.h +47 -0
  239. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/qrcode/detector/QRAlignmentPattern.cpp +47 -0
  240. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/qrcode/detector/QRAlignmentPatternFinder.cpp +208 -0
  241. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/qrcode/detector/QRDetector.cpp +315 -0
  242. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/qrcode/detector/QRFinderPattern.cpp +69 -0
  243. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/qrcode/detector/QRFinderPatternFinder.cpp +638 -0
  244. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/qrcode/detector/QRFinderPatternInfo.cpp +41 -0
  245. data/lib/commonAPI/coreapi/ext.yml +1 -1
  246. data/lib/commonAPI/coreapi/ext/platform/android/src/com/rho/network/Network.java +21 -7
  247. data/lib/commonAPI/coreapi/ext/platform/qt/coreapi.pro +10 -0
  248. data/lib/commonAPI/coreapi/ext/platform/wm/src/Registry.cpp +57 -7
  249. data/lib/commonAPI/coreapi/ext/shared/SystemImplBase.cpp +11 -0
  250. data/lib/commonAPI/coreapi/ext/shared/SystemImplBase.h +2 -0
  251. data/lib/commonAPI/coreapi/ext/shared/qt/NavbarImpl.cpp +1 -1
  252. data/lib/commonAPI/coreapi/ext/system.xml +3 -0
  253. data/lib/commonAPI/coreapi/ext/webview.xml +0 -2
  254. data/lib/commonAPI/coreapi/public/api/rhonodejsapi.js +921 -0
  255. data/lib/commonAPI/mediacapture/ext.yml +1 -0
  256. data/lib/commonAPI/mediacapture/ext/platform/android/src/com/rho/camera/CameraObject.java +3 -2
  257. data/lib/commonAPI/mediacapture/ext/platform/android/src/com/rho/camera/CameraRhoListener.java +260 -230
  258. data/lib/commonAPI/mediacapture/ext/platform/qt/MediaCapture.pro +17 -5
  259. data/lib/commonAPI/mediacapture/ext/platform/qt/resources/buttonBack.png +0 -0
  260. data/lib/commonAPI/mediacapture/ext/platform/qt/resources/mediacapture.qrc +1 -0
  261. data/lib/commonAPI/mediacapture/ext/platform/qt/src/CCameraData.cpp +11 -4
  262. data/lib/commonAPI/mediacapture/ext/platform/qt/src/CCameraData.h +4 -7
  263. data/lib/commonAPI/mediacapture/ext/platform/qt/src/CameraDialogView.h +1 -6
  264. data/lib/commonAPI/mediacapture/ext/platform/qt/src/CameraRefresher.h +54 -0
  265. data/lib/commonAPI/mediacapture/ext/platform/qt/src/Camera_impl.cpp +15 -21
  266. data/lib/commonAPI/mediacapture/ext/platform/qt/src/ImageFilenameGetterResult.h +7 -2
  267. data/lib/commonAPI/mediacapture/ext/platform/qt/src/cameradialogview.cpp +34 -32
  268. data/lib/extensions/zlib/ext/zlib.pro +11 -0
  269. data/platform/android/Rhodes/jni/src/fileapi.cpp +36 -22
  270. data/platform/iphone/Classes/SimpleMainView.m +1 -1
  271. data/platform/shared/api_generator/MethodResult.cpp +22 -7
  272. data/platform/shared/api_generator/MethodResult.h +3 -1
  273. data/platform/shared/api_generator/iphone/CMethodResult.m +6 -2
  274. data/platform/shared/api_generator/js_helpers.cpp +19 -0
  275. data/platform/shared/api_generator/js_helpers.h +23 -0
  276. data/platform/shared/common/RhoConf.cpp +0 -1
  277. data/platform/shared/common/RhoPort.h +3 -0
  278. data/platform/shared/common/RhodesApp.cpp +46 -11
  279. data/platform/shared/common/RhodesApp.h +7 -0
  280. data/platform/shared/common/RhodesAppBase.cpp +5 -1
  281. data/platform/shared/common/RhodesAppBase.h +8 -1
  282. data/platform/shared/common/ThreadQueue.h +1 -1
  283. data/platform/shared/common/map/BaseMapEngine.cpp +2 -0
  284. data/platform/shared/net/HttpServer.cpp +0 -1
  285. data/platform/shared/qt/RhoSimulator.pro +11 -0
  286. data/platform/shared/qt/RhoSimulator_dev.pro +12 -2
  287. data/platform/shared/qt/curl/curl.pro +10 -0
  288. data/platform/shared/qt/rhodes/guithreadfunchelper.h +29 -0
  289. data/platform/shared/qt/rhodes/iexecutable.h +9 -0
  290. data/platform/shared/qt/rhodes/impl/MainWindowImpl.cpp +10 -21
  291. data/platform/shared/qt/rhodes/impl/MainWindowImpl.h +1 -1
  292. data/platform/shared/qt/rhodes/impl/QtSystemImpl.cpp +15 -1
  293. data/platform/shared/qt/rhodes/impl/RhoThreadImpl.cpp +7 -7
  294. data/platform/shared/qt/rhodes/mainwindowinterface.h +12 -0
  295. data/platform/shared/qt/rhodes/newVersion/DateTimeDialog.cpp +96 -0
  296. data/platform/shared/qt/rhodes/newVersion/DateTimeDialog.h +54 -0
  297. data/platform/shared/qt/rhodes/newVersion/ExternalWebView.cpp +45 -0
  298. data/platform/shared/qt/rhodes/newVersion/ExternalWebView.h +47 -0
  299. data/platform/shared/qt/rhodes/newVersion/QWebEngineViewSelectionSuppressor.h +103 -0
  300. data/platform/shared/qt/rhodes/newVersion/QtMainWindow.cpp +1181 -0
  301. data/platform/shared/qt/rhodes/newVersion/QtMainWindow.h +194 -0
  302. data/platform/shared/qt/rhodes/newVersion/QtNativeTabBar.cpp +107 -0
  303. data/platform/shared/qt/rhodes/newVersion/QtNativeTabBar.h +40 -0
  304. data/platform/shared/qt/rhodes/newVersion/RhoNativeApiCall.cpp +51 -0
  305. data/platform/shared/qt/rhodes/newVersion/RhoNativeApiCall.h +52 -0
  306. data/platform/shared/qt/rhodes/newVersion/main.cpp +280 -0
  307. data/platform/shared/qt/rhodes/newVersion/qtwebenginepage.cpp +19 -0
  308. data/platform/shared/qt/rhodes/newVersion/qtwebenginepage.h +21 -0
  309. data/platform/shared/qt/rhodes/newVersion/qtwebengineview.cpp +6 -0
  310. data/platform/shared/qt/rhodes/newVersion/qtwebengineview.h +18 -0
  311. data/platform/shared/qt/rhodes/{DateTimeDialog.cpp → oldVersion/DateTimeDialog.cpp} +0 -0
  312. data/platform/shared/qt/rhodes/{DateTimeDialog.h → oldVersion/DateTimeDialog.h} +0 -0
  313. data/platform/shared/qt/rhodes/{DateTimeDialog.ui → oldVersion/DateTimeDialog.ui} +0 -0
  314. data/platform/shared/qt/rhodes/{ExternalWebView.cpp → oldVersion/ExternalWebView.cpp} +0 -0
  315. data/platform/shared/qt/rhodes/{ExternalWebView.h → oldVersion/ExternalWebView.h} +0 -0
  316. data/platform/shared/qt/rhodes/{ExternalWebView.ui → oldVersion/ExternalWebView.ui} +0 -0
  317. data/platform/shared/qt/rhodes/{QtMainWindow.cpp → oldVersion/QtMainWindow.cpp} +4 -1
  318. data/platform/shared/qt/rhodes/{QtMainWindow.h → oldVersion/QtMainWindow.h} +8 -5
  319. data/platform/shared/qt/rhodes/{QtMainWindow.ui → oldVersion/QtMainWindow.ui} +0 -0
  320. data/platform/shared/qt/rhodes/{QtNativeTabBar.cpp → oldVersion/QtNativeTabBar.cpp} +0 -0
  321. data/platform/shared/qt/rhodes/{QtNativeTabBar.h → oldVersion/QtNativeTabBar.h} +0 -0
  322. data/platform/shared/qt/rhodes/{QtWebInspector.cpp → oldVersion/QtWebInspector.cpp} +0 -0
  323. data/platform/shared/qt/rhodes/{QtWebInspector.h → oldVersion/QtWebInspector.h} +0 -0
  324. data/platform/shared/qt/rhodes/{QtWebInspector.ui → oldVersion/QtWebInspector.ui} +0 -0
  325. data/platform/shared/qt/rhodes/{QtWebPage.cpp → oldVersion/QtWebPage.cpp} +0 -0
  326. data/platform/shared/qt/rhodes/{QtWebPage.h → oldVersion/QtWebPage.h} +0 -0
  327. data/platform/shared/qt/rhodes/{RhoNativeApiCall.cpp → oldVersion/RhoNativeApiCall.cpp} +0 -0
  328. data/platform/shared/qt/rhodes/{RhoNativeApiCall.h → oldVersion/RhoNativeApiCall.h} +0 -0
  329. data/platform/shared/qt/rhodes/{main.cpp → oldVersion/main.cpp} +2 -0
  330. data/platform/shared/qt/rhodes/{qkineticscroller.cpp → oldVersion/qkineticscroller.cpp} +0 -0
  331. data/platform/shared/qt/rhodes/{qkineticscroller.h → oldVersion/qkineticscroller.h} +0 -0
  332. data/platform/shared/qt/rhodes/{qkineticscroller_p.h → oldVersion/qkineticscroller_p.h} +0 -0
  333. data/platform/shared/qt/rhodes/{qtflickgesture.cpp → oldVersion/qtflickgesture.cpp} +0 -0
  334. data/platform/shared/qt/rhodes/{qtflickgesture_p.h → oldVersion/qtflickgesture_p.h} +0 -0
  335. data/platform/shared/qt/rhodes/{qtscroller.cpp → oldVersion/qtscroller.cpp} +0 -0
  336. data/platform/shared/qt/rhodes/{qtscroller.h → oldVersion/qtscroller.h} +0 -0
  337. data/platform/shared/qt/rhodes/{qtscroller_p.h → oldVersion/qtscroller_p.h} +0 -0
  338. data/platform/shared/qt/rhodes/{qtscrollerfilter.cpp → oldVersion/qtscrollerfilter.cpp} +0 -0
  339. data/platform/shared/qt/rhodes/{qtscrollerfilter_p.h → oldVersion/qtscrollerfilter_p.h} +0 -0
  340. data/platform/shared/qt/rhodes/{qtscrollerproperties.cpp → oldVersion/qtscrollerproperties.cpp} +0 -0
  341. data/platform/shared/qt/rhodes/{qtscrollerproperties.h → oldVersion/qtscrollerproperties.h} +0 -0
  342. data/platform/shared/qt/rhodes/{qtscrollerproperties_p.h → oldVersion/qtscrollerproperties_p.h} +0 -0
  343. data/platform/shared/qt/rhodes/{qtscrollevent.cpp → oldVersion/qtscrollevent.cpp} +0 -0
  344. data/platform/shared/qt/rhodes/{qtscrollevent.h → oldVersion/qtscrollevent.h} +0 -0
  345. data/platform/shared/qt/rhodes/{qtscrollevent_p.h → oldVersion/qtscrollevent_p.h} +0 -0
  346. data/platform/shared/qt/rhodes/{qwebviewkineticscroller.cpp → oldVersion/qwebviewkineticscroller.cpp} +0 -0
  347. data/platform/shared/qt/rhodes/{qwebviewkineticscroller.h → oldVersion/qwebviewkineticscroller.h} +0 -0
  348. data/platform/shared/qt/rhodes/{qwebviewselectionsuppressor.h → oldVersion/qwebviewselectionsuppressor.h} +0 -0
  349. data/platform/shared/qt/rhodes/rhodes.pro +92 -47
  350. data/platform/shared/qt/rholib/rholib.pro +32 -19
  351. data/platform/shared/qt/rubylib/rubylib.pro +12 -0
  352. data/platform/shared/qt/sqlite3/sqlite3.pro +11 -1
  353. data/platform/shared/qt/syncengine/syncengine.pro +10 -0
  354. data/platform/shared/ruby/eval.c +2 -4
  355. data/platform/shared/ruby/eval_intern.h +12 -0
  356. data/platform/shared/ruby/ext/rho/extensions.c +6 -2
  357. data/platform/shared/ruby/include/ruby/missing.h +6 -4
  358. data/platform/shared/ruby/io.c +27 -0
  359. data/platform/shared/ruby/numeric.c +5 -2
  360. data/platform/shared/ruby/time.c +4 -0
  361. data/platform/shared/ruby/win32/win32 backup.c +5808 -0
  362. data/platform/shared/ruby/win32/win32.c +2254 -2131
  363. data/platform/shared/unzip/deflate.cpp +6 -1
  364. data/platform/shared/unzip/gunzip.cpp +1 -1
  365. data/platform/shared/unzip/unzip.cpp +3 -6
  366. data/platform/shared/unzip/zip.cpp +1 -25
  367. data/platform/shared/unzip/zutil.cpp +1 -1
  368. data/platform/shared/unzip/zutil.h +1 -1
  369. data/platform/win32/RhoSimulator/rho/Databases/Databases.db +0 -0
  370. data/platform/win32/RhoSimulator/rho/WebpageIcons.db +0 -0
  371. data/platform/win32/RhoSimulator/rho/rholog.txt_pos +0 -0
  372. data/platform/win32/RhoSimulator/rhosimulator/Databases/Databases.db +0 -0
  373. data/platform/win32/RhoSimulator/rhosimulator/WebpageIcons.db +0 -0
  374. data/platform/win32/RhoSimulator/rhosimulator/rholog.txt_pos +0 -0
  375. data/platform/wm/build/build_inf.js +7 -3
  376. data/platform/wm/build/wm.rake +96 -30
  377. data/platform/wm/rhodes/rho/rubyext/SystemImpl.cpp +3 -1
  378. data/rakefile.rb +48 -13
  379. data/res/generators/rhogen.rb +87 -8
  380. data/res/generators/templates/api/cpp/montana_js_wrap.cpp +1 -1
  381. data/res/generators/templates/application/nodejs/main.js +501 -0
  382. data/res/generators/templates/application/nodejs/rhoapp.js +71 -0
  383. data/res/generators/templates/application/nodejs/server/app.js +19 -0
  384. data/res/generators/templates/application/nodejs/server/package.json +16 -0
  385. data/res/generators/templates/application/nodejs/server/public/bootstrap-3.3.7/css/bootstrap-theme.css +587 -0
  386. data/res/generators/templates/application/nodejs/server/public/bootstrap-3.3.7/css/bootstrap-theme.css.map +1 -0
  387. data/res/generators/templates/application/nodejs/server/public/bootstrap-3.3.7/css/bootstrap-theme.min.css +6 -0
  388. data/res/generators/templates/application/nodejs/server/public/bootstrap-3.3.7/css/bootstrap-theme.min.css.map +1 -0
  389. data/res/generators/templates/application/nodejs/server/public/bootstrap-3.3.7/css/bootstrap.css +6757 -0
  390. data/res/generators/templates/application/nodejs/server/public/bootstrap-3.3.7/css/bootstrap.css.map +1 -0
  391. data/res/generators/templates/application/nodejs/server/public/bootstrap-3.3.7/css/bootstrap.min.css +6 -0
  392. data/res/generators/templates/application/nodejs/server/public/bootstrap-3.3.7/css/bootstrap.min.css.map +1 -0
  393. data/res/generators/templates/application/nodejs/server/public/bootstrap-3.3.7/fonts/glyphicons-halflings-regular.eot +0 -0
  394. data/res/generators/templates/application/nodejs/server/public/bootstrap-3.3.7/fonts/glyphicons-halflings-regular.svg +288 -0
  395. data/res/generators/templates/application/nodejs/server/public/bootstrap-3.3.7/fonts/glyphicons-halflings-regular.ttf +0 -0
  396. data/res/generators/templates/application/nodejs/server/public/bootstrap-3.3.7/fonts/glyphicons-halflings-regular.woff +0 -0
  397. data/res/generators/templates/application/nodejs/server/public/bootstrap-3.3.7/fonts/glyphicons-halflings-regular.woff2 +0 -0
  398. data/res/generators/templates/application/nodejs/server/public/bootstrap-3.3.7/js/bootstrap.js +2377 -0
  399. data/res/generators/templates/application/nodejs/server/public/bootstrap-3.3.7/js/bootstrap.min.js +7 -0
  400. data/res/generators/templates/application/nodejs/server/public/bootstrap-3.3.7/js/npm.js +13 -0
  401. data/res/generators/templates/application/nodejs/server/public/images/bar/back_btn.png +0 -0
  402. data/res/generators/templates/application/nodejs/server/public/images/bar/back_btn@2x.png +0 -0
  403. data/res/generators/templates/application/nodejs/server/public/images/bar/back_btn@3x.png +0 -0
  404. data/res/generators/templates/application/nodejs/server/public/images/bar/forward_btn.png +0 -0
  405. data/res/generators/templates/application/nodejs/server/public/images/bar/forward_btn@2x.png +0 -0
  406. data/res/generators/templates/application/nodejs/server/public/images/bar/forward_btn@3x.png +0 -0
  407. data/res/generators/templates/application/nodejs/server/public/images/bar/gears.png +0 -0
  408. data/res/generators/templates/application/nodejs/server/public/images/bar/gears@2x.png +0 -0
  409. data/res/generators/templates/application/nodejs/server/public/images/bar/gears@3x.png +0 -0
  410. data/res/generators/templates/application/nodejs/server/public/images/bar/home_btn.png +0 -0
  411. data/res/generators/templates/application/nodejs/server/public/images/bar/home_btn@2x.png +0 -0
  412. data/res/generators/templates/application/nodejs/server/public/images/bar/home_btn@3x.png +0 -0
  413. data/res/generators/templates/application/nodejs/server/public/images/bar/sync_btn.png +0 -0
  414. data/res/generators/templates/application/nodejs/server/public/images/bar/sync_btn@2x.png +0 -0
  415. data/res/generators/templates/application/nodejs/server/public/images/bar/sync_btn@3x.png +0 -0
  416. data/res/generators/templates/application/nodejs/server/public/jquery/jquery-3.1.1.min.js +4 -0
  417. data/res/generators/templates/application/nodejs/server/public/jquery/jquery-3.1.1.min.map +1 -0
  418. data/res/generators/templates/application/nodejs_build.yml +76 -0
  419. data/res/generators/templates/application/nodejs_rhoconfig.txt +137 -0
  420. data/version +1 -1
  421. metadata +345 -77
  422. data/platform/win32/RhoSimulator/D3Dcompiler_46.dll +0 -0
  423. data/platform/win32/RhoSimulator/Qt5Core.dll +0 -0
  424. data/platform/win32/RhoSimulator/Qt5Gui.dll +0 -0
  425. data/platform/win32/RhoSimulator/Qt5Multimedia.dll +0 -0
  426. data/platform/win32/RhoSimulator/Qt5MultimediaWidgets.dll +0 -0
  427. data/platform/win32/RhoSimulator/Qt5Network.dll +0 -0
  428. data/platform/win32/RhoSimulator/Qt5OpenGL.dll +0 -0
  429. data/platform/win32/RhoSimulator/Qt5PrintSupport.dll +0 -0
  430. data/platform/win32/RhoSimulator/Qt5Qml.dll +0 -0
  431. data/platform/win32/RhoSimulator/Qt5Quick.dll +0 -0
  432. data/platform/win32/RhoSimulator/Qt5Sensors.dll +0 -0
  433. data/platform/win32/RhoSimulator/Qt5Sql.dll +0 -0
  434. data/platform/win32/RhoSimulator/Qt5V8.dll +0 -0
  435. data/platform/win32/RhoSimulator/Qt5WebKit.dll +0 -0
  436. data/platform/win32/RhoSimulator/Qt5WebKitWidgets.dll +0 -0
  437. data/platform/win32/RhoSimulator/Qt5Widgets.dll +0 -0
  438. data/platform/win32/RhoSimulator/RhoSimulator.exe +0 -0
  439. data/platform/win32/RhoSimulator/icudt52.dll +0 -0
  440. data/platform/win32/RhoSimulator/icuin52.dll +0 -0
  441. data/platform/win32/RhoSimulator/icuuc52.dll +0 -0
  442. data/platform/win32/RhoSimulator/imageformats/qgif.dll +0 -0
  443. data/platform/win32/RhoSimulator/imageformats/qico.dll +0 -0
  444. data/platform/win32/RhoSimulator/imageformats/qjpeg.dll +0 -0
  445. data/platform/win32/RhoSimulator/imageformats/qmng.dll +0 -0
  446. data/platform/win32/RhoSimulator/imageformats/qsvg.dll +0 -0
  447. data/platform/win32/RhoSimulator/imageformats/qtga.dll +0 -0
  448. data/platform/win32/RhoSimulator/imageformats/qtiff.dll +0 -0
  449. data/platform/win32/RhoSimulator/imageformats/qwbmp.dll +0 -0
  450. data/platform/win32/RhoSimulator/libEGL.dll +0 -0
  451. data/platform/win32/RhoSimulator/libGLESv2.dll +0 -0
  452. data/platform/win32/RhoSimulator/libeay32.dll +0 -0
  453. data/platform/win32/RhoSimulator/msvcp110.dll +0 -0
  454. data/platform/win32/RhoSimulator/msvcr110.dll +0 -0
  455. data/platform/win32/RhoSimulator/platforms/qwindows.dll +0 -0
  456. data/platform/win32/RhoSimulator/ssleay32.dll +0 -0
  457. data/platform/win32/RhoSimulator/vccorlib110.dll +0 -0
  458. data/platform/win32/RhoSimulator/vcomp110.dll +0 -0
@@ -0,0 +1,215 @@
1
+ #ifndef BIGINTEGER_H
2
+ #define BIGINTEGER_H
3
+
4
+ #include "BigUnsigned.hh"
5
+
6
+ /* A BigInteger object represents a signed integer of size limited only by
7
+ * available memory. BigUnsigneds support most mathematical operators and can
8
+ * be converted to and from most primitive integer types.
9
+ *
10
+ * A BigInteger is just an aggregate of a BigUnsigned and a sign. (It is no
11
+ * longer derived from BigUnsigned because that led to harmful implicit
12
+ * conversions.) */
13
+ class BigInteger {
14
+
15
+ public:
16
+ typedef BigUnsigned::Blk Blk;
17
+ typedef BigUnsigned::Index Index;
18
+ typedef BigUnsigned::CmpRes CmpRes;
19
+ static const CmpRes
20
+ less = BigUnsigned::less ,
21
+ equal = BigUnsigned::equal ,
22
+ greater = BigUnsigned::greater;
23
+ // Enumeration for the sign of a BigInteger.
24
+ enum Sign { negative = -1, zero = 0, positive = 1 };
25
+
26
+ protected:
27
+ Sign sign;
28
+ BigUnsigned mag;
29
+
30
+ public:
31
+ // Constructs zero.
32
+ BigInteger() : sign(zero), mag() {}
33
+
34
+ // Copy constructor
35
+ BigInteger(const BigInteger &x) : sign(x.sign), mag(x.mag) {};
36
+
37
+ // Assignment operator
38
+ void operator=(const BigInteger &x);
39
+
40
+ // Constructor that copies from a given array of blocks with a sign.
41
+ BigInteger(const Blk *b, Index blen, Sign s);
42
+
43
+ // Nonnegative constructor that copies from a given array of blocks.
44
+ BigInteger(const Blk *b, Index blen) : mag(b, blen) {
45
+ sign = mag.isZero() ? zero : positive;
46
+ }
47
+
48
+ // Constructor from a BigUnsigned and a sign
49
+ BigInteger(const BigUnsigned &x, Sign s);
50
+
51
+ // Nonnegative constructor from a BigUnsigned
52
+ BigInteger(const BigUnsigned &x) : mag(x) {
53
+ sign = mag.isZero() ? zero : positive;
54
+ }
55
+
56
+ // Constructors from primitive integer types
57
+ BigInteger(unsigned long x);
58
+ BigInteger( long x);
59
+ BigInteger(unsigned int x);
60
+ BigInteger( int x);
61
+ BigInteger(unsigned short x);
62
+ BigInteger( short x);
63
+
64
+ /* Converters to primitive integer types
65
+ * The implicit conversion operators caused trouble, so these are now
66
+ * named. */
67
+ unsigned long toUnsignedLong () const;
68
+ long toLong () const;
69
+ unsigned int toUnsignedInt () const;
70
+ int toInt () const;
71
+ unsigned short toUnsignedShort() const;
72
+ short toShort () const;
73
+ protected:
74
+ // Helper
75
+ template <class X> X convertToUnsignedPrimitive() const;
76
+ template <class X, class UX> X convertToSignedPrimitive() const;
77
+ public:
78
+
79
+ // ACCESSORS
80
+ Sign getSign() const { return sign; }
81
+ /* The client can't do any harm by holding a read-only reference to the
82
+ * magnitude. */
83
+ const BigUnsigned &getMagnitude() const { return mag; }
84
+
85
+ // Some accessors that go through to the magnitude
86
+ Index getLength() const { return mag.getLength(); }
87
+ Index getCapacity() const { return mag.getCapacity(); }
88
+ Blk getBlock(Index i) const { return mag.getBlock(i); }
89
+ bool isZero() const { return sign == zero; } // A bit special
90
+
91
+ // COMPARISONS
92
+
93
+ // Compares this to x like Perl's <=>
94
+ CmpRes compareTo(const BigInteger &x) const;
95
+
96
+ // Ordinary comparison operators
97
+ bool operator ==(const BigInteger &x) const {
98
+ return sign == x.sign && mag == x.mag;
99
+ }
100
+ bool operator !=(const BigInteger &x) const { return !operator ==(x); };
101
+ bool operator < (const BigInteger &x) const { return compareTo(x) == less ; }
102
+ bool operator <=(const BigInteger &x) const { return compareTo(x) != greater; }
103
+ bool operator >=(const BigInteger &x) const { return compareTo(x) != less ; }
104
+ bool operator > (const BigInteger &x) const { return compareTo(x) == greater; }
105
+
106
+ // OPERATORS -- See the discussion in BigUnsigned.hh.
107
+ void add (const BigInteger &a, const BigInteger &b);
108
+ void subtract(const BigInteger &a, const BigInteger &b);
109
+ void multiply(const BigInteger &a, const BigInteger &b);
110
+ /* See the comment on BigUnsigned::divideWithRemainder. Semantics
111
+ * differ from those of primitive integers when negatives and/or zeros
112
+ * are involved. */
113
+ void divideWithRemainder(const BigInteger &b, BigInteger &q);
114
+ void negate(const BigInteger &a);
115
+
116
+ /* Bitwise operators are not provided for BigIntegers. Use
117
+ * getMagnitude to get the magnitude and operate on that instead. */
118
+
119
+ BigInteger operator +(const BigInteger &x) const;
120
+ BigInteger operator -(const BigInteger &x) const;
121
+ BigInteger operator *(const BigInteger &x) const;
122
+ BigInteger operator /(const BigInteger &x) const;
123
+ BigInteger operator %(const BigInteger &x) const;
124
+ BigInteger operator -() const;
125
+
126
+ void operator +=(const BigInteger &x);
127
+ void operator -=(const BigInteger &x);
128
+ void operator *=(const BigInteger &x);
129
+ void operator /=(const BigInteger &x);
130
+ void operator %=(const BigInteger &x);
131
+ void flipSign();
132
+
133
+ // INCREMENT/DECREMENT OPERATORS
134
+ void operator ++( );
135
+ void operator ++(int);
136
+ void operator --( );
137
+ void operator --(int);
138
+ };
139
+
140
+ // NORMAL OPERATORS
141
+ /* These create an object to hold the result and invoke
142
+ * the appropriate put-here operation on it, passing
143
+ * this and x. The new object is then returned. */
144
+ inline BigInteger BigInteger::operator +(const BigInteger &x) const {
145
+ BigInteger ans;
146
+ ans.add(*this, x);
147
+ return ans;
148
+ }
149
+ inline BigInteger BigInteger::operator -(const BigInteger &x) const {
150
+ BigInteger ans;
151
+ ans.subtract(*this, x);
152
+ return ans;
153
+ }
154
+ inline BigInteger BigInteger::operator *(const BigInteger &x) const {
155
+ BigInteger ans;
156
+ ans.multiply(*this, x);
157
+ return ans;
158
+ }
159
+ inline BigInteger BigInteger::operator /(const BigInteger &x) const {
160
+ if (x.isZero()) throw "BigInteger::operator /: division by zero";
161
+ BigInteger q, r;
162
+ r = *this;
163
+ r.divideWithRemainder(x, q);
164
+ return q;
165
+ }
166
+ inline BigInteger BigInteger::operator %(const BigInteger &x) const {
167
+ if (x.isZero()) throw "BigInteger::operator %: division by zero";
168
+ BigInteger q, r;
169
+ r = *this;
170
+ r.divideWithRemainder(x, q);
171
+ return r;
172
+ }
173
+ inline BigInteger BigInteger::operator -() const {
174
+ BigInteger ans;
175
+ ans.negate(*this);
176
+ return ans;
177
+ }
178
+
179
+ /*
180
+ * ASSIGNMENT OPERATORS
181
+ *
182
+ * Now the responsibility for making a temporary copy if necessary
183
+ * belongs to the put-here operations. See Assignment Operators in
184
+ * BigUnsigned.hh.
185
+ */
186
+ inline void BigInteger::operator +=(const BigInteger &x) {
187
+ add(*this, x);
188
+ }
189
+ inline void BigInteger::operator -=(const BigInteger &x) {
190
+ subtract(*this, x);
191
+ }
192
+ inline void BigInteger::operator *=(const BigInteger &x) {
193
+ multiply(*this, x);
194
+ }
195
+ inline void BigInteger::operator /=(const BigInteger &x) {
196
+ if (x.isZero()) throw "BigInteger::operator /=: division by zero";
197
+ /* The following technique is slightly faster than copying *this first
198
+ * when x is large. */
199
+ BigInteger q;
200
+ divideWithRemainder(x, q);
201
+ // *this contains the remainder, but we overwrite it with the quotient.
202
+ *this = q;
203
+ }
204
+ inline void BigInteger::operator %=(const BigInteger &x) {
205
+ if (x.isZero()) throw "BigInteger::operator %=: division by zero";
206
+ BigInteger q;
207
+ // Mods *this by x. Don't care about quotient left in q.
208
+ divideWithRemainder(x, q);
209
+ }
210
+ // This one is trivial
211
+ inline void BigInteger::flipSign() {
212
+ sign = Sign(-sign);
213
+ }
214
+
215
+ #endif
@@ -0,0 +1,70 @@
1
+ #include "BigIntegerAlgorithms.hh"
2
+
3
+ BigUnsigned gcd(BigUnsigned a, BigUnsigned b) {
4
+ BigUnsigned trash;
5
+ // Neat in-place alternating technique.
6
+ for (;;) {
7
+ if (b.isZero())
8
+ return a;
9
+ a.divideWithRemainder(b, trash);
10
+ if (a.isZero())
11
+ return b;
12
+ b.divideWithRemainder(a, trash);
13
+ }
14
+ }
15
+
16
+ void extendedEuclidean(BigInteger m, BigInteger n,
17
+ BigInteger &g, BigInteger &r, BigInteger &s) {
18
+ if (&g == &r || &g == &s || &r == &s)
19
+ throw "BigInteger extendedEuclidean: Outputs are aliased";
20
+ BigInteger r1(1), s1(0), r2(0), s2(1), q;
21
+ /* Invariants:
22
+ * r1*m(orig) + s1*n(orig) == m(current)
23
+ * r2*m(orig) + s2*n(orig) == n(current) */
24
+ for (;;) {
25
+ if (n.isZero()) {
26
+ r = r1; s = s1; g = m;
27
+ return;
28
+ }
29
+ // Subtract q times the second invariant from the first invariant.
30
+ m.divideWithRemainder(n, q);
31
+ r1 -= q*r2; s1 -= q*s2;
32
+
33
+ if (m.isZero()) {
34
+ r = r2; s = s2; g = n;
35
+ return;
36
+ }
37
+ // Subtract q times the first invariant from the second invariant.
38
+ n.divideWithRemainder(m, q);
39
+ r2 -= q*r1; s2 -= q*s1;
40
+ }
41
+ }
42
+
43
+ BigUnsigned modinv(const BigInteger &x, const BigUnsigned &n) {
44
+ BigInteger g, r, s;
45
+ extendedEuclidean(x, n, g, r, s);
46
+ if (g == 1)
47
+ // r*x + s*n == 1, so r*x === 1 (mod n), so r is the answer.
48
+ return (r % n).getMagnitude(); // (r % n) will be nonnegative
49
+ else
50
+ throw "BigInteger modinv: x and n have a common factor";
51
+ }
52
+
53
+ BigUnsigned modexp(const BigInteger &base, const BigUnsigned &exponent,
54
+ const BigUnsigned &modulus) {
55
+ BigUnsigned ans = 1, base2 = (base % modulus).getMagnitude();
56
+ BigUnsigned::Index i = exponent.bitLength();
57
+ // For each bit of the exponent, most to least significant...
58
+ while (i > 0) {
59
+ i--;
60
+ // Square.
61
+ ans *= ans;
62
+ ans %= modulus;
63
+ // And multiply if the bit is a 1.
64
+ if (exponent.getBit(i)) {
65
+ ans *= base2;
66
+ ans %= modulus;
67
+ }
68
+ }
69
+ return ans;
70
+ }
@@ -0,0 +1,25 @@
1
+ #ifndef BIGINTEGERALGORITHMS_H
2
+ #define BIGINTEGERALGORITHMS_H
3
+
4
+ #include "BigInteger.hh"
5
+
6
+ /* Some mathematical algorithms for big integers.
7
+ * This code is new and, as such, experimental. */
8
+
9
+ // Returns the greatest common divisor of a and b.
10
+ BigUnsigned gcd(BigUnsigned a, BigUnsigned b);
11
+
12
+ /* Extended Euclidean algorithm.
13
+ * Given m and n, finds gcd g and numbers r, s such that r*m + s*n == g. */
14
+ void extendedEuclidean(BigInteger m, BigInteger n,
15
+ BigInteger &g, BigInteger &r, BigInteger &s);
16
+
17
+ /* Returns the multiplicative inverse of x modulo n, or throws an exception if
18
+ * they have a common factor. */
19
+ BigUnsigned modinv(const BigInteger &x, const BigUnsigned &n);
20
+
21
+ // Returns (base ^ exponent) % modulus.
22
+ BigUnsigned modexp(const BigInteger &base, const BigUnsigned &exponent,
23
+ const BigUnsigned &modulus);
24
+
25
+ #endif
@@ -0,0 +1,8 @@
1
+ // This header file includes all of the library header files.
2
+
3
+ #include "NumberlikeArray.hh"
4
+ #include "BigUnsigned.hh"
5
+ #include "BigInteger.hh"
6
+ #include "BigIntegerAlgorithms.hh"
7
+ #include "BigUnsignedInABase.hh"
8
+ #include "BigIntegerUtils.hh"
@@ -0,0 +1,50 @@
1
+ #include "BigIntegerUtils.hh"
2
+ #include "BigUnsignedInABase.hh"
3
+
4
+ std::string bigUnsignedToString(const BigUnsigned &x) {
5
+ return std::string(BigUnsignedInABase(x, 10));
6
+ }
7
+
8
+ std::string bigIntegerToString(const BigInteger &x) {
9
+ return (x.getSign() == BigInteger::negative)
10
+ ? (std::string("-") + bigUnsignedToString(x.getMagnitude()))
11
+ : (bigUnsignedToString(x.getMagnitude()));
12
+ }
13
+
14
+ BigUnsigned stringToBigUnsigned(const std::string &s) {
15
+ return BigUnsigned(BigUnsignedInABase(s, 10));
16
+ }
17
+
18
+ BigInteger stringToBigInteger(const std::string &s) {
19
+ // Recognize a sign followed by a BigUnsigned.
20
+ return (s[0] == '-') ? BigInteger(stringToBigUnsigned(s.substr(1, s.length() - 1)), BigInteger::negative)
21
+ : (s[0] == '+') ? BigInteger(stringToBigUnsigned(s.substr(1, s.length() - 1)))
22
+ : BigInteger(stringToBigUnsigned(s));
23
+ }
24
+
25
+ std::ostream &operator <<(std::ostream &os, const BigUnsigned &x) {
26
+ BigUnsignedInABase::Base base;
27
+ long osFlags = os.flags();
28
+ if (osFlags & os.dec)
29
+ base = 10;
30
+ else if (osFlags & os.hex) {
31
+ base = 16;
32
+ if (osFlags & os.showbase)
33
+ os << "0x";
34
+ } else if (osFlags & os.oct) {
35
+ base = 8;
36
+ if (osFlags & os.showbase)
37
+ os << '0';
38
+ } else
39
+ throw "std::ostream << BigUnsigned: Could not determine the desired base from output-stream flags";
40
+ std::string s = std::string(BigUnsignedInABase(x, base));
41
+ os << s;
42
+ return os;
43
+ }
44
+
45
+ std::ostream &operator <<(std::ostream &os, const BigInteger &x) {
46
+ if (x.getSign() == BigInteger::negative)
47
+ os << '-';
48
+ os << x.getMagnitude();
49
+ return os;
50
+ }
@@ -0,0 +1,72 @@
1
+ #ifndef BIGINTEGERUTILS_H
2
+ #define BIGINTEGERUTILS_H
3
+
4
+ #include "BigInteger.hh"
5
+ #include <string>
6
+ #include <iostream>
7
+
8
+ /* This file provides:
9
+ * - Convenient std::string <-> BigUnsigned/BigInteger conversion routines
10
+ * - std::ostream << operators for BigUnsigned/BigInteger */
11
+
12
+ // std::string conversion routines. Base 10 only.
13
+ std::string bigUnsignedToString(const BigUnsigned &x);
14
+ std::string bigIntegerToString(const BigInteger &x);
15
+ BigUnsigned stringToBigUnsigned(const std::string &s);
16
+ BigInteger stringToBigInteger(const std::string &s);
17
+
18
+ // Creates a BigInteger from data such as `char's; read below for details.
19
+ template <class T>
20
+ BigInteger dataToBigInteger(const T* data, BigInteger::Index length, BigInteger::Sign sign);
21
+
22
+ // Outputs x to os, obeying the flags `dec', `hex', `bin', and `showbase'.
23
+ std::ostream &operator <<(std::ostream &os, const BigUnsigned &x);
24
+
25
+ // Outputs x to os, obeying the flags `dec', `hex', `bin', and `showbase'.
26
+ // My somewhat arbitrary policy: a negative sign comes before a base indicator (like -0xFF).
27
+ std::ostream &operator <<(std::ostream &os, const BigInteger &x);
28
+
29
+ // BEGIN TEMPLATE DEFINITIONS.
30
+
31
+ /*
32
+ * Converts binary data to a BigInteger.
33
+ * Pass an array `data', its length, and the desired sign.
34
+ *
35
+ * Elements of `data' may be of any type `T' that has the following
36
+ * two properties (this includes almost all integral types):
37
+ *
38
+ * (1) `sizeof(T)' correctly gives the amount of binary data in one
39
+ * value of `T' and is a factor of `sizeof(Blk)'.
40
+ *
41
+ * (2) When a value of `T' is casted to a `Blk', the low bytes of
42
+ * the result contain the desired binary data.
43
+ */
44
+ template <class T>
45
+ BigInteger dataToBigInteger(const T* data, BigInteger::Index length, BigInteger::Sign sign) {
46
+ // really ceiling(numBytes / sizeof(BigInteger::Blk))
47
+ unsigned int pieceSizeInBits = 8 * sizeof(T);
48
+ unsigned int piecesPerBlock = sizeof(BigInteger::Blk) / sizeof(T);
49
+ unsigned int numBlocks = (length + piecesPerBlock - 1) / piecesPerBlock;
50
+
51
+ // Allocate our block array
52
+ BigInteger::Blk *blocks = new BigInteger::Blk[numBlocks];
53
+
54
+ BigInteger::Index blockNum, pieceNum, pieceNumHere;
55
+
56
+ // Convert
57
+ for (blockNum = 0, pieceNum = 0; blockNum < numBlocks; blockNum++) {
58
+ BigInteger::Blk curBlock = 0;
59
+ for (pieceNumHere = 0; pieceNumHere < piecesPerBlock && pieceNum < length;
60
+ pieceNumHere++, pieceNum++)
61
+ curBlock |= (BigInteger::Blk(data[pieceNum]) << (pieceSizeInBits * pieceNumHere));
62
+ blocks[blockNum] = curBlock;
63
+ }
64
+
65
+ // Create the BigInteger.
66
+ BigInteger x(blocks, numBlocks, sign);
67
+
68
+ delete [] blocks;
69
+ return x;
70
+ }
71
+
72
+ #endif
@@ -0,0 +1,697 @@
1
+ #include "BigUnsigned.hh"
2
+
3
+ // Memory management definitions have moved to the bottom of NumberlikeArray.hh.
4
+
5
+ // The templates used by these constructors and converters are at the bottom of
6
+ // BigUnsigned.hh.
7
+
8
+ BigUnsigned::BigUnsigned(unsigned long x) { initFromPrimitive (x); }
9
+ BigUnsigned::BigUnsigned(unsigned int x) { initFromPrimitive (x); }
10
+ BigUnsigned::BigUnsigned(unsigned short x) { initFromPrimitive (x); }
11
+ BigUnsigned::BigUnsigned( long x) { initFromSignedPrimitive(x); }
12
+ BigUnsigned::BigUnsigned( int x) { initFromSignedPrimitive(x); }
13
+ BigUnsigned::BigUnsigned( short x) { initFromSignedPrimitive(x); }
14
+
15
+ unsigned long BigUnsigned::toUnsignedLong () const { return convertToPrimitive <unsigned long >(); }
16
+ unsigned int BigUnsigned::toUnsignedInt () const { return convertToPrimitive <unsigned int >(); }
17
+ unsigned short BigUnsigned::toUnsignedShort() const { return convertToPrimitive <unsigned short>(); }
18
+ long BigUnsigned::toLong () const { return convertToSignedPrimitive< long >(); }
19
+ int BigUnsigned::toInt () const { return convertToSignedPrimitive< int >(); }
20
+ short BigUnsigned::toShort () const { return convertToSignedPrimitive< short>(); }
21
+
22
+ // BIT/BLOCK ACCESSORS
23
+
24
+ void BigUnsigned::setBlock(Index i, Blk newBlock) {
25
+ if (newBlock == 0) {
26
+ if (i < len) {
27
+ blk[i] = 0;
28
+ zapLeadingZeros();
29
+ }
30
+ // If i >= len, no effect.
31
+ } else {
32
+ if (i >= len) {
33
+ // The nonzero block extends the number.
34
+ allocateAndCopy(i+1);
35
+ // Zero any added blocks that we aren't setting.
36
+ for (Index j = len; j < i; j++)
37
+ blk[j] = 0;
38
+ len = i+1;
39
+ }
40
+ blk[i] = newBlock;
41
+ }
42
+ }
43
+
44
+ /* Evidently the compiler wants BigUnsigned:: on the return type because, at
45
+ * that point, it hasn't yet parsed the BigUnsigned:: on the name to get the
46
+ * proper scope. */
47
+ BigUnsigned::Index BigUnsigned::bitLength() const {
48
+ if (isZero())
49
+ return 0;
50
+ else {
51
+ Blk leftmostBlock = getBlock(len - 1);
52
+ Index leftmostBlockLen = 0;
53
+ while (leftmostBlock != 0) {
54
+ leftmostBlock >>= 1;
55
+ leftmostBlockLen++;
56
+ }
57
+ return leftmostBlockLen + (len - 1) * N;
58
+ }
59
+ }
60
+
61
+ void BigUnsigned::setBit(Index bi, bool newBit) {
62
+ Index blockI = bi / N;
63
+ Blk block = getBlock(blockI), mask = Blk(1) << (bi % N);
64
+ block = newBit ? (block | mask) : (block & ~mask);
65
+ setBlock(blockI, block);
66
+ }
67
+
68
+ // COMPARISON
69
+ BigUnsigned::CmpRes BigUnsigned::compareTo(const BigUnsigned &x) const {
70
+ // A bigger length implies a bigger number.
71
+ if (len < x.len)
72
+ return less;
73
+ else if (len > x.len)
74
+ return greater;
75
+ else {
76
+ // Compare blocks one by one from left to right.
77
+ Index i = len;
78
+ while (i > 0) {
79
+ i--;
80
+ if (blk[i] == x.blk[i])
81
+ continue;
82
+ else if (blk[i] > x.blk[i])
83
+ return greater;
84
+ else
85
+ return less;
86
+ }
87
+ // If no blocks differed, the numbers are equal.
88
+ return equal;
89
+ }
90
+ }
91
+
92
+ // COPY-LESS OPERATIONS
93
+
94
+ /*
95
+ * On most calls to copy-less operations, it's safe to read the inputs little by
96
+ * little and write the outputs little by little. However, if one of the
97
+ * inputs is coming from the same variable into which the output is to be
98
+ * stored (an "aliased" call), we risk overwriting the input before we read it.
99
+ * In this case, we first compute the result into a temporary BigUnsigned
100
+ * variable and then copy it into the requested output variable *this.
101
+ * Each put-here operation uses the DTRT_ALIASED macro (Do The Right Thing on
102
+ * aliased calls) to generate code for this check.
103
+ *
104
+ * I adopted this approach on 2007.02.13 (see Assignment Operators in
105
+ * BigUnsigned.hh). Before then, put-here operations rejected aliased calls
106
+ * with an exception. I think doing the right thing is better.
107
+ *
108
+ * Some of the put-here operations can probably handle aliased calls safely
109
+ * without the extra copy because (for example) they process blocks strictly
110
+ * right-to-left. At some point I might determine which ones don't need the
111
+ * copy, but my reasoning would need to be verified very carefully. For now
112
+ * I'll leave in the copy.
113
+ */
114
+ #define DTRT_ALIASED(cond, op) \
115
+ if (cond) { \
116
+ BigUnsigned tmpThis; \
117
+ tmpThis.op; \
118
+ *this = tmpThis; \
119
+ return; \
120
+ }
121
+
122
+
123
+
124
+ void BigUnsigned::add(const BigUnsigned &a, const BigUnsigned &b) {
125
+ DTRT_ALIASED(this == &a || this == &b, add(a, b));
126
+ // If one argument is zero, copy the other.
127
+ if (a.len == 0) {
128
+ operator =(b);
129
+ return;
130
+ } else if (b.len == 0) {
131
+ operator =(a);
132
+ return;
133
+ }
134
+ // Some variables...
135
+ // Carries in and out of an addition stage
136
+ bool carryIn, carryOut;
137
+ Blk temp;
138
+ Index i;
139
+ // a2 points to the longer input, b2 points to the shorter
140
+ const BigUnsigned *a2, *b2;
141
+ if (a.len >= b.len) {
142
+ a2 = &a;
143
+ b2 = &b;
144
+ } else {
145
+ a2 = &b;
146
+ b2 = &a;
147
+ }
148
+ // Set prelimiary length and make room in this BigUnsigned
149
+ len = a2->len + 1;
150
+ allocate(len);
151
+ // For each block index that is present in both inputs...
152
+ for (i = 0, carryIn = false; i < b2->len; i++) {
153
+ // Add input blocks
154
+ temp = a2->blk[i] + b2->blk[i];
155
+ // If a rollover occurred, the result is less than either input.
156
+ // This test is used many times in the BigUnsigned code.
157
+ carryOut = (temp < a2->blk[i]);
158
+ // If a carry was input, handle it
159
+ if (carryIn) {
160
+ temp++;
161
+ carryOut |= (temp == 0);
162
+ }
163
+ blk[i] = temp; // Save the addition result
164
+ carryIn = carryOut; // Pass the carry along
165
+ }
166
+ // If there is a carry left over, increase blocks until
167
+ // one does not roll over.
168
+ for (; i < a2->len && carryIn; i++) {
169
+ temp = a2->blk[i] + 1;
170
+ carryIn = (temp == 0);
171
+ blk[i] = temp;
172
+ }
173
+ // If the carry was resolved but the larger number
174
+ // still has blocks, copy them over.
175
+ for (; i < a2->len; i++)
176
+ blk[i] = a2->blk[i];
177
+ // Set the extra block if there's still a carry, decrease length otherwise
178
+ if (carryIn)
179
+ blk[i] = 1;
180
+ else
181
+ len--;
182
+ }
183
+
184
+ void BigUnsigned::subtract(const BigUnsigned &a, const BigUnsigned &b) {
185
+ DTRT_ALIASED(this == &a || this == &b, subtract(a, b));
186
+ if (b.len == 0) {
187
+ // If b is zero, copy a.
188
+ operator =(a);
189
+ return;
190
+ } else if (a.len < b.len)
191
+ // If a is shorter than b, the result is negative.
192
+ throw "BigUnsigned::subtract: "
193
+ "Negative result in unsigned calculation";
194
+ // Some variables...
195
+ bool borrowIn, borrowOut;
196
+ Blk temp;
197
+ Index i;
198
+ // Set preliminary length and make room
199
+ len = a.len;
200
+ allocate(len);
201
+ // For each block index that is present in both inputs...
202
+ for (i = 0, borrowIn = false; i < b.len; i++) {
203
+ temp = a.blk[i] - b.blk[i];
204
+ // If a reverse rollover occurred,
205
+ // the result is greater than the block from a.
206
+ borrowOut = (temp > a.blk[i]);
207
+ // Handle an incoming borrow
208
+ if (borrowIn) {
209
+ borrowOut |= (temp == 0);
210
+ temp--;
211
+ }
212
+ blk[i] = temp; // Save the subtraction result
213
+ borrowIn = borrowOut; // Pass the borrow along
214
+ }
215
+ // If there is a borrow left over, decrease blocks until
216
+ // one does not reverse rollover.
217
+ for (; i < a.len && borrowIn; i++) {
218
+ borrowIn = (a.blk[i] == 0);
219
+ blk[i] = a.blk[i] - 1;
220
+ }
221
+ /* If there's still a borrow, the result is negative.
222
+ * Throw an exception, but zero out this object so as to leave it in a
223
+ * predictable state. */
224
+ if (borrowIn) {
225
+ len = 0;
226
+ throw "BigUnsigned::subtract: Negative result in unsigned calculation";
227
+ } else
228
+ // Copy over the rest of the blocks
229
+ for (; i < a.len; i++)
230
+ blk[i] = a.blk[i];
231
+ // Zap leading zeros
232
+ zapLeadingZeros();
233
+ }
234
+
235
+ /*
236
+ * About the multiplication and division algorithms:
237
+ *
238
+ * I searched unsucessfully for fast C++ built-in operations like the `b_0'
239
+ * and `c_0' Knuth describes in Section 4.3.1 of ``The Art of Computer
240
+ * Programming'' (replace `place' by `Blk'):
241
+ *
242
+ * ``b_0[:] multiplication of a one-place integer by another one-place
243
+ * integer, giving a two-place answer;
244
+ *
245
+ * ``c_0[:] division of a two-place integer by a one-place integer,
246
+ * provided that the quotient is a one-place integer, and yielding
247
+ * also a one-place remainder.''
248
+ *
249
+ * I also missed his note that ``[b]y adjusting the word size, if
250
+ * necessary, nearly all computers will have these three operations
251
+ * available'', so I gave up on trying to use algorithms similar to his.
252
+ * A future version of the library might include such algorithms; I
253
+ * would welcome contributions from others for this.
254
+ *
255
+ * I eventually decided to use bit-shifting algorithms. To multiply `a'
256
+ * and `b', we zero out the result. Then, for each `1' bit in `a', we
257
+ * shift `b' left the appropriate amount and add it to the result.
258
+ * Similarly, to divide `a' by `b', we shift `b' left varying amounts,
259
+ * repeatedly trying to subtract it from `a'. When we succeed, we note
260
+ * the fact by setting a bit in the quotient. While these algorithms
261
+ * have the same O(n^2) time complexity as Knuth's, the ``constant factor''
262
+ * is likely to be larger.
263
+ *
264
+ * Because I used these algorithms, which require single-block addition
265
+ * and subtraction rather than single-block multiplication and division,
266
+ * the innermost loops of all four routines are very similar. Study one
267
+ * of them and all will become clear.
268
+ */
269
+
270
+ /*
271
+ * This is a little inline function used by both the multiplication
272
+ * routine and the division routine.
273
+ *
274
+ * `getShiftedBlock' returns the `x'th block of `num << y'.
275
+ * `y' may be anything from 0 to N - 1, and `x' may be anything from
276
+ * 0 to `num.len'.
277
+ *
278
+ * Two things contribute to this block:
279
+ *
280
+ * (1) The `N - y' low bits of `num.blk[x]', shifted `y' bits left.
281
+ *
282
+ * (2) The `y' high bits of `num.blk[x-1]', shifted `N - y' bits right.
283
+ *
284
+ * But we must be careful if `x == 0' or `x == num.len', in
285
+ * which case we should use 0 instead of (2) or (1), respectively.
286
+ *
287
+ * If `y == 0', then (2) contributes 0, as it should. However,
288
+ * in some computer environments, for a reason I cannot understand,
289
+ * `a >> b' means `a >> (b % N)'. This means `num.blk[x-1] >> (N - y)'
290
+ * will return `num.blk[x-1]' instead of the desired 0 when `y == 0';
291
+ * the test `y == 0' handles this case specially.
292
+ */
293
+ inline BigUnsigned::Blk getShiftedBlock(const BigUnsigned &num,
294
+ BigUnsigned::Index x, unsigned int y) {
295
+ BigUnsigned::Blk part1 = (x == 0 || y == 0) ? 0 : (num.blk[x - 1] >> (BigUnsigned::N - y));
296
+ BigUnsigned::Blk part2 = (x == num.len) ? 0 : (num.blk[x] << y);
297
+ return part1 | part2;
298
+ }
299
+
300
+ void BigUnsigned::multiply(const BigUnsigned &a, const BigUnsigned &b) {
301
+ DTRT_ALIASED(this == &a || this == &b, multiply(a, b));
302
+ // If either a or b is zero, set to zero.
303
+ if (a.len == 0 || b.len == 0) {
304
+ len = 0;
305
+ return;
306
+ }
307
+ /*
308
+ * Overall method:
309
+ *
310
+ * Set this = 0.
311
+ * For each 1-bit of `a' (say the `i2'th bit of block `i'):
312
+ * Add `b << (i blocks and i2 bits)' to *this.
313
+ */
314
+ // Variables for the calculation
315
+ Index i, j, k;
316
+ unsigned int i2;
317
+ Blk temp;
318
+ bool carryIn, carryOut;
319
+ // Set preliminary length and make room
320
+ len = a.len + b.len;
321
+ allocate(len);
322
+ // Zero out this object
323
+ for (i = 0; i < len; i++)
324
+ blk[i] = 0;
325
+ // For each block of the first number...
326
+ for (i = 0; i < a.len; i++) {
327
+ // For each 1-bit of that block...
328
+ for (i2 = 0; i2 < N; i2++) {
329
+ if ((a.blk[i] & (Blk(1) << i2)) == 0)
330
+ continue;
331
+ /*
332
+ * Add b to this, shifted left i blocks and i2 bits.
333
+ * j is the index in b, and k = i + j is the index in this.
334
+ *
335
+ * `getShiftedBlock', a short inline function defined above,
336
+ * is now used for the bit handling. It replaces the more
337
+ * complex `bHigh' code, in which each run of the loop dealt
338
+ * immediately with the low bits and saved the high bits to
339
+ * be picked up next time. The last run of the loop used to
340
+ * leave leftover high bits, which were handled separately.
341
+ * Instead, this loop runs an additional time with j == b.len.
342
+ * These changes were made on 2005.01.11.
343
+ */
344
+ for (j = 0, k = i, carryIn = false; j <= b.len; j++, k++) {
345
+ /*
346
+ * The body of this loop is very similar to the body of the first loop
347
+ * in `add', except that this loop does a `+=' instead of a `+'.
348
+ */
349
+ temp = blk[k] + getShiftedBlock(b, j, i2);
350
+ carryOut = (temp < blk[k]);
351
+ if (carryIn) {
352
+ temp++;
353
+ carryOut |= (temp == 0);
354
+ }
355
+ blk[k] = temp;
356
+ carryIn = carryOut;
357
+ }
358
+ // No more extra iteration to deal with `bHigh'.
359
+ // Roll-over a carry as necessary.
360
+ for (; carryIn; k++) {
361
+ blk[k]++;
362
+ carryIn = (blk[k] == 0);
363
+ }
364
+ }
365
+ }
366
+ // Zap possible leading zero
367
+ if (blk[len - 1] == 0)
368
+ len--;
369
+ }
370
+
371
+ /*
372
+ * DIVISION WITH REMAINDER
373
+ * This monstrous function mods *this by the given divisor b while storing the
374
+ * quotient in the given object q; at the end, *this contains the remainder.
375
+ * The seemingly bizarre pattern of inputs and outputs was chosen so that the
376
+ * function copies as little as possible (since it is implemented by repeated
377
+ * subtraction of multiples of b from *this).
378
+ *
379
+ * "modWithQuotient" might be a better name for this function, but I would
380
+ * rather not change the name now.
381
+ */
382
+ void BigUnsigned::divideWithRemainder(const BigUnsigned &b, BigUnsigned &q) {
383
+ /* Defending against aliased calls is more complex than usual because we
384
+ * are writing to both *this and q.
385
+ *
386
+ * It would be silly to try to write quotient and remainder to the
387
+ * same variable. Rule that out right away. */
388
+ if (this == &q)
389
+ throw "BigUnsigned::divideWithRemainder: Cannot write quotient and remainder into the same variable";
390
+ /* Now *this and q are separate, so the only concern is that b might be
391
+ * aliased to one of them. If so, use a temporary copy of b. */
392
+ if (this == &b || &q == &b) {
393
+ BigUnsigned tmpB(b);
394
+ divideWithRemainder(tmpB, q);
395
+ return;
396
+ }
397
+
398
+ /*
399
+ * Knuth's definition of mod (which this function uses) is somewhat
400
+ * different from the C++ definition of % in case of division by 0.
401
+ *
402
+ * We let a / 0 == 0 (it doesn't matter much) and a % 0 == a, no
403
+ * exceptions thrown. This allows us to preserve both Knuth's demand
404
+ * that a mod 0 == a and the useful property that
405
+ * (a / b) * b + (a % b) == a.
406
+ */
407
+ if (b.len == 0) {
408
+ q.len = 0;
409
+ return;
410
+ }
411
+
412
+ /*
413
+ * If *this.len < b.len, then *this < b, and we can be sure that b doesn't go into
414
+ * *this at all. The quotient is 0 and *this is already the remainder (so leave it alone).
415
+ */
416
+ if (len < b.len) {
417
+ q.len = 0;
418
+ return;
419
+ }
420
+
421
+ // At this point we know (*this).len >= b.len > 0. (Whew!)
422
+
423
+ /*
424
+ * Overall method:
425
+ *
426
+ * For each appropriate i and i2, decreasing:
427
+ * Subtract (b << (i blocks and i2 bits)) from *this, storing the
428
+ * result in subtractBuf.
429
+ * If the subtraction succeeds with a nonnegative result:
430
+ * Turn on bit i2 of block i of the quotient q.
431
+ * Copy subtractBuf back into *this.
432
+ * Otherwise bit i2 of block i remains off, and *this is unchanged.
433
+ *
434
+ * Eventually q will contain the entire quotient, and *this will
435
+ * be left with the remainder.
436
+ *
437
+ * subtractBuf[x] corresponds to blk[x], not blk[x+i], since 2005.01.11.
438
+ * But on a single iteration, we don't touch the i lowest blocks of blk
439
+ * (and don't use those of subtractBuf) because these blocks are
440
+ * unaffected by the subtraction: we are subtracting
441
+ * (b << (i blocks and i2 bits)), which ends in at least `i' zero
442
+ * blocks. */
443
+ // Variables for the calculation
444
+ Index i, j, k;
445
+ unsigned int i2;
446
+ Blk temp;
447
+ bool borrowIn, borrowOut;
448
+
449
+ /*
450
+ * Make sure we have an extra zero block just past the value.
451
+ *
452
+ * When we attempt a subtraction, we might shift `b' so
453
+ * its first block begins a few bits left of the dividend,
454
+ * and then we'll try to compare these extra bits with
455
+ * a nonexistent block to the left of the dividend. The
456
+ * extra zero block ensures sensible behavior; we need
457
+ * an extra block in `subtractBuf' for exactly the same reason.
458
+ */
459
+ Index origLen = len; // Save real length.
460
+ /* To avoid an out-of-bounds access in case of reallocation, allocate
461
+ * first and then increment the logical length. */
462
+ allocateAndCopy(len + 1);
463
+ len++;
464
+ blk[origLen] = 0; // Zero the added block.
465
+
466
+ // subtractBuf holds part of the result of a subtraction; see above.
467
+ Blk *subtractBuf = new Blk[len];
468
+
469
+ // Set preliminary length for quotient and make room
470
+ q.len = origLen - b.len + 1;
471
+ q.allocate(q.len);
472
+ // Zero out the quotient
473
+ for (i = 0; i < q.len; i++)
474
+ q.blk[i] = 0;
475
+
476
+ // For each possible left-shift of b in blocks...
477
+ i = q.len;
478
+ while (i > 0) {
479
+ i--;
480
+ // For each possible left-shift of b in bits...
481
+ // (Remember, N is the number of bits in a Blk.)
482
+ q.blk[i] = 0;
483
+ i2 = N;
484
+ while (i2 > 0) {
485
+ i2--;
486
+ /*
487
+ * Subtract b, shifted left i blocks and i2 bits, from *this,
488
+ * and store the answer in subtractBuf. In the for loop, `k == i + j'.
489
+ *
490
+ * Compare this to the middle section of `multiply'. They
491
+ * are in many ways analogous. See especially the discussion
492
+ * of `getShiftedBlock'.
493
+ */
494
+ for (j = 0, k = i, borrowIn = false; j <= b.len; j++, k++) {
495
+ temp = blk[k] - getShiftedBlock(b, j, i2);
496
+ borrowOut = (temp > blk[k]);
497
+ if (borrowIn) {
498
+ borrowOut |= (temp == 0);
499
+ temp--;
500
+ }
501
+ // Since 2005.01.11, indices of `subtractBuf' directly match those of `blk', so use `k'.
502
+ subtractBuf[k] = temp;
503
+ borrowIn = borrowOut;
504
+ }
505
+ // No more extra iteration to deal with `bHigh'.
506
+ // Roll-over a borrow as necessary.
507
+ for (; k < origLen && borrowIn; k++) {
508
+ borrowIn = (blk[k] == 0);
509
+ subtractBuf[k] = blk[k] - 1;
510
+ }
511
+ /*
512
+ * If the subtraction was performed successfully (!borrowIn),
513
+ * set bit i2 in block i of the quotient.
514
+ *
515
+ * Then, copy the portion of subtractBuf filled by the subtraction
516
+ * back to *this. This portion starts with block i and ends--
517
+ * where? Not necessarily at block `i + b.len'! Well, we
518
+ * increased k every time we saved a block into subtractBuf, so
519
+ * the region of subtractBuf we copy is just [i, k).
520
+ */
521
+ if (!borrowIn) {
522
+ q.blk[i] |= (Blk(1) << i2);
523
+ while (k > i) {
524
+ k--;
525
+ blk[k] = subtractBuf[k];
526
+ }
527
+ }
528
+ }
529
+ }
530
+ // Zap possible leading zero in quotient
531
+ if (q.blk[q.len - 1] == 0)
532
+ q.len--;
533
+ // Zap any/all leading zeros in remainder
534
+ zapLeadingZeros();
535
+ // Deallocate subtractBuf.
536
+ // (Thanks to Brad Spencer for noticing my accidental omission of this!)
537
+ delete [] subtractBuf;
538
+ }
539
+
540
+ /* BITWISE OPERATORS
541
+ * These are straightforward blockwise operations except that they differ in
542
+ * the output length and the necessity of zapLeadingZeros. */
543
+
544
+ void BigUnsigned::bitAnd(const BigUnsigned &a, const BigUnsigned &b) {
545
+ DTRT_ALIASED(this == &a || this == &b, bitAnd(a, b));
546
+ // The bitwise & can't be longer than either operand.
547
+ len = (a.len >= b.len) ? b.len : a.len;
548
+ allocate(len);
549
+ Index i;
550
+ for (i = 0; i < len; i++)
551
+ blk[i] = a.blk[i] & b.blk[i];
552
+ zapLeadingZeros();
553
+ }
554
+
555
+ void BigUnsigned::bitOr(const BigUnsigned &a, const BigUnsigned &b) {
556
+ DTRT_ALIASED(this == &a || this == &b, bitOr(a, b));
557
+ Index i;
558
+ const BigUnsigned *a2, *b2;
559
+ if (a.len >= b.len) {
560
+ a2 = &a;
561
+ b2 = &b;
562
+ } else {
563
+ a2 = &b;
564
+ b2 = &a;
565
+ }
566
+ allocate(a2->len);
567
+ for (i = 0; i < b2->len; i++)
568
+ blk[i] = a2->blk[i] | b2->blk[i];
569
+ for (; i < a2->len; i++)
570
+ blk[i] = a2->blk[i];
571
+ len = a2->len;
572
+ // Doesn't need zapLeadingZeros.
573
+ }
574
+
575
+ void BigUnsigned::bitXor(const BigUnsigned &a, const BigUnsigned &b) {
576
+ DTRT_ALIASED(this == &a || this == &b, bitXor(a, b));
577
+ Index i;
578
+ const BigUnsigned *a2, *b2;
579
+ if (a.len >= b.len) {
580
+ a2 = &a;
581
+ b2 = &b;
582
+ } else {
583
+ a2 = &b;
584
+ b2 = &a;
585
+ }
586
+ allocate(a2->len);
587
+ for (i = 0; i < b2->len; i++)
588
+ blk[i] = a2->blk[i] ^ b2->blk[i];
589
+ for (; i < a2->len; i++)
590
+ blk[i] = a2->blk[i];
591
+ len = a2->len;
592
+ zapLeadingZeros();
593
+ }
594
+
595
+ void BigUnsigned::bitShiftLeft(const BigUnsigned &a, int b) {
596
+ DTRT_ALIASED(this == &a, bitShiftLeft(a, b));
597
+ if (b < 0) {
598
+ if (b << 1 == 0)
599
+ throw "BigUnsigned::bitShiftLeft: "
600
+ "Pathological shift amount not implemented";
601
+ else {
602
+ bitShiftRight(a, -b);
603
+ return;
604
+ }
605
+ }
606
+ Index shiftBlocks = b / N;
607
+ unsigned int shiftBits = b % N;
608
+ // + 1: room for high bits nudged left into another block
609
+ len = a.len + shiftBlocks + 1;
610
+ allocate(len);
611
+ Index i, j;
612
+ for (i = 0; i < shiftBlocks; i++)
613
+ blk[i] = 0;
614
+ for (j = 0, i = shiftBlocks; j <= a.len; j++, i++)
615
+ blk[i] = getShiftedBlock(a, j, shiftBits);
616
+ // Zap possible leading zero
617
+ if (blk[len - 1] == 0)
618
+ len--;
619
+ }
620
+
621
+ void BigUnsigned::bitShiftRight(const BigUnsigned &a, int b) {
622
+ DTRT_ALIASED(this == &a, bitShiftRight(a, b));
623
+ if (b < 0) {
624
+ if (b << 1 == 0)
625
+ throw "BigUnsigned::bitShiftRight: "
626
+ "Pathological shift amount not implemented";
627
+ else {
628
+ bitShiftLeft(a, -b);
629
+ return;
630
+ }
631
+ }
632
+ // This calculation is wacky, but expressing the shift as a left bit shift
633
+ // within each block lets us use getShiftedBlock.
634
+ Index rightShiftBlocks = (b + N - 1) / N;
635
+ unsigned int leftShiftBits = N * rightShiftBlocks - b;
636
+ // Now (N * rightShiftBlocks - leftShiftBits) == b
637
+ // and 0 <= leftShiftBits < N.
638
+ if (rightShiftBlocks >= a.len + 1) {
639
+ // All of a is guaranteed to be shifted off, even considering the left
640
+ // bit shift.
641
+ len = 0;
642
+ return;
643
+ }
644
+ // Now we're allocating a positive amount.
645
+ // + 1: room for high bits nudged left into another block
646
+ len = a.len + 1 - rightShiftBlocks;
647
+ allocate(len);
648
+ Index i, j;
649
+ for (j = rightShiftBlocks, i = 0; j <= a.len; j++, i++)
650
+ blk[i] = getShiftedBlock(a, j, leftShiftBits);
651
+ // Zap possible leading zero
652
+ if (blk[len - 1] == 0)
653
+ len--;
654
+ }
655
+
656
+ // INCREMENT/DECREMENT OPERATORS
657
+
658
+ // Prefix increment
659
+ void BigUnsigned::operator ++() {
660
+ Index i;
661
+ bool carry = true;
662
+ for (i = 0; i < len && carry; i++) {
663
+ blk[i]++;
664
+ carry = (blk[i] == 0);
665
+ }
666
+ if (carry) {
667
+ // Allocate and then increase length, as in divideWithRemainder
668
+ allocateAndCopy(len + 1);
669
+ len++;
670
+ blk[i] = 1;
671
+ }
672
+ }
673
+
674
+ // Postfix increment: same as prefix
675
+ void BigUnsigned::operator ++(int) {
676
+ operator ++();
677
+ }
678
+
679
+ // Prefix decrement
680
+ void BigUnsigned::operator --() {
681
+ if (len == 0)
682
+ throw "BigUnsigned::operator --(): Cannot decrement an unsigned zero";
683
+ Index i;
684
+ bool borrow = true;
685
+ for (i = 0; borrow; i++) {
686
+ borrow = (blk[i] == 0);
687
+ blk[i]--;
688
+ }
689
+ // Zap possible leading zero (there can only be one)
690
+ if (blk[len - 1] == 0)
691
+ len--;
692
+ }
693
+
694
+ // Postfix decrement: same as prefix
695
+ void BigUnsigned::operator --(int) {
696
+ operator --();
697
+ }