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,331 @@
1
+ /*
2
+ *************************************************************************
3
+ ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart
4
+ ** C#-SQLite is an independent reimplementation of the SQLite software library
5
+ **
6
+ ** SQLITE_SOURCE_ID: 2010-01-05 15:30:36 28d0d7710761114a44a1a3a425a6883c661f06e7
7
+ **
8
+ ** $Header$
9
+ *************************************************************************
10
+ */
11
+
12
+ namespace Community.CsharpSqlite
13
+ {
14
+ public partial class Sqlite3
15
+ {
16
+ //#define TK_SEMI 1
17
+ //#define TK_EXPLAIN 2
18
+ //#define TK_QUERY 3
19
+ //#define TK_PLAN 4
20
+ //#define TK_BEGIN 5
21
+ //#define TK_TRANSACTION 6
22
+ //#define TK_DEFERRED 7
23
+ //#define TK_IMMEDIATE 8
24
+ //#define TK_EXCLUSIVE 9
25
+ //#define TK_COMMIT 10
26
+ //#define TK_END 11
27
+ //#define TK_ROLLBACK 12
28
+ //#define TK_SAVEPOINT 13
29
+ //#define TK_RELEASE 14
30
+ //#define TK_TO 15
31
+ //#define TK_TABLE 16
32
+ //#define TK_CREATE 17
33
+ //#define TK_IF 18
34
+ //#define TK_NOT 19
35
+ //#define TK_EXISTS 20
36
+ //#define TK_TEMP 21
37
+ //#define TK_LP 22
38
+ //#define TK_RP 23
39
+ //#define TK_AS 24
40
+ //#define TK_COMMA 25
41
+ //#define TK_ID 26
42
+ //#define TK_INDEXED 27
43
+ //#define TK_ABORT 28
44
+ //#define TK_ACTION 29
45
+ //#define TK_AFTER 30
46
+ //#define TK_ANALYZE 31
47
+ //#define TK_ASC 32
48
+ //#define TK_ATTACH 33
49
+ //#define TK_BEFORE 34
50
+ //#define TK_BY 35
51
+ //#define TK_CASCADE 36
52
+ //#define TK_CAST 37
53
+ //#define TK_COLUMNKW 38
54
+ //#define TK_CONFLICT 39
55
+ //#define TK_DATABASE 40
56
+ //#define TK_DESC 41
57
+ //#define TK_DETACH 42
58
+ //#define TK_EACH 43
59
+ //#define TK_FAIL 44
60
+ //#define TK_FOR 45
61
+ //#define TK_IGNORE 46
62
+ //#define TK_INITIALLY 47
63
+ //#define TK_INSTEAD 48
64
+ //#define TK_LIKE_KW 49
65
+ //#define TK_MATCH 50
66
+ //#define TK_NO 51
67
+ //#define TK_KEY 52
68
+ //#define TK_OF 53
69
+ //#define TK_OFFSET 54
70
+ //#define TK_PRAGMA 55
71
+ //#define TK_RAISE 56
72
+ //#define TK_REPLACE 57
73
+ //#define TK_RESTRICT 58
74
+ //#define TK_ROW 59
75
+ //#define TK_TRIGGER 60
76
+ //#define TK_VACUUM 61
77
+ //#define TK_VIEW 62
78
+ //#define TK_VIRTUAL 63
79
+ //#define TK_REINDEX 64
80
+ //#define TK_RENAME 65
81
+ //#define TK_CTIME_KW 66
82
+ //#define TK_ANY 67
83
+ //#define TK_OR 68
84
+ //#define TK_AND 69
85
+ //#define TK_IS 70
86
+ //#define TK_BETWEEN 71
87
+ //#define TK_IN 72
88
+ //#define TK_ISNULL 73
89
+ //#define TK_NOTNULL 74
90
+ //#define TK_NE 75
91
+ //#define TK_EQ 76
92
+ //#define TK_GT 77
93
+ //#define TK_LE 78
94
+ //#define TK_LT 79
95
+ //#define TK_GE 80
96
+ //#define TK_ESCAPE 81
97
+ //#define TK_BITAND 82
98
+ //#define TK_BITOR 83
99
+ //#define TK_LSHIFT 84
100
+ //#define TK_RSHIFT 85
101
+ //#define TK_PLUS 86
102
+ //#define TK_MINUS 87
103
+ //#define TK_STAR 88
104
+ //#define TK_SLASH 89
105
+ //#define TK_REM 90
106
+ //#define TK_CONCAT 91
107
+ //#define TK_COLLATE 92
108
+ //#define TK_BITNOT 93
109
+ //#define TK_STRING 94
110
+ //#define TK_JOIN_KW 95
111
+ //#define TK_CONSTRAINT 96
112
+ //#define TK_DEFAULT 97
113
+ //#define TK_NULL 98
114
+ //#define TK_PRIMARY 99
115
+ //#define TK_UNIQUE 100
116
+ //#define TK_CHECK 101
117
+ //#define TK_REFERENCES 102
118
+ //#define TK_AUTOINCR 103
119
+ //#define TK_ON 104
120
+ //#define TK_INSERT 105
121
+ //#define TK_DELETE 106
122
+ //#define TK_UPDATE 107
123
+ //#define TK_SET 108
124
+ //#define TK_DEFERRABLE 109
125
+ //#define TK_FOREIGN 110
126
+ //#define TK_DROP 111
127
+ //#define TK_UNION 112
128
+ //#define TK_ALL 113
129
+ //#define TK_EXCEPT 114
130
+ //#define TK_INTERSECT 115
131
+ //#define TK_SELECT 116
132
+ //#define TK_DISTINCT 117
133
+ //#define TK_DOT 118
134
+ //#define TK_FROM 119
135
+ //#define TK_JOIN 120
136
+ //#define TK_USING 121
137
+ //#define TK_ORDER 122
138
+ //#define TK_GROUP 123
139
+ //#define TK_HAVING 124
140
+ //#define TK_LIMIT 125
141
+ //#define TK_WHERE 126
142
+ //#define TK_INTO 127
143
+ //#define TK_VALUES 128
144
+ //#define TK_INTEGER 129
145
+ //#define TK_FLOAT 130
146
+ //#define TK_BLOB 131
147
+ //#define TK_REGISTER 132
148
+ //#define TK_VARIABLE 133
149
+ //#define TK_CASE 134
150
+ //#define TK_WHEN 135
151
+ //#define TK_THEN 136
152
+ //#define TK_ELSE 137
153
+ //#define TK_INDEX 138
154
+ //#define TK_ALTER 139
155
+ //#define TK_ADD 140
156
+ //#define TK_TO_TEXT 141
157
+ //#define TK_TO_BLOB 142
158
+ //#define TK_TO_NUMERIC 143
159
+ //#define TK_TO_INT 144
160
+ //#define TK_TO_REAL 145
161
+ //#define TK_ISNOT 146
162
+ //#define TK_END_OF_FILE 147
163
+ //#define TK_ILLEGAL 148
164
+ //#define TK_SPACE 149
165
+ //#define TK_UNCLOSED_STRING 150
166
+ //#define TK_FUNCTION 151
167
+ //#define TK_COLUMN 152
168
+ //#define TK_AGG_FUNCTION 153
169
+ //#define TK_AGG_COLUMN 154
170
+ //#define TK_CONST_FUNC 155
171
+ //#define TK_UMINUS 156
172
+ //#define TK_UPLUS 157
173
+ public const int TK_SEMI = 1;
174
+ public const int TK_EXPLAIN = 2;
175
+ public const int TK_QUERY = 3;
176
+ public const int TK_PLAN = 4;
177
+ public const int TK_BEGIN = 5;
178
+ public const int TK_TRANSACTION = 6;
179
+ public const int TK_DEFERRED = 7;
180
+ public const int TK_IMMEDIATE = 8;
181
+ public const int TK_EXCLUSIVE = 9;
182
+ public const int TK_COMMIT = 10;
183
+ public const int TK_END = 11;
184
+ public const int TK_ROLLBACK = 12;
185
+ public const int TK_SAVEPOINT = 13;
186
+ public const int TK_RELEASE = 14;
187
+ public const int TK_TO = 15;
188
+ public const int TK_TABLE = 16;
189
+ public const int TK_CREATE = 17;
190
+ public const int TK_IF = 18;
191
+ public const int TK_NOT = 19;
192
+ public const int TK_EXISTS = 20;
193
+ public const int TK_TEMP = 21;
194
+ public const int TK_LP = 22;
195
+ public const int TK_RP = 23;
196
+ public const int TK_AS = 24;
197
+ public const int TK_COMMA = 25;
198
+ public const int TK_ID = 26;
199
+ public const int TK_INDEXED = 27;
200
+ public const int TK_ABORT = 28;
201
+ public const int TK_ACTION = 29;
202
+ public const int TK_AFTER = 30;
203
+ public const int TK_ANALYZE = 31;
204
+ public const int TK_ASC = 32;
205
+ public const int TK_ATTACH = 33;
206
+ public const int TK_BEFORE = 34;
207
+ public const int TK_BY = 35;
208
+ public const int TK_CASCADE = 36;
209
+ public const int TK_CAST = 37;
210
+ public const int TK_COLUMNKW = 38;
211
+ public const int TK_CONFLICT = 39;
212
+ public const int TK_DATABASE = 40;
213
+ public const int TK_DESC = 41;
214
+ public const int TK_DETACH = 42;
215
+ public const int TK_EACH = 43;
216
+ public const int TK_FAIL = 44;
217
+ public const int TK_FOR = 45;
218
+ public const int TK_IGNORE = 46;
219
+ public const int TK_INITIALLY = 47;
220
+ public const int TK_INSTEAD = 48;
221
+ public const int TK_LIKE_KW = 49;
222
+ public const int TK_MATCH = 50;
223
+ public const int TK_NO = 51;
224
+ public const int TK_KEY = 52;
225
+ public const int TK_OF = 53;
226
+ public const int TK_OFFSET = 54;
227
+ public const int TK_PRAGMA = 55;
228
+ public const int TK_RAISE = 56;
229
+ public const int TK_REPLACE = 57;
230
+ public const int TK_RESTRICT = 58;
231
+ public const int TK_ROW = 59;
232
+ public const int TK_TRIGGER = 60;
233
+ public const int TK_VACUUM = 61;
234
+ public const int TK_VIEW = 62;
235
+ public const int TK_VIRTUAL = 63;
236
+ public const int TK_REINDEX = 64;
237
+ public const int TK_RENAME = 65;
238
+ public const int TK_CTIME_KW = 66;
239
+ public const int TK_ANY = 67;
240
+ public const int TK_OR = 68;
241
+ public const int TK_AND = 69;
242
+ public const int TK_IS = 70;
243
+ public const int TK_BETWEEN = 71;
244
+ public const int TK_IN = 72;
245
+ public const int TK_ISNULL = 73;
246
+ public const int TK_NOTNULL = 74;
247
+ public const int TK_NE = 75;
248
+ public const int TK_EQ = 76;
249
+ public const int TK_GT = 77;
250
+ public const int TK_LE = 78;
251
+ public const int TK_LT = 79;
252
+ public const int TK_GE = 80;
253
+ public const int TK_ESCAPE = 81;
254
+ public const int TK_BITAND = 82;
255
+ public const int TK_BITOR = 83;
256
+ public const int TK_LSHIFT = 84;
257
+ public const int TK_RSHIFT = 85;
258
+ public const int TK_PLUS = 86;
259
+ public const int TK_MINUS = 87;
260
+ public const int TK_STAR = 88;
261
+ public const int TK_SLASH = 89;
262
+ public const int TK_REM = 90;
263
+ public const int TK_CONCAT = 91;
264
+ public const int TK_COLLATE = 92;
265
+ public const int TK_BITNOT = 93;
266
+ public const int TK_STRING = 94;
267
+ public const int TK_JOIN_KW = 95;
268
+ public const int TK_CONSTRAINT = 96;
269
+ public const int TK_DEFAULT = 97;
270
+ public const int TK_NULL = 98;
271
+ public const int TK_PRIMARY = 99;
272
+ public const int TK_UNIQUE = 100;
273
+ public const int TK_CHECK = 101;
274
+ public const int TK_REFERENCES = 102;
275
+ public const int TK_AUTOINCR = 103;
276
+ public const int TK_ON = 104;
277
+ public const int TK_INSERT = 105;
278
+ public const int TK_DELETE = 106;
279
+ public const int TK_UPDATE = 107;
280
+ public const int TK_SET = 108;
281
+ public const int TK_DEFERRABLE = 109;
282
+ public const int TK_FOREIGN = 110;
283
+ public const int TK_DROP = 111;
284
+ public const int TK_UNION = 112;
285
+ public const int TK_ALL = 113;
286
+ public const int TK_EXCEPT = 114;
287
+ public const int TK_INTERSECT = 115;
288
+ public const int TK_SELECT = 116;
289
+ public const int TK_DISTINCT = 117;
290
+ public const int TK_DOT = 118;
291
+ public const int TK_FROM = 119;
292
+ public const int TK_JOIN = 120;
293
+ public const int TK_USING = 121;
294
+ public const int TK_ORDER = 122;
295
+ public const int TK_GROUP = 123;
296
+ public const int TK_HAVING = 124;
297
+ public const int TK_LIMIT = 125;
298
+ public const int TK_WHERE = 126;
299
+ public const int TK_INTO = 127;
300
+ public const int TK_VALUES = 128;
301
+ public const int TK_INTEGER = 129;
302
+ public const int TK_FLOAT = 130;
303
+ public const int TK_BLOB = 131;
304
+ public const int TK_REGISTER = 132;
305
+ public const int TK_VARIABLE = 133;
306
+ public const int TK_CASE = 134;
307
+ public const int TK_WHEN = 135;
308
+ public const int TK_THEN = 136;
309
+ public const int TK_ELSE = 137;
310
+ public const int TK_INDEX = 138;
311
+ public const int TK_ALTER = 139;
312
+ public const int TK_ADD = 140;
313
+ public const int TK_TO_TEXT = 141;
314
+ public const int TK_TO_BLOB = 142;
315
+ public const int TK_TO_NUMERIC = 143;
316
+ public const int TK_TO_INT = 144;
317
+ public const int TK_TO_REAL = 145;
318
+ public const int TK_ISNOT = 146;
319
+ public const int TK_END_OF_FILE = 147;
320
+ public const int TK_ILLEGAL = 148;
321
+ public const int TK_SPACE = 149;
322
+ public const int TK_UNCLOSED_STRING = 150;
323
+ public const int TK_FUNCTION = 151;
324
+ public const int TK_COLUMN = 152;
325
+ public const int TK_AGG_FUNCTION = 153;
326
+ public const int TK_AGG_COLUMN = 154;
327
+ public const int TK_CONST_FUNC = 155;
328
+ public const int TK_UMINUS = 156;
329
+ public const int TK_UPLUS = 157;
330
+ }
331
+ }
@@ -0,0 +1,969 @@
1
+ using System.Diagnostics;
2
+ using System.Text;
3
+
4
+ using u8 = System.Byte;
5
+ using u32 = System.UInt32;
6
+
7
+ using Pgno = System.UInt32;
8
+
9
+ namespace Community.CsharpSqlite
10
+ {
11
+ using sqlite3_value = Sqlite3.Mem;
12
+ using sqlite3_pcache = Sqlite3.PCache1;
13
+ public partial class Sqlite3
14
+ {
15
+ /*
16
+ ** 2008 November 05
17
+ **
18
+ ** The author disclaims copyright to this source code. In place of
19
+ ** a legal notice, here is a blessing:
20
+ **
21
+ ** May you do good and not evil.
22
+ ** May you find forgiveness for yourself and forgive others.
23
+ ** May you share freely, never taking more than you give.
24
+ **
25
+ *************************************************************************
26
+ **
27
+ ** This file implements the default page cache implementation (the
28
+ ** sqlite3_pcache interface). It also contains part of the implementation
29
+ ** of the SQLITE_CONFIG_PAGECACHE and sqlite3_release_memory() features.
30
+ ** If the default page cache implementation is overriden, then neither of
31
+ ** these two features are available.
32
+ *************************************************************************
33
+ ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart
34
+ ** C#-SQLite is an independent reimplementation of the SQLite software library
35
+ **
36
+ ** SQLITE_SOURCE_ID: 2009-12-07 16:39:13 1ed88e9d01e9eda5cbc622e7614277f29bcc551c
37
+ **
38
+ ** $Header$
39
+ *************************************************************************
40
+ */
41
+
42
+ //#include "sqliteInt.h"
43
+
44
+ //typedef struct PCache1 PCache1;
45
+ //typedef struct PgHdr1 PgHdr1;
46
+ //typedef struct PgFreeslot PgFreeslot;
47
+
48
+ /* Pointers to structures of this type are cast and returned as
49
+ ** opaque sqlite3_pcache* handles
50
+ */
51
+
52
+ public class PCache1
53
+ {
54
+ /* Cache configuration parameters. Page size (szPage) and the purgeable
55
+ ** flag (bPurgeable) are set when the cache is created. nMax may be
56
+ ** modified at any time by a call to the pcache1CacheSize() method.
57
+ ** The global mutex must be held when accessing nMax.
58
+ */
59
+ public int szPage; /* Size of every page in this cache */
60
+ public bool bPurgeable; /* True if pages are on backing store */
61
+ public u32 nMin; /* Minimum number of pages reserved */
62
+ public u32 nMax; /* Configured "cache_size" value */
63
+
64
+ /* Hash table of all pages. The following variables may only be accessed
65
+ ** when the accessor is holding the global mutex (see pcache1EnterMutex()
66
+ ** and pcache1LeaveMutex()).
67
+ */
68
+ public u32 nRecyclable; /* Number of pages in the LRU list */
69
+ public u32 nPage; /* Total number of pages in apHash */
70
+ public u32 nHash; /* Number of slots in apHash[] */
71
+ public PgHdr1[] apHash; /* Hash table for fast lookup by pgno */
72
+ public u32 iMaxKey; /* Largest key seen since xTruncate() */
73
+
74
+
75
+ public void Clear()
76
+ {
77
+ nRecyclable = 0;
78
+ nPage = 0;
79
+ nHash = 0;
80
+ apHash = null;
81
+ iMaxKey = 0;
82
+ }
83
+ };
84
+
85
+ /*
86
+ ** Each cache entry is represented by an instance of the following
87
+ ** structure. A buffer of PgHdr1.pCache.szPage bytes is allocated
88
+ ** directly before this structure in memory (see the PGHDR1_TO_PAGE()
89
+ ** macro below).
90
+ */
91
+ public class PgHdr1
92
+ {
93
+ public u32 iKey; /* Key value (page number) */
94
+ public PgHdr1 pNext; /* Next in hash table chain */
95
+ public PCache1 pCache; /* Cache that currently owns this page */
96
+ public PgHdr1 pLruNext; /* Next in LRU list of unpinned pages */
97
+ public PgHdr1 pLruPrev; /* Previous in LRU list of unpinned pages */
98
+ public PgHdr pPgHdr = new PgHdr(); /* Pointer to Actual Page Header */
99
+
100
+ public void Clear()
101
+ {
102
+ this.iKey = 0;
103
+ this.pNext = null;
104
+ this.pCache = null;
105
+ this.pPgHdr.Clear();
106
+ }
107
+ };
108
+
109
+ /*
110
+ ** Free slots in the allocator used to divide up the buffer provided using
111
+ ** the SQLITE_CONFIG_PAGECACHE mechanism.
112
+ */
113
+ //typedef struct PgFreeslot PgFreeslot;
114
+ public class PgFreeslot
115
+ {
116
+ public PgFreeslot pNext; /* Next free slot */
117
+ public PgHdr _PgHdr; /* Next Free Header */
118
+ };
119
+
120
+ /*
121
+ ** Global data for the page cache.
122
+ */
123
+ public class PCacheGlobal
124
+ {
125
+ public sqlite3_mutex mutex; /* static mutex MUTEX_STATIC_LRU */
126
+
127
+ public int nMaxPage; /* Sum of nMaxPage for purgeable caches */
128
+ public int nMinPage; /* Sum of nMinPage for purgeable caches */
129
+ public int nCurrentPage; /* Number of purgeable pages allocated */
130
+ public PgHdr1 pLruHead, pLruTail; /* LRU list of unused clean pgs */
131
+
132
+ /* Variables related to SQLITE_CONFIG_PAGECACHE settings. */
133
+ public int szSlot; /* Size of each free slot */
134
+ public object pStart, pEnd; /* Bounds of pagecache malloc range */
135
+ public PgFreeslot pFree; /* Free page blocks */
136
+ public int isInit; /* True if initialized */
137
+ }
138
+ static PCacheGlobal pcache = new PCacheGlobal();
139
+
140
+ /*
141
+ ** All code in this file should access the global structure above via the
142
+ ** alias "pcache1". This ensures that the WSD emulation is used when
143
+ ** compiling for systems that do not support real WSD.
144
+ */
145
+
146
+ //#define pcache1 (GLOBAL(struct PCacheGlobal, pcache1_g))
147
+ static PCacheGlobal pcache1 = pcache;
148
+
149
+ /*
150
+ ** When a PgHdr1 structure is allocated, the associated PCache1.szPage
151
+ ** bytes of data are located directly before it in memory (i.e. the total
152
+ ** size of the allocation is sizeof(PgHdr1)+PCache1.szPage byte). The
153
+ ** PGHDR1_TO_PAGE() macro takes a pointer to a PgHdr1 structure as
154
+ ** an argument and returns a pointer to the associated block of szPage
155
+ ** bytes. The PAGE_TO_PGHDR1() macro does the opposite: its argument is
156
+ ** a pointer to a block of szPage bytes of data and the return value is
157
+ ** a pointer to the associated PgHdr1 structure.
158
+ **
159
+ ** assert( PGHDR1_TO_PAGE(PAGE_TO_PGHDR1(pCache, X))==X );
160
+ */
161
+ //#define PGHDR1_TO_PAGE(p) (void*)(((char*)p) - p->pCache->szPage)
162
+ static PgHdr PGHDR1_TO_PAGE( PgHdr1 p ) { return p.pPgHdr; }
163
+
164
+ //#define PAGE_TO_PGHDR1(c, p) (PgHdr1*)(((char*)p) + c->szPage)
165
+ static PgHdr1 PAGE_TO_PGHDR1( PCache1 c, PgHdr p ) { return p.pPgHdr1; }
166
+ /*
167
+ ** Macros to enter and leave the global LRU mutex.
168
+ */
169
+ //#define pcache1EnterMutex() sqlite3_mutex_enter(pcache1.mutex)
170
+ //#define pcache1LeaveMutex() sqlite3_mutex_leave(pcache1.mutex)
171
+ static void pcache1EnterMutex() { sqlite3_mutex_enter( pcache1.mutex ); }
172
+ static void pcache1LeaveMutex() { sqlite3_mutex_leave( pcache1.mutex ); }
173
+
174
+ /******************************************************************************/
175
+ /******** Page Allocation/SQLITE_CONFIG_PCACHE Related Functions **************/
176
+
177
+ /*
178
+ ** This function is called during initialization if a static buffer is
179
+ ** supplied to use for the page-cache by passing the SQLITE_CONFIG_PAGECACHE
180
+ ** verb to sqlite3_config(). Parameter pBuf points to an allocation large
181
+ ** enough to contain 'n' buffers of 'sz' bytes each.
182
+ */
183
+ static void sqlite3PCacheBufferSetup( object pBuf, int sz, int n )
184
+ {
185
+ if ( pcache1.isInit != 0 )
186
+ {
187
+ PgFreeslot p;
188
+ sz = ROUNDDOWN8( sz );
189
+ pcache1.szSlot = sz;
190
+ pcache1.pStart = pBuf;
191
+ pcache1.pFree = null;
192
+ while ( n-- != 0 )
193
+ {
194
+ p = new PgFreeslot();// (PgFreeslot)pBuf;
195
+ p._PgHdr = new PgHdr();
196
+ p.pNext = pcache1.pFree;
197
+ pcache1.pFree = p;
198
+ //pBuf = (void*)&((char*)pBuf)[sz];
199
+ }
200
+ pcache1.pEnd = pBuf;
201
+ }
202
+ }
203
+
204
+ /*
205
+ ** Malloc function used within this file to allocate space from the buffer
206
+ ** configured using sqlite3_config(SQLITE_CONFIG_PAGECACHE) option. If no
207
+ ** such buffer exists or there is no space left in it, this function falls
208
+ ** back to sqlite3Malloc().
209
+ */
210
+ static PgHdr pcache1Alloc( int nByte )
211
+ {
212
+ PgHdr p;
213
+ Debug.Assert( sqlite3_mutex_held( pcache1.mutex ) );
214
+ if ( nByte <= pcache1.szSlot && pcache1.pFree != null )
215
+ {
216
+ Debug.Assert( pcache1.isInit != 0 );
217
+ p = pcache1.pFree._PgHdr;
218
+ p.CacheAllocated = true;
219
+ pcache1.pFree = pcache1.pFree.pNext;
220
+ sqlite3StatusSet( SQLITE_STATUS_PAGECACHE_SIZE, nByte );
221
+ sqlite3StatusAdd( SQLITE_STATUS_PAGECACHE_USED, 1 );
222
+ }
223
+ else
224
+ {
225
+
226
+ /* Allocate a new buffer using sqlite3Malloc. Before doing so, exit the
227
+ ** global pcache mutex and unlock the pager-cache object pCache. This is
228
+ ** so that if the attempt to allocate a new buffer causes the the
229
+ ** configured soft-heap-limit to be breached, it will be possible to
230
+ ** reclaim memory from this pager-cache.
231
+ */
232
+ pcache1LeaveMutex();
233
+ p = new PgHdr();// p = sqlite3Malloc(nByte);
234
+ p.CacheAllocated = false;
235
+ pcache1EnterMutex();
236
+ // if( p !=null){
237
+ int sz = nByte;//int sz = sqlite3MallocSize(p);
238
+ sqlite3StatusAdd( SQLITE_STATUS_PAGECACHE_OVERFLOW, sz );
239
+ }
240
+ return p;
241
+ }
242
+
243
+ /*
244
+ ** Free an allocated buffer obtained from pcache1Alloc().
245
+ */
246
+ static void pcache1Free( ref PgHdr p )
247
+ {
248
+ Debug.Assert( sqlite3_mutex_held( pcache1.mutex ) );
249
+ if ( p == null ) return;
250
+ if ( p.CacheAllocated ) //if ( p >= pcache1.pStart && p < pcache1.pEnd )
251
+ {
252
+ PgFreeslot pSlot = new PgFreeslot();
253
+ sqlite3StatusAdd( SQLITE_STATUS_PAGECACHE_USED, -1 );
254
+ pSlot._PgHdr = p;// (PgFreeslot)p;
255
+ pSlot.pNext = pcache1.pFree;
256
+ pcache1.pFree = pSlot;
257
+ }
258
+ else
259
+ {
260
+ int iSize = sqlite3MallocSize(p.pData);
261
+ sqlite3StatusAdd( SQLITE_STATUS_PAGECACHE_OVERFLOW, -iSize );
262
+ sqlite3_free(ref p.pData);
263
+ p = null;
264
+ }
265
+ }
266
+
267
+ /*
268
+ ** Allocate a new page object initially associated with cache pCache.
269
+ */
270
+ static PgHdr1 pcache1AllocPage( PCache1 pCache )
271
+ {
272
+ //int nByte = sizeof(PgHdr1) + pCache.szPage;
273
+ PgHdr pPg = pcache1Alloc( pCache.szPage );
274
+ PgHdr1 p;
275
+ //if ( pPg != null )
276
+ {
277
+ // PAGE_TO_PGHDR1( pCache, pPg );
278
+ p = new PgHdr1();
279
+ p.pCache = pCache;
280
+ p.pPgHdr = pPg;
281
+ if ( pCache.bPurgeable )
282
+ {
283
+ pcache1.nCurrentPage++;
284
+ }
285
+ }
286
+ //else
287
+ //{
288
+ // p = null;
289
+ //}
290
+ return p;
291
+ }
292
+
293
+ /*
294
+ ** Free a page object allocated by pcache1AllocPage().
295
+ **
296
+ ** The pointer is allowed to be NULL, which is prudent. But it turns out
297
+ ** that the current implementation happens to never call this routine
298
+ ** with a NULL pointer, so we mark the NULL test with ALWAYS().
299
+ */
300
+ static void pcache1FreePage( ref PgHdr1 p )
301
+ {
302
+ if ( ALWAYS( p != null ) )
303
+ {
304
+ if ( p.pCache.bPurgeable )
305
+ {
306
+ pcache1.nCurrentPage--;
307
+ }
308
+ pcache1Free( ref p.pPgHdr );//PGHDR1_TO_PAGE( p );
309
+ }
310
+ }
311
+
312
+ /*
313
+ ** Malloc function used by SQLite to obtain space from the buffer configured
314
+ ** using sqlite3_config(SQLITE_CONFIG_PAGECACHE) option. If no such buffer
315
+ ** exists, this function falls back to sqlite3Malloc().
316
+ */
317
+ static PgHdr sqlite3PageMalloc( int sz )
318
+ {
319
+ PgHdr p;
320
+ pcache1EnterMutex();
321
+ p = pcache1Alloc( sz );
322
+ pcache1LeaveMutex();
323
+ return p;
324
+ }
325
+
326
+ /*
327
+ ** Free an allocated buffer obtained from sqlite3PageMalloc().
328
+ */
329
+ static void sqlite3PageFree(ref byte[] p)
330
+ {
331
+ if ( p != null )
332
+ {
333
+ sqlite3_free(ref p );
334
+ p = null;
335
+ }
336
+ }
337
+ static void sqlite3PageFree( ref PgHdr p )
338
+ {
339
+ pcache1EnterMutex();
340
+ pcache1Free( ref p );
341
+ pcache1LeaveMutex();
342
+ }
343
+
344
+ /******************************************************************************/
345
+ /******** General Implementation Functions ************************************/
346
+
347
+ /*
348
+ ** This function is used to resize the hash table used by the cache passed
349
+ ** as the first argument.
350
+ **
351
+ ** The global mutex must be held when this function is called.
352
+ */
353
+ static int pcache1ResizeHash( PCache1 p )
354
+ {
355
+ PgHdr1[] apNew;
356
+ u32 nNew;
357
+ u32 i;
358
+
359
+ Debug.Assert( sqlite3_mutex_held( pcache1.mutex ) );
360
+
361
+ nNew = p.nHash * 2;
362
+ if ( nNew < 256 )
363
+ {
364
+ nNew = 256;
365
+ }
366
+
367
+ pcache1LeaveMutex();
368
+ if ( p.nHash != 0 ) { sqlite3BeginBenignMalloc(); }
369
+ apNew = new PgHdr1[nNew];// (PgHdr1**)sqlite3_malloc( sizeof( PgHdr1* ) * nNew );
370
+ if ( p.nHash != 0 ) { sqlite3EndBenignMalloc(); }
371
+ pcache1EnterMutex();
372
+ if ( apNew != null )
373
+ {
374
+ //memset(apNew, 0, sizeof(PgHdr1 *)*nNew);
375
+ for ( i = 0; i < p.nHash; i++ )
376
+ {
377
+ PgHdr1 pPage;
378
+ PgHdr1 pNext = p.apHash[i];
379
+ while ( ( pPage = pNext ) != null )
380
+ {
381
+ u32 h = (u32)( pPage.iKey % nNew );
382
+ pNext = pPage.pNext;
383
+ pPage.pNext = apNew[h];
384
+ apNew[h] = pPage;
385
+ }
386
+ }
387
+ //sqlite3_free( ref p.apHash );
388
+ p.apHash = apNew;
389
+ p.nHash = nNew;
390
+ }
391
+
392
+ return ( p.apHash != null ? SQLITE_OK : SQLITE_NOMEM );
393
+ }
394
+
395
+ /*
396
+ ** This function is used internally to remove the page pPage from the
397
+ ** global LRU list, if is part of it. If pPage is not part of the global
398
+ ** LRU list, then this function is a no-op.
399
+ **
400
+ ** The global mutex must be held when this function is called.
401
+ */
402
+ static void pcache1PinPage( PgHdr1 pPage )
403
+ {
404
+ Debug.Assert( sqlite3_mutex_held( pcache1.mutex ) );
405
+ if ( pPage != null && ( pPage.pLruNext != null || pPage == pcache1.pLruTail ) )
406
+ {
407
+ if ( pPage.pLruPrev != null )
408
+ {
409
+ pPage.pLruPrev.pLruNext = pPage.pLruNext;
410
+ }
411
+ if ( pPage.pLruNext != null )
412
+ {
413
+ pPage.pLruNext.pLruPrev = pPage.pLruPrev;
414
+ }
415
+ if ( pcache1.pLruHead == pPage )
416
+ {
417
+ pcache1.pLruHead = pPage.pLruNext;
418
+ }
419
+ if ( pcache1.pLruTail == pPage )
420
+ {
421
+ pcache1.pLruTail = pPage.pLruPrev;
422
+ }
423
+ pPage.pLruNext = null;
424
+ pPage.pLruPrev = null;
425
+ pPage.pCache.nRecyclable--;
426
+ }
427
+ }
428
+
429
+
430
+ /*
431
+ ** Remove the page supplied as an argument from the hash table
432
+ ** (PCache1.apHash structure) that it is currently stored in.
433
+ **
434
+ ** The global mutex must be held when this function is called.
435
+ */
436
+ static void pcache1RemoveFromHash( PgHdr1 pPage )
437
+ {
438
+ u32 h;
439
+ PCache1 pCache = pPage.pCache;
440
+ PgHdr1 pp, pPrev;
441
+
442
+ h = pPage.iKey % pCache.nHash;
443
+ pPrev = null;
444
+ for ( pp = pCache.apHash[h]; pp != pPage; pPrev = pp, pp = pp.pNext ) ;
445
+ if ( pPrev == null ) pCache.apHash[h] = pp.pNext; else pPrev.pNext = pp.pNext; // pCache.apHash[h] = pp.pNext;
446
+ pCache.nPage--;
447
+ #if FALSE
448
+ Debug.Assert(pcache1CountHash(pCache)==pCache.nPage);
449
+ #endif
450
+ }
451
+
452
+ #if DEBUG && FALSE
453
+ static u32 pcache1CountHash( PCache1 pCache )
454
+ {
455
+ u32 nPage = 0;
456
+ for ( u32 h = 0; h < pCache.nHash; h++ )
457
+ {
458
+ PgHdr1 pp = pCache.apHash[h];
459
+ while ( pp != null )
460
+ {
461
+ nPage++;
462
+ pp = pp.pNext;
463
+ }
464
+ }
465
+ return nPage;
466
+ }
467
+ #endif
468
+
469
+ /*
470
+ ** If there are currently more than pcache.nMaxPage pages allocated, try
471
+ ** to recycle pages to reduce the number allocated to pcache.nMaxPage.
472
+ */
473
+ static void pcache1EnforceMaxPage()
474
+ {
475
+ Debug.Assert( sqlite3_mutex_held( pcache1.mutex ) );
476
+ while ( pcache1.nCurrentPage > pcache1.nMaxPage && pcache1.pLruTail != null )
477
+ {
478
+ PgHdr1 p = pcache1.pLruTail;
479
+ pcache1PinPage( p );
480
+ pcache1RemoveFromHash( p );
481
+ pcache1FreePage( ref p );
482
+ }
483
+ }
484
+
485
+ /*
486
+ ** Discard all pages from cache pCache with a page number (key value)
487
+ ** greater than or equal to iLimit. Any pinned pages that meet this
488
+ ** criteria are unpinned before they are discarded.
489
+ **
490
+ ** The global mutex must be held when this function is called.
491
+ */
492
+ static void pcache1TruncateUnsafe(
493
+ PCache1 pCache,
494
+ u32 iLimit
495
+ )
496
+ {
497
+ //TESTONLY( unsigned int nPage = 0; ) /* Used to assert pCache->nPage is correct */
498
+ #if !NDEBUG || SQLITE_COVERAGE_TEST
499
+ u32 nPage = 0;
500
+ #endif
501
+ u32 h;
502
+ Debug.Assert( sqlite3_mutex_held( pcache1.mutex ) );
503
+ for ( h = 0; h < pCache.nHash; h++ )
504
+ {
505
+ PgHdr1 pPrev = null;
506
+ PgHdr1 pp = pCache.apHash[h];
507
+ PgHdr1 pPage;
508
+ while ( ( pPage = pp ) != null )
509
+ {
510
+ if ( pPage.iKey >= iLimit )
511
+ {
512
+ pp = pPage.pNext;
513
+ pcache1PinPage( pPage );
514
+ if ( pCache.apHash[h] == pPage ) pCache.apHash[h] = pPage.pNext;
515
+ else pPrev.pNext = pp;
516
+ pcache1FreePage( ref pPage );
517
+ pCache.nPage--;
518
+ #if FALSE
519
+ Debug.Assert( pcache1CountHash( pCache ) == pCache.nPage );
520
+ #endif
521
+ }
522
+ else
523
+ {
524
+ pp = pPage.pNext;
525
+ //TESTONLY( nPage++; )
526
+ #if !NDEBUG || SQLITE_COVERAGE_TEST
527
+ nPage++;
528
+ #endif
529
+ }
530
+ pPrev = pPage;
531
+ }
532
+ }
533
+ #if !NDEBUG || SQLITE_COVERAGE_TEST
534
+ Debug.Assert( pCache.nPage == nPage );
535
+ #endif
536
+ }
537
+
538
+ /******************************************************************************/
539
+ /******** sqlite3_pcache Methods **********************************************/
540
+
541
+ /*
542
+ ** Implementation of the sqlite3_pcache.xInit method.
543
+ */
544
+ static int pcache1Init( object NotUsed )
545
+ {
546
+ UNUSED_PARAMETER( NotUsed );
547
+ Debug.Assert( pcache1.isInit == 0 );
548
+ pcache1 = new PCacheGlobal();// memset( &pcache1, 0, sizeof( pcache1 ) );
549
+ if ( sqlite3GlobalConfig.bCoreMutex )
550
+ {
551
+ pcache1.mutex = sqlite3_mutex_alloc( SQLITE_MUTEX_STATIC_LRU );
552
+ }
553
+ pcache1.isInit = 1;
554
+ return SQLITE_OK;
555
+ }
556
+
557
+ /*
558
+ ** Implementation of the sqlite3_pcache.xShutdown method.
559
+ ** Note that the static mutex allocated in xInit does
560
+ ** not need to be freed.
561
+ */
562
+ static void pcache1Shutdown( object NotUsed )
563
+ {
564
+ UNUSED_PARAMETER( NotUsed );
565
+ Debug.Assert( pcache1.isInit != 0 );
566
+ pcache1 = new PCacheGlobal(); //memset( &pcache1, 0, sizeof( pcache1 ) );
567
+ }
568
+
569
+ /*
570
+ ** Implementation of the sqlite3_pcache.xCreate method.
571
+ **
572
+ ** Allocate a new cache.
573
+ */
574
+ static sqlite3_pcache pcache1Create( int szPage, int bPurgeable )
575
+ {
576
+ PCache1 pCache;
577
+
578
+ pCache = new PCache1();// (PCache1*)sqlite3_malloc( sizeof( PCache1 ) );
579
+ if ( pCache != null )
580
+ {
581
+ //memset(pCache, 0, sizeof(PCache1));
582
+ pCache.szPage = szPage;
583
+ pCache.bPurgeable = ( bPurgeable != 0 );
584
+ if ( bPurgeable != 0 )
585
+ {
586
+ pCache.nMin = 10;
587
+ pcache1EnterMutex();
588
+ pcache1.nMinPage += (int)pCache.nMin;
589
+ pcache1LeaveMutex();
590
+ }
591
+ }
592
+ return pCache;
593
+ }
594
+
595
+ /*
596
+ ** Implementation of the sqlite3_pcache.xCachesize method.
597
+ **
598
+ ** Configure the cache_size limit for a cache.
599
+ */
600
+ static void pcache1Cachesize( sqlite3_pcache p, int nMax )
601
+ {
602
+ PCache1 pCache = (PCache1)p;
603
+ if ( pCache.bPurgeable )
604
+ {
605
+ pcache1EnterMutex();
606
+ pcache1.nMaxPage += (int)( nMax - pCache.nMax );
607
+ pCache.nMax = (u32)nMax;
608
+ pcache1EnforceMaxPage();
609
+ pcache1LeaveMutex();
610
+ }
611
+ }
612
+
613
+ /*
614
+ ** Implementation of the sqlite3_pcache.xPagecount method.
615
+ */
616
+ static int pcache1Pagecount( sqlite3_pcache p )
617
+ {
618
+ int n;
619
+ pcache1EnterMutex();
620
+ n = (int)( (PCache1)p ).nPage;
621
+ pcache1LeaveMutex();
622
+ return n;
623
+ }
624
+
625
+ /*
626
+ ** Implementation of the sqlite3_pcache.xFetch method.
627
+ **
628
+ ** Fetch a page by key value.
629
+ **
630
+ ** Whether or not a new page may be allocated by this function depends on
631
+ ** the value of the createFlag argument. 0 means do not allocate a new
632
+ ** page. 1 means allocate a new page if space is easily available. 2
633
+ ** means to try really hard to allocate a new page.
634
+ **
635
+ ** For a non-purgeable cache (a cache used as the storage for an in-memory
636
+ ** database) there is really no difference between createFlag 1 and 2. So
637
+ ** the calling function (pcache.c) will never have a createFlag of 1 on
638
+ ** a non-purgable cache.
639
+ **
640
+ ** There are three different approaches to obtaining space for a page,
641
+ ** depending on the value of parameter createFlag (which may be 0, 1 or 2).
642
+ **
643
+ ** 1. Regardless of the value of createFlag, the cache is searched for a
644
+ ** copy of the requested page. If one is found, it is returned.
645
+ **
646
+ ** 2. If createFlag==0 and the page is not already in the cache, NULL is
647
+ ** returned.
648
+ **
649
+ ** 3. If createFlag is 1, and the page is not already in the cache,
650
+ ** and if either of the following are true, return NULL:
651
+ **
652
+ ** (a) the number of pages pinned by the cache is greater than
653
+ ** PCache1.nMax, or
654
+ ** (b) the number of pages pinned by the cache is greater than
655
+ ** the sum of nMax for all purgeable caches, less the sum of
656
+ ** nMin for all other purgeable caches.
657
+ **
658
+ ** 4. If none of the first three conditions apply and the cache is marked
659
+ ** as purgeable, and if one of the following is true:
660
+ **
661
+ ** (a) The number of pages allocated for the cache is already
662
+ ** PCache1.nMax, or
663
+ **
664
+ ** (b) The number of pages allocated for all purgeable caches is
665
+ ** already equal to or greater than the sum of nMax for all
666
+ ** purgeable caches,
667
+ **
668
+ ** then attempt to recycle a page from the LRU list. If it is the right
669
+ ** size, return the recycled buffer. Otherwise, free the buffer and
670
+ ** proceed to step 5.
671
+ **
672
+ ** 5. Otherwise, allocate and return a new page buffer.
673
+ */
674
+ static PgHdr pcache1Fetch( sqlite3_pcache p, u32 iKey, int createFlag )
675
+ {
676
+ u32 nPinned;
677
+ PCache1 pCache = p;
678
+ PgHdr1 pPage = null;
679
+
680
+ Debug.Assert( pCache.bPurgeable || createFlag != 1 );
681
+ pcache1EnterMutex();
682
+ if ( createFlag == 1 ) sqlite3BeginBenignMalloc();
683
+
684
+ /* Search the hash table for an existing entry. */
685
+ if ( pCache.nHash > 0 )
686
+ {
687
+ u32 h = iKey % pCache.nHash;
688
+ for ( pPage = pCache.apHash[h]; pPage != null && pPage.iKey != iKey; pPage = pPage.pNext ) ;
689
+ }
690
+
691
+ if ( pPage != null || createFlag == 0 )
692
+ {
693
+ pcache1PinPage( pPage );
694
+ goto fetch_out;
695
+ }
696
+
697
+ /* Step 3 of header comment. */
698
+ nPinned = pCache.nPage - pCache.nRecyclable;
699
+ if ( createFlag == 1 && (
700
+ nPinned >= ( pcache1.nMaxPage + pCache.nMin - pcache1.nMinPage )
701
+ || nPinned >= ( pCache.nMax * 9 / 10 )
702
+ ) )
703
+ {
704
+ goto fetch_out;
705
+ }
706
+
707
+ if ( pCache.nPage >= pCache.nHash && pcache1ResizeHash( pCache ) != 0 )
708
+ {
709
+ goto fetch_out;
710
+ }
711
+
712
+ /* Step 4. Try to recycle a page buffer if appropriate. */
713
+ if ( pCache.bPurgeable && pcache1.pLruTail != null && (
714
+ pCache.nPage + 1 >= pCache.nMax || pcache1.nCurrentPage >= pcache1.nMaxPage
715
+ ) )
716
+ {
717
+ pPage = pcache1.pLruTail;
718
+ pcache1RemoveFromHash( pPage );
719
+ pcache1PinPage( pPage );
720
+ if ( pPage.pCache.szPage != pCache.szPage )
721
+ {
722
+ pcache1FreePage( ref pPage );
723
+ pPage = null;
724
+ }
725
+ else
726
+ {
727
+ pcache1.nCurrentPage -= ( ( pPage.pCache.bPurgeable ? 1 : 0 ) - ( pCache.bPurgeable ? 1 : 0 ) );
728
+ }
729
+ }
730
+
731
+ /* Step 5. If a usable page buffer has still not been found,
732
+ ** attempt to allocate a new one.
733
+ */
734
+ if ( null == pPage )
735
+ {
736
+ pPage = pcache1AllocPage( pCache );
737
+ }
738
+
739
+ if ( pPage != null )
740
+ {
741
+ u32 h = iKey % pCache.nHash;
742
+ pCache.nPage++;
743
+ pPage.iKey = iKey;
744
+ pPage.pNext = pCache.apHash[h];
745
+ pPage.pCache = pCache;
746
+ pPage.pLruPrev = null;
747
+ pPage.pLruNext = null;
748
+ PGHDR1_TO_PAGE( pPage ).Clear();// *(void **)(PGHDR1_TO_PAGE(pPage)) = 0;
749
+ pPage.pPgHdr.pPgHdr1 = pPage;
750
+ pCache.apHash[h] = pPage;
751
+ #if FALSE
752
+ Debug.Assert( pcache1CountHash( pCache ) == pCache.nPage );
753
+ #endif
754
+ }
755
+
756
+ fetch_out:
757
+ if ( pPage != null && iKey > pCache.iMaxKey )
758
+ {
759
+ pCache.iMaxKey = iKey;
760
+ }
761
+ if ( createFlag == 1 ) sqlite3EndBenignMalloc();
762
+ pcache1LeaveMutex();
763
+ return ( pPage != null ? PGHDR1_TO_PAGE( pPage ) : null );
764
+ }
765
+
766
+
767
+ /*
768
+ ** Implementation of the sqlite3_pcache.xUnpin method.
769
+ **
770
+ ** Mark a page as unpinned (eligible for asynchronous recycling).
771
+ */
772
+ static void pcache1Unpin( sqlite3_pcache p, PgHdr pPg, int reuseUnlikely )
773
+ {
774
+ PCache1 pCache = (PCache1)p;
775
+ PgHdr1 pPage = PAGE_TO_PGHDR1( pCache, pPg );
776
+
777
+ Debug.Assert( pPage.pCache == pCache );
778
+ pcache1EnterMutex();
779
+
780
+ /* It is an error to call this function if the page is already
781
+ ** part of the global LRU list.
782
+ */
783
+ Debug.Assert( pPage.pLruPrev == null && pPage.pLruNext == null );
784
+ Debug.Assert( pcache1.pLruHead != pPage && pcache1.pLruTail != pPage );
785
+
786
+ if ( reuseUnlikely != 0 || pcache1.nCurrentPage > pcache1.nMaxPage )
787
+ {
788
+ pcache1RemoveFromHash( pPage );
789
+ pcache1FreePage( ref pPage );
790
+ }
791
+ else
792
+ {
793
+ /* Add the page to the global LRU list. Normally, the page is added to
794
+ ** the head of the list (last page to be recycled). However, if the
795
+ ** reuseUnlikely flag passed to this function is true, the page is added
796
+ ** to the tail of the list (first page to be recycled).
797
+ */
798
+ if ( pcache1.pLruHead != null )
799
+ {
800
+ pcache1.pLruHead.pLruPrev = pPage;
801
+ pPage.pLruNext = pcache1.pLruHead;
802
+ pcache1.pLruHead = pPage;
803
+ }
804
+ else
805
+ {
806
+ pcache1.pLruTail = pPage;
807
+ pcache1.pLruHead = pPage;
808
+ }
809
+ pCache.nRecyclable++;
810
+ }
811
+
812
+ pcache1LeaveMutex();
813
+ }
814
+
815
+ /*
816
+ ** Implementation of the sqlite3_pcache.xRekey method.
817
+ */
818
+ static void pcache1Rekey(
819
+ sqlite3_pcache p,
820
+ PgHdr pPg,
821
+ u32 iOld,
822
+ u32 iNew
823
+ )
824
+ {
825
+ PCache1 pCache = p;
826
+ PgHdr1 pPage = PAGE_TO_PGHDR1( pCache, pPg );
827
+ PgHdr1 pp;
828
+ u32 h;
829
+ Debug.Assert( pPage.iKey == iOld );
830
+ Debug.Assert( pPage.pCache == pCache );
831
+
832
+ pcache1EnterMutex();
833
+
834
+ h = iOld % pCache.nHash;
835
+ pp = pCache.apHash[h];
836
+ while ( pp != pPage )
837
+ {
838
+ pp = pp.pNext;
839
+ }
840
+ if ( pp == pCache.apHash[h] ) pCache.apHash[h] = pp.pNext;
841
+ else pp.pNext = pPage.pNext;
842
+
843
+ h = iNew % pCache.nHash;
844
+ pPage.iKey = iNew;
845
+ pPage.pNext = pCache.apHash[h];
846
+ pCache.apHash[h] = pPage;
847
+ if ( iNew > pCache.iMaxKey )
848
+ {
849
+ pCache.iMaxKey = iNew;
850
+ }
851
+
852
+ pcache1LeaveMutex();
853
+ }
854
+
855
+ /*
856
+ ** Implementation of the sqlite3_pcache.xTruncate method.
857
+ **
858
+ ** Discard all unpinned pages in the cache with a page number equal to
859
+ ** or greater than parameter iLimit. Any pinned pages with a page number
860
+ ** equal to or greater than iLimit are implicitly unpinned.
861
+ */
862
+ static void pcache1Truncate( sqlite3_pcache p, u32 iLimit )
863
+ {
864
+ PCache1 pCache = (PCache1)p;
865
+ pcache1EnterMutex();
866
+ if ( iLimit <= pCache.iMaxKey )
867
+ {
868
+ pcache1TruncateUnsafe( pCache, iLimit );
869
+ pCache.iMaxKey = iLimit - 1;
870
+ }
871
+ pcache1LeaveMutex();
872
+ }
873
+
874
+ /*
875
+ ** Implementation of the sqlite3_pcache.xDestroy method.
876
+ **
877
+ ** Destroy a cache allocated using pcache1Create().
878
+ */
879
+ static void pcache1Destroy( ref sqlite3_pcache p )
880
+ {
881
+ PCache1 pCache = p;
882
+ pcache1EnterMutex();
883
+ pcache1TruncateUnsafe( pCache, 0 );
884
+ pcache1.nMaxPage -= (int)pCache.nMax;
885
+ pcache1.nMinPage -= (int)pCache.nMin;
886
+ pcache1EnforceMaxPage();
887
+ pcache1LeaveMutex();
888
+ //sqlite3_free( ref pCache.apHash );
889
+ //sqlite3_free( ref pCache );
890
+ p = null;
891
+ }
892
+
893
+ /*
894
+ ** This function is called during initialization (sqlite3_initialize()) to
895
+ ** install the default pluggable cache module, assuming the user has not
896
+ ** already provided an alternative.
897
+ */
898
+ static void sqlite3PCacheSetDefault()
899
+ {
900
+ sqlite3_pcache_methods defaultMethods = new sqlite3_pcache_methods(
901
+ 0, /* pArg */
902
+ (dxPC_Init)pcache1Init, /* xInit */
903
+ (dxPC_Shutdown)pcache1Shutdown, /* xShutdown */
904
+ (dxPC_Create)pcache1Create, /* xCreate */
905
+ (dxPC_Cachesize)pcache1Cachesize,/* xCachesize */
906
+ (dxPC_Pagecount)pcache1Pagecount,/* xPagecount */
907
+ (dxPC_Fetch)pcache1Fetch, /* xFetch */
908
+ (dxPC_Unpin)pcache1Unpin, /* xUnpin */
909
+ (dxPC_Rekey)pcache1Rekey, /* xRekey */
910
+ (dxPC_Truncate)pcache1Truncate, /* xTruncate */
911
+ (dxPC_Destroy)pcache1Destroy /* xDestroy */
912
+ );
913
+ sqlite3_config( SQLITE_CONFIG_PCACHE, defaultMethods );
914
+ }
915
+
916
+ #if SQLITE_ENABLE_MEMORY_MANAGEMENT
917
+ /*
918
+ ** This function is called to free superfluous dynamically allocated memory
919
+ ** held by the pager system. Memory in use by any SQLite pager allocated
920
+ ** by the current thread may be //sqlite3_free()ed.
921
+ **
922
+ ** nReq is the number of bytes of memory required. Once this much has
923
+ ** been released, the function returns. The return value is the total number
924
+ ** of bytes of memory released.
925
+ */
926
+ int sqlite3PcacheReleaseMemory(int nReq){
927
+ int nFree = 0;
928
+ if( pcache1.pStart==0 ){
929
+ PgHdr1 p;
930
+ pcache1EnterMutex();
931
+ while( (nReq<0 || nFree<nReq) && (p=pcache1.pLruTail) ){
932
+ nFree += sqlite3MallocSize(PGHDR1_TO_PAGE(p));
933
+ pcache1PinPage(p);
934
+ pcache1RemoveFromHash(p);
935
+ pcache1FreePage(p);
936
+ }
937
+ pcache1LeaveMutex();
938
+ }
939
+ return nFree;
940
+ }
941
+ #endif //* SQLITE_ENABLE_MEMORY_MANAGEMENT */
942
+
943
+ #if SQLITE_TEST
944
+ /*
945
+ ** This function is used by test procedures to inspect the internal state
946
+ ** of the global cache.
947
+ */
948
+ static void sqlite3PcacheStats(
949
+ ref int pnCurrent, /* OUT: Total number of pages cached */
950
+ ref int pnMax, /* OUT: Global maximum cache size */
951
+ ref int pnMin, /* OUT: Sum of PCache1.nMin for purgeable caches */
952
+ ref int pnRecyclable /* OUT: Total number of pages available for recycling */
953
+ )
954
+ {
955
+ PgHdr1 p;
956
+ int nRecyclable = 0;
957
+ for ( p = pcache1.pLruHead; p != null; p = p.pLruNext )
958
+ {
959
+ nRecyclable++;
960
+ }
961
+ pnCurrent = pcache1.nCurrentPage;
962
+ pnMax = pcache1.nMaxPage;
963
+ pnMin = pcache1.nMinPage;
964
+ pnRecyclable = nRecyclable;
965
+ }
966
+ #endif
967
+
968
+ }
969
+ }