rhodes 2.3.2 → 2.4.0.beta.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (623) hide show
  1. data/CHANGELOG +18 -0
  2. data/CREDITS +38 -0
  3. data/README.md +2 -2
  4. data/Rakefile +60 -2
  5. data/bin/set-rhodes-sdk.bat +1 -0
  6. data/doc/application.txt +11 -0
  7. data/doc/build.txt +156 -39
  8. data/doc/configuration.txt +1 -10
  9. data/doc/connect-to-web-services.txt +6 -6
  10. data/doc/device-caps.txt +48 -5
  11. data/doc/extensions.txt +8 -1
  12. data/doc/rhom.txt +16 -0
  13. data/doc/synchronization.txt +56 -14
  14. data/doc/ui.txt +23 -2
  15. data/installer/instant-rhodes.nsi +6 -6
  16. data/lib/extensions/barcode/ext/barcode/platform/iphone/Barcode.xcodeproj/project.pbxproj +4 -2
  17. data/lib/extensions/barcode/ext/barcode/platform/wm/Rakefile +1 -1
  18. data/lib/extensions/digest-md5/ext/Rakefile +3 -3
  19. data/lib/extensions/digest-md5/ext/build +0 -1
  20. data/lib/extensions/digest-sha1/ext/Rakefile +1 -1
  21. data/lib/extensions/digest-sha1/ext/build +0 -1
  22. data/lib/extensions/digest/ext/Rakefile +3 -3
  23. data/lib/extensions/digest/ext/build +0 -1
  24. data/lib/extensions/fcntl/ext/Rakefile +1 -1
  25. data/lib/extensions/mspec/mspec/guards/guard.rb +4 -0
  26. data/lib/extensions/mspec/mspec/helpers/environment.rb +4 -0
  27. data/lib/extensions/nfc/ext.yml +2 -0
  28. data/lib/extensions/nfc/ext/build +12 -0
  29. data/lib/extensions/nfc/ext/build.bat +8 -0
  30. data/lib/extensions/nfc/ext/nfc/platform/android/AndroidManifest.xml +25 -0
  31. data/lib/extensions/nfc/ext/nfc/platform/android/Rakefile +94 -0
  32. data/lib/extensions/nfc/ext/nfc/platform/android/ext_build.files +4 -0
  33. data/lib/extensions/nfc/ext/nfc/platform/android/jni/src/nfc.cpp +404 -0
  34. data/lib/extensions/nfc/ext/nfc/platform/android/src/com/nfc/Nfc.java +138 -0
  35. data/lib/extensions/nfc/ext/nfc/platform/android/src/com/nfc/NfcMessage.java +34 -0
  36. data/lib/extensions/nfc/ext/nfc/platform/android/src/com/nfc/NfcMessagePack.java +33 -0
  37. data/lib/extensions/nfc/ext/nfc/platform/android/src/com/nfc/NfcRecord.java +149 -0
  38. data/lib/extensions/nfc/ext/nfc/shared/ruby/nfc.i +22 -0
  39. data/lib/extensions/nfc/ext/nfc/shared/ruby/nfc_wrap.c +2034 -0
  40. data/lib/extensions/nfc/nfc.rb +120 -0
  41. data/lib/extensions/rholang/{lang_ca.rb → rholang/lang_ca.rb} +0 -0
  42. data/lib/extensions/rholang/{lang_cf.rb → rholang/lang_cf.rb} +0 -0
  43. data/lib/extensions/rholang/{lang_chef.rb → rholang/lang_chef.rb} +0 -0
  44. data/lib/extensions/rholang/{lang_cs.rb → rholang/lang_cs.rb} +0 -0
  45. data/lib/extensions/rholang/{lang_da.rb → rholang/lang_da.rb} +0 -0
  46. data/lib/extensions/rholang/{lang_de.rb → rholang/lang_de.rb} +0 -0
  47. data/lib/extensions/rholang/{lang_es.rb → rholang/lang_es.rb} +0 -0
  48. data/lib/extensions/rholang/{lang_es_ar.rb → rholang/lang_es_ar.rb} +0 -0
  49. data/lib/extensions/rholang/{lang_fi.rb → rholang/lang_fi.rb} +0 -0
  50. data/lib/extensions/rholang/{lang_fr.rb → rholang/lang_fr.rb} +0 -0
  51. data/lib/extensions/rholang/{lang_it.rb → rholang/lang_it.rb} +0 -0
  52. data/lib/extensions/rholang/{lang_ko.rb → rholang/lang_ko.rb} +0 -0
  53. data/lib/extensions/rholang/{lang_nl.rb → rholang/lang_nl.rb} +0 -0
  54. data/lib/extensions/rholang/{lang_no.rb → rholang/lang_no.rb} +0 -0
  55. data/lib/extensions/rholang/{lang_pt.rb → rholang/lang_pt.rb} +0 -0
  56. data/lib/extensions/rholang/{lang_pt_br.rb → rholang/lang_pt_br.rb} +0 -0
  57. data/lib/extensions/rholang/{lang_ru.rb → rholang/lang_ru.rb} +0 -0
  58. data/lib/extensions/rholang/{lang_se.rb → rholang/lang_se.rb} +0 -0
  59. data/lib/extensions/rholang/{lang_sr.rb → rholang/lang_sr.rb} +0 -0
  60. data/lib/extensions/rholang/{rhoerror_ru.rb → rholang/rhoerror_ru.rb} +0 -0
  61. data/lib/extensions/rholang/{rhomsg_ru.rb → rholang/rhomsg_ru.rb} +0 -0
  62. data/lib/framework/date/format.rb +2 -0
  63. data/lib/framework/dateOrig.rb +17 -8
  64. data/lib/framework/rational18.rb +532 -0
  65. data/lib/framework/res/back_btn.wp7.png +0 -0
  66. data/lib/framework/res/blue_pushpin.wp7.png +0 -0
  67. data/lib/framework/res/blue_pushpin_small.wp7.png +0 -0
  68. data/lib/framework/res/callout.wp7.png +0 -0
  69. data/lib/framework/res/callout_link.wp7.png +0 -0
  70. data/lib/framework/res/esri.wp7.png +0 -0
  71. data/lib/framework/res/forward_btn.wp7.png +0 -0
  72. data/lib/framework/res/home_btn.wp7.png +0 -0
  73. data/lib/framework/res/options_btn.wp7.png +0 -0
  74. data/lib/framework/res/refresh_btn.wp7.png +0 -0
  75. data/lib/framework/rho/render.rb +8 -1
  76. data/lib/framework/rho/rho.rb +30 -7
  77. data/lib/framework/rho/rhoapplication.rb +9 -4
  78. data/lib/framework/rho/rhofsconnector.rb +5 -1
  79. data/lib/framework/rho/rhotabbar.rb +8 -0
  80. data/lib/framework/rho/rhotoolbar.rb +1 -1
  81. data/lib/framework/rho/rhoviewhelpers.rb +18 -1
  82. data/lib/framework/rhodes.rb +1 -1
  83. data/lib/framework/rhoframework.rb +46 -1
  84. data/lib/framework/rholang/localization_simplified.rb +17 -16
  85. data/lib/framework/rhom/rhom_db_adapter.rb +2 -2
  86. data/lib/framework/rhom/rhom_object_factory.rb +115 -12
  87. data/lib/framework/rhosystem.rb +135 -0
  88. data/lib/framework/version.rb +1 -1
  89. data/lib/rhodes.rb +1 -1
  90. data/lib/test/apps/rhoconfig.txt +23 -23
  91. data/platform/android/Rhodes/AndroidManifest.full.xml +101 -0
  92. data/platform/android/Rhodes/AndroidManifest.xml +10 -15
  93. data/platform/android/Rhodes/default.properties +11 -0
  94. data/platform/android/Rhodes/gen/com/rhomobile/rhodes/R.java +59 -53
  95. data/platform/android/Rhodes/jni/include/rhodes.h +1 -0
  96. data/platform/android/Rhodes/jni/include/rhodes/jni/com_rhomobile_rhodes_RhodesApplication.h +21 -0
  97. data/platform/android/Rhodes/jni/include/rhodes/jni/com_rhomobile_rhodes_alert_PopupActivity.h +21 -0
  98. data/platform/android/Rhodes/jni/include/rhodes/jni/com_rhomobile_rhodes_file_RhoFileApi.h +10 -2
  99. data/platform/android/Rhodes/jni/src/alert.cpp +2 -1
  100. data/platform/android/Rhodes/jni/src/datetimepicker.cpp +2 -0
  101. data/platform/android/Rhodes/jni/src/fileapi.cpp +671 -84
  102. data/platform/android/Rhodes/jni/src/nativebar.cpp +18 -0
  103. data/platform/android/Rhodes/jni/src/rhodes.cpp +92 -1
  104. data/platform/android/Rhodes/res/values/styles.xml +7 -0
  105. data/platform/android/Rhodes/src/com/rhomobile/rhodes/BaseActivity.java +35 -2
  106. data/platform/android/Rhodes/src/com/rhomobile/rhodes/Capabilities.java +12 -13
  107. data/platform/android/Rhodes/src/com/rhomobile/rhodes/LocalFileProvider.java +130 -0
  108. data/platform/android/Rhodes/src/com/rhomobile/rhodes/NativeBar.java +6 -0
  109. data/platform/android/Rhodes/src/com/rhomobile/rhodes/PushReceiver.java +5 -1
  110. data/platform/android/Rhodes/src/com/rhomobile/rhodes/PushService.java +6 -2
  111. data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhoMenu.java +7 -36
  112. data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesActivity.java +43 -20
  113. data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesApplication.java +2 -0
  114. data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesService.java +63 -28
  115. data/platform/android/Rhodes/src/com/rhomobile/rhodes/Utils.java +2 -2
  116. data/platform/android/Rhodes/src/com/rhomobile/rhodes/WebView.java +6 -2
  117. data/platform/android/Rhodes/src/com/rhomobile/rhodes/alert/Alert.java +19 -282
  118. data/platform/android/Rhodes/src/com/rhomobile/rhodes/alert/PopupActivity.java +354 -0
  119. data/platform/android/Rhodes/src/com/rhomobile/rhodes/datetime/DateTimePickerScreen.java +4 -0
  120. data/platform/android/Rhodes/src/com/rhomobile/rhodes/event/EventStore.java +1 -2
  121. data/platform/android/Rhodes/src/com/rhomobile/rhodes/file/RhoFileApi.java +71 -5
  122. data/platform/android/Rhodes/src/com/rhomobile/rhodes/geolocation/GeoLocationImpl.java +107 -37
  123. data/platform/android/Rhodes/src/com/rhomobile/rhodes/mainview/SimpleMainView.java +10 -7
  124. data/platform/android/Rhodes/src/com/rhomobile/rhodes/mainview/TabbedMainView.java +156 -56
  125. data/platform/android/Rhodes/src/com/rhomobile/rhodes/mapview/MapView.java +0 -1
  126. data/platform/android/Rhodes/src/com/rhomobile/rhodes/phonebook/ContactAccessorNew.java +40 -32
  127. data/platform/android/Rhodes/src/com/rhomobile/rhodes/signature/SignatureView.java +1 -0
  128. data/platform/android/Rhodes/src/com/rhomobile/rhodes/uri/ExternalHttpHandler.java +14 -6
  129. data/platform/android/Rhodes/src/com/rhomobile/rhodes/uri/LocalFileHandler.java +46 -0
  130. data/platform/android/Rhodes/src/com/rhomobile/rhodes/uri/MailUriHandler.java +4 -24
  131. data/platform/android/Rhodes/src/com/rhomobile/rhodes/uri/UriHandler.java +3 -1
  132. data/platform/android/build/RhodesSRC_build.files +28 -25
  133. data/platform/android/build/android.rake +230 -54
  134. data/platform/android/build/androidcommon.rb +1 -1
  135. data/platform/android/build/librhocommon_build.files +1 -0
  136. data/platform/bb/Hsqldb/BlackBerry_App_Descriptor.xml +20 -0
  137. data/platform/bb/Hsqldb/src/com/rho/db/HsqlDBResult.java +1 -5
  138. data/platform/bb/Hsqldb/src/com/rho/db/HsqlDBStorage.java +6 -1
  139. data/platform/bb/Hsqldb/src/org/hsqldb/rowio/RowOutputBase.java +1 -1
  140. data/platform/bb/Hsqldb/src/org/hsqldb/rowio/RowOutputBinary.java +1 -1
  141. data/platform/bb/RubyVM/BlackBerry_App_Descriptor.xml +20 -0
  142. data/platform/bb/RubyVM/src/com/rho/IRhoRubyHelper.java +2 -0
  143. data/platform/bb/RubyVM/src/com/rho/RhoLogOutputSink.java +0 -1
  144. data/platform/bb/RubyVM/src/com/rho/RhoLogger.java +12 -10
  145. data/platform/bb/RubyVM/src/com/rho/RhoThread.java +16 -0
  146. data/platform/bb/RubyVM/src/com/rho/RhoTimer.java +89 -0
  147. data/platform/bb/RubyVM/src/com/rho/RhodesApp.java +20 -13
  148. data/platform/bb/RubyVM/src/com/rho/SplashScreen.java +1 -2
  149. data/platform/bb/RubyVM/src/com/rho/ThreadQueue.java +2 -2
  150. data/platform/bb/RubyVM/src/com/rho/TimeInterval.java +5 -0
  151. data/platform/bb/RubyVM/src/com/rho/db/DBAdapter.java +54 -48
  152. data/platform/bb/RubyVM/src/com/rho/db/IDBResult.java +0 -1
  153. data/platform/bb/RubyVM/src/com/rho/db/IDBStorage.java +1 -0
  154. data/platform/bb/RubyVM/src/com/rho/net/AsyncHttp.java +1 -1
  155. data/platform/bb/RubyVM/src/com/rho/sync/ClientRegister.java +1 -1
  156. data/platform/bb/RubyVM/src/com/rho/sync/JSONStructIterator.java +1 -1
  157. data/platform/bb/RubyVM/src/com/rho/sync/SyncEngine.java +16 -8
  158. data/platform/bb/RubyVM/src/com/rho/sync/SyncNotify.java +2 -2
  159. data/platform/bb/RubyVM/src/com/rho/sync/SyncSource.java +52 -29
  160. data/platform/bb/RubyVM/src/com/rho/sync/SyncThread.java +1 -3
  161. data/platform/bb/build/RubyVM_build.files +1 -0
  162. data/platform/bb/build/bb.rake +29 -9
  163. data/platform/bb/rhodes/BlackBerry_App_Descriptor.xml +23 -0
  164. data/platform/bb/rhodes/platform/5.0/com/rho/RhodesApplicationPlatform.java +1 -1
  165. data/platform/bb/rhodes/platform/5.0/com/rho/db/SqliteCopyResult.java +0 -4
  166. data/platform/bb/rhodes/platform/5.0/com/rho/db/SqliteResult.java +13 -20
  167. data/platform/bb/rhodes/platform/5.0/com/rho/db/SqliteStorage.java +183 -157
  168. data/platform/bb/rhodes/src/com/rho/RhoRubyHelper.java +22 -0
  169. data/platform/bb/rhodes/src/com/rho/RhodesApplicationPlatform.java +1 -1
  170. data/platform/bb/rhodes/src/com/rho/db/SqliteCopyResult.java +0 -4
  171. data/platform/bb/rhodes/src/com/rho/db/SqliteResult.java +13 -20
  172. data/platform/bb/rhodes/src/com/rho/db/SqliteStorage.java +183 -157
  173. data/platform/bb/rhodes/src/com/rho/rubyext/System.java +46 -1
  174. data/platform/bb/rhodes/src/rhomobile/RhodesApplication.java +8 -1
  175. data/platform/bb/rhodes/src/rhomobile/camera/CameraFilesListener.java +13 -3
  176. data/platform/iphone/Classes/AppManager/AppManager.h +5 -1
  177. data/platform/iphone/Classes/AppManager/AppManager.m +170 -7
  178. data/platform/iphone/Classes/DateTimePicker.m +14 -1
  179. data/platform/iphone/Classes/DateTimePickerDelegate.h +2 -0
  180. data/platform/iphone/Classes/DateTimePickerDelegate.m +36 -2
  181. data/platform/iphone/Classes/NativeBar.h +1 -0
  182. data/platform/iphone/Classes/NativeBar.m +15 -3
  183. data/platform/iphone/Classes/Phonebook/phonebook.m +8 -9
  184. data/platform/iphone/Classes/Rhodes.m +50 -6
  185. data/platform/iphone/Classes/SimpleMainView.m +7 -6
  186. data/platform/iphone/Classes/SplitView/RightViewController.h +3 -1
  187. data/platform/iphone/Classes/SplitView/RightViewController.m +14 -1
  188. data/platform/iphone/Classes/TabbedMainView.h +4 -0
  189. data/platform/iphone/Classes/TabbedMainView.m +43 -26
  190. data/platform/iphone/Info.plist +1 -1
  191. data/platform/iphone/RhoLib/RhoLib.xcodeproj/project.pbxproj +4 -0
  192. data/platform/iphone/curl/curl.xcodeproj/project.pbxproj +3 -3
  193. data/platform/iphone/rbuild/iphone.rake +168 -119
  194. data/platform/iphone/rhoextlib/rhoextlib.xcodeproj/project.pbxproj +4 -2
  195. data/platform/iphone/rhorubylib/rhorubylib.xcodeproj/project.pbxproj +3 -3
  196. data/platform/iphone/rhorunner.xcodeproj/project.pbxproj +2 -2
  197. data/platform/iphone/rhosynclib/rhosynclib.xcodeproj/project.pbxproj +3 -3
  198. data/platform/shared/SyncClient/SyncClient.cpp +20 -8
  199. data/platform/shared/SyncClient/SyncClient.h +2 -1
  200. data/platform/shared/common/RhoDefs.h +4 -0
  201. data/platform/shared/common/RhoPort.h +22 -0
  202. data/platform/shared/common/RhoStd.h +5 -0
  203. data/platform/shared/common/RhoTime.cpp +73 -0
  204. data/platform/shared/common/RhoTime.h +26 -53
  205. data/platform/shared/common/RhodesApp.cpp +29 -28
  206. data/platform/shared/common/RhodesApp.h +4 -1
  207. data/platform/shared/common/StringConverter.h +37 -10
  208. data/platform/shared/common/app_build_capabilities.h +2 -0
  209. data/platform/shared/common/rhoparams.cpp +25 -12
  210. data/platform/shared/common/rhoparams.h +10 -8
  211. data/platform/shared/db/DBAdapter.cpp +0 -22
  212. data/platform/shared/json/RJSONTokener.c +15 -23
  213. data/platform/shared/net/AsyncHttp.cpp +9 -8
  214. data/platform/shared/net/HttpServer.cpp +61 -19
  215. data/platform/shared/net/HttpServer.h +2 -0
  216. data/platform/shared/ruby/ext/datetimepicker/datetimepicker.i +3 -0
  217. data/platform/shared/ruby/ext/datetimepicker/datetimepicker_wrap.c +151 -402
  218. data/platform/shared/ruby/ext/nativebar/nativebar.i +3 -0
  219. data/platform/shared/ruby/ext/nativebar/nativebar_wrap.c +154 -403
  220. data/platform/shared/ruby/ext/rho/rhoruby.c +4 -0
  221. data/platform/shared/ruby/ext/rho/rhoruby.h +2 -0
  222. data/platform/shared/ruby/ext/system/system.i +8 -0
  223. data/platform/shared/ruby/ext/system/system_wrap.c +80 -5
  224. data/platform/shared/ruby/file.c +6 -4
  225. data/platform/shared/ruby/gc.c +1 -1
  226. data/platform/shared/ruby/linux/ruby/config.h +7 -2
  227. data/platform/shared/ruby/missing/acosh.c +3 -3
  228. data/platform/shared/ruby/wince/_time.h +1 -1
  229. data/platform/shared/ruby/wince/stdlib.c +1 -1
  230. data/platform/shared/ruby/wince/string_wce.c +2 -2
  231. data/platform/shared/ruby/wince/sys/timeb.c +1 -0
  232. data/platform/shared/ruby/wince/time_wce.c +8 -0
  233. data/platform/shared/ruby/wince/wince.c +7 -7
  234. data/platform/shared/ruby/wince/wince.h +22 -0
  235. data/platform/shared/rubyext/System.cpp +19 -1
  236. data/platform/shared/sqlite/sqlite3.c +18993 -8129
  237. data/platform/shared/sqlite/sqlite3.h +953 -358
  238. data/platform/shared/sqlite/sqlite3ext.h +42 -0
  239. data/platform/shared/sync/SyncEngine.cpp +10 -0
  240. data/platform/shared/sync/SyncSource.cpp +41 -19
  241. data/platform/shared/sync/SyncSource.h +1 -1
  242. data/platform/shared/tcmalloc/rhomem.h +7 -2
  243. data/platform/shared/tcmalloc/windows/port.h +2 -0
  244. data/platform/shared/unzip/unzip.cpp +1 -0
  245. data/platform/shared/xruby/src/com/xruby/compiler/parser/RubyParser.java +11 -1
  246. data/platform/wm/RhoLib/RhoLib.vcproj +182 -24
  247. data/platform/wm/build/wm.rake +16 -3
  248. data/platform/wm/rhodes.sln +106 -113
  249. data/platform/wm/rhodes/Alert.cpp +6 -7
  250. data/platform/wm/rhodes/AppManager.cpp +8 -17
  251. data/platform/wm/rhodes/DateTimePicker.cpp +3 -0
  252. data/platform/wm/rhodes/DateTimePicker.h +2 -0
  253. data/platform/wm/rhodes/MainWindow.cpp +36 -16
  254. data/platform/wm/rhodes/MainWindow.h +6 -3
  255. data/platform/wm/rhodes/OutlookApp.cpp +3 -3
  256. data/platform/wm/rhodes/Rhodes.cpp +46 -27
  257. data/platform/wm/rhodes/Rhodes.rc +16 -3
  258. data/platform/wm/rhodes/RingtoneManager.cpp +7 -7
  259. data/platform/wm/rhodes/RingtoneManager.h +1 -1
  260. data/platform/wm/rhodes/Utils.cpp +2 -1
  261. data/platform/wm/rhodes/bluetooth/Bluetooth.cpp +1 -13
  262. data/platform/wm/rhodes/bluetooth/Bluetooth.h +1 -2
  263. data/platform/wm/rhodes/camera/Camera.cpp +6 -12
  264. data/platform/wm/rhodes/phonebook/phonebook.cpp +11 -11
  265. data/platform/wm/rhodes/phonebook/phonebook.h +1 -1
  266. data/platform/wm/rhodes/resource.h +3 -1
  267. data/platform/wm/rhodes/rho/net/NetRequestImpl.cpp +7 -5
  268. data/platform/wm/rhodes/rho/rubyext/GeoLocationImpl.cpp +6 -6
  269. data/platform/wm/rhodes/rho/rubyext/GeoLocationImpl.h +1 -1
  270. data/platform/wm/rhodes/rho/rubyext/NativeToolbar.cpp +6 -1
  271. data/platform/wm/rhodes/rho/rubyext/SystemImpl.cpp +84 -19
  272. data/platform/wm/rhodes/rho/rubyext/calendar.cpp +2 -2
  273. data/platform/wm/rhodes/rhodes.vcproj +316 -73
  274. data/platform/wm/rhodes/signature/Signature.cpp +336 -6
  275. data/platform/wm/rhodes/signature/Signature.h +55 -0
  276. data/platform/wm/rhodes/stdafx.h +7 -4
  277. data/platform/wm/rubylib/rubylib.vcproj +261 -91
  278. data/platform/wm/sqlite3/sqlite3.vcproj +223 -69
  279. data/platform/wm/syncengine/syncengine.vcproj +220 -66
  280. data/platform/wm/tcmalloc/tcmalloc.vcproj +197 -43
  281. data/platform/wp7/IronRuby/Languages/Ruby/Ruby/Builtins/ConsoleStream.cs +107 -0
  282. data/platform/wp7/IronRuby/Languages/Ruby/Ruby/Runtime/Loader.cs +1037 -0
  283. data/platform/wp7/IronRuby/Languages/Ruby/Ruby/Runtime/RubyUtils.cs +1476 -0
  284. data/platform/wp7/RhoAppRunner/Program.cs +55 -0
  285. data/platform/wp7/RhoAppRunner/Properties/AssemblyInfo.cs +36 -0
  286. data/platform/wp7/RhoAppRunner/RhoAppRunner.csproj +69 -0
  287. data/platform/wp7/RhoRubyExtGen/GenerateInitializers.cmd +7 -0
  288. data/platform/wp7/RhoRubyExtGen/Properties/AssemblyInfo.cs +36 -0
  289. data/platform/wp7/RhoRubyExtGen/RhoAsyncHttp.cs +38 -0
  290. data/platform/wp7/RhoRubyExtGen/RhoDatabase.cs +93 -0
  291. data/platform/wp7/RhoRubyExtGen/RhoJSON.cs +37 -0
  292. data/platform/wp7/RhoRubyExtGen/RhoNativeBar.cs +106 -0
  293. data/platform/wp7/RhoRubyExtGen/RhoRubyExtGen.csproj +75 -0
  294. data/platform/wp7/RhoRubyExtGen/RhoSyncEngine.cs +123 -0
  295. data/platform/wp7/RhoRubyExtGen/RhoWebView.cs +42 -0
  296. data/platform/wp7/RhoRubyLib/Initializers.Generated.cs +309 -0
  297. data/platform/wp7/RhoRubyLib/Properties/AssemblyInfo.cs +36 -0
  298. data/platform/wp7/RhoRubyLib/RhoAppAdapter.cs +96 -0
  299. data/platform/wp7/RhoRubyLib/RhoRuby.cs +296 -0
  300. data/platform/wp7/RhoRubyLib/RhoRubyLib.csproj +155 -0
  301. data/platform/wp7/RhoRubyLib/WP_PlatformAdaptationLayer.cs +107 -0
  302. data/platform/wp7/RhoRubyLib/common/IInputStream.cs +21 -0
  303. data/platform/wp7/RhoRubyLib/common/Mutex.cs +30 -0
  304. data/platform/wp7/RhoRubyLib/common/RhoConf.cs +389 -0
  305. data/platform/wp7/RhoRubyLib/common/RhoEmptyProfiler.cs +27 -0
  306. data/platform/wp7/RhoRubyLib/common/RhoFile.cs +332 -0
  307. data/platform/wp7/RhoRubyLib/common/RhoFilePath.cs +89 -0
  308. data/platform/wp7/RhoRubyLib/common/RhoParamArray.cs +33 -0
  309. data/platform/wp7/RhoRubyLib/common/RhoParams.cs +66 -0
  310. data/platform/wp7/RhoRubyLib/common/RhoProfiler.cs +145 -0
  311. data/platform/wp7/RhoRubyLib/common/RhoResourceMap.cs +68 -0
  312. data/platform/wp7/RhoRubyLib/common/RhoStd.cs +205 -0
  313. data/platform/wp7/RhoRubyLib/common/RhoThread.cs +114 -0
  314. data/platform/wp7/RhoRubyLib/common/RhodesApp.cs +504 -0
  315. data/platform/wp7/RhoRubyLib/common/ThreadQueue.cs +199 -0
  316. data/platform/wp7/RhoRubyLib/common/TimeInterval.cs +56 -0
  317. data/platform/wp7/RhoRubyLib/common/Tokenizer.cs +52 -0
  318. data/platform/wp7/RhoRubyLib/db/DBAdapter.cs +1129 -0
  319. data/platform/wp7/RhoRubyLib/db/DBAttrManager.cs +92 -0
  320. data/platform/wp7/RhoRubyLib/db/DBException.cs +35 -0
  321. data/platform/wp7/RhoRubyLib/db/IDBCallback.cs +10 -0
  322. data/platform/wp7/RhoRubyLib/db/IDBResult.cs +33 -0
  323. data/platform/wp7/RhoRubyLib/db/IDBStorage.cs +32 -0
  324. data/platform/wp7/RhoRubyLib/db/SqliteCopyResult.cs +79 -0
  325. data/platform/wp7/RhoRubyLib/db/SqliteResult.cs +267 -0
  326. data/platform/wp7/RhoRubyLib/db/SqliteStorage.cs +319 -0
  327. data/platform/wp7/RhoRubyLib/json/JSONArrayIterator.cs +63 -0
  328. data/platform/wp7/RhoRubyLib/json/JSONEntry.cs +96 -0
  329. data/platform/wp7/RhoRubyLib/json/JSONStructIterator.cs +77 -0
  330. data/platform/wp7/RhoRubyLib/json/JsonParser.cs +483 -0
  331. data/platform/wp7/RhoRubyLib/json/RJSONTokener.cs +406 -0
  332. data/platform/wp7/RhoRubyLib/logging/IRhoLogSink.cs +12 -0
  333. data/platform/wp7/RhoRubyLib/logging/RhoLogConf.cs +161 -0
  334. data/platform/wp7/RhoRubyLib/logging/RhoLogFileSink.cs +174 -0
  335. data/platform/wp7/RhoRubyLib/logging/RhoLogger.cs +320 -0
  336. data/platform/wp7/RhoRubyLib/net/AsyncHttp.cs +362 -0
  337. data/platform/wp7/RhoRubyLib/net/HttpServer.cs +466 -0
  338. data/platform/wp7/RhoRubyLib/net/NetRequest.cs +717 -0
  339. data/platform/wp7/RhoRubyLib/net/NetResponse.cs +64 -0
  340. data/platform/wp7/RhoRubyLib/net/URI.cs +187 -0
  341. data/platform/wp7/RhoRubyLib/rubyext/RhoAsyncHttp.cs +43 -0
  342. data/platform/wp7/RhoRubyLib/rubyext/RhoDatabase.cs +177 -0
  343. data/platform/wp7/RhoRubyLib/rubyext/RhoJSON.cs +39 -0
  344. data/platform/wp7/RhoRubyLib/rubyext/RhoKernelOps.cs +19 -0
  345. data/platform/wp7/RhoRubyLib/rubyext/RhoNativeBar.cs +117 -0
  346. data/platform/wp7/RhoRubyLib/rubyext/RhoSyncEngine.cs +199 -0
  347. data/platform/wp7/RhoRubyLib/rubyext/RhoWebView.cs +49 -0
  348. data/platform/wp7/RhoRubyLib/sync/ClientRegister.cs +142 -0
  349. data/platform/wp7/RhoRubyLib/sync/ISyncProtocol.cs +23 -0
  350. data/platform/wp7/RhoRubyLib/sync/ISyncStatusListener.cs +10 -0
  351. data/platform/wp7/RhoRubyLib/sync/SyncEngine.cs +1051 -0
  352. data/platform/wp7/RhoRubyLib/sync/SyncNotify.cs +651 -0
  353. data/platform/wp7/RhoRubyLib/sync/SyncProtocol_3.cs +79 -0
  354. data/platform/wp7/RhoRubyLib/sync/SyncSource.cs +1105 -0
  355. data/platform/wp7/RhoRubyLib/sync/SyncThread.cs +301 -0
  356. data/platform/wp7/WPApplication.sln +50 -0
  357. data/platform/wp7/WPApplication/App.xaml +19 -0
  358. data/platform/wp7/WPApplication/App.xaml.cs +211 -0
  359. data/platform/wp7/WPApplication/ApplicationIcon.png +0 -0
  360. data/platform/wp7/WPApplication/Background.png +0 -0
  361. data/platform/wp7/WPApplication/MainPage.xaml +44 -0
  362. data/platform/wp7/WPApplication/MainPage.xaml.cs +132 -0
  363. data/platform/wp7/WPApplication/Properties/AppManifest.xml +6 -0
  364. data/platform/wp7/WPApplication/Properties/AssemblyInfo.cs +35 -0
  365. data/platform/wp7/WPApplication/Properties/WMAppManifest.xml +32 -0
  366. data/platform/wp7/WPApplication/SplashScreenImage.jpg +0 -0
  367. data/platform/wp7/WPApplication/WPApplication.csproj +201 -0
  368. data/platform/wp7/WPApplication/WP_PlatformAdaptationLayer.cs +88 -0
  369. data/platform/wp7/WPApplication/app_manifest.txt +1 -0
  370. data/platform/wp7/WPApplication/readme.htm +40 -0
  371. data/platform/wp7/WPApplication/readme2.htm +37 -0
  372. data/platform/wp7/WPApplication/rho/apps/app/Model1/edit.bb.erb +29 -0
  373. data/platform/wp7/WPApplication/rho/apps/app/Model1/edit.erb +32 -0
  374. data/platform/wp7/WPApplication/rho/apps/app/Model1/index.bb.erb +21 -0
  375. data/platform/wp7/WPApplication/rho/apps/app/Model1/index.erb +26 -0
  376. data/platform/wp7/WPApplication/rho/apps/app/Model1/model1.rb +10 -0
  377. data/platform/wp7/WPApplication/rho/apps/app/Model1/model1_controller.rb +58 -0
  378. data/platform/wp7/WPApplication/rho/apps/app/Model1/new.bb.erb +29 -0
  379. data/platform/wp7/WPApplication/rho/apps/app/Model1/new.erb +31 -0
  380. data/platform/wp7/WPApplication/rho/apps/app/Model1/show.bb.erb +26 -0
  381. data/platform/wp7/WPApplication/rho/apps/app/Model1/show.erb +28 -0
  382. data/platform/wp7/WPApplication/rho/apps/app/Settings/controller.rb +75 -0
  383. data/platform/wp7/WPApplication/rho/apps/app/Settings/home.bb.erb +17 -0
  384. data/platform/wp7/WPApplication/rho/apps/app/Settings/home.erb +20 -0
  385. data/platform/wp7/WPApplication/rho/apps/app/Settings/index.bb.erb +32 -0
  386. data/platform/wp7/WPApplication/rho/apps/app/Settings/index.erb +30 -0
  387. data/platform/wp7/WPApplication/rho/apps/app/Settings/login.bb.erb +35 -0
  388. data/platform/wp7/WPApplication/rho/apps/app/Settings/login.erb +27 -0
  389. data/platform/wp7/WPApplication/rho/apps/app/Settings/reset.bb.erb +15 -0
  390. data/platform/wp7/WPApplication/rho/apps/app/Settings/reset.erb +17 -0
  391. data/platform/wp7/WPApplication/rho/apps/app/Settings/wait.bb.erb +3 -0
  392. data/platform/wp7/WPApplication/rho/apps/app/Settings/wait.erb +5 -0
  393. data/platform/wp7/WPApplication/rho/apps/app/application.rb +16 -0
  394. data/platform/wp7/WPApplication/rho/apps/app/helpers/application_helper.rb +126 -0
  395. data/platform/wp7/WPApplication/rho/apps/app/helpers/browser_helper.rb +18 -0
  396. data/platform/wp7/WPApplication/rho/apps/app/index.bb.erb +26 -0
  397. data/platform/wp7/WPApplication/rho/apps/app/index.erb +26 -0
  398. data/platform/wp7/WPApplication/rho/apps/app/layout.erb +45 -0
  399. data/platform/wp7/WPApplication/rho/apps/app/loading.html +11 -0
  400. data/platform/wp7/WPApplication/rho/apps/app_manifest.txt +1 -0
  401. data/platform/wp7/WPApplication/rho/apps/public/css/android.css +330 -0
  402. data/platform/wp7/WPApplication/rho/apps/public/css/blackberry.css +115 -0
  403. data/platform/wp7/WPApplication/rho/apps/public/css/iphone.css +410 -0
  404. data/platform/wp7/WPApplication/rho/apps/public/css/windows_mobile.css +222 -0
  405. data/platform/wp7/WPApplication/rho/apps/public/images/IUI_LICENSE.txt +21 -0
  406. data/platform/wp7/WPApplication/rho/apps/public/images/android/btn_check_off.png +0 -0
  407. data/platform/wp7/WPApplication/rho/apps/public/images/android/btn_check_on.png +0 -0
  408. data/platform/wp7/WPApplication/rho/apps/public/images/android/btn_radio_off.png +0 -0
  409. data/platform/wp7/WPApplication/rho/apps/public/images/android/btn_radio_on.png +0 -0
  410. data/platform/wp7/WPApplication/rho/apps/public/images/android/disclosure.png +0 -0
  411. data/platform/wp7/WPApplication/rho/apps/public/images/android/ic_menu_more.png +0 -0
  412. data/platform/wp7/WPApplication/rho/apps/public/images/backButton.png +0 -0
  413. data/platform/wp7/WPApplication/rho/apps/public/images/blueButton.png +0 -0
  414. data/platform/wp7/WPApplication/rho/apps/public/images/cancel.png +0 -0
  415. data/platform/wp7/WPApplication/rho/apps/public/images/grayButton.png +0 -0
  416. data/platform/wp7/WPApplication/rho/apps/public/images/iphone/disclosure.png +0 -0
  417. data/platform/wp7/WPApplication/rho/apps/public/images/iphone/disclosure_detail.png +0 -0
  418. data/platform/wp7/WPApplication/rho/apps/public/images/iphone/jqtouch/backButton.png +0 -0
  419. data/platform/wp7/WPApplication/rho/apps/public/images/iphone/jqtouch/blueButton.png +0 -0
  420. data/platform/wp7/WPApplication/rho/apps/public/images/iphone/jqtouch/cancel.png +0 -0
  421. data/platform/wp7/WPApplication/rho/apps/public/images/iphone/jqtouch/chevron.png +0 -0
  422. data/platform/wp7/WPApplication/rho/apps/public/images/iphone/jqtouch/grayButton.png +0 -0
  423. data/platform/wp7/WPApplication/rho/apps/public/images/iphone/jqtouch/listArrowSel.png +0 -0
  424. data/platform/wp7/WPApplication/rho/apps/public/images/iphone/jqtouch/listGroup.png +0 -0
  425. data/platform/wp7/WPApplication/rho/apps/public/images/iphone/jqtouch/loading.gif +0 -0
  426. data/platform/wp7/WPApplication/rho/apps/public/images/iphone/jqtouch/on_off.png +0 -0
  427. data/platform/wp7/WPApplication/rho/apps/public/images/iphone/jqtouch/pinstripes.png +0 -0
  428. data/platform/wp7/WPApplication/rho/apps/public/images/iphone/jqtouch/selection.png +0 -0
  429. data/platform/wp7/WPApplication/rho/apps/public/images/iphone/jqtouch/thumb.png +0 -0
  430. data/platform/wp7/WPApplication/rho/apps/public/images/iphone/jqtouch/toggle.png +0 -0
  431. data/platform/wp7/WPApplication/rho/apps/public/images/iphone/jqtouch/toggleOn.png +0 -0
  432. data/platform/wp7/WPApplication/rho/apps/public/images/iphone/jqtouch/toolButton.png +0 -0
  433. data/platform/wp7/WPApplication/rho/apps/public/images/iphone/jqtouch/toolbar.png +0 -0
  434. data/platform/wp7/WPApplication/rho/apps/public/images/iphone/jqtouch/whiteButton.png +0 -0
  435. data/platform/wp7/WPApplication/rho/apps/public/images/iphone/radiobutton.png +0 -0
  436. data/platform/wp7/WPApplication/rho/apps/public/images/iphone/select.png +0 -0
  437. data/platform/wp7/WPApplication/rho/apps/public/images/iphone/switch.png +0 -0
  438. data/platform/wp7/WPApplication/rho/apps/public/images/iui-logo-touch-icon.png +0 -0
  439. data/platform/wp7/WPApplication/rho/apps/public/images/listArrow.png +0 -0
  440. data/platform/wp7/WPApplication/rho/apps/public/images/listArrowDown.png +0 -0
  441. data/platform/wp7/WPApplication/rho/apps/public/images/listArrowSel.png +0 -0
  442. data/platform/wp7/WPApplication/rho/apps/public/images/listGroup.png +0 -0
  443. data/platform/wp7/WPApplication/rho/apps/public/images/loading.gif +0 -0
  444. data/platform/wp7/WPApplication/rho/apps/public/images/pinstripes.png +0 -0
  445. data/platform/wp7/WPApplication/rho/apps/public/images/right_button.png +0 -0
  446. data/platform/wp7/WPApplication/rho/apps/public/images/selection.png +0 -0
  447. data/platform/wp7/WPApplication/rho/apps/public/images/thumb.png +0 -0
  448. data/platform/wp7/WPApplication/rho/apps/public/images/toggle.png +0 -0
  449. data/platform/wp7/WPApplication/rho/apps/public/images/toggleOn.png +0 -0
  450. data/platform/wp7/WPApplication/rho/apps/public/images/toolButton.png +0 -0
  451. data/platform/wp7/WPApplication/rho/apps/public/images/toolButton_new.png +0 -0
  452. data/platform/wp7/WPApplication/rho/apps/public/images/toolbar.png +0 -0
  453. data/platform/wp7/WPApplication/rho/apps/public/images/whiteButton.png +0 -0
  454. data/platform/wp7/WPApplication/rho/apps/public/jqtouch/jqtouch-iphone.css +9 -0
  455. data/platform/wp7/WPApplication/rho/apps/public/jqtouch/jqtouch.css +374 -0
  456. data/platform/wp7/WPApplication/rho/apps/public/jqtouch/jqtouch.js +742 -0
  457. data/platform/wp7/WPApplication/rho/apps/public/jqtouch/jqtouch.transitions.js +60 -0
  458. data/platform/wp7/WPApplication/rho/apps/public/jqtouch/jquery.1.3.2.min.js +19 -0
  459. data/platform/wp7/WPApplication/rho/apps/public/js/application.js +1 -0
  460. data/platform/wp7/WPApplication/rho/apps/public/js/rho.js +4 -0
  461. data/platform/wp7/WPApplication/rho/apps/public/js/rhogeolocation-wm.js +59 -0
  462. data/platform/wp7/WPApplication/rho/apps/public/js/rhogeolocation.js +11 -0
  463. data/platform/wp7/WPApplication/rho/apps/rhoconfig.txt +32 -0
  464. data/platform/wp7/WPApplication/rhoconfig.txt +32 -0
  465. data/platform/wp7/WPApplication/windows_mobile.css +222 -0
  466. data/platform/wp7/build/wp.rake +261 -0
  467. data/platform/wp7/rhodes.sln +79 -0
  468. data/platform/wp7/rhodes/App.xaml +19 -0
  469. data/platform/wp7/rhodes/App.xaml.cs +144 -0
  470. data/platform/wp7/rhodes/Background.png +0 -0
  471. data/platform/wp7/rhodes/MainPage.xaml +44 -0
  472. data/platform/wp7/rhodes/MainPage.xaml.cs +98 -0
  473. data/platform/wp7/rhodes/Properties/AppManifest.xml +6 -0
  474. data/platform/wp7/rhodes/Properties/AssemblyInfo.cs +35 -0
  475. data/platform/wp7/rhodes/Properties/WMAppManifest.xml +31 -0
  476. data/platform/wp7/rhodes/Rhodes.csproj +127 -0
  477. data/platform/wp7/rhodes/SplashScreenImage.jpg +0 -0
  478. data/platform/wp7/rhodes/icon.png +0 -0
  479. data/platform/wp7/sqlite3/Properties/AssemblyInfo.cs +35 -0
  480. data/platform/wp7/sqlite3/SQLiteClient.cs +550 -0
  481. data/platform/wp7/sqlite3/SqliteWrapper/BtreeInt_h.cs +774 -0
  482. data/platform/wp7/sqlite3/SqliteWrapper/Btree_h.cs +280 -0
  483. data/platform/wp7/sqlite3/SqliteWrapper/ClassDiagram1.cd +1306 -0
  484. data/platform/wp7/sqlite3/SqliteWrapper/Delagates.cs +365 -0
  485. data/platform/wp7/sqlite3/SqliteWrapper/Hash_h.cs +133 -0
  486. data/platform/wp7/sqlite3/SqliteWrapper/VdbeInt_h.cs +620 -0
  487. data/platform/wp7/sqlite3/SqliteWrapper/Vdbe_h.cs +302 -0
  488. data/platform/wp7/sqlite3/SqliteWrapper/_Custom.cs +449 -0
  489. data/platform/wp7/sqlite3/SqliteWrapper/alter_c.cs +872 -0
  490. data/platform/wp7/sqlite3/SqliteWrapper/analyze_c.cs +757 -0
  491. data/platform/wp7/sqlite3/SqliteWrapper/attach_c.cs +628 -0
  492. data/platform/wp7/sqlite3/SqliteWrapper/auth_c.cs +268 -0
  493. data/platform/wp7/sqlite3/SqliteWrapper/backup_c.cs +737 -0
  494. data/platform/wp7/sqlite3/SqliteWrapper/bitvec_c.cs +509 -0
  495. data/platform/wp7/sqlite3/SqliteWrapper/btmutex_c.cs +379 -0
  496. data/platform/wp7/sqlite3/SqliteWrapper/btree_c.cs +9138 -0
  497. data/platform/wp7/sqlite3/SqliteWrapper/build_c.cs +4189 -0
  498. data/platform/wp7/sqlite3/SqliteWrapper/callback_c.cs +548 -0
  499. data/platform/wp7/sqlite3/SqliteWrapper/complete_c.cs +342 -0
  500. data/platform/wp7/sqlite3/SqliteWrapper/ctime_cs.cs +408 -0
  501. data/platform/wp7/sqlite3/SqliteWrapper/date_c.cs +1317 -0
  502. data/platform/wp7/sqlite3/SqliteWrapper/delete_c.cs +726 -0
  503. data/platform/wp7/sqlite3/SqliteWrapper/expr_c.cs +4406 -0
  504. data/platform/wp7/sqlite3/SqliteWrapper/fault_c.cs +115 -0
  505. data/platform/wp7/sqlite3/SqliteWrapper/fkey_c.cs +1330 -0
  506. data/platform/wp7/sqlite3/SqliteWrapper/func_c.cs +2025 -0
  507. data/platform/wp7/sqlite3/SqliteWrapper/global_c.cs +228 -0
  508. data/platform/wp7/sqlite3/SqliteWrapper/hash_c.cs +351 -0
  509. data/platform/wp7/sqlite3/SqliteWrapper/hwtime_c.cs +101 -0
  510. data/platform/wp7/sqlite3/SqliteWrapper/insert_c.cs +2122 -0
  511. data/platform/wp7/sqlite3/SqliteWrapper/journal_c.cs +247 -0
  512. data/platform/wp7/sqlite3/SqliteWrapper/keywordhash_h.cs +302 -0
  513. data/platform/wp7/sqlite3/SqliteWrapper/legacy_c.cs +223 -0
  514. data/platform/wp7/sqlite3/SqliteWrapper/loadext_c.cs +683 -0
  515. data/platform/wp7/sqlite3/SqliteWrapper/main_c.cs +2716 -0
  516. data/platform/wp7/sqlite3/SqliteWrapper/malloc_c.cs +977 -0
  517. data/platform/wp7/sqlite3/SqliteWrapper/mem_Pool.cs +394 -0
  518. data/platform/wp7/sqlite3/SqliteWrapper/memjournal_c.cs +315 -0
  519. data/platform/wp7/sqlite3/SqliteWrapper/mutex_c.cs +182 -0
  520. data/platform/wp7/sqlite3/SqliteWrapper/mutex_h.cs +91 -0
  521. data/platform/wp7/sqlite3/SqliteWrapper/mutex_noop_c.cs +202 -0
  522. data/platform/wp7/sqlite3/SqliteWrapper/mutex_w32.cs +344 -0
  523. data/platform/wp7/sqlite3/SqliteWrapper/notify_c.cs +347 -0
  524. data/platform/wp7/sqlite3/SqliteWrapper/opcodes_c.cs +171 -0
  525. data/platform/wp7/sqlite3/SqliteWrapper/opcodes_h.cs +346 -0
  526. data/platform/wp7/sqlite3/SqliteWrapper/os_c.cs +367 -0
  527. data/platform/wp7/sqlite3/SqliteWrapper/os_common_h.cs +174 -0
  528. data/platform/wp7/sqlite3/SqliteWrapper/os_h.cs +295 -0
  529. data/platform/wp7/sqlite3/SqliteWrapper/os_win_c.cs +1255 -0
  530. data/platform/wp7/sqlite3/SqliteWrapper/pager_c.cs +6078 -0
  531. data/platform/wp7/sqlite3/SqliteWrapper/pager_h.cs +188 -0
  532. data/platform/wp7/sqlite3/SqliteWrapper/parse_c.cs +4045 -0
  533. data/platform/wp7/sqlite3/SqliteWrapper/parse_h.cs +331 -0
  534. data/platform/wp7/sqlite3/SqliteWrapper/pcache1_c.cs +969 -0
  535. data/platform/wp7/sqlite3/SqliteWrapper/pcache_c.cs +712 -0
  536. data/platform/wp7/sqlite3/SqliteWrapper/pcache_h.cs +213 -0
  537. data/platform/wp7/sqlite3/SqliteWrapper/pragma_c.cs +1767 -0
  538. data/platform/wp7/sqlite3/SqliteWrapper/prepare_c.cs +1015 -0
  539. data/platform/wp7/sqlite3/SqliteWrapper/printf_c.cs +1300 -0
  540. data/platform/wp7/sqlite3/SqliteWrapper/random_c.cs +201 -0
  541. data/platform/wp7/sqlite3/SqliteWrapper/resolve_c.cs +1396 -0
  542. data/platform/wp7/sqlite3/SqliteWrapper/rowset_c.cs +519 -0
  543. data/platform/wp7/sqlite3/SqliteWrapper/select_c.cs +4878 -0
  544. data/platform/wp7/sqlite3/SqliteWrapper/sqlite3_h.cs +6253 -0
  545. data/platform/wp7/sqlite3/SqliteWrapper/sqlite3ext_h.cs +397 -0
  546. data/platform/wp7/sqlite3/SqliteWrapper/sqliteInt_h.cs +4075 -0
  547. data/platform/wp7/sqlite3/SqliteWrapper/sqliteLimit_h.cs +214 -0
  548. data/platform/wp7/sqlite3/SqliteWrapper/sqliteicu_h.cs +39 -0
  549. data/platform/wp7/sqlite3/SqliteWrapper/status_c.cs +155 -0
  550. data/platform/wp7/sqlite3/SqliteWrapper/table_c.cs +222 -0
  551. data/platform/wp7/sqlite3/SqliteWrapper/tokenize_c.cs +673 -0
  552. data/platform/wp7/sqlite3/SqliteWrapper/trigger_c.cs +1219 -0
  553. data/platform/wp7/sqlite3/SqliteWrapper/update_c.cs +766 -0
  554. data/platform/wp7/sqlite3/SqliteWrapper/utf_c.cs +612 -0
  555. data/platform/wp7/sqlite3/SqliteWrapper/util_c.cs +1476 -0
  556. data/platform/wp7/sqlite3/SqliteWrapper/vacuum_c.cs +382 -0
  557. data/platform/wp7/sqlite3/SqliteWrapper/vdbe_c.cs +6566 -0
  558. data/platform/wp7/sqlite3/SqliteWrapper/vdbeapi_c.cs +1557 -0
  559. data/platform/wp7/sqlite3/SqliteWrapper/vdbeaux_c.cs +4019 -0
  560. data/platform/wp7/sqlite3/SqliteWrapper/vdbeblob_c.cs +396 -0
  561. data/platform/wp7/sqlite3/SqliteWrapper/vdbemem_c.cs +1480 -0
  562. data/platform/wp7/sqlite3/SqliteWrapper/vdbetrace_c.cs +181 -0
  563. data/platform/wp7/sqlite3/SqliteWrapper/vtab_c.cs +957 -0
  564. data/platform/wp7/sqlite3/SqliteWrapper/walker_c.cs +174 -0
  565. data/platform/wp7/sqlite3/SqliteWrapper/where_c.cs +4651 -0
  566. data/platform/wp7/sqlite3/sqlite3.csproj +155 -0
  567. data/rakefile.rb +60 -2
  568. data/res/build-tools/7za.exe +0 -0
  569. data/res/build-tools/RhoAppRunner.exe +0 -0
  570. data/res/build-tools/xruby-0.3.3.jar +0 -0
  571. data/res/generators/rhogen.rb +9 -1
  572. data/res/generators/templates/application/app/Settings/reset.erb +1 -1
  573. data/res/generators/templates/application/app/layout.erb +17 -10
  574. data/res/generators/templates/application/build.yml +5 -3
  575. data/res/generators/templates/application/public/jqtouch/changes.txt +20 -0
  576. data/res/generators/templates/application/public/jqtouch/jqtouch.js +12 -4
  577. data/res/generators/templates/application/public/jqtouch/jquery.1.3.2.min.js +1 -1
  578. data/res/generators/templates/application/public/js/wp7.js +7 -0
  579. data/res/generators/templates/model/controller.rb +5 -6
  580. data/rhobuild.yml.example +1 -0
  581. data/rhodes.gemspec +2 -1
  582. data/spec/framework_spec/app/spec/core/dir/close_spec.rb +1 -1
  583. data/spec/framework_spec/app/spec/core/dir/shared/pwd.rb +13 -11
  584. data/spec/framework_spec/app/spec/core/env/shared/store.rb +12 -10
  585. data/spec/framework_spec/app/spec/core/env/update_spec.rb +1 -0
  586. data/spec/framework_spec/app/spec/core/file/expand_path_spec.rb +3 -2
  587. data/spec/framework_spec/app/spec/core/file/fixtures/file_types.rb +7 -1
  588. data/spec/framework_spec/app/spec/core/file/flock_spec.rb +8 -1
  589. data/spec/framework_spec/app/spec/core/file/ftype_spec.rb +5 -3
  590. data/spec/framework_spec/app/spec/core/file/lchmod_spec.rb +1 -1
  591. data/spec/framework_spec/app/spec/core/file/setgid_spec.rb +1 -1
  592. data/spec/framework_spec/app/spec/core/file/setuid_spec.rb +1 -1
  593. data/spec/framework_spec/app/spec/core/file/stat/ftype_spec.rb +6 -4
  594. data/spec/framework_spec/app/spec/core/file/truncate_spec.rb +5 -1
  595. data/spec/framework_spec/app/spec/core/float/to_s_spec.rb +1 -1
  596. data/spec/framework_spec/app/spec/core/process/gid_spec.rb +5 -3
  597. data/spec/framework_spec/app/spec/core/process/groups_spec.rb +11 -9
  598. data/spec/framework_spec/app/spec/core/process/uid_spec.rb +5 -3
  599. data/spec/framework_spec/app/spec/language/execution_spec.rb +10 -6
  600. data/spec/framework_spec/app/spec/shared/file/directory.rb +6 -1
  601. data/spec/framework_spec/app/spec/shared/file/executable.rb +7 -1
  602. data/spec/framework_spec/app/spec/shared/file/file.rb +6 -1
  603. data/spec/framework_spec/app/spec/shared/file/readable.rb +13 -4
  604. data/spec/framework_spec/app/spec/shared/file/writable.rb +6 -1
  605. data/spec/phone_spec/app/spec/rho_controller_spec.rb +11 -0
  606. data/spec/phone_spec/app/spec/rho_spec.rb +11 -0
  607. data/spec/phone_spec/app/spec/rhom_object_spec.rb +102 -6
  608. data/spec/phone_spec/app/spec/string/end_with_spec.rb +4 -1
  609. data/spec/phone_spec/app/spec/string/slice_spec.rb +5 -1
  610. data/spec/phone_spec/app/spec/string/start_with_spec.rb +4 -0
  611. data/spec/phone_spec/app/spec/syncengine_spec.rb +73 -6
  612. data/spec/phone_spec/app/spec_runner.rb +7 -3
  613. metadata +380 -41
  614. data/Manifest.txt +0 -5819
  615. data/platform/bb/Hsqldb/Hsqldb.cso +0 -5
  616. data/platform/bb/Hsqldb/Hsqldb.jdp +0 -197
  617. data/platform/bb/RhoBundle/RhoBundle.cso +0 -5
  618. data/platform/bb/RhoBundle/RhoBundle.jdp +0 -42
  619. data/platform/bb/RubyVM/RubyVM.cso +0 -5
  620. data/platform/bb/RubyVM/RubyVM.jdp +0 -467
  621. data/platform/bb/rhodes/rhodes.csl +0 -3
  622. data/platform/bb/rhodes/rhodes.cso +0 -5
  623. data/platform/bb/rhodes/rhodes.jdp +0 -104
@@ -0,0 +1,1476 @@
1
+ using System;
2
+ using System.Diagnostics;
3
+ using System.Text;
4
+
5
+ using i64 = System.Int64;
6
+
7
+ using u8 = System.Byte;
8
+ using u32 = System.UInt32;
9
+ using u64 = System.UInt64;
10
+
11
+ using Pgno = System.UInt32;
12
+
13
+
14
+ namespace Community.CsharpSqlite
15
+ {
16
+ using sqlite_int64 = System.Int64;
17
+ using System.Globalization;
18
+
19
+ public partial class Sqlite3
20
+ {
21
+ /*
22
+ ** 2001 September 15
23
+ **
24
+ ** The author disclaims copyright to this source code. In place of
25
+ ** a legal notice, here is a blessing:
26
+ **
27
+ ** May you do good and not evil.
28
+ ** May you find forgiveness for yourself and forgive others.
29
+ ** May you share freely, never taking more than you give.
30
+ **
31
+ *************************************************************************
32
+ ** Utility functions used throughout sqlite.
33
+ **
34
+ ** This file contains functions for allocating memory, comparing
35
+ ** strings, and stuff like that.
36
+ **
37
+ *************************************************************************
38
+ ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart
39
+ ** C#-SQLite is an independent reimplementation of the SQLite software library
40
+ **
41
+ ** SQLITE_SOURCE_ID: 2010-03-09 19:31:43 4ae453ea7be69018d8c16eb8dabe05617397dc4d
42
+ **
43
+ ** $Header$
44
+ *************************************************************************
45
+ */
46
+ //#include "sqliteInt.h"
47
+ //#include <stdarg.h>
48
+ #if SQLITE_HAVE_ISNAN
49
+ //# include <math.h>
50
+ #endif
51
+
52
+
53
+ /*
54
+ ** Routine needed to support the testcase() macro.
55
+ */
56
+ #if SQLITE_COVERAGE_TEST
57
+ void sqlite3Coverage(int x){
58
+ static int dummy = 0;
59
+ dummy += x;
60
+ }
61
+ #endif
62
+
63
+ #if !SQLITE_OMIT_FLOATING_POINT
64
+ /*
65
+ ** Return true if the floating point value is Not a Number (NaN).
66
+ **
67
+ ** Use the math library isnan() function if compiled with SQLITE_HAVE_ISNAN.
68
+ ** Otherwise, we have our own implementation that works on most systems.
69
+ */
70
+ static bool sqlite3IsNaN(double x)
71
+ {
72
+ bool rc; /* The value return */
73
+ #if !(SQLITE_HAVE_ISNAN)
74
+ /*
75
+ ** Systems that support the isnan() library function should probably
76
+ ** make use of it by compiling with -DSQLITE_HAVE_ISNAN. But we have
77
+ ** found that many systems do not have a working isnan() function so
78
+ ** this implementation is provided as an alternative.
79
+ **
80
+ ** This NaN test sometimes fails if compiled on GCC with -ffast-math.
81
+ ** On the other hand, the use of -ffast-math comes with the following
82
+ ** warning:
83
+ **
84
+ ** This option [-ffast-math] should never be turned on by any
85
+ ** -O option since it can result in incorrect output for programs
86
+ ** which depend on an exact implementation of IEEE or ISO
87
+ ** rules/specifications for math functions.
88
+ **
89
+ ** Under MSVC, this NaN test may fail if compiled with a floating-
90
+ ** point precision mode other than /fp:precise. From the MSDN
91
+ ** documentation:
92
+ **
93
+ ** The compiler [with /fp:precise] will properly handle comparisons
94
+ ** involving NaN. For example, x != x evaluates to true if x is NaN
95
+ ** ...
96
+ */
97
+ #if __FAST_MATH__
98
+ # error SQLite will not work correctly with the -ffast-math option of GCC.
99
+ #endif
100
+ double y = x;
101
+ double z = y;
102
+ rc = (y != z);
103
+ #else //* if defined(SQLITE_HAVE_ISNAN) */
104
+ rc = isnan(x);
105
+ #endif //* SQLITE_HAVE_ISNAN */
106
+ testcase(rc);
107
+ return rc;
108
+ }
109
+ #endif //* SQLITE_OMIT_FLOATING_POINT */
110
+
111
+ /*
112
+ ** Compute a string length that is limited to what can be stored in
113
+ ** lower 30 bits of a 32-bit signed integer.
114
+ **
115
+ ** The value returned will never be negative. Nor will it ever be greater
116
+ ** than the actual length of the string. For very long strings (greater
117
+ ** than 1GiB) the value returned might be less than the true string length.
118
+ */
119
+ static int sqlite3Strlen30(int z)
120
+ {
121
+ return 0x3fffffff & z;
122
+ }
123
+ static int sqlite3Strlen30(StringBuilder z)
124
+ {
125
+ //const char *z2 = z;
126
+ if (z == null) return 0;
127
+ //while( *z2 ){ z2++; }
128
+ //return 0x3fffffff & (int)(z2 - z);
129
+ return 0x3fffffff & z.Length;
130
+ }
131
+ static int sqlite3Strlen30(string z)
132
+ {
133
+ //const char *z2 = z;
134
+ if (z == null) return 0;
135
+ //while( *z2 ){ z2++; }
136
+ //return 0x3fffffff & (int)(z2 - z);
137
+ return 0x3fffffff & z.Length;
138
+ }
139
+
140
+
141
+ /*
142
+ ** Set the most recent error code and error string for the sqlite
143
+ ** handle "db". The error code is set to "err_code".
144
+ **
145
+ ** If it is not NULL, string zFormat specifies the format of the
146
+ ** error string in the style of the printf functions: The following
147
+ ** format characters are allowed:
148
+ **
149
+ ** %s Insert a string
150
+ ** %z A string that should be freed after use
151
+ ** %d Insert an integer
152
+ ** %T Insert a token
153
+ ** %S Insert the first element of a SrcList
154
+ **
155
+ ** zFormat and any string tokens that follow it are assumed to be
156
+ ** encoded in UTF-8.
157
+ **
158
+ ** To clear the most recent error for sqlite handle "db", sqlite3Error
159
+ ** should be called with err_code set to SQLITE_OK and zFormat set
160
+ ** to NULL.
161
+ */
162
+ //Overloads
163
+ static void sqlite3Error(sqlite3 db, int err_code, int noString)
164
+ { sqlite3Error(db, err_code, err_code == 0 ? null : ""); }
165
+
166
+ static void sqlite3Error(sqlite3 db, int err_code, string zFormat, params object[] ap)
167
+ {
168
+ if (db != null && (db.pErr != null || (db.pErr = sqlite3ValueNew(db)) != null))
169
+ {
170
+ db.errCode = err_code;
171
+ if (zFormat != null)
172
+ {
173
+ string z;
174
+ va_start(ap, zFormat);
175
+ z = sqlite3VMPrintf(db, zFormat, ap);
176
+ va_end(ap);
177
+ sqlite3ValueSetStr(db.pErr, -1, z, SQLITE_UTF8, (dxDel)SQLITE_DYNAMIC);
178
+ }
179
+ else
180
+ {
181
+ sqlite3ValueSetStr(db.pErr, 0, null, SQLITE_UTF8, SQLITE_STATIC);
182
+ }
183
+ }
184
+ }
185
+
186
+ /*
187
+ ** Add an error message to pParse.zErrMsg and increment pParse.nErr.
188
+ ** The following formatting characters are allowed:
189
+ **
190
+ ** %s Insert a string
191
+ ** %z A string that should be freed after use
192
+ ** %d Insert an integer
193
+ ** %T Insert a token
194
+ ** %S Insert the first element of a SrcList
195
+ **
196
+ ** This function should be used to report any error that occurs whilst
197
+ ** compiling an SQL statement (i.e. within sqlite3_prepare()). The
198
+ ** last thing the sqlite3_prepare() function does is copy the error
199
+ ** stored by this function into the database handle using sqlite3Error().
200
+ ** Function sqlite3Error() should be used during statement execution
201
+ ** (sqlite3_step() etc.).
202
+ */
203
+ static void sqlite3ErrorMsg(Parse pParse, string zFormat, params object[] ap)
204
+ {
205
+ string zMsg;
206
+ //va_list ap;
207
+ sqlite3 db = pParse.db;
208
+ va_start(ap, zFormat);
209
+ zMsg = sqlite3VMPrintf(db, zFormat, ap);
210
+ va_end(ap);
211
+ if (db.suppressErr != 0)
212
+ {
213
+ sqlite3DbFree(db, ref zMsg);
214
+ }
215
+ else
216
+ {
217
+ pParse.nErr++;
218
+ sqlite3DbFree(db, ref pParse.zErrMsg);
219
+ pParse.zErrMsg = zMsg;
220
+ pParse.rc = SQLITE_ERROR;
221
+ }
222
+ }
223
+
224
+ /*
225
+ ** Convert an SQL-style quoted string into a normal string by removing
226
+ ** the quote characters. The conversion is done in-place. If the
227
+ ** input does not begin with a quote character, then this routine
228
+ ** is a no-op.
229
+ **
230
+ ** The input string must be zero-terminated. A new zero-terminator
231
+ ** is added to the dequoted string.
232
+ **
233
+ ** The return value is -1 if no dequoting occurs or the length of the
234
+ ** dequoted string, exclusive of the zero terminator, if dequoting does
235
+ ** occur.
236
+ **
237
+ ** 2002-Feb-14: This routine is extended to remove MS-Access style
238
+ ** brackets from around identifers. For example: "[a-b-c]" becomes
239
+ ** "a-b-c".
240
+ */
241
+ static int sqlite3Dequote(ref string z)
242
+ {
243
+ char quote;
244
+ int i;
245
+ if (z == null || z == "") return -1;
246
+ quote = z[0];
247
+ switch (quote)
248
+ {
249
+ case '\'': break;
250
+ case '"': break;
251
+ case '`': break; /* For MySQL compatibility */
252
+ case '[': quote = ']'; break; /* For MS SqlServer compatibility */
253
+ default: return -1;
254
+ }
255
+ StringBuilder sbZ = new StringBuilder(z.Length);
256
+ for (i = 1; i < z.Length; i++) //z[i] != 0; i++)
257
+ {
258
+ if (z[i] == quote)
259
+ {
260
+ if (i < z.Length - 1 && (z[i + 1] == quote))
261
+ {
262
+ sbZ.Append(quote);
263
+ i++;
264
+ }
265
+ else
266
+ {
267
+ break;
268
+ }
269
+ }
270
+ else
271
+ {
272
+ sbZ.Append(z[i]);
273
+ }
274
+ }
275
+ z = sbZ.ToString();
276
+ return sbZ.Length;
277
+ }
278
+
279
+ /* Convenient short-hand */
280
+ //#define UpperToLower sqlite3UpperToLower
281
+ static int[] UpperToLower;
282
+
283
+ /*
284
+ ** Some systems have stricmp(). Others have strcasecmp(). Because
285
+ ** there is no consistency, we will define our own.
286
+ */
287
+
288
+ static int sqlite3StrICmp(string zLeft, string zRight)
289
+ {
290
+ //register unsigned char *a, *b;
291
+ //a = (unsigned char *)zLeft;
292
+ //b = (unsigned char *)zRight;
293
+ //while( *a!=0 && UpperToLower[*a]==UpperToLower[*b]){ a++; b++; }
294
+ //return UpperToLower[*a] - UpperToLower[*b];
295
+ int a = 0, b = 0;
296
+ if (zRight == null) return 0;
297
+ while (a < zLeft.Length && b < zRight.Length && UpperToLower[zLeft[a]] == UpperToLower[zRight[b]]) { a++; b++; }
298
+ if (a == zLeft.Length && b == zRight.Length) return 0;
299
+ else
300
+ {
301
+ if (a == zLeft.Length) return -UpperToLower[zRight[b]];
302
+ if (b == zRight.Length) return UpperToLower[zLeft[a]];
303
+ return UpperToLower[zLeft[a]] - UpperToLower[zRight[b]];
304
+ }
305
+ }
306
+
307
+ static int sqlite3_strnicmp(string zLeft, int offsetLeft, string zRight, int N)
308
+ { return sqlite3StrNICmp(zLeft, offsetLeft, zRight, N); }
309
+
310
+ static int sqlite3StrNICmp(string zLeft, int offsetLeft, string zRight, int N)
311
+ {
312
+ //register unsigned char *a, *b;
313
+ //a = (unsigned char *)zLeft;
314
+ //b = (unsigned char *)zRight;
315
+ int a = 0, b = 0;
316
+ while (N-- > 0 && a < zLeft.Length - offsetLeft && b < zRight.Length && zLeft[a + offsetLeft] != 0 && UpperToLower[zLeft[a + offsetLeft]] == UpperToLower[zRight[b]]) { a++; b++; }
317
+ return N < 0 ? 0 : ((a < zLeft.Length - offsetLeft)?UpperToLower[zLeft[a + offsetLeft]]:0) - UpperToLower[zRight[b]];
318
+ }
319
+
320
+ static int sqlite3StrNICmp(string zLeft, string zRight, int N)
321
+ {
322
+ //register unsigned char *a, *b;
323
+ //a = (unsigned char *)zLeft;
324
+ //b = (unsigned char *)zRight;
325
+ int a = 0, b = 0;
326
+ while (N-- > 0 && a < zLeft.Length && b < zRight.Length && (zLeft[a] == zRight[b] || (zLeft[a] != 0 && zLeft[a] < 256 && zRight[b] < 256 && UpperToLower[zLeft[a]] == UpperToLower[zRight[b]]))) { a++; b++; }
327
+ if (N < 0) return 0;
328
+ if (a == zLeft.Length && b == zRight.Length) return 0;
329
+ if (a == zLeft.Length) return -UpperToLower[zRight[b]];
330
+ if (b == zRight.Length) return UpperToLower[zLeft[a]];
331
+ return (zLeft[a] < 256 ? UpperToLower[zLeft[a]] : zLeft[a]) - (zRight[b] < 256 ? UpperToLower[zRight[b]] : zRight[b]);
332
+ }
333
+
334
+ /*
335
+ ** Return TRUE if z is a pure numeric string. Return FALSE and leave
336
+ ** *realnum unchanged if the string contains any character which is not
337
+ ** part of a number.
338
+ **
339
+ ** If the string is pure numeric, set *realnum to TRUE if the string
340
+ ** contains the '.' character or an "E+000" style exponentiation suffix.
341
+ ** Otherwise set *realnum to FALSE. Note that just becaue *realnum is
342
+ ** false does not mean that the number can be successfully converted into
343
+ ** an integer - it might be too big.
344
+ **
345
+ ** An empty string is considered non-numeric.
346
+ */
347
+ static int sqlite3IsNumber(string z, ref int realnum, int enc)
348
+ {
349
+ if (String.IsNullOrEmpty(z)) return 0;
350
+ int incr = (enc == SQLITE_UTF8 ? 1 : 2);
351
+ int zIndex = 0;
352
+ if (enc == SQLITE_UTF16BE) zIndex++;// z++;
353
+ if (z[zIndex] == '-' || z[zIndex] == '+') zIndex += incr;//z += incr;
354
+ if (zIndex == z.Length || !sqlite3Isdigit(z[zIndex]))
355
+ {
356
+ return 0;
357
+ }
358
+ zIndex += incr;//z += incr;
359
+ realnum = 0;
360
+ while (zIndex < z.Length && sqlite3Isdigit(z[zIndex])) { zIndex += incr; }//z += incr; }
361
+ #if !SQLITE_OMIT_FLOATING_POINT
362
+ if (zIndex < z.Length && z[zIndex] == '.')
363
+ {
364
+ zIndex += incr;//z += incr;
365
+ if (!sqlite3Isdigit(z[zIndex])) return 0;
366
+ while (zIndex < z.Length && sqlite3Isdigit(z[zIndex])) { zIndex += incr; }//z += incr; }
367
+ realnum = 1;
368
+ }
369
+ if (zIndex < z.Length && (z[zIndex] == 'e' || z[zIndex] == 'E'))
370
+ {
371
+ zIndex += incr;//z += incr;
372
+ if (zIndex < z.Length && (z[zIndex] == '+' || z[zIndex] == '-')) zIndex += incr;//z += incr;
373
+ if (zIndex == z.Length || !sqlite3Isdigit(z[zIndex])) return 0;
374
+ while (zIndex < z.Length && sqlite3Isdigit(z[zIndex])) { zIndex += incr; }//z += incr; }
375
+ realnum = 1;
376
+ }
377
+ #endif
378
+ return zIndex == z.Length ? 1 : 0;// z[zIndex] == 0;
379
+ }
380
+
381
+ /*
382
+ ** The string z[] is an ASCII representation of a real number.
383
+ ** Convert this string to a double.
384
+ **
385
+ ** This routine assumes that z[] really is a valid number. If it
386
+ ** is not, the result is undefined.
387
+ **
388
+ ** This routine is used instead of the library atof() function because
389
+ ** the library atof() might want to use "," as the decimal point instead
390
+ ** of "." depending on how locale is set. But that would cause problems
391
+ ** for SQL. So this routine always uses "." regardless of locale.
392
+ */
393
+ static int sqlite3AtoF(string z, ref double pResult)
394
+ {
395
+ #if !SQLITE_OMIT_FLOATING_POINT
396
+ if (String.IsNullOrEmpty(z)) { pResult = 0; return 0; }
397
+ z = z.Trim() + " ";//const char *zBegin = z;
398
+
399
+ /* sign * significand * (10 ^ (esign * exponent)) */
400
+ int sign = 1; /* sign of significand */
401
+ i64 s = 0; /* significand */
402
+ int d = 0; /* adjust exponent for shifting decimal point */
403
+ int esign = 1; /* sign of exponent */
404
+ int e = 0; /* exponent */
405
+ double result = 0;
406
+ int nDigits = 0;
407
+
408
+ int zDx = 0;
409
+ while (sqlite3Isspace(z[zDx])) zDx++;
410
+ /* get sign of significand */
411
+ if (z[zDx] == '-')
412
+ {
413
+ sign = -1;
414
+ zDx++;
415
+ }
416
+ else if (z[zDx] == '+')
417
+ {
418
+ zDx++;
419
+ }
420
+ /* skip leading zeroes */
421
+ while (z[zDx] == '0')
422
+ {
423
+ zDx++;
424
+ nDigits++;
425
+ }
426
+ /* copy max significant digits to significand */
427
+ while (sqlite3Isdigit(z[zDx]) && s < ((LARGEST_INT64 - 9) / 10))
428
+ {
429
+ s = s * 10 + (z[zDx] - '0');
430
+ zDx++; nDigits++;
431
+ }
432
+ /* skip non-significant significand digits
433
+ ** (increase exponent by d to shift decimal left) */
434
+ while (sqlite3Isdigit(z[zDx])) { zDx++; nDigits++; d++; }
435
+
436
+ /* if decimal point is present */
437
+ if (z[zDx] == '.')
438
+ {
439
+ zDx++;
440
+ /* copy digits from after decimal to significand
441
+ ** (decrease exponent by d to shift decimal right) */
442
+ while (sqlite3Isdigit(z[zDx]) && s < ((LARGEST_INT64 - 9) / 10))
443
+ {
444
+ s = s * 10 + (z[zDx] - '0');
445
+ zDx++; nDigits++; d--;
446
+ }
447
+ /* skip non-significant digits */
448
+ while (sqlite3Isdigit(z[zDx])) { zDx++; nDigits++; }
449
+ }
450
+
451
+ /* if exponent is present */
452
+ if (z[zDx] == 'e' || z[zDx] == 'E')
453
+ {
454
+ zDx++;
455
+ /* get sign of exponent */
456
+ if (z[zDx] == '-')
457
+ {
458
+ esign = -1;
459
+ zDx++;
460
+ }
461
+ else if (z[zDx] == '+')
462
+ {
463
+ zDx++;
464
+ }
465
+ /* copy digits to exponent */
466
+ while (sqlite3Isdigit(z[zDx]))
467
+ {
468
+ e = e * 10 + (z[zDx] - '0');
469
+ zDx++;
470
+ }
471
+ }
472
+
473
+ /* adjust exponent by d, and update sign */
474
+ e = (e * esign) + d;
475
+ if (e < 0)
476
+ {
477
+ esign = -1;
478
+ e *= -1;
479
+ }
480
+ else
481
+ {
482
+ esign = 1;
483
+ }
484
+
485
+ /* if 0 significand */
486
+ if (0 == s)
487
+ {
488
+ /* In the IEEE 754 standard, zero is signed.
489
+ ** Add the sign if we've seen at least one digit */
490
+ result = (sign < 0 && nDigits != 0) ? -(double)0 : (double)0;
491
+ }
492
+ else
493
+ {
494
+ /* attempt to reduce exponent */
495
+ if (esign > 0)
496
+ {
497
+ while (s < (LARGEST_INT64 / 10) && e > 0) { e--; s *= 10; }
498
+ }
499
+ else
500
+ {
501
+ while (0 == (s % 10) && e > 0)
502
+ {
503
+ e--; s /= 10;
504
+ }
505
+ }
506
+
507
+ /* adjust the sign of significand */
508
+ s = sign < 0 ? -s : s;
509
+
510
+ /* if exponent, scale significand as appropriate
511
+ ** and store in result. */
512
+ if (e != 0)
513
+ {
514
+ double scale = 1.0;
515
+ /* attempt to handle extremely small/large numbers better */
516
+ if (e > 307 && e < 342)
517
+ {
518
+ while ((e % 308) != 0) { scale *= 1.0e+1; e -= 1; }
519
+ if (esign < 0)
520
+ {
521
+ result = s / scale;
522
+ result /= 1.0e+308;
523
+ }
524
+ else
525
+ {
526
+ result = s * scale;
527
+ result *= 1.0e+308;
528
+ }
529
+ }
530
+ else
531
+ {
532
+ /* 1.0e+22 is the largest power of 10 than can be
533
+ ** represented exactly. */
534
+ while ((e % 22) != 0) { scale *= 1.0e+1; e -= 1; }
535
+ while (e > 0) { scale *= 1.0e+22; e -= 22; }
536
+ if (esign < 0)
537
+ {
538
+ result = s / scale;
539
+ }
540
+ else
541
+ {
542
+ result = s * scale;
543
+ }
544
+ }
545
+ }
546
+ else
547
+ {
548
+ result = (double)s;
549
+ }
550
+ }
551
+ /* store the result */
552
+ pResult = result;
553
+
554
+ /* return number of characters used */
555
+ return (int)(zDx);
556
+ #else
557
+ return sqlite3Atoi64(z, pResult);
558
+ #endif //* SQLITE_OMIT_FLOATING_POINT */
559
+ }
560
+
561
+ /*
562
+ ** Compare the 19-character string zNum against the text representation
563
+ ** value 2^63: 9223372036854775808. Return negative, zero, or positive
564
+ ** if zNum is less than, equal to, or greater than the string.
565
+ **
566
+ ** Unlike memcmp() this routine is guaranteed to return the difference
567
+ ** in the values of the last digit if the only difference is in the
568
+ ** last digit. So, for example,
569
+ **
570
+ ** compare2pow63("9223372036854775800")
571
+ **
572
+ ** will return -8.
573
+ */
574
+ static int compare2pow63(string zNum)
575
+ {
576
+ int c;
577
+ if (zNum.Length <= 18)
578
+ c = string.Compare(zNum, "922337203685477580");
579
+ else
580
+ {
581
+ c = (string.Compare(zNum.Substring(0, 18), "922337203685477580") == 1) ? 10 : 0;
582
+ if (c == 0)
583
+ {
584
+ c = zNum[18] - '8';
585
+ testcase(c == (-1));
586
+ testcase(c == 0);
587
+ testcase(c == (+1));
588
+ }
589
+ }
590
+ return c;
591
+ }
592
+
593
+
594
+ /*
595
+ ** Return TRUE if zNum is a 64-bit signed integer and write
596
+ ** the value of the integer into pNum. If zNum is not an integer
597
+ ** or is an integer that is too large to be expressed with 64 bits,
598
+ ** then return false.
599
+ **
600
+ ** When this routine was originally written it dealt with only
601
+ ** 32-bit numbers. At that time, it was much faster than the
602
+ ** atoi() library routine in RedHat 7.2.
603
+ */
604
+ static bool sqlite3Atoi64(string zNum, ref i64 pNum)
605
+ {
606
+ zNum = zNum.Trim() + " ";
607
+ int i;
608
+ for (i = 1; i < zNum.Length; i++) if (!sqlite3Isdigit(zNum[i])) break;
609
+ bool c = Int64.TryParse(zNum.Substring(0, i), out pNum);
610
+ if (i < zNum.Length - 1) c = false;
611
+ return c;
612
+ //i64 v = 0;
613
+ //int neg;
614
+ //int i, c;
615
+ //const char *zStart;
616
+ //while( sqlite3Isspace(*(u8*)zNum) ) zNum++;
617
+ //if( *zNum=='-' ){
618
+ // neg = 1;
619
+ // zNum++;
620
+ //}else if( *zNum=='+' ){
621
+ // neg = 0;
622
+ // zNum++;
623
+ //}else{
624
+ // neg = 0;
625
+ //}
626
+ //zStart = zNum;
627
+ //while( zNum[0]=='0' ){ zNum++; } /* Skip over leading zeros. Ticket #2454 */
628
+ //for(i=0; (c=zNum[i])>='0' && c<='9'; i++){
629
+ // v = v*10 + c - '0';
630
+ //}
631
+ //*pNum = neg ? -v : v;
632
+ //testcase(i == 18);
633
+ //testcase(i == 19);
634
+ //testcase(i == 20);
635
+ //if( c!=0 || (i==0 && zStart==zNum) || i>19 ){
636
+ // /* zNum is empty or contains non-numeric text or is longer
637
+ // ** than 19 digits (thus guaranting that it is too large) */
638
+ // return 0;
639
+ //}else if( i<19 ){
640
+ // /* Less than 19 digits, so we know that it fits in 64 bits */
641
+ // return 1;
642
+ //}else{
643
+ // /* 19-digit numbers must be no larger than 9223372036854775807 if positive
644
+ // ** or 9223372036854775808 if negative. Note that 9223372036854665808
645
+ // ** is 2^63. */
646
+ // return compare2pow63(zNum)<neg;
647
+ //}
648
+ }
649
+
650
+ /*
651
+ ** The string zNum represents an unsigned integer. The zNum string
652
+ ** consists of one or more digit characters and is terminated by
653
+ ** a zero character. Any stray characters in zNum result in undefined
654
+ ** behavior.
655
+ **
656
+ ** If the unsigned integer that zNum represents will fit in a
657
+ ** 64-bit signed integer, return TRUE. Otherwise return FALSE.
658
+ **
659
+ ** If the negFlag parameter is true, that means that zNum really represents
660
+ ** a negative number. (The leading "-" is omitted from zNum.) This
661
+ ** parameter is needed to determine a boundary case. A string
662
+ ** of "9223373036854775808" returns false if negFlag is false or true
663
+ ** if negFlag is true.
664
+ **
665
+ ** Leading zeros are ignored.
666
+ */
667
+ static bool sqlite3FitsIn64Bits(string zNum, bool negFlag)
668
+ {
669
+ Int64 pNum;
670
+ Debug.Assert(zNum[0] >= '0' && zNum[0] <= '9'); /* zNum is an unsigned number */
671
+ bool result = negFlag ? Int64.TryParse("-" + zNum, out pNum) : Int64.TryParse(zNum, out pNum);
672
+ // if ( result && negFlag && pNum == Int64.MaxValue ) result = false;
673
+ return result;
674
+ //int i;
675
+ //int neg = 0;
676
+ //if (negFlag != 0) neg = 1 - neg;
677
+ //while (*zNum == '0')
678
+ //{
679
+ // zNum++; /* Skip leading zeros. Ticket #2454 */
680
+ //}
681
+ //for (i = 0; zNum[i]; i++){ assert( zNum[i]>='0' && zNum[i]<='9' ); }
682
+ //testcase(i == 18);
683
+ //testcase(i == 19);
684
+ //testcase(i == 20);
685
+ //if (i < 19)
686
+ //{
687
+ /* Guaranteed to fit if less than 19 digits */
688
+ // return 1;
689
+ //}
690
+ //else if (i > 19)
691
+ //{
692
+ /* Guaranteed to be too big if greater than 19 digits */
693
+ // return 0;
694
+ //}
695
+ //else
696
+ //{
697
+ /* Compare against 2^63. */
698
+ // if (compare2pow63(new string(zNum)) < neg) return 1; else return 0;
699
+ //}
700
+ }
701
+
702
+ /*
703
+ ** If zNum represents an integer that will fit in 32-bits, then set
704
+ ** pValue to that integer and return true. Otherwise return false.
705
+ **
706
+ ** Any non-numeric characters that following zNum are ignored.
707
+ ** This is different from sqlite3Atoi64() which requires the
708
+ ** input number to be zero-terminated.
709
+ */
710
+ static bool sqlite3GetInt32(string zNum, ref int pValue)
711
+ { return sqlite3GetInt32(zNum, 0, ref pValue); }
712
+ static bool sqlite3GetInt32(string zNum, int iZnum, ref int pValue)
713
+ {
714
+ sqlite_int64 v = 0;
715
+ int i, c;
716
+ int neg = 0;
717
+ if (zNum[iZnum] == '-')
718
+ {
719
+ neg = 1;
720
+ iZnum++;
721
+ }
722
+ else if (zNum[iZnum] == '+')
723
+ {
724
+ iZnum++;
725
+ }
726
+ while (iZnum < zNum.Length && zNum[iZnum] == '0') iZnum++;
727
+ for (i = 0; i < 11 && i + iZnum < zNum.Length && (c = zNum[iZnum + i] - '0') >= 0 && c <= 9; i++)
728
+ {
729
+ v = v * 10 + c;
730
+ }
731
+
732
+ /* The longest decimal representation of a 32 bit integer is 10 digits:
733
+ **
734
+ ** 1234567890
735
+ ** 2^31 . 2147483648
736
+ */
737
+ testcase(i == 10);
738
+ if (i > 10)
739
+ {
740
+ return false;
741
+ }
742
+ testcase(v - neg == 2147483647);
743
+ if (v - neg > 2147483647)
744
+ {
745
+ return false;
746
+ }
747
+ if (neg != 0)
748
+ {
749
+ v = -v;
750
+ }
751
+ pValue = (int)v;
752
+ return true;
753
+ }
754
+
755
+ /*
756
+ ** The variable-length integer encoding is as follows:
757
+ **
758
+ ** KEY:
759
+ ** A = 0xxxxxxx 7 bits of data and one flag bit
760
+ ** B = 1xxxxxxx 7 bits of data and one flag bit
761
+ ** C = xxxxxxxx 8 bits of data
762
+ **
763
+ ** 7 bits - A
764
+ ** 14 bits - BA
765
+ ** 21 bits - BBA
766
+ ** 28 bits - BBBA
767
+ ** 35 bits - BBBBA
768
+ ** 42 bits - BBBBBA
769
+ ** 49 bits - BBBBBBA
770
+ ** 56 bits - BBBBBBBA
771
+ ** 64 bits - BBBBBBBBC
772
+ */
773
+
774
+ /*
775
+ ** Write a 64-bit variable-length integer to memory starting at p[0].
776
+ ** The length of data write will be between 1 and 9 bytes. The number
777
+ ** of bytes written is returned.
778
+ **
779
+ ** A variable-length integer consists of the lower 7 bits of each byte
780
+ ** for all bytes that have the 8th bit set and one byte with the 8th
781
+ ** bit clear. Except, if we get to the 9th byte, it stores the full
782
+ ** 8 bits and is the last byte.
783
+ */
784
+ static int getVarint(byte[] p, ref u32 v)
785
+ {
786
+ v = p[0];
787
+ if (v <= 0x7F) return 1;
788
+ u64 u64_v = 0;
789
+ int result = sqlite3GetVarint(p, 0, ref u64_v);
790
+ v = (u32)u64_v;
791
+ return result;
792
+ }
793
+ static int getVarint(byte[] p, int offset, ref u32 v)
794
+ {
795
+ v = p[offset + 0];
796
+ if (v <= 0x7F) return 1;
797
+ u64 u64_v = 0;
798
+ int result = sqlite3GetVarint(p, offset, ref u64_v);
799
+ v = (u32)u64_v;
800
+ return result;
801
+ }
802
+ static int getVarint(byte[] p, int offset, ref int v)
803
+ {
804
+ v = p[offset + 0];
805
+ if (v <= 0x7F) return 1;
806
+ u64 u64_v = 0;
807
+ int result = sqlite3GetVarint(p, offset, ref u64_v);
808
+ v = (int)u64_v;
809
+ return result;
810
+ }
811
+ static int getVarint(byte[] p, int offset, ref i64 v)
812
+ {
813
+ v = offset >= p.Length ? 0 : (int)p[offset + 0];
814
+ if ( v <= 0x7F ) return 1;
815
+ if ( offset + 1 >= p.Length )
816
+ { v = 65535; return 2; }
817
+ else
818
+ {
819
+ u64 u64_v = 0;
820
+ int result = sqlite3GetVarint( p, offset, ref u64_v );
821
+ v = (i64)u64_v;
822
+ return result;
823
+ }
824
+ }
825
+ static int getVarint(byte[] p, int offset, ref u64 v)
826
+ {
827
+ v = p[offset + 0];
828
+ if (v <= 0x7F) return 1;
829
+ int result = sqlite3GetVarint(p, offset, ref v);
830
+ return result;
831
+ }
832
+ static int getVarint32(byte[] p, ref u32 v)
833
+ { //(*B=*(A))<=0x7f?1:sqlite3GetVarint32(A,B))
834
+ v = p[0];
835
+ if (v <= 0x7F) return 1;
836
+ return sqlite3GetVarint32(p, 0, ref v);
837
+ }
838
+ static byte[] pByte4 = new byte[4];
839
+ static int getVarint32(string s, u32 offset, ref int v)
840
+ { //(*B=*(A))<=0x7f?1:sqlite3GetVarint32(A,B))
841
+ v = s[(int)offset];
842
+ if (v <= 0x7F) return 1;
843
+ pByte4[0] = (u8)s[(int)offset + 0];
844
+ pByte4[1] = (u8)s[(int)offset + 1];
845
+ pByte4[2] = (u8)s[(int)offset + 2];
846
+ pByte4[3] = (u8)s[(int)offset + 3];
847
+ u32 u32_v = 0;
848
+ int result = sqlite3GetVarint32(pByte4, 0, ref u32_v);
849
+ v = (int)u32_v;
850
+ return sqlite3GetVarint32(pByte4, 0, ref v);
851
+ }
852
+ static int getVarint32(string s, u32 offset, ref u32 v)
853
+ { //(*B=*(A))<=0x7f?1:sqlite3GetVarint32(A,B))
854
+ v = s[(int)offset];
855
+ if (v <= 0x7F) return 1;
856
+ pByte4[0] = (u8)s[(int)offset + 0];
857
+ pByte4[1] = (u8)s[(int)offset + 1];
858
+ pByte4[2] = (u8)s[(int)offset + 2];
859
+ pByte4[3] = (u8)s[(int)offset + 3];
860
+ return sqlite3GetVarint32(pByte4, 0, ref v);
861
+ }
862
+ static int getVarint32(byte[] p, u32 offset, ref u32 v)
863
+ { //(*B=*(A))<=0x7f?1:sqlite3GetVarint32(A,B))
864
+ v = p[offset];
865
+ if (v <= 0x7F) return 1;
866
+ return sqlite3GetVarint32(p, (int)offset, ref v);
867
+ }
868
+ static int getVarint32(byte[] p, int offset, ref u32 v)
869
+ { //(*B=*(A))<=0x7f?1:sqlite3GetVarint32(A,B))
870
+ v = offset >= p.Length ? 0 : (u32)p[offset];
871
+ if ( v <= 0x7F ) return 1;
872
+ return sqlite3GetVarint32(p, offset, ref v);
873
+ }
874
+ static int getVarint32(byte[] p, int offset, ref int v)
875
+ { //(*B=*(A))<=0x7f?1:sqlite3GetVarint32(A,B))
876
+ v = p[offset + 0];
877
+ if (v <= 0x7F) return 1;
878
+ u32 u32_v = 0;
879
+ int result = sqlite3GetVarint32(p, offset, ref u32_v);
880
+ v = (int)u32_v;
881
+ return result;
882
+ }
883
+ static int putVarint(byte[] p, int offset, int v)
884
+ { return putVarint(p, offset, (u64)v); }
885
+ static int putVarint(byte[] p, int offset, u64 v)
886
+ {
887
+ return sqlite3PutVarint(p, offset, v);
888
+ }
889
+ static int sqlite3PutVarint(byte[] p, int offset, int v)
890
+ { return sqlite3PutVarint(p, offset, (u64)v); }
891
+ static u8[] bufByte10 = new u8[10];
892
+ static int sqlite3PutVarint(byte[] p, int offset, u64 v)
893
+ {
894
+ int i, j, n;
895
+ if ((v & (((u64)0xff000000) << 32)) != 0)
896
+ {
897
+ p[offset + 8] = (byte)v;
898
+ v >>= 8;
899
+ for (i = 7; i >= 0; i--)
900
+ {
901
+ p[offset + i] = (byte)((v & 0x7f) | 0x80);
902
+ v >>= 7;
903
+ }
904
+ return 9;
905
+ }
906
+ n = 0;
907
+ do
908
+ {
909
+ bufByte10[n++] = (byte)((v & 0x7f) | 0x80);
910
+ v >>= 7;
911
+ } while (v != 0);
912
+ bufByte10[0] &= 0x7f;
913
+ Debug.Assert(n <= 9);
914
+ for (i = 0, j = n - 1; j >= 0; j--, i++)
915
+ {
916
+ p[offset + i] = bufByte10[j];
917
+ }
918
+ return n;
919
+ }
920
+
921
+ /*
922
+ ** This routine is a faster version of sqlite3PutVarint() that only
923
+ ** works for 32-bit positive integers and which is optimized for
924
+ ** the common case of small integers.
925
+ */
926
+ static int putVarint32(byte[] p, int offset, int v)
927
+ {
928
+ #if !putVarint32
929
+ if ((v & ~0x7f) == 0)
930
+ {
931
+ p[offset] = (byte)v;
932
+ return 1;
933
+ }
934
+ #endif
935
+ if ((v & ~0x3fff) == 0)
936
+ {
937
+ p[offset] = (byte)((v >> 7) | 0x80);
938
+ p[offset + 1] = (byte)(v & 0x7f);
939
+ return 2;
940
+ }
941
+ return sqlite3PutVarint(p, offset, v);
942
+ }
943
+
944
+ static int putVarint32(byte[] p, int v)
945
+ {
946
+ if ((v & ~0x7f) == 0)
947
+ {
948
+ p[0] = (byte)v;
949
+ return 1;
950
+ }
951
+ else if ((v & ~0x3fff) == 0)
952
+ {
953
+ p[0] = (byte)((v >> 7) | 0x80);
954
+ p[1] = (byte)(v & 0x7f);
955
+ return 2;
956
+ }
957
+ else
958
+ {
959
+ return sqlite3PutVarint(p, 0, v);
960
+ }
961
+ }
962
+
963
+ /*
964
+ ** Bitmasks used by sqlite3GetVarint(). These precomputed constants
965
+ ** are defined here rather than simply putting the constant expressions
966
+ ** inline in order to work around bugs in the RVT compiler.
967
+ **
968
+ ** SLOT_2_0 A mask for (0x7f<<14) | 0x7f
969
+ **
970
+ ** SLOT_4_2_0 A mask for (0x7f<<28) | SLOT_2_0
971
+ */
972
+ const int SLOT_2_0 = 0x001fc07f; //#define SLOT_2_0 0x001fc07f
973
+ const u32 SLOT_4_2_0 = (u32)0xf01fc07f; //#define SLOT_4_2_0 0xf01fc07f
974
+
975
+ /*
976
+ ** Read a 64-bit variable-length integer from memory starting at p[0].
977
+ ** Return the number of bytes read. The value is stored in *v.
978
+ */
979
+ static u8 sqlite3GetVarint(byte[] p, int offset, ref u64 v)
980
+ {
981
+ u32 a, b, s;
982
+
983
+ a = p[offset + 0];
984
+ /* a: p0 (unmasked) */
985
+ if ( 0 == ( a & 0x80 ) )
986
+ {
987
+ v = a;
988
+ return 1;
989
+ }
990
+
991
+ //p++;
992
+ b = p[offset + 1];
993
+ /* b: p1 (unmasked) */
994
+ if (0 == (b & 0x80))
995
+ {
996
+ a &= 0x7f;
997
+ a = a << 7;
998
+ a |= b;
999
+ v = a;
1000
+ return 2;
1001
+ }
1002
+
1003
+ /* Verify that constants are precomputed correctly */
1004
+ Debug.Assert(SLOT_2_0 == ((0x7f << 14) | (0x7f)));
1005
+ Debug.Assert(SLOT_4_2_0 == ((0xfU << 28) | (0x7f << 14) | (0x7f)));
1006
+ //p++;
1007
+ a = a << 14;
1008
+ a |= p[offset + 2];
1009
+ /* a: p0<<14 | p2 (unmasked) */
1010
+ if (0 == (a & 0x80))
1011
+ {
1012
+ a &= SLOT_2_0;
1013
+ b &= 0x7f;
1014
+ b = b << 7;
1015
+ a |= b;
1016
+ v = a;
1017
+ return 3;
1018
+ }
1019
+
1020
+ /* CSE1 from below */
1021
+ a &= SLOT_2_0;
1022
+ //p++;
1023
+ b = b << 14;
1024
+ b |= p[offset + 3];
1025
+ /* b: p1<<14 | p3 (unmasked) */
1026
+ if (0 == (b & 0x80))
1027
+ {
1028
+ b &= SLOT_2_0;
1029
+ /* moved CSE1 up */
1030
+ /* a &= (0x7f<<14)|(0x7f); */
1031
+ a = a << 7;
1032
+ a |= b;
1033
+ v = a;
1034
+ return 4;
1035
+ }
1036
+
1037
+ /* a: p0<<14 | p2 (masked) */
1038
+ /* b: p1<<14 | p3 (unmasked) */
1039
+ /* 1:save off p0<<21 | p1<<14 | p2<<7 | p3 (masked) */
1040
+ /* moved CSE1 up */
1041
+ /* a &= (0x7f<<14)|(0x7f); */
1042
+ b &= SLOT_2_0;
1043
+ s = a;
1044
+ /* s: p0<<14 | p2 (masked) */
1045
+
1046
+ //p++;
1047
+ a = a << 14;
1048
+ a |= p[offset + 4];
1049
+ /* a: p0<<28 | p2<<14 | p4 (unmasked) */
1050
+ if (0 == (a & 0x80))
1051
+ {
1052
+ /* we can skip these cause they were (effectively) done above in calc'ing s */
1053
+ /* a &= (0x1f<<28)|(0x7f<<14)|(0x7f); */
1054
+ /* b &= (0x7f<<14)|(0x7f); */
1055
+ b = b << 7;
1056
+ a |= b;
1057
+ s = s >> 18;
1058
+ v = ((u64)s) << 32 | a;
1059
+ return 5;
1060
+ }
1061
+
1062
+ /* 2:save off p0<<21 | p1<<14 | p2<<7 | p3 (masked) */
1063
+ s = s << 7;
1064
+ s |= b;
1065
+ /* s: p0<<21 | p1<<14 | p2<<7 | p3 (masked) */
1066
+
1067
+ //p++;
1068
+ b = b << 14;
1069
+ b |= p[offset + 5];
1070
+ /* b: p1<<28 | p3<<14 | p5 (unmasked) */
1071
+ if (0 == (b & 0x80))
1072
+ {
1073
+ /* we can skip this cause it was (effectively) done above in calc'ing s */
1074
+ /* b &= (0x1f<<28)|(0x7f<<14)|(0x7f); */
1075
+ a &= SLOT_2_0;
1076
+ a = a << 7;
1077
+ a |= b;
1078
+ s = s >> 18;
1079
+ v = ((u64)s) << 32 | a;
1080
+ return 6;
1081
+ }
1082
+
1083
+ //p++;
1084
+ a = a << 14;
1085
+ a |= p[offset + 6];
1086
+ /* a: p2<<28 | p4<<14 | p6 (unmasked) */
1087
+ if (0 == (a & 0x80))
1088
+ {
1089
+ a &= SLOT_4_2_0;
1090
+ b &= SLOT_2_0;
1091
+ b = b << 7;
1092
+ a |= b;
1093
+ s = s >> 11;
1094
+ v = ((u64)s) << 32 | a;
1095
+ return 7;
1096
+ }
1097
+
1098
+ /* CSE2 from below */
1099
+ a &= SLOT_2_0;
1100
+ //p++;
1101
+ b = b << 14;
1102
+ b |= p[offset + 7];
1103
+ /* b: p3<<28 | p5<<14 | p7 (unmasked) */
1104
+ if (0 == (b & 0x80))
1105
+ {
1106
+ b &= SLOT_4_2_0;
1107
+ /* moved CSE2 up */
1108
+ /* a &= (0x7f<<14)|(0x7f); */
1109
+ a = a << 7;
1110
+ a |= b;
1111
+ s = s >> 4;
1112
+ v = ((u64)s) << 32 | a;
1113
+ return 8;
1114
+ }
1115
+
1116
+ //p++;
1117
+ a = a << 15;
1118
+ a |= p[offset + 8];
1119
+ /* a: p4<<29 | p6<<15 | p8 (unmasked) */
1120
+
1121
+ /* moved CSE2 up */
1122
+ /* a &= (0x7f<<29)|(0x7f<<15)|(0xff); */
1123
+ b &= SLOT_2_0;
1124
+ b = b << 8;
1125
+ a |= b;
1126
+
1127
+ s = s << 4;
1128
+ b = p[offset + 4];
1129
+ b &= 0x7f;
1130
+ b = b >> 3;
1131
+ s |= b;
1132
+
1133
+ v = ((u64)s) << 32 | a;
1134
+
1135
+ return 9;
1136
+ }
1137
+
1138
+
1139
+ /*
1140
+ ** Read a 32-bit variable-length integer from memory starting at p[0].
1141
+ ** Return the number of bytes read. The value is stored in *v.
1142
+ **
1143
+ ** If the varint stored in p[0] is larger than can fit in a 32-bit unsigned
1144
+ ** integer, then set *v to 0xffffffff.
1145
+ **
1146
+ ** A MACRO version, getVarint32, is provided which inlines the
1147
+ ** single-byte case. All code should use the MACRO version as
1148
+ ** this function assumes the single-byte case has already been handled.
1149
+ */
1150
+ static u8 sqlite3GetVarint32(byte[] p, ref int v)
1151
+ {
1152
+ u32 u32_v = 0;
1153
+ u8 result = sqlite3GetVarint32(p, 0, ref u32_v);
1154
+ v = (int)u32_v;
1155
+ return result;
1156
+ }
1157
+ static u8 sqlite3GetVarint32(byte[] p, int offset, ref int v)
1158
+ {
1159
+ u32 u32_v = 0;
1160
+ u8 result = sqlite3GetVarint32(p, offset, ref u32_v);
1161
+ v = (int)u32_v;
1162
+ return result;
1163
+ }
1164
+ static u8 sqlite3GetVarint32(byte[] p, ref u32 v)
1165
+ { return sqlite3GetVarint32(p, 0, ref v); }
1166
+ static u8 sqlite3GetVarint32(byte[] p, int offset, ref u32 v)
1167
+ {
1168
+ u32 a, b;
1169
+
1170
+ /* The 1-byte case. Overwhelmingly the most common. Handled inline
1171
+ ** by the getVarin32() macro */
1172
+ a = p[offset + 0];
1173
+ /* a: p0 (unmasked) */
1174
+ //#if getVarint32
1175
+ // if ( 0==( a&0x80))
1176
+ // {
1177
+ /* Values between 0 and 127 */
1178
+ // v = a;
1179
+ // return 1;
1180
+ // }
1181
+ //#endif
1182
+
1183
+ /* The 2-byte case */
1184
+ //p++;
1185
+ b = p[offset + 1];
1186
+ /* b: p1 (unmasked) */
1187
+ if (0 == (b & 0x80))
1188
+ {
1189
+ /* Values between 128 and 16383 */
1190
+ a &= 0x7f;
1191
+ a = a << 7;
1192
+ v = a | b;
1193
+ return 2;
1194
+ }
1195
+
1196
+ /* The 3-byte case */
1197
+ //p++;
1198
+ a = a << 14;
1199
+ a |= p[offset + 2];
1200
+ /* a: p0<<14 | p2 (unmasked) */
1201
+ if (0 == (a & 0x80))
1202
+ {
1203
+ /* Values between 16384 and 2097151 */
1204
+ a &= (0x7f << 14) | (0x7f);
1205
+ b &= 0x7f;
1206
+ b = b << 7;
1207
+ v = a | b;
1208
+ return 3;
1209
+ }
1210
+
1211
+ /* A 32-bit varint is used to store size information in btrees.
1212
+ ** Objects are rarely larger than 2MiB limit of a 3-byte varint.
1213
+ ** A 3-byte varint is sufficient, for example, to record the size
1214
+ ** of a 1048569-byte BLOB or string.
1215
+ **
1216
+ ** We only unroll the first 1-, 2-, and 3- byte cases. The very
1217
+ ** rare larger cases can be handled by the slower 64-bit varint
1218
+ ** routine.
1219
+ */
1220
+ #if TRUE
1221
+ {
1222
+ u64 v64 = 0;
1223
+ u8 n;
1224
+
1225
+ //p -= 2;
1226
+ n = sqlite3GetVarint(p, offset, ref v64);
1227
+ Debug.Assert(n > 3 && n <= 9);
1228
+ if ((v64 & SQLITE_MAX_U32) != v64)
1229
+ {
1230
+ v = 0xffffffff;
1231
+ }
1232
+ else
1233
+ {
1234
+ v = (u32)v64;
1235
+ } return n;
1236
+ }
1237
+ #else
1238
+ /* For following code (kept for historical record only) shows an
1239
+ ** unrolling for the 3- and 4-byte varint cases. This code is
1240
+ ** slightly faster, but it is also larger and much harder to test.
1241
+ */
1242
+ //p++;
1243
+ b = b << 14;
1244
+ b |= p[offset + 3];
1245
+ /* b: p1<<14 | p3 (unmasked) */
1246
+ if ( 0 == ( b & 0x80 ) )
1247
+ {
1248
+ /* Values between 2097152 and 268435455 */
1249
+ b &= ( 0x7f << 14 ) | ( 0x7f );
1250
+ a &= ( 0x7f << 14 ) | ( 0x7f );
1251
+ a = a << 7;
1252
+ v = a | b;
1253
+ return 4;
1254
+ }
1255
+
1256
+ //p++;
1257
+ a = a << 14;
1258
+ a |= p[offset + 4];
1259
+ /* a: p0<<28 | p2<<14 | p4 (unmasked) */
1260
+ if ( 0 == ( a & 0x80 ) )
1261
+ {
1262
+ /* Values between 268435456 and 34359738367 */
1263
+ a &= SLOT_2_0;
1264
+ b &= SLOT_4_2_0;
1265
+ b = b << 7;
1266
+ v = a | b;
1267
+ return 5;
1268
+ }
1269
+
1270
+ /* We can only reach this point when reading a corrupt database
1271
+ ** file. In that case we are not in any hurry. Use the (relatively
1272
+ ** slow) general-purpose sqlite3GetVarint() routine to extract the
1273
+ ** value. */
1274
+ {
1275
+ u64 v64 = 0;
1276
+ int n;
1277
+
1278
+ //p -= 4;
1279
+ n = sqlite3GetVarint( p, offset, ref v64 );
1280
+ Debug.Assert( n > 5 && n <= 9 );
1281
+ v = (u32)v64;
1282
+ return n;
1283
+ }
1284
+ #endif
1285
+ }
1286
+
1287
+
1288
+ /*
1289
+ ** Return the number of bytes that will be needed to store the given
1290
+ ** 64-bit integer.
1291
+ */
1292
+ static int sqlite3VarintLen(u64 v)
1293
+ {
1294
+ int i = 0;
1295
+ do
1296
+ {
1297
+ i++;
1298
+ v >>= 7;
1299
+ } while (v != 0 && ALWAYS(i < 9));
1300
+ return i;
1301
+ }
1302
+
1303
+
1304
+ /*
1305
+ ** Read or write a four-byte big-endian integer value.
1306
+ */
1307
+ static u32 sqlite3Get4byte(u8[] p, int p_offset, int offset)
1308
+ {
1309
+ offset += p_offset;
1310
+ return (offset +3> p.Length )? 0 : ( u32 )( ( p[0 + offset] << 24 ) | ( p[1 + offset] << 16 ) | ( p[2 + offset] << 8 ) | p[3 + offset] );
1311
+ }
1312
+ static u32 sqlite3Get4byte(u8[] p, int offset)
1313
+ {
1314
+ return ( offset + 3 > p.Length ) ? 0 : (u32)( ( p[0 + offset] << 24 ) | ( p[1 + offset] << 16 ) | ( p[2 + offset] << 8 ) | p[3 + offset] );
1315
+ }
1316
+ static u32 sqlite3Get4byte(u8[] p, u32 offset)
1317
+ {
1318
+ return ( offset + 3 > p.Length ) ? 0 : (u32)( ( p[0 + offset] << 24 ) | ( p[1 + offset] << 16 ) | ( p[2 + offset] << 8 ) | p[3 + offset] );
1319
+ }
1320
+ static u32 sqlite3Get4byte(u8[] p)
1321
+ {
1322
+ return (u32)((p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]);
1323
+ }
1324
+ static void sqlite3Put4byte(byte[] p, int v)
1325
+ {
1326
+ p[0] = (byte)(v >> 24 & 0xFF);
1327
+ p[1] = (byte)(v >> 16 & 0xFF);
1328
+ p[2] = (byte)(v >> 8 & 0xFF);
1329
+ p[3] = (byte)(v & 0xFF);
1330
+ }
1331
+ static void sqlite3Put4byte(byte[] p, int offset, int v)
1332
+ {
1333
+ p[0 + offset] = (byte)(v >> 24 & 0xFF);
1334
+ p[1 + offset] = (byte)(v >> 16 & 0xFF);
1335
+ p[2 + offset] = (byte)(v >> 8 & 0xFF);
1336
+ p[3 + offset] = (byte)(v & 0xFF);
1337
+ }
1338
+ static void sqlite3Put4byte(byte[] p, u32 offset, u32 v)
1339
+ {
1340
+ p[0 + offset] = (byte)(v >> 24 & 0xFF);
1341
+ p[1 + offset] = (byte)(v >> 16 & 0xFF);
1342
+ p[2 + offset] = (byte)(v >> 8 & 0xFF);
1343
+ p[3 + offset] = (byte)(v & 0xFF);
1344
+ }
1345
+ static void sqlite3Put4byte(byte[] p, int offset, u64 v)
1346
+ {
1347
+ p[0 + offset] = (byte)(v >> 24 & 0xFF);
1348
+ p[1 + offset] = (byte)(v >> 16 & 0xFF);
1349
+ p[2 + offset] = (byte)(v >> 8 & 0xFF);
1350
+ p[3 + offset] = (byte)(v & 0xFF);
1351
+ }
1352
+ static void sqlite3Put4byte(byte[] p, u64 v)
1353
+ {
1354
+ p[0] = (byte)(v >> 24 & 0xFF);
1355
+ p[1] = (byte)(v >> 16 & 0xFF);
1356
+ p[2] = (byte)(v >> 8 & 0xFF);
1357
+ p[3] = (byte)(v & 0xFF);
1358
+ }
1359
+
1360
+
1361
+
1362
+ #if !SQLITE_OMIT_BLOB_LITERAL || SQLITE_HAS_CODEC
1363
+ /*
1364
+ ** Translate a single byte of Hex into an integer.
1365
+ ** This routine only works if h really is a valid hexadecimal
1366
+ ** character: 0..9a..fA..F
1367
+ */
1368
+ static int hexToInt(int h)
1369
+ {
1370
+ Debug.Assert((h >= '0' && h <= '9') || (h >= 'a' && h <= 'f') || (h >= 'A' && h <= 'F'));
1371
+ #if SQLITE_ASCII
1372
+ h += 9 * (1 & (h >> 6));
1373
+ #endif
1374
+ #if SQLITE_EBCDIC
1375
+ h += 9*(1&~(h>>4));
1376
+ #endif
1377
+ return h & 0xf;
1378
+ }
1379
+ #endif // * !SQLITE_OMIT_BLOB_LITERAL || SQLITE_HAS_CODEC */
1380
+
1381
+ #if !SQLITE_OMIT_BLOB_LITERAL || SQLITE_HAS_CODEC
1382
+ /*
1383
+ ** Convert a BLOB literal of the form "x'hhhhhh'" into its binary
1384
+ ** value. Return a pointer to its binary value. Space to hold the
1385
+ ** binary value has been obtained from malloc and must be freed by
1386
+ ** the calling routine.
1387
+ */
1388
+ static byte[] sqlite3HexToBlob(sqlite3 db, string z, int n)
1389
+ {
1390
+ StringBuilder zBlob;
1391
+ int i;
1392
+
1393
+ zBlob = new StringBuilder(n / 2 + 1);// (char*)sqlite3DbMallocRaw(db, n / 2 + 1);
1394
+ n--;
1395
+ if (zBlob != null)
1396
+ {
1397
+ for (i = 0; i < n; i += 2)
1398
+ {
1399
+ zBlob.Append(Convert.ToChar((hexToInt(z[i]) << 4) | hexToInt(z[i + 1])));
1400
+ }
1401
+ //zBlob[i / 2] = '\0'; ;
1402
+ }
1403
+ return Encoding.UTF8.GetBytes(zBlob.ToString());
1404
+ }
1405
+ #endif // * !SQLITE_OMIT_BLOB_LITERAL || SQLITE_HAS_CODEC */
1406
+
1407
+
1408
+ /*
1409
+ ** Log an error that is an API call on a connection pointer that should
1410
+ ** not have been used. The "type" of connection pointer is given as the
1411
+ ** argument. The zType is a word like "NULL" or "closed" or "invalid".
1412
+ */
1413
+ static void logBadConnection(string zType)
1414
+ {
1415
+ sqlite3_log(SQLITE_MISUSE,
1416
+ "API call with %s database connection pointer",
1417
+ zType
1418
+ );
1419
+ }
1420
+
1421
+ /*
1422
+ ** Check to make sure we have a valid db pointer. This test is not
1423
+ ** foolproof but it does provide some measure of protection against
1424
+ ** misuse of the interface such as passing in db pointers that are
1425
+ ** NULL or which have been previously closed. If this routine returns
1426
+ ** 1 it means that the db pointer is valid and 0 if it should not be
1427
+ ** dereferenced for any reason. The calling function should invoke
1428
+ ** SQLITE_MISUSE immediately.
1429
+ **
1430
+ ** sqlite3SafetyCheckOk() requires that the db pointer be valid for
1431
+ ** use. sqlite3SafetyCheckSickOrOk() allows a db pointer that failed to
1432
+ ** open properly and is not fit for general use but which can be
1433
+ ** used as an argument to sqlite3_errmsg() or sqlite3_close().
1434
+ */
1435
+ static bool sqlite3SafetyCheckOk(sqlite3 db)
1436
+ {
1437
+ u32 magic;
1438
+ if (db == null)
1439
+ {
1440
+ logBadConnection("NULL");
1441
+ return false;
1442
+ }
1443
+ magic = db.magic;
1444
+ if (magic != SQLITE_MAGIC_OPEN)
1445
+ {
1446
+ if (sqlite3SafetyCheckSickOrOk(db))
1447
+ {
1448
+ testcase(sqlite3GlobalConfig.xLog != null);
1449
+ logBadConnection("unopened");
1450
+ }
1451
+ return false;
1452
+ }
1453
+ else
1454
+ {
1455
+ return true;
1456
+ }
1457
+ }
1458
+ static bool sqlite3SafetyCheckSickOrOk(sqlite3 db)
1459
+ {
1460
+ u32 magic;
1461
+ magic = db.magic;
1462
+ if (magic != SQLITE_MAGIC_SICK &&
1463
+ magic != SQLITE_MAGIC_OPEN &&
1464
+ magic != SQLITE_MAGIC_BUSY)
1465
+ {
1466
+ testcase(sqlite3GlobalConfig.xLog != null);
1467
+ logBadConnection("invalid");
1468
+ return false;
1469
+ }
1470
+ else
1471
+ {
1472
+ return true;
1473
+ }
1474
+ }
1475
+ }
1476
+ }