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,181 @@
1
+ using System;
2
+ using System.Diagnostics;
3
+ using System.Text;
4
+
5
+ using Bitmask = System.UInt64;
6
+ using u8 = System.Byte;
7
+ using u16 = System.UInt16;
8
+ using u32 = System.UInt32;
9
+
10
+ namespace Community.CsharpSqlite
11
+ {
12
+ public partial class Sqlite3
13
+ {
14
+ /*
15
+ ** 2009 November 25
16
+ **
17
+ ** The author disclaims copyright to this source code. In place of
18
+ ** a legal notice, here is a blessing:
19
+ **
20
+ ** May you do good and not evil.
21
+ ** May you find forgiveness for yourself and forgive others.
22
+ ** May you share freely, never taking more than you give.
23
+ **
24
+ *************************************************************************
25
+ **
26
+ ** This file contains code used to insert the values of host parameters
27
+ ** (aka "wildcards") into the SQL text output by sqlite3_trace().
28
+ */
29
+ //#include "sqliteInt.h"
30
+ //#include "vdbeInt.h"
31
+
32
+ #if !SQLITE_OMIT_TRACE
33
+
34
+ /*
35
+ ** zSql is a zero-terminated string of UTF-8 SQL text. Return the number of
36
+ ** bytes in this text up to but excluding the first character in
37
+ ** a host parameter. If the text contains no host parameters, return
38
+ ** the total number of bytes in the text.
39
+ */
40
+ static int findNextHostParameter( string zSql, int iOffset, ref int pnToken )
41
+ {
42
+ int tokenType = 0;
43
+ int nTotal = 0;
44
+ int n;
45
+
46
+ pnToken = 0;
47
+ while ( iOffset < zSql.Length )
48
+ {
49
+ n = sqlite3GetToken( zSql, iOffset, ref tokenType );
50
+ Debug.Assert( n > 0 && tokenType != TK_ILLEGAL );
51
+ if ( tokenType == TK_VARIABLE )
52
+ {
53
+ pnToken = n;
54
+ break;
55
+ }
56
+ nTotal += n;
57
+ iOffset += n;// zSql += n;
58
+ }
59
+ return nTotal;
60
+ }
61
+
62
+ /*
63
+ ** Return a pointer to a string in memory obtained form sqlite3DbMalloc() which
64
+ ** holds a copy of zRawSql but with host parameters expanded to their
65
+ ** current bindings.
66
+ **
67
+ ** The calling function is responsible for making sure the memory returned
68
+ ** is eventually freed.
69
+ **
70
+ ** ALGORITHM: Scan the input string looking for host parameters in any of
71
+ ** these forms: ?, ?N, $A, @A, :A. Take care to avoid text within
72
+ ** string literals, quoted identifier names, and comments. For text forms,
73
+ ** the host parameter index is found by scanning the perpared
74
+ ** statement for the corresponding OP_Variable opcode. Once the host
75
+ ** parameter index is known, locate the value in p->aVar[]. Then render
76
+ ** the value as a literal in place of the host parameter name.
77
+ */
78
+ static string sqlite3VdbeExpandSql(
79
+ Vdbe p, /* The prepared statement being evaluated */
80
+ string zRawSql /* Raw text of the SQL statement */
81
+ )
82
+ {
83
+ sqlite3 db; /* The database connection */
84
+ int idx = 0; /* Index of a host parameter */
85
+ int nextIndex = 1; /* Index of next ? host parameter */
86
+ int n; /* Length of a token prefix */
87
+ int nToken = 0; /* Length of the parameter token */
88
+ int i; /* Loop counter */
89
+ Mem pVar; /* Value of a host parameter */
90
+ StrAccum _out = new StrAccum(1000); /* Accumulate the _output here */
91
+ //StringBuilder zBase = new StringBuilder( 100 ); /* Initial working space */
92
+ int izRawSql = 0;
93
+
94
+ db = p.db;
95
+ sqlite3StrAccumInit( _out, null, 100,
96
+ db.aLimit[SQLITE_LIMIT_LENGTH] );
97
+ _out.db = db;
98
+ while ( izRawSql < zRawSql.Length )
99
+ {
100
+ n = findNextHostParameter( zRawSql, izRawSql, ref nToken );
101
+ Debug.Assert( n > 0 );
102
+ sqlite3StrAccumAppend( _out, zRawSql.Substring( izRawSql, n ), n );
103
+ izRawSql += n;
104
+ Debug.Assert( izRawSql < zRawSql.Length || nToken == 0 );
105
+ if ( nToken == 0 ) break;
106
+ if ( zRawSql[izRawSql] == '?' )
107
+ {
108
+ if ( nToken > 1 )
109
+ {
110
+ Debug.Assert( sqlite3Isdigit( zRawSql[izRawSql + 1] ) );
111
+ sqlite3GetInt32( zRawSql, izRawSql + 1, ref idx );
112
+ }
113
+ else
114
+ {
115
+ idx = nextIndex;
116
+ }
117
+ }
118
+ else
119
+ {
120
+ Debug.Assert( zRawSql[izRawSql] == ':' || zRawSql[izRawSql] == '$' || zRawSql[izRawSql] == '@' );
121
+ testcase( zRawSql[izRawSql] == ':' );
122
+ testcase( zRawSql[izRawSql] == '$' );
123
+ testcase( zRawSql[izRawSql] == '@' );
124
+ idx = sqlite3VdbeParameterIndex( p, zRawSql.Substring( izRawSql, nToken ), nToken );
125
+ Debug.Assert( idx > 0 );
126
+ }
127
+ izRawSql += nToken;
128
+ nextIndex = idx + 1;
129
+ Debug.Assert( idx > 0 && idx <= p.nVar );
130
+ pVar = p.aVar[idx - 1];
131
+ if ( ( pVar.flags & MEM_Null ) != 0 )
132
+ {
133
+ sqlite3StrAccumAppend( _out, "NULL", 4 );
134
+ }
135
+ else if ( ( pVar.flags & MEM_Int ) != 0 )
136
+ {
137
+ sqlite3XPrintf( _out, "%lld", pVar.u.i );
138
+ }
139
+ else if ( ( pVar.flags & MEM_Real ) != 0 )
140
+ {
141
+ sqlite3XPrintf( _out, "%!.15g", pVar.r );
142
+ }
143
+ else if ( ( pVar.flags & MEM_Str ) != 0 )
144
+ {
145
+ #if !SQLITE_OMIT_UTF16
146
+ u8 enc = ENC(db);
147
+ if( enc!=SQLITE_UTF8 ){
148
+ Mem utf8;
149
+ memset(&utf8, 0, sizeof(utf8));
150
+ utf8.db = db;
151
+ sqlite3VdbeMemSetStr(&utf8, pVar.z, pVar.n, enc, SQLITE_STATIC);
152
+ sqlite3VdbeChangeEncoding(&utf8, SQLITE_UTF8);
153
+ sqlite3XPrintf(_out, "'%.*q'", utf8.n, utf8.z);
154
+ sqlite3VdbeMemRelease(&utf8);
155
+ }else
156
+ #endif
157
+ {
158
+ sqlite3XPrintf( _out, "'%.*q'", pVar.n, pVar.z );
159
+ }
160
+ }
161
+ else if ( ( pVar.flags & MEM_Zero ) != 0 )
162
+ {
163
+ sqlite3XPrintf( _out, "zeroblob(%d)", pVar.u.nZero );
164
+ }
165
+ else
166
+ {
167
+ Debug.Assert( ( pVar.flags & MEM_Blob ) != 0 );
168
+ sqlite3StrAccumAppend( _out, "x'", 2 );
169
+ for ( i = 0; i < pVar.n; i++ )
170
+ {
171
+ sqlite3XPrintf( _out, "%02x", pVar.zBLOB[i] & 0xff );
172
+ }
173
+ sqlite3StrAccumAppend( _out, "'", 1 );
174
+ }
175
+ }
176
+ return sqlite3StrAccumFinish( _out );
177
+ }
178
+
179
+ #endif //* #if !SQLITE_OMIT_TRACE */
180
+ }
181
+ }
@@ -0,0 +1,957 @@
1
+ using System;
2
+ using System.Diagnostics;
3
+ using System.Text;
4
+
5
+ namespace Community.CsharpSqlite
6
+ {
7
+ public partial class Sqlite3
8
+ {
9
+ /*
10
+ ** 2006 June 10
11
+ **
12
+ ** The author disclaims copyright to this source code. In place of
13
+ ** a legal notice, here is a blessing:
14
+ **
15
+ ** May you do good and not evil.
16
+ ** May you find forgiveness for yourself and forgive others.
17
+ ** May you share freely, never taking more than you give.
18
+ **
19
+ *************************************************************************
20
+ ** This file contains code used to help implement virtual tables.
21
+ *************************************************************************
22
+ ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart
23
+ ** C#-SQLite is an independent reimplementation of the SQLite software library
24
+ **
25
+ ** SQLITE_SOURCE_ID: 2010-03-09 19:31:43 4ae453ea7be69018d8c16eb8dabe05617397dc4d
26
+ **
27
+ ** $Header$
28
+ *************************************************************************
29
+ */
30
+ #if !SQLITE_OMIT_VIRTUALTABLE
31
+ //#include "sqliteInt.h"
32
+
33
+ /*
34
+ ** The actual function that does the work of creating a new module.
35
+ ** This function implements the sqlite3_create_module() and
36
+ ** sqlite3_create_module_v2() interfaces.
37
+ */
38
+ static int createModule(
39
+ sqlite3 *db, /* Database in which module is registered */
40
+ const char *zName, /* Name assigned to this module */
41
+ const sqlite3_module *pModule, /* The definition of the module */
42
+ void *pAux, /* Context pointer for xCreate/xConnect */
43
+ void (*xDestroy)(void *) /* Module destructor function */
44
+ ){
45
+ int rc, nName;
46
+ Module *pMod;
47
+
48
+ sqlite3_mutex_enter(db->mutex);
49
+ nName = sqlite3Strlen30(zName);
50
+ pMod = (Module *)sqlite3DbMallocRaw(db, sizeof(Module) + nName + 1);
51
+ if( pMod ){
52
+ Module *pDel;
53
+ char *zCopy = (char *)(&pMod[1]);
54
+ memcpy(zCopy, zName, nName+1);
55
+ pMod->zName = zCopy;
56
+ pMod->pModule = pModule;
57
+ pMod->pAux = pAux;
58
+ pMod->xDestroy = xDestroy;
59
+ pDel = (Module *)sqlite3HashInsert(&db->aModule, zCopy, nName, (void*)pMod);
60
+ if( pDel && pDel->xDestroy ){
61
+ pDel->xDestroy(pDel->pAux);
62
+ }
63
+ sqlite3DbFree(db, ref pDel);
64
+ if( pDel==pMod ){
65
+ db->mallocFailed = 1;
66
+ }
67
+ sqlite3ResetInternalSchema(db, 0);
68
+ }else if( xDestroy ){
69
+ xDestroy(pAux);
70
+ }
71
+ rc = sqlite3ApiExit(db, SQLITE_OK);
72
+ sqlite3_mutex_leave(db->mutex);
73
+ return rc;
74
+ }
75
+
76
+
77
+ /*
78
+ ** External API function used to create a new virtual-table module.
79
+ */
80
+ int sqlite3_create_module(
81
+ sqlite3 *db, /* Database in which module is registered */
82
+ const char *zName, /* Name assigned to this module */
83
+ const sqlite3_module *pModule, /* The definition of the module */
84
+ void *pAux /* Context pointer for xCreate/xConnect */
85
+ ){
86
+ return createModule(db, zName, pModule, pAux, 0);
87
+ }
88
+
89
+ /*
90
+ ** External API function used to create a new virtual-table module.
91
+ */
92
+ int sqlite3_create_module_v2(
93
+ sqlite3 *db, /* Database in which module is registered */
94
+ const char *zName, /* Name assigned to this module */
95
+ const sqlite3_module *pModule, /* The definition of the module */
96
+ void *pAux, /* Context pointer for xCreate/xConnect */
97
+ void (*xDestroy)(void *) /* Module destructor function */
98
+ ){
99
+ return createModule(db, zName, pModule, pAux, xDestroy);
100
+ }
101
+
102
+ /*
103
+ ** Lock the virtual table so that it cannot be disconnected.
104
+ ** Locks nest. Every lock should have a corresponding unlock.
105
+ ** If an unlock is omitted, resources leaks will occur.
106
+ **
107
+ ** If a disconnect is attempted while a virtual table is locked,
108
+ ** the disconnect is deferred until all locks have been removed.
109
+ */
110
+ void sqlite3VtabLock(VTable *pVTab){
111
+ pVTab->nRef++;
112
+ }
113
+
114
+
115
+ /*
116
+ ** pTab is a pointer to a Table structure representing a virtual-table.
117
+ ** Return a pointer to the VTable object used by connection db to access
118
+ ** this virtual-table, if one has been created, or NULL otherwise.
119
+ */
120
+ VTable *sqlite3GetVTable(sqlite3 *db, Table *pTab){
121
+ VTable *pVtab;
122
+ assert( IsVirtual(pTab) );
123
+ for(pVtab=pTab->pVTable; pVtab && pVtab->db!=db; pVtab=pVtab->pNext);
124
+ return pVtab;
125
+ }
126
+
127
+ /*
128
+ ** Decrement the ref-count on a virtual table object. When the ref-count
129
+ ** reaches zero, call the xDisconnect() method to delete the object.
130
+ */
131
+ void sqlite3VtabUnlock(VTable *pVTab){
132
+ sqlite3 *db = pVTab->db;
133
+
134
+ assert( db );
135
+ assert( pVTab->nRef>0 );
136
+ assert( sqlite3SafetyCheckOk(db) );
137
+
138
+ pVTab->nRef--;
139
+ if( pVTab->nRef==0 ){
140
+ sqlite3_vtab *p = pVTab->pVtab;
141
+ if( p ){
142
+ p->pModule->xDisconnect(p);
143
+ }
144
+ sqlite3DbFree(db, ref pVTab);
145
+ }
146
+ }
147
+
148
+ /*
149
+ ** Table p is a virtual table. This function moves all elements in the
150
+ ** p->pVTable list to the sqlite3.pDisconnect lists of their associated
151
+ ** database connections to be disconnected at the next opportunity.
152
+ ** Except, if argument db is not NULL, then the entry associated with
153
+ ** connection db is left in the p->pVTable list.
154
+ */
155
+ static VTable *vtabDisconnectAll(sqlite3 *db, Table *p){
156
+ VTable *pRet = 0;
157
+ VTable *pVTable = p->pVTable;
158
+ p->pVTable = 0;
159
+
160
+ /* Assert that the mutex (if any) associated with the BtShared database
161
+ ** that contains table p is held by the caller. See header comments
162
+ ** above function sqlite3VtabUnlockList() for an explanation of why
163
+ ** this makes it safe to access the sqlite3.pDisconnect list of any
164
+ ** database connection that may have an entry in the p->pVTable list. */
165
+ assert( db==0 ||
166
+ sqlite3BtreeHoldsMutex(db->aDb[sqlite3SchemaToIndex(db, p->pSchema)].pBt)
167
+ );
168
+
169
+ while( pVTable ){
170
+ sqlite3 *db2 = pVTable->db;
171
+ VTable *pNext = pVTable->pNext;
172
+ assert( db2 );
173
+ if( db2==db ){
174
+ pRet = pVTable;
175
+ p->pVTable = pRet;
176
+ pRet->pNext = 0;
177
+ }else{
178
+ pVTable->pNext = db2->pDisconnect;
179
+ db2->pDisconnect = pVTable;
180
+ }
181
+ pVTable = pNext;
182
+ }
183
+
184
+ assert( !db || pRet );
185
+ return pRet;
186
+ }
187
+
188
+
189
+ /*
190
+ ** Disconnect all the virtual table objects in the sqlite3.pDisconnect list.
191
+ **
192
+ ** This function may only be called when the mutexes associated with all
193
+ ** shared b-tree databases opened using connection db are held by the
194
+ ** caller. This is done to protect the sqlite3.pDisconnect list. The
195
+ ** sqlite3.pDisconnect list is accessed only as follows:
196
+ **
197
+ ** 1) By this function. In this case, all BtShared mutexes and the mutex
198
+ ** associated with the database handle itself must be held.
199
+ **
200
+ ** 2) By function vtabDisconnectAll(), when it adds a VTable entry to
201
+ ** the sqlite3.pDisconnect list. In this case either the BtShared mutex
202
+ ** associated with the database the virtual table is stored in is held
203
+ ** or, if the virtual table is stored in a non-sharable database, then
204
+ ** the database handle mutex is held.
205
+ **
206
+ ** As a result, a sqlite3.pDisconnect cannot be accessed simultaneously
207
+ ** by multiple threads. It is thread-safe.
208
+ */
209
+ void sqlite3VtabUnlockList(sqlite3 *db){
210
+ VTable *p = db->pDisconnect;
211
+ db->pDisconnect = 0;
212
+
213
+ assert( sqlite3BtreeHoldsAllMutexes(db) );
214
+ assert( sqlite3_mutex_held(db->mutex) );
215
+
216
+ if( p ){
217
+ sqlite3ExpirePreparedStatements(db);
218
+ do {
219
+ VTable *pNext = p->pNext;
220
+ sqlite3VtabUnlock(p);
221
+ p = pNext;
222
+ }while( p );
223
+ }
224
+ }
225
+
226
+ /*
227
+ ** Clear any and all virtual-table information from the Table record.
228
+ ** This routine is called, for example, just before deleting the Table
229
+ ** record.
230
+ **
231
+ ** Since it is a virtual-table, the Table structure contains a pointer
232
+ ** to the head of a linked list of VTable structures. Each VTable
233
+ ** structure is associated with a single sqlite3* user of the schema.
234
+ ** The reference count of the VTable structure associated with database
235
+ ** connection db is decremented immediately (which may lead to the
236
+ ** structure being xDisconnected and free). Any other VTable structures
237
+ ** in the list are moved to the sqlite3.pDisconnect list of the associated
238
+ ** database connection.
239
+ */
240
+ void sqlite3VtabClear(Table *p){
241
+ vtabDisconnectAll(0, p);
242
+ if( p->azModuleArg ){
243
+ int i;
244
+ for(i=0; i<p->nModuleArg; i++){
245
+ sqlite3DbFree(p->dbMem, p->azModuleArg[i]);
246
+ }
247
+ sqlite3DbFree(p->dbMem, p->azModuleArg);
248
+ }
249
+ }
250
+
251
+ /*
252
+ ** Add a new module argument to pTable->azModuleArg[].
253
+ ** The string is not copied - the pointer is stored. The
254
+ ** string will be freed automatically when the table is
255
+ ** deleted.
256
+ */
257
+ static void addModuleArgument(sqlite3 *db, Table *pTable, char *zArg){
258
+ int i = pTable->nModuleArg++;
259
+ int nBytes = sizeof(char *)*(1+pTable->nModuleArg);
260
+ char **azModuleArg;
261
+ azModuleArg = sqlite3DbRealloc(db, pTable->azModuleArg, nBytes);
262
+ if( azModuleArg==0 ){
263
+ int j;
264
+ for(j=0; j<i; j++){
265
+ sqlite3DbFree(db, ref pTable->azModuleArg[j]);
266
+ }
267
+ sqlite3DbFree(db, zArg);
268
+ sqlite3DbFree(db, ref pTable->azModuleArg);
269
+ pTable->nModuleArg = 0;
270
+ }else{
271
+ azModuleArg[i] = zArg;
272
+ azModuleArg[i+1] = 0;
273
+ }
274
+ pTable->azModuleArg = azModuleArg;
275
+ }
276
+
277
+ /*
278
+ ** The parser calls this routine when it first sees a CREATE VIRTUAL TABLE
279
+ ** statement. The module name has been parsed, but the optional list
280
+ ** of parameters that follow the module name are still pending.
281
+ */
282
+ void sqlite3VtabBeginParse(
283
+ Parse *pParse, /* Parsing context */
284
+ Token *pName1, /* Name of new table, or database name */
285
+ Token *pName2, /* Name of new table or NULL */
286
+ Token *pModuleName /* Name of the module for the virtual table */
287
+ ){
288
+ int iDb; /* The database the table is being created in */
289
+ Table *pTable; /* The new virtual table */
290
+ sqlite3 *db; /* Database connection */
291
+
292
+ sqlite3StartTable(pParse, pName1, pName2, 0, 0, 1, 0);
293
+ pTable = pParse->pNewTable;
294
+ if( pTable==0 ) return;
295
+ assert( 0==pTable->pIndex );
296
+
297
+ db = pParse->db;
298
+ iDb = sqlite3SchemaToIndex(db, pTable->pSchema);
299
+ assert( iDb>=0 );
300
+
301
+ pTable->tabFlags |= TF_Virtual;
302
+ pTable->nModuleArg = 0;
303
+ addModuleArgument(db, pTable, sqlite3NameFromToken(db, pModuleName));
304
+ addModuleArgument(db, pTable, sqlite3DbStrDup(db, db->aDb[iDb].zName));
305
+ addModuleArgument(db, pTable, sqlite3DbStrDup(db, pTable->zName));
306
+ pParse->sNameToken.n = (int)(&pModuleName->z[pModuleName->n] - pName1->z);
307
+
308
+ #if !SQLITE_OMIT_AUTHORIZATION
309
+ /* Creating a virtual table invokes the authorization callback twice.
310
+ ** The first invocation, to obtain permission to INSERT a row into the
311
+ ** sqlite_master table, has already been made by sqlite3StartTable().
312
+ ** The second call, to obtain permission to create the table, is made now.
313
+ */
314
+ if( pTable->azModuleArg ){
315
+ sqlite3AuthCheck(pParse, SQLITE_CREATE_VTABLE, pTable->zName,
316
+ pTable->azModuleArg[0], pParse->db->aDb[iDb].zName);
317
+ }
318
+ #endif
319
+ }
320
+
321
+ /*
322
+ ** This routine takes the module argument that has been accumulating
323
+ ** in pParse->zArg[] and appends it to the list of arguments on the
324
+ ** virtual table currently under construction in pParse->pTable.
325
+ */
326
+ static void addArgumentToVtab(Parse *pParse){
327
+ if( pParse->sArg.z && ALWAYS(pParse->pNewTable) ){
328
+ const char *z = (const char*)pParse->sArg.z;
329
+ int n = pParse->sArg.n;
330
+ sqlite3 *db = pParse->db;
331
+ addModuleArgument(db, pParse->pNewTable, sqlite3DbStrNDup(db, z, n));
332
+ }
333
+ }
334
+
335
+ /*
336
+ ** The parser calls this routine after the CREATE VIRTUAL TABLE statement
337
+ ** has been completely parsed.
338
+ */
339
+ void sqlite3VtabFinishParse(Parse *pParse, Token *pEnd){
340
+ Table *pTab = pParse->pNewTable; /* The table being constructed */
341
+ sqlite3 *db = pParse->db; /* The database connection */
342
+
343
+ if( pTab==0 ) return;
344
+ addArgumentToVtab(pParse);
345
+ pParse->sArg.z = 0;
346
+ if( pTab->nModuleArg<1 ) return;
347
+
348
+ /* If the CREATE VIRTUAL TABLE statement is being entered for the
349
+ ** first time (in other words if the virtual table is actually being
350
+ ** created now instead of just being read out of sqlite_master) then
351
+ ** do additional initialization work and store the statement text
352
+ ** in the sqlite_master table.
353
+ */
354
+ if( !db->init.busy ){
355
+ char *zStmt;
356
+ char *zWhere;
357
+ int iDb;
358
+ Vdbe *v;
359
+
360
+ /* Compute the complete text of the CREATE VIRTUAL TABLE statement */
361
+ if( pEnd ){
362
+ pParse->sNameToken.n = (int)(pEnd->z - pParse->sNameToken.z) + pEnd->n;
363
+ }
364
+ zStmt = sqlite3MPrintf(db, "CREATE VIRTUAL TABLE %T", &pParse->sNameToken);
365
+
366
+ /* A slot for the record has already been allocated in the
367
+ ** SQLITE_MASTER table. We just need to update that slot with all
368
+ ** the information we've collected.
369
+ **
370
+ ** The VM register number pParse->regRowid holds the rowid of an
371
+ ** entry in the sqlite_master table tht was created for this vtab
372
+ ** by sqlite3StartTable().
373
+ */
374
+ iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
375
+ sqlite3NestedParse(pParse,
376
+ "UPDATE %Q.%s "
377
+ "SET type='table', name=%Q, tbl_name=%Q, rootpage=0, sql=%Q "
378
+ "WHERE rowid=#%d",
379
+ db->aDb[iDb].zName, SCHEMA_TABLE(iDb),
380
+ pTab->zName,
381
+ pTab->zName,
382
+ zStmt,
383
+ pParse->regRowid
384
+ );
385
+ sqlite3DbFree(db, zStmt);
386
+ v = sqlite3GetVdbe(pParse);
387
+ sqlite3ChangeCookie(pParse, iDb);
388
+
389
+ sqlite3VdbeAddOp2(v, OP_Expire, 0, 0);
390
+ zWhere = sqlite3MPrintf(db, "name='%q'", pTab->zName);
391
+ sqlite3VdbeAddOp4(v, OP_ParseSchema, iDb, 1, 0, zWhere, P4_DYNAMIC);
392
+ sqlite3VdbeAddOp4(v, OP_VCreate, iDb, 0, 0,
393
+ pTab->zName, sqlite3Strlen30(pTab->zName) + 1);
394
+ }
395
+
396
+ /* If we are rereading the sqlite_master table create the in-memory
397
+ ** record of the table. The xConnect() method is not called until
398
+ ** the first time the virtual table is used in an SQL statement. This
399
+ ** allows a schema that contains virtual tables to be loaded before
400
+ ** the required virtual table implementations are registered. */
401
+ else {
402
+ Table *pOld;
403
+ Schema *pSchema = pTab->pSchema;
404
+ const char *zName = pTab->zName;
405
+ int nName = sqlite3Strlen30(zName);
406
+ pOld = sqlite3HashInsert(&pSchema->tblHash, zName, nName, pTab);
407
+ if( pOld ){
408
+ db->mallocFailed = 1;
409
+ assert( pTab==pOld ); /* Malloc must have failed inside HashInsert() */
410
+ return;
411
+ }
412
+ pSchema->db = pParse->db;
413
+ pParse->pNewTable = 0;
414
+ }
415
+ }
416
+
417
+ /*
418
+ ** The parser calls this routine when it sees the first token
419
+ ** of an argument to the module name in a CREATE VIRTUAL TABLE statement.
420
+ */
421
+ void sqlite3VtabArgInit(Parse *pParse){
422
+ addArgumentToVtab(pParse);
423
+ pParse->sArg.z = 0;
424
+ pParse->sArg.n = 0;
425
+ }
426
+
427
+ /*
428
+ ** The parser calls this routine for each token after the first token
429
+ ** in an argument to the module name in a CREATE VIRTUAL TABLE statement.
430
+ */
431
+ void sqlite3VtabArgExtend(Parse *pParse, Token *p){
432
+ Token *pArg = &pParse->sArg;
433
+ if( pArg->z==0 ){
434
+ pArg->z = p->z;
435
+ pArg->n = p->n;
436
+ }else{
437
+ assert(pArg->z < p->z);
438
+ pArg->n = (int)(&p->z[p->n] - pArg->z);
439
+ }
440
+ }
441
+
442
+ /*
443
+ ** Invoke a virtual table constructor (either xCreate or xConnect). The
444
+ ** pointer to the function to invoke is passed as the fourth parameter
445
+ ** to this procedure.
446
+ */
447
+ static int vtabCallConstructor(
448
+ sqlite3 *db,
449
+ Table *pTab,
450
+ Module *pMod,
451
+ int (*xConstruct)(sqlite3*,void*,int,const char*const*,sqlite3_vtab**,char**),
452
+ char **pzErr
453
+ ){
454
+ VTable *pVTable;
455
+ int rc;
456
+ const char *const*azArg = (const char *const*)pTab->azModuleArg;
457
+ int nArg = pTab->nModuleArg;
458
+ char *zErr = 0;
459
+ char *zModuleName = sqlite3MPrintf(db, "%s", pTab->zName);
460
+
461
+ if( !zModuleName ){
462
+ return SQLITE_NOMEM;
463
+ }
464
+
465
+ pVTable = sqlite3DbMallocZero(db, sizeof(VTable));
466
+ if( !pVTable ){
467
+ sqlite3DbFree(db, zModuleName);
468
+ return SQLITE_NOMEM;
469
+ }
470
+ pVTable->db = db;
471
+ pVTable->pMod = pMod;
472
+
473
+ assert( !db->pVTab );
474
+ assert( xConstruct );
475
+ db->pVTab = pTab;
476
+
477
+ /* Invoke the virtual table constructor */
478
+ rc = xConstruct(db, pMod->pAux, nArg, azArg, &pVTable->pVtab, &zErr);
479
+ if( rc==SQLITE_NOMEM ) db->mallocFailed = 1;
480
+
481
+ if( SQLITE_OK!=rc ){
482
+ if( zErr==0 ){
483
+ *pzErr = sqlite3MPrintf(db, "vtable constructor failed: %s", zModuleName);
484
+ }else {
485
+ *pzErr = sqlite3MPrintf(db, "%s", zErr);
486
+ sqlite3DbFree(db, zErr);
487
+ }
488
+ sqlite3DbFree(db, ref pVTable);
489
+ }else if( ALWAYS(pVTable->pVtab) ){
490
+ /* Justification of ALWAYS(): A correct vtab constructor must allocate
491
+ ** the sqlite3_vtab object if successful. */
492
+ pVTable->pVtab->pModule = pMod->pModule;
493
+ pVTable->nRef = 1;
494
+ if( db->pVTab ){
495
+ const char *zFormat = "vtable constructor did not declare schema: %s";
496
+ *pzErr = sqlite3MPrintf(db, zFormat, pTab->zName);
497
+ sqlite3VtabUnlock(pVTable);
498
+ rc = SQLITE_ERROR;
499
+ }else{
500
+ int iCol;
501
+ /* If everything went according to plan, link the new VTable structure
502
+ ** into the linked list headed by pTab->pVTable. Then loop through the
503
+ ** columns of the table to see if any of them contain the token "hidden".
504
+ ** If so, set the Column.isHidden flag and remove the token from
505
+ ** the type string. */
506
+ pVTable->pNext = pTab->pVTable;
507
+ pTab->pVTable = pVTable;
508
+
509
+ for(iCol=0; iCol<pTab->nCol; iCol++){
510
+ char *zType = pTab->aCol[iCol].zType;
511
+ int nType;
512
+ int i = 0;
513
+ if( !zType ) continue;
514
+ nType = sqlite3Strlen30(zType);
515
+ if( sqlite3StrNICmp("hidden", zType, 6)||(zType[6] && zType[6]!=' ') ){
516
+ for(i=0; i<nType; i++){
517
+ if( (0==sqlite3StrNICmp(" hidden", &zType[i], 7))
518
+ && (zType[i+7]=='\0' || zType[i+7]==' ')
519
+ ){
520
+ i++;
521
+ break;
522
+ }
523
+ }
524
+ }
525
+ if( i<nType ){
526
+ int j;
527
+ int nDel = 6 + (zType[i+6] ? 1 : 0);
528
+ for(j=i; (j+nDel)<=nType; j++){
529
+ zType[j] = zType[j+nDel];
530
+ }
531
+ if( zType[i]=='\0' && i>0 ){
532
+ assert(zType[i-1]==' ');
533
+ zType[i-1] = '\0';
534
+ }
535
+ pTab->aCol[iCol].isHidden = 1;
536
+ }
537
+ }
538
+ }
539
+ }
540
+
541
+ sqlite3DbFree(db, zModuleName);
542
+ db->pVTab = 0;
543
+ return rc;
544
+ }
545
+
546
+ /*
547
+ ** This function is invoked by the parser to call the xConnect() method
548
+ ** of the virtual table pTab. If an error occurs, an error code is returned
549
+ ** and an error left in pParse.
550
+ **
551
+ ** This call is a no-op if table pTab is not a virtual table.
552
+ */
553
+ int sqlite3VtabCallConnect(Parse *pParse, Table *pTab){
554
+ sqlite3 *db = pParse->db;
555
+ const char *zMod;
556
+ Module *pMod;
557
+ int rc;
558
+
559
+ assert( pTab );
560
+ if( (pTab->tabFlags & TF_Virtual)==0 || sqlite3GetVTable(db, pTab) ){
561
+ return SQLITE_OK;
562
+ }
563
+
564
+ /* Locate the required virtual table module */
565
+ zMod = pTab->azModuleArg[0];
566
+ pMod = (Module*)sqlite3HashFind(&db->aModule, zMod, sqlite3Strlen30(zMod));
567
+
568
+ if( !pMod ){
569
+ const char *zModule = pTab->azModuleArg[0];
570
+ sqlite3ErrorMsg(pParse, "no such module: %s", zModule);
571
+ rc = SQLITE_ERROR;
572
+ }else{
573
+ char *zErr = 0;
574
+ rc = vtabCallConstructor(db, pTab, pMod, pMod->pModule->xConnect, &zErr);
575
+ if( rc!=SQLITE_OK ){
576
+ sqlite3ErrorMsg(pParse, "%s", zErr);
577
+ }
578
+ sqlite3DbFree(db, zErr);
579
+ }
580
+
581
+ return rc;
582
+ }
583
+
584
+ /*
585
+ ** Add the virtual table pVTab to the array sqlite3.aVTrans[].
586
+ */
587
+ static int addToVTrans(sqlite3 *db, VTable *pVTab){
588
+ const int ARRAY_INCR = 5;
589
+
590
+ /* Grow the sqlite3.aVTrans array if required */
591
+ if( (db->nVTrans%ARRAY_INCR)==0 ){
592
+ VTable **aVTrans;
593
+ int nBytes = sizeof(sqlite3_vtab *) * (db->nVTrans + ARRAY_INCR);
594
+ aVTrans = sqlite3DbRealloc(db, (void *)db->aVTrans, nBytes);
595
+ if( !aVTrans ){
596
+ return SQLITE_NOMEM;
597
+ }
598
+ memset(&aVTrans[db->nVTrans], 0, sizeof(sqlite3_vtab *)*ARRAY_INCR);
599
+ db->aVTrans = aVTrans;
600
+ }
601
+
602
+ /* Add pVtab to the end of sqlite3.aVTrans */
603
+ db->aVTrans[db->nVTrans++] = pVTab;
604
+ sqlite3VtabLock(pVTab);
605
+ return SQLITE_OK;
606
+ }
607
+
608
+ /*
609
+ ** This function is invoked by the vdbe to call the xCreate method
610
+ ** of the virtual table named zTab in database iDb.
611
+ **
612
+ ** If an error occurs, *pzErr is set to point an an English language
613
+ ** description of the error and an SQLITE_XXX error code is returned.
614
+ ** In this case the caller must call sqlite3DbFree(db, ) on *pzErr.
615
+ */
616
+ int sqlite3VtabCallCreate(sqlite3 *db, int iDb, const char *zTab, char **pzErr){
617
+ int rc = SQLITE_OK;
618
+ Table *pTab;
619
+ Module *pMod;
620
+ const char *zMod;
621
+
622
+ pTab = sqlite3FindTable(db, zTab, db->aDb[iDb].zName);
623
+ assert( pTab && (pTab->tabFlags & TF_Virtual)!=0 && !pTab->pVTable );
624
+
625
+ /* Locate the required virtual table module */
626
+ zMod = pTab->azModuleArg[0];
627
+ pMod = (Module*)sqlite3HashFind(&db->aModule, zMod, sqlite3Strlen30(zMod));
628
+
629
+ /* If the module has been registered and includes a Create method,
630
+ ** invoke it now. If the module has not been registered, return an
631
+ ** error. Otherwise, do nothing.
632
+ */
633
+ if( !pMod ){
634
+ *pzErr = sqlite3MPrintf(db, "no such module: %s", zMod);
635
+ rc = SQLITE_ERROR;
636
+ }else{
637
+ rc = vtabCallConstructor(db, pTab, pMod, pMod->pModule->xCreate, pzErr);
638
+ }
639
+
640
+ /* Justification of ALWAYS(): The xConstructor method is required to
641
+ ** create a valid sqlite3_vtab if it returns SQLITE_OK. */
642
+ if( rc==SQLITE_OK && ALWAYS(sqlite3GetVTable(db, pTab)) ){
643
+ rc = addToVTrans(db, sqlite3GetVTable(db, pTab));
644
+ }
645
+
646
+ return rc;
647
+ }
648
+
649
+ /*
650
+ ** This function is used to set the schema of a virtual table. It is only
651
+ ** valid to call this function from within the xCreate() or xConnect() of a
652
+ ** virtual table module.
653
+ */
654
+ int sqlite3_declare_vtab(sqlite3 *db, const char *zCreateTable){
655
+ Parse *pParse;
656
+
657
+ int rc = SQLITE_OK;
658
+ Table *pTab;
659
+ char *zErr = 0;
660
+
661
+ sqlite3_mutex_enter(db->mutex);
662
+ pTab = db->pVTab;
663
+ if( !pTab ){
664
+ sqlite3Error(db, SQLITE_MISUSE, 0);
665
+ sqlite3_mutex_leave(db->mutex);
666
+ return SQLITE_MISUSE_BKPT();
667
+ }
668
+ assert( (pTab->tabFlags & TF_Virtual)!=0 );
669
+
670
+ pParse = sqlite3StackAllocZero(db, sizeof(*pParse));
671
+ if( pParse==0 ){
672
+ rc = SQLITE_NOMEM;
673
+ }else{
674
+ pParse->declareVtab = 1;
675
+ pParse->db = db;
676
+
677
+ if( SQLITE_OK==sqlite3RunParser(pParse, zCreateTable, &zErr)
678
+ && pParse->pNewTable
679
+ && !db->mallocFailed
680
+ && !pParse->pNewTable->pSelect
681
+ && (pParse->pNewTable->tabFlags & TF_Virtual)==0
682
+ ){
683
+ if( !pTab->aCol ){
684
+ pTab->aCol = pParse->pNewTable->aCol;
685
+ pTab->nCol = pParse->pNewTable->nCol;
686
+ pParse->pNewTable->nCol = 0;
687
+ pParse->pNewTable->aCol = 0;
688
+ }
689
+ db->pVTab = 0;
690
+ }else{
691
+ sqlite3Error(db, SQLITE_ERROR, zErr);
692
+ sqlite3DbFree(db, zErr);
693
+ rc = SQLITE_ERROR;
694
+ }
695
+ pParse->declareVtab = 0;
696
+
697
+ if( pParse->pVdbe ){
698
+ sqlite3VdbeFinalize(pParse->pVdbe);
699
+ }
700
+ sqlite3DeleteTable(pParse->pNewTable);
701
+ sqlite3StackFree(db, pParse);
702
+ }
703
+
704
+ assert( (rc&0xff)==rc );
705
+ rc = sqlite3ApiExit(db, rc);
706
+ sqlite3_mutex_leave(db->mutex);
707
+ return rc;
708
+ }
709
+
710
+ /*
711
+ ** This function is invoked by the vdbe to call the xDestroy method
712
+ ** of the virtual table named zTab in database iDb. This occurs
713
+ ** when a DROP TABLE is mentioned.
714
+ **
715
+ ** This call is a no-op if zTab is not a virtual table.
716
+ */
717
+ int sqlite3VtabCallDestroy(sqlite3 *db, int iDb, const char *zTab){
718
+ int rc = SQLITE_OK;
719
+ Table *pTab;
720
+
721
+ pTab = sqlite3FindTable(db, zTab, db->aDb[iDb].zName);
722
+ if( ALWAYS(pTab!=0 && pTab->pVTable!=0) ){
723
+ VTable *p = vtabDisconnectAll(db, pTab);
724
+
725
+ assert( rc==SQLITE_OK );
726
+ rc = p->pMod->pModule->xDestroy(p->pVtab);
727
+
728
+ /* Remove the sqlite3_vtab* from the aVTrans[] array, if applicable */
729
+ if( rc==SQLITE_OK ){
730
+ assert( pTab->pVTable==p && p->pNext==0 );
731
+ p->pVtab = 0;
732
+ pTab->pVTable = 0;
733
+ sqlite3VtabUnlock(p);
734
+ }
735
+ }
736
+
737
+ return rc;
738
+ }
739
+
740
+ /*
741
+ ** This function invokes either the xRollback or xCommit method
742
+ ** of each of the virtual tables in the sqlite3.aVTrans array. The method
743
+ ** called is identified by the second argument, "offset", which is
744
+ ** the offset of the method to call in the sqlite3_module structure.
745
+ **
746
+ ** The array is cleared after invoking the callbacks.
747
+ */
748
+ static void callFinaliser(sqlite3 *db, int offset){
749
+ int i;
750
+ if( db->aVTrans ){
751
+ for(i=0; i<db->nVTrans; i++){
752
+ VTable *pVTab = db->aVTrans[i];
753
+ sqlite3_vtab *p = pVTab->pVtab;
754
+ if( p ){
755
+ int (*x)(sqlite3_vtab *);
756
+ x = *(int (**)(sqlite3_vtab *))((char *)p->pModule + offset);
757
+ if( x ) x(p);
758
+ }
759
+ sqlite3VtabUnlock(pVTab);
760
+ }
761
+ sqlite3DbFree(db, db->aVTrans);
762
+ db->nVTrans = 0;
763
+ db->aVTrans = 0;
764
+ }
765
+ }
766
+
767
+ /*
768
+ ** Invoke the xSync method of all virtual tables in the sqlite3.aVTrans
769
+ ** array. Return the error code for the first error that occurs, or
770
+ ** SQLITE_OK if all xSync operations are successful.
771
+ **
772
+ ** Set *pzErrmsg to point to a buffer that should be released using
773
+ ** sqlite3DbFree() containing an error message, if one is available.
774
+ */
775
+ int sqlite3VtabSync(sqlite3 *db, char **pzErrmsg){
776
+ int i;
777
+ int rc = SQLITE_OK;
778
+ VTable **aVTrans = db->aVTrans;
779
+
780
+ db->aVTrans = 0;
781
+ for(i=0; rc==SQLITE_OK && i<db->nVTrans; i++){
782
+ int (*x)(sqlite3_vtab *);
783
+ sqlite3_vtab *pVtab = aVTrans[i]->pVtab;
784
+ if( pVtab && (x = pVtab->pModule->xSync)!=0 ){
785
+ rc = x(pVtab);
786
+ sqlite3DbFree(db, *pzErrmsg);
787
+ *pzErrmsg = pVtab->zErrMsg;
788
+ pVtab->zErrMsg = 0;
789
+ }
790
+ }
791
+ db->aVTrans = aVTrans;
792
+ return rc;
793
+ }
794
+
795
+ /*
796
+ ** Invoke the xRollback method of all virtual tables in the
797
+ ** sqlite3.aVTrans array. Then clear the array itself.
798
+ */
799
+ int sqlite3VtabRollback(sqlite3 *db){
800
+ callFinaliser(db, offsetof(sqlite3_module,xRollback));
801
+ return SQLITE_OK;
802
+ }
803
+
804
+ /*
805
+ ** Invoke the xCommit method of all virtual tables in the
806
+ ** sqlite3.aVTrans array. Then clear the array itself.
807
+ */
808
+ int sqlite3VtabCommit(sqlite3 *db){
809
+ callFinaliser(db, offsetof(sqlite3_module,xCommit));
810
+ return SQLITE_OK;
811
+ }
812
+
813
+ /*
814
+ ** If the virtual table pVtab supports the transaction interface
815
+ ** (xBegin/xRollback/xCommit and optionally xSync) and a transaction is
816
+ ** not currently open, invoke the xBegin method now.
817
+ **
818
+ ** If the xBegin call is successful, place the sqlite3_vtab pointer
819
+ ** in the sqlite3.aVTrans array.
820
+ */
821
+ int sqlite3VtabBegin(sqlite3 *db, VTable *pVTab){
822
+ int rc = SQLITE_OK;
823
+ const sqlite3_module *pModule;
824
+
825
+ /* Special case: If db->aVTrans is NULL and db->nVTrans is greater
826
+ ** than zero, then this function is being called from within a
827
+ ** virtual module xSync() callback. It is illegal to write to
828
+ ** virtual module tables in this case, so return SQLITE_LOCKED.
829
+ */
830
+ if( sqlite3VtabInSync(db) ){
831
+ return SQLITE_LOCKED;
832
+ }
833
+ if( !pVTab ){
834
+ return SQLITE_OK;
835
+ }
836
+ pModule = pVTab->pVtab->pModule;
837
+
838
+ if( pModule->xBegin ){
839
+ int i;
840
+
841
+
842
+ /* If pVtab is already in the aVTrans array, return early */
843
+ for(i=0; i<db->nVTrans; i++){
844
+ if( db->aVTrans[i]==pVTab ){
845
+ return SQLITE_OK;
846
+ }
847
+ }
848
+
849
+ /* Invoke the xBegin method */
850
+ rc = pModule->xBegin(pVTab->pVtab);
851
+ if( rc==SQLITE_OK ){
852
+ rc = addToVTrans(db, pVTab);
853
+ }
854
+ }
855
+ return rc;
856
+ }
857
+
858
+ /*
859
+ ** The first parameter (pDef) is a function implementation. The
860
+ ** second parameter (pExpr) is the first argument to this function.
861
+ ** If pExpr is a column in a virtual table, then let the virtual
862
+ ** table implementation have an opportunity to overload the function.
863
+ **
864
+ ** This routine is used to allow virtual table implementations to
865
+ ** overload MATCH, LIKE, GLOB, and REGEXP operators.
866
+ **
867
+ ** Return either the pDef argument (indicating no change) or a
868
+ ** new FuncDef structure that is marked as ephemeral using the
869
+ ** SQLITE_FUNC_EPHEM flag.
870
+ */
871
+ FuncDef *sqlite3VtabOverloadFunction(
872
+ sqlite3 *db, /* Database connection for reporting malloc problems */
873
+ FuncDef *pDef, /* Function to possibly overload */
874
+ int nArg, /* Number of arguments to the function */
875
+ Expr *pExpr /* First argument to the function */
876
+ ){
877
+ Table *pTab;
878
+ sqlite3_vtab *pVtab;
879
+ sqlite3_module *pMod;
880
+ void (*xFunc)(sqlite3_context*,int,sqlite3_value**) = 0;
881
+ void *pArg = 0;
882
+ FuncDef *pNew;
883
+ int rc = 0;
884
+ char *zLowerName;
885
+ unsigned char *z;
886
+
887
+
888
+ /* Check to see the left operand is a column in a virtual table */
889
+ if( NEVER(pExpr==0) ) return pDef;
890
+ if( pExpr->op!=TK_COLUMN ) return pDef;
891
+ pTab = pExpr->pTab;
892
+ if( NEVER(pTab==0) ) return pDef;
893
+ if( (pTab->tabFlags & TF_Virtual)==0 ) return pDef;
894
+ pVtab = sqlite3GetVTable(db, pTab)->pVtab;
895
+ assert( pVtab!=0 );
896
+ assert( pVtab->pModule!=0 );
897
+ pMod = (sqlite3_module *)pVtab->pModule;
898
+ if( pMod->xFindFunction==0 ) return pDef;
899
+
900
+ /* Call the xFindFunction method on the virtual table implementation
901
+ ** to see if the implementation wants to overload this function
902
+ */
903
+ zLowerName = sqlite3DbStrDup(db, pDef->zName);
904
+ if( zLowerName ){
905
+ for(z=(unsigned char*)zLowerName; *z; z++){
906
+ *z = sqlite3UpperToLower[*z];
907
+ }
908
+ rc = pMod->xFindFunction(pVtab, nArg, zLowerName, &xFunc, &pArg);
909
+ sqlite3DbFree(db, zLowerName);
910
+ }
911
+ if( rc==0 ){
912
+ return pDef;
913
+ }
914
+
915
+ /* Create a new ephemeral function definition for the overloaded
916
+ ** function */
917
+ pNew = sqlite3DbMallocZero(db, sizeof(*pNew)
918
+ + sqlite3Strlen30(pDef->zName) + 1);
919
+ if( pNew==0 ){
920
+ return pDef;
921
+ }
922
+ *pNew = *pDef;
923
+ pNew->zName = (char *)&pNew[1];
924
+ memcpy(pNew->zName, pDef->zName, sqlite3Strlen30(pDef->zName)+1);
925
+ pNew->xFunc = xFunc;
926
+ pNew->pUserData = pArg;
927
+ pNew->flags |= SQLITE_FUNC_EPHEM;
928
+ return pNew;
929
+ }
930
+
931
+ /*
932
+ ** Make sure virtual table pTab is contained in the pParse->apVirtualLock[]
933
+ ** array so that an OP_VBegin will get generated for it. Add pTab to the
934
+ ** array if it is missing. If pTab is already in the array, this routine
935
+ ** is a no-op.
936
+ */
937
+ void sqlite3VtabMakeWritable(Parse *pParse, Table *pTab){
938
+ Parse *pToplevel = sqlite3ParseToplevel(pParse);
939
+ int i, n;
940
+ Table **apVtabLock;
941
+
942
+ assert( IsVirtual(pTab) );
943
+ for(i=0; i<pToplevel->nVtabLock; i++){
944
+ if( pTab==pToplevel->apVtabLock[i] ) return;
945
+ }
946
+ n = (pToplevel->nVtabLock+1)*sizeof(pToplevel->apVtabLock[0]);
947
+ apVtabLock = sqlite3_realloc(pToplevel->apVtabLock, n);
948
+ if( apVtabLock ){
949
+ pToplevel->apVtabLock = apVtabLock;
950
+ pToplevel->apVtabLock[pToplevel->nVtabLock++] = pTab;
951
+ }else{
952
+ pToplevel->db->mallocFailed = 1;
953
+ }
954
+ }
955
+ #endif //* SQLITE_OMIT_VIRTUALTABLE */
956
+ }
957
+ }