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,1219 @@
1
+ using System;
2
+ using System.Diagnostics;
3
+ using System.Text;
4
+
5
+ using u8 = System.Byte;
6
+ using u32 = System.UInt32;
7
+ namespace Community.CsharpSqlite
8
+ {
9
+ public partial class Sqlite3
10
+ {
11
+ /*
12
+ **
13
+ ** The author disclaims copyright to this source code. In place of
14
+ ** a legal notice, here is a blessing:
15
+ **
16
+ ** May you do good and not evil.
17
+ ** May you find forgiveness for yourself and forgive others.
18
+ ** May you share freely, never taking more than you give.
19
+ **
20
+ *************************************************************************
21
+ ** This file contains the implementation for TRIGGERs
22
+ *************************************************************************
23
+ ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart
24
+ ** C#-SQLite is an independent reimplementation of the SQLite software library
25
+ **
26
+ ** SQLITE_SOURCE_ID: 2010-03-09 19:31:43 4ae453ea7be69018d8c16eb8dabe05617397dc4d
27
+ **
28
+ ** $Header$
29
+ *************************************************************************
30
+ */
31
+ //#include "sqliteInt.h"
32
+
33
+ #if !SQLITE_OMIT_TRIGGER
34
+ /*
35
+ ** Delete a linked list of TriggerStep structures.
36
+ */
37
+ static void sqlite3DeleteTriggerStep( sqlite3 db, ref TriggerStep pTriggerStep )
38
+ {
39
+ while ( pTriggerStep != null )
40
+ {
41
+ TriggerStep pTmp = pTriggerStep;
42
+ pTriggerStep = pTriggerStep.pNext;
43
+
44
+ sqlite3ExprDelete( db, ref pTmp.pWhere );
45
+ sqlite3ExprListDelete( db, ref pTmp.pExprList );
46
+ sqlite3SelectDelete( db, ref pTmp.pSelect );
47
+ sqlite3IdListDelete( db, ref pTmp.pIdList );
48
+
49
+ pTriggerStep = null;sqlite3DbFree( db, ref pTmp );
50
+ }
51
+ }
52
+
53
+ /*
54
+ ** Given table pTab, return a list of all the triggers attached to
55
+ ** the table. The list is connected by Trigger.pNext pointers.
56
+ **
57
+ ** All of the triggers on pTab that are in the same database as pTab
58
+ ** are already attached to pTab.pTrigger. But there might be additional
59
+ ** triggers on pTab in the TEMP schema. This routine prepends all
60
+ ** TEMP triggers on pTab to the beginning of the pTab.pTrigger list
61
+ ** and returns the combined list.
62
+ **
63
+ ** To state it another way: This routine returns a list of all triggers
64
+ ** that fire off of pTab. The list will include any TEMP triggers on
65
+ ** pTab as well as the triggers lised in pTab.pTrigger.
66
+ */
67
+ static Trigger sqlite3TriggerList( Parse pParse, Table pTab )
68
+ {
69
+ Schema pTmpSchema = pParse.db.aDb[1].pSchema;
70
+ Trigger pList = null; /* List of triggers to return */
71
+
72
+ if( pParse.disableTriggers !=0){
73
+ return null;
74
+ }
75
+
76
+ if ( pTmpSchema != pTab.pSchema )
77
+ {
78
+ HashElem p;
79
+ for ( p = sqliteHashFirst( pTmpSchema.trigHash ) ; p != null ; p = sqliteHashNext( p ) )
80
+ {
81
+ Trigger pTrig = (Trigger)sqliteHashData( p );
82
+ if ( pTrig.pTabSchema == pTab.pSchema
83
+ && 0 == sqlite3StrICmp( pTrig.table, pTab.zName )
84
+ )
85
+ {
86
+ pTrig.pNext = ( pList != null ? pList : pTab.pTrigger );
87
+ pList = pTrig;
88
+ }
89
+ }
90
+ }
91
+
92
+ return ( pList != null ? pList : pTab.pTrigger );
93
+ }
94
+
95
+ /*
96
+ ** This is called by the parser when it sees a CREATE TRIGGER statement
97
+ ** up to the point of the BEGIN before the trigger actions. A Trigger
98
+ ** structure is generated based on the information available and stored
99
+ ** in pParse.pNewTrigger. After the trigger actions have been parsed, the
100
+ ** sqlite3FinishTrigger() function is called to complete the trigger
101
+ ** construction process.
102
+ */
103
+ static void sqlite3BeginTrigger(
104
+ Parse pParse, /* The parse context of the CREATE TRIGGER statement */
105
+ Token pName1, /* The name of the trigger */
106
+ Token pName2, /* The name of the trigger */
107
+ int tr_tm, /* One of TK_BEFORE, TK_AFTER, TK_INSTEAD */
108
+ int op, /* One of TK_INSERT, TK_UPDATE, TK_DELETE */
109
+ IdList pColumns, /* column list if this is an UPDATE OF trigger */
110
+ SrcList pTableName,/* The name of the table/view the trigger applies to */
111
+ Expr pWhen, /* WHEN clause */
112
+ int isTemp, /* True if the TEMPORARY keyword is present */
113
+ int noErr /* Suppress errors if the trigger already exists */
114
+ )
115
+ {
116
+ Trigger pTrigger = null; /* The new trigger */
117
+ Table pTab; /* Table that the trigger fires off of */
118
+ string zName = null; /* Name of the trigger */
119
+ sqlite3 db = pParse.db; /* The database connection */
120
+ int iDb; /* The database to store the trigger in */
121
+ Token pName = null; /* The unqualified db name */
122
+ DbFixer sFix = new DbFixer(); /* State vector for the DB fixer */
123
+ int iTabDb; /* Index of the database holding pTab */
124
+
125
+ Debug.Assert( pName1 != null ); /* pName1.z might be NULL, but not pName1 itself */
126
+ Debug.Assert( pName2 != null );
127
+ Debug.Assert( op == TK_INSERT || op == TK_UPDATE || op == TK_DELETE );
128
+ Debug.Assert( op > 0 && op < 0xff );
129
+ if ( isTemp != 0 )
130
+ {
131
+ /* If TEMP was specified, then the trigger name may not be qualified. */
132
+ if ( pName2.n > 0 )
133
+ {
134
+ sqlite3ErrorMsg( pParse, "temporary trigger may not have qualified name" );
135
+ goto trigger_cleanup;
136
+ }
137
+ iDb = 1;
138
+ pName = pName1;
139
+ }
140
+ else
141
+ {
142
+ /* Figure out the db that the the trigger will be created in */
143
+ iDb = sqlite3TwoPartName( pParse, pName1, pName2, ref pName );
144
+ if ( iDb < 0 )
145
+ {
146
+ goto trigger_cleanup;
147
+ }
148
+ }
149
+
150
+ /* If the trigger name was unqualified, and the table is a temp table,
151
+ ** then set iDb to 1 to create the trigger in the temporary database.
152
+ ** If sqlite3SrcListLookup() returns 0, indicating the table does not
153
+ ** exist, the error is caught by the block below.
154
+ */
155
+ if ( pTableName == null /*|| db.mallocFailed != 0 */ )
156
+ {
157
+ goto trigger_cleanup;
158
+ }
159
+ pTab = sqlite3SrcListLookup( pParse, pTableName );
160
+ if (db.init.busy == 0 && pName2.n == 0 && pTab != null
161
+ && pTab.pSchema == db.aDb[1].pSchema)
162
+ {
163
+ iDb = 1;
164
+ }
165
+
166
+ /* Ensure the table name matches database name and that the table exists */
167
+ // if ( db.mallocFailed != 0 ) goto trigger_cleanup;
168
+ Debug.Assert( pTableName.nSrc == 1 );
169
+ if ( sqlite3FixInit( sFix, pParse, iDb, "trigger", pName ) != 0 &&
170
+ sqlite3FixSrcList( sFix, pTableName ) != 0 )
171
+ {
172
+ goto trigger_cleanup;
173
+ }
174
+ pTab = sqlite3SrcListLookup( pParse, pTableName );
175
+ if ( pTab == null )
176
+ {
177
+ /* The table does not exist. */
178
+ if ( db.init.iDb == 1 )
179
+ {
180
+ /* Ticket #3810.
181
+ ** Normally, whenever a table is dropped, all associated triggers are
182
+ ** dropped too. But if a TEMP trigger is created on a non-TEMP table
183
+ ** and the table is dropped by a different database connection, the
184
+ ** trigger is not visible to the database connection that does the
185
+ ** drop so the trigger cannot be dropped. This results in an
186
+ ** "orphaned trigger" - a trigger whose associated table is missing.
187
+ */
188
+ db.init.orphanTrigger = 1;
189
+ }
190
+ goto trigger_cleanup;
191
+ }
192
+ if ( IsVirtual( pTab ) )
193
+ {
194
+ sqlite3ErrorMsg( pParse, "cannot create triggers on virtual tables" );
195
+ goto trigger_cleanup;
196
+ }
197
+
198
+ /* Check that the trigger name is not reserved and that no trigger of the
199
+ ** specified name exists */
200
+ zName = sqlite3NameFromToken( db, pName );
201
+ if ( zName == null || SQLITE_OK != sqlite3CheckObjectName( pParse, zName ) )
202
+ {
203
+ goto trigger_cleanup;
204
+ }
205
+ if ( sqlite3HashFind( ( db.aDb[iDb].pSchema.trigHash ),
206
+ zName, sqlite3Strlen30( zName ) ) != null )
207
+ {
208
+ if ( noErr == 0 )
209
+ {
210
+ sqlite3ErrorMsg( pParse, "trigger %T already exists", pName );
211
+ }
212
+ goto trigger_cleanup;
213
+ }
214
+
215
+ /* Do not create a trigger on a system table */
216
+ if ( sqlite3StrNICmp( pTab.zName, "sqlite_", 7 ) == 0 )
217
+ {
218
+ sqlite3ErrorMsg( pParse, "cannot create trigger on system table" );
219
+ pParse.nErr++;
220
+ goto trigger_cleanup;
221
+ }
222
+
223
+ /* INSTEAD of triggers are only for views and views only support INSTEAD
224
+ ** of triggers.
225
+ */
226
+ if ( pTab.pSelect != null && tr_tm != TK_INSTEAD )
227
+ {
228
+ sqlite3ErrorMsg( pParse, "cannot create %s trigger on view: %S",
229
+ ( tr_tm == TK_BEFORE ) ? "BEFORE" : "AFTER", pTableName, 0 );
230
+ goto trigger_cleanup;
231
+ }
232
+ if ( pTab.pSelect == null && tr_tm == TK_INSTEAD )
233
+ {
234
+ sqlite3ErrorMsg( pParse, "cannot create INSTEAD OF" +
235
+ " trigger on table: %S", pTableName, 0 );
236
+ goto trigger_cleanup;
237
+ }
238
+ iTabDb = sqlite3SchemaToIndex( db, pTab.pSchema );
239
+
240
+ #if !SQLITE_OMIT_AUTHORIZATION
241
+ {
242
+ int code = SQLITE_CREATE_TRIGGER;
243
+ string zDb = db.aDb[iTabDb].zName;
244
+ string zDbTrig = isTemp ? db.aDb[1].zName : zDb;
245
+ if( iTabDb==1 || isTemp ) code = SQLITE_CREATE_TEMP_TRIGGER;
246
+ if( sqlite3AuthCheck(pParse, code, zName, pTab.zName, zDbTrig) ){
247
+ goto trigger_cleanup;
248
+ }
249
+ if( sqlite3AuthCheck(pParse, SQLITE_INSERT, SCHEMA_TABLE(iTabDb),0,zDb)){
250
+ goto trigger_cleanup;
251
+ }
252
+ }
253
+ #endif
254
+
255
+ /* INSTEAD OF triggers can only appear on views and BEFORE triggers
256
+ ** cannot appear on views. So we might as well translate every
257
+ ** INSTEAD OF trigger into a BEFORE trigger. It simplifies code
258
+ ** elsewhere.
259
+ */
260
+ if ( tr_tm == TK_INSTEAD )
261
+ {
262
+ tr_tm = TK_BEFORE;
263
+ }
264
+
265
+ /* Build the Trigger object */
266
+ pTrigger = new Trigger();// (Trigger*)sqlite3DbMallocZero( db, sizeof(Trigger ))
267
+ if ( pTrigger == null ) goto trigger_cleanup;
268
+ pTrigger.zName = zName;
269
+ pTrigger.table = pTableName.a[0].zName;// sqlite3DbStrDup( db, pTableName.a[0].zName );
270
+ pTrigger.pSchema = db.aDb[iDb].pSchema;
271
+ pTrigger.pTabSchema = pTab.pSchema;
272
+ pTrigger.op = (u8)op;
273
+ pTrigger.tr_tm = tr_tm == TK_BEFORE ? TRIGGER_BEFORE : TRIGGER_AFTER;
274
+ pTrigger.pWhen = sqlite3ExprDup( db, pWhen, EXPRDUP_REDUCE );
275
+ pTrigger.pColumns = sqlite3IdListDup( db, pColumns );
276
+ Debug.Assert( pParse.pNewTrigger == null );
277
+ pParse.pNewTrigger = pTrigger;
278
+
279
+ trigger_cleanup:
280
+ sqlite3DbFree( db, ref zName );
281
+ sqlite3SrcListDelete( db, ref pTableName );
282
+ sqlite3IdListDelete( db, ref pColumns );
283
+ sqlite3ExprDelete( db, ref pWhen );
284
+ if ( pParse.pNewTrigger == null )
285
+ {
286
+ sqlite3DeleteTrigger( db, ref pTrigger );
287
+ }
288
+ else
289
+ {
290
+ Debug.Assert( pParse.pNewTrigger == pTrigger );
291
+ }
292
+ }
293
+
294
+ /*
295
+ ** This routine is called after all of the trigger actions have been parsed
296
+ ** in order to complete the process of building the trigger.
297
+ */
298
+ static void sqlite3FinishTrigger(
299
+ Parse pParse, /* Parser context */
300
+ TriggerStep pStepList, /* The triggered program */
301
+ Token pAll /* Token that describes the complete CREATE TRIGGER */
302
+ )
303
+ {
304
+ Trigger pTrig = pParse.pNewTrigger; /* Trigger being finished */
305
+ string zName; /* Name of trigger */
306
+
307
+ sqlite3 db = pParse.db; /* The database */
308
+ DbFixer sFix = new DbFixer(); /* Fixer object */
309
+ int iDb; /* Database containing the trigger */
310
+ Token nameToken = new Token(); /* Trigger name for error reporting */
311
+
312
+ pTrig = pParse.pNewTrigger;
313
+ pParse.pNewTrigger = null;
314
+ if ( NEVER( pParse.nErr != 0 ) || pTrig == null ) goto triggerfinish_cleanup;
315
+ zName = pTrig.zName;
316
+ iDb = sqlite3SchemaToIndex( pParse.db, pTrig.pSchema );
317
+ pTrig.step_list = pStepList;
318
+ while ( pStepList != null )
319
+ {
320
+ pStepList.pTrig = pTrig;
321
+ pStepList = pStepList.pNext;
322
+ }
323
+ nameToken.z = pTrig.zName;
324
+ nameToken.n = sqlite3Strlen30( nameToken.z );
325
+ if ( sqlite3FixInit( sFix, pParse, iDb, "trigger", nameToken ) != 0
326
+ && sqlite3FixTriggerStep( sFix, pTrig.step_list ) != 0 )
327
+ {
328
+ goto triggerfinish_cleanup;
329
+ }
330
+
331
+ /* if we are not initializing,
332
+ ** build the sqlite_master entry
333
+ */
334
+ if ( 0 == db.init.busy )
335
+ {
336
+ Vdbe v;
337
+ string z;
338
+
339
+ /* Make an entry in the sqlite_master table */
340
+ v = sqlite3GetVdbe( pParse );
341
+ if ( v == null ) goto triggerfinish_cleanup;
342
+ sqlite3BeginWriteOperation( pParse, 0, iDb );
343
+ z = pAll.z.Substring( 0, pAll.n );//sqlite3DbStrNDup( db, (char*)pAll.z, pAll.n );
344
+ sqlite3NestedParse( pParse,
345
+ "INSERT INTO %Q.%s VALUES('trigger',%Q,%Q,0,'CREATE TRIGGER %q')",
346
+ db.aDb[iDb].zName, SCHEMA_TABLE( iDb ), zName,
347
+ pTrig.table, z );
348
+ sqlite3DbFree( db, ref z );
349
+ sqlite3ChangeCookie( pParse, iDb );
350
+ sqlite3VdbeAddOp4( v, OP_ParseSchema, iDb, 0, 0, sqlite3MPrintf(
351
+ db, "type='trigger' AND name='%q'", zName ), P4_DYNAMIC
352
+ );
353
+ }
354
+
355
+ if ( db.init.busy != 0 )
356
+ {
357
+ Trigger pLink = pTrig;
358
+ Hash pHash = db.aDb[iDb].pSchema.trigHash;
359
+ pTrig = (Trigger)sqlite3HashInsert( ref pHash, zName, sqlite3Strlen30( zName ), pTrig );
360
+ if ( pTrig != null )
361
+ {
362
+ //db.mallocFailed = 1;
363
+ }
364
+ else if ( pLink.pSchema == pLink.pTabSchema )
365
+ {
366
+ Table pTab;
367
+ int n = sqlite3Strlen30( pLink.table );
368
+ pTab = (Table)sqlite3HashFind( pLink.pTabSchema.tblHash, pLink.table, n );
369
+ Debug.Assert( pTab != null );
370
+ pLink.pNext = pTab.pTrigger;
371
+ pTab.pTrigger = pLink;
372
+ }
373
+ }
374
+
375
+ triggerfinish_cleanup:
376
+ sqlite3DeleteTrigger( db, ref pTrig );
377
+ Debug.Assert( pParse.pNewTrigger == null );
378
+ sqlite3DeleteTriggerStep( db, ref pStepList );
379
+ }
380
+
381
+ /*
382
+ ** Turn a SELECT statement (that the pSelect parameter points to) into
383
+ ** a trigger step. Return a pointer to a TriggerStep structure.
384
+ **
385
+ ** The parser calls this routine when it finds a SELECT statement in
386
+ ** body of a TRIGGER.
387
+ */
388
+ static TriggerStep sqlite3TriggerSelectStep( sqlite3 db, Select pSelect )
389
+ {
390
+ TriggerStep pTriggerStep = new TriggerStep();// sqlite3DbMallocZero( db, sizeof(TriggerStep ))
391
+ if ( pTriggerStep == null )
392
+ {
393
+ sqlite3SelectDelete( db, ref pSelect );
394
+ return null;
395
+ }
396
+
397
+ pTriggerStep.op = TK_SELECT;
398
+ pTriggerStep.pSelect = pSelect;
399
+ pTriggerStep.orconf = OE_Default;
400
+ return pTriggerStep;
401
+ }
402
+
403
+ /*
404
+ ** Allocate space to hold a new trigger step. The allocated space
405
+ ** holds both the TriggerStep object and the TriggerStep.target.z string.
406
+ **
407
+ ** If an OOM error occurs, NULL is returned and db.mallocFailed is set.
408
+ */
409
+ static TriggerStep triggerStepAllocate(
410
+ sqlite3 db, /* Database connection */
411
+ u8 op, /* Trigger opcode */
412
+ Token pName /* The target name */
413
+ )
414
+ {
415
+ TriggerStep pTriggerStep;
416
+
417
+ pTriggerStep = new TriggerStep();// sqlite3DbMallocZero( db, sizeof( TriggerStep ) + pName.n );
418
+ //if ( pTriggerStep != null )
419
+ //{
420
+ string z;// = (char*)&pTriggerStep[1];
421
+ z = pName.z;// memcpy( z, pName.z, pName.n );
422
+ pTriggerStep.target.z = z;
423
+ pTriggerStep.target.n = pName.n;
424
+ pTriggerStep.op = op;
425
+ //}
426
+ return pTriggerStep;
427
+ }
428
+
429
+ /*
430
+ ** Build a trigger step out of an INSERT statement. Return a pointer
431
+ ** to the new trigger step.
432
+ **
433
+ ** The parser calls this routine when it sees an INSERT inside the
434
+ ** body of a trigger.
435
+ */
436
+ // OVERLOADS, so I don't need to rewrite parse.c
437
+ static TriggerStep sqlite3TriggerInsertStep( sqlite3 db, Token pTableName, IdList pColumn, int null_4, int null_5, u8 orconf )
438
+ { return sqlite3TriggerInsertStep( db, pTableName, pColumn, null, null, orconf ); }
439
+ static TriggerStep sqlite3TriggerInsertStep( sqlite3 db, Token pTableName, IdList pColumn, ExprList pEList, int null_5, u8 orconf )
440
+ { return sqlite3TriggerInsertStep( db, pTableName, pColumn, pEList, null, orconf ); }
441
+ static TriggerStep sqlite3TriggerInsertStep( sqlite3 db, Token pTableName, IdList pColumn, int null_4, Select pSelect, u8 orconf )
442
+ { return sqlite3TriggerInsertStep( db, pTableName, pColumn, null, pSelect, orconf ); }
443
+ static TriggerStep sqlite3TriggerInsertStep(
444
+ sqlite3 db, /* The database connection */
445
+ Token pTableName, /* Name of the table into which we insert */
446
+ IdList pColumn, /* List of columns in pTableName to insert into */
447
+ ExprList pEList, /* The VALUE clause: a list of values to be inserted */
448
+ Select pSelect, /* A SELECT statement that supplies values */
449
+ u8 orconf /* The conflict algorithm (OE_Abort, OE_Replace, etc.) */
450
+ )
451
+ {
452
+ TriggerStep pTriggerStep;
453
+
454
+ Debug.Assert( pEList == null || pSelect == null );
455
+ Debug.Assert( pEList != null || pSelect != null /*|| db.mallocFailed != 0 */ );
456
+
457
+ pTriggerStep = triggerStepAllocate( db, TK_INSERT, pTableName );
458
+ //if ( pTriggerStep != null )
459
+ //{
460
+ pTriggerStep.pSelect = sqlite3SelectDup( db, pSelect, EXPRDUP_REDUCE );
461
+ pTriggerStep.pIdList = pColumn;
462
+ pTriggerStep.pExprList = sqlite3ExprListDup( db, pEList, EXPRDUP_REDUCE );
463
+ pTriggerStep.orconf = orconf;
464
+ //}
465
+ //else
466
+ //{
467
+ // sqlite3IdListDelete( db, ref pColumn );
468
+ //}
469
+ sqlite3ExprListDelete( db, ref pEList );
470
+ sqlite3SelectDelete( db, ref pSelect );
471
+
472
+ return pTriggerStep;
473
+ }
474
+
475
+ /*
476
+ ** Construct a trigger step that implements an UPDATE statement and return
477
+ ** a pointer to that trigger step. The parser calls this routine when it
478
+ ** sees an UPDATE statement inside the body of a CREATE TRIGGER.
479
+ */
480
+ static TriggerStep sqlite3TriggerUpdateStep(
481
+ sqlite3 db, /* The database connection */
482
+ Token pTableName, /* Name of the table to be updated */
483
+ ExprList pEList, /* The SET clause: list of column and new values */
484
+ Expr pWhere, /* The WHERE clause */
485
+ u8 orconf /* The conflict algorithm. (OE_Abort, OE_Ignore, etc) */
486
+ )
487
+ {
488
+ TriggerStep pTriggerStep;
489
+
490
+ pTriggerStep = triggerStepAllocate( db, TK_UPDATE, pTableName );
491
+ //if ( pTriggerStep != null )
492
+ //{
493
+ pTriggerStep.pExprList = sqlite3ExprListDup( db, pEList, EXPRDUP_REDUCE );
494
+ pTriggerStep.pWhere = sqlite3ExprDup( db, pWhere, EXPRDUP_REDUCE );
495
+ pTriggerStep.orconf = orconf;
496
+ //}
497
+ sqlite3ExprListDelete( db, ref pEList );
498
+ sqlite3ExprDelete( db, ref pWhere );
499
+ return pTriggerStep;
500
+ }
501
+
502
+ /*
503
+ ** Construct a trigger step that implements a DELETE statement and return
504
+ ** a pointer to that trigger step. The parser calls this routine when it
505
+ ** sees a DELETE statement inside the body of a CREATE TRIGGER.
506
+ */
507
+ static TriggerStep sqlite3TriggerDeleteStep(
508
+ sqlite3 db, /* Database connection */
509
+ Token pTableName, /* The table from which rows are deleted */
510
+ Expr pWhere /* The WHERE clause */
511
+ )
512
+ {
513
+ TriggerStep pTriggerStep;
514
+
515
+ pTriggerStep = triggerStepAllocate( db, TK_DELETE, pTableName );
516
+ //if ( pTriggerStep != null )
517
+ //{
518
+ pTriggerStep.pWhere = sqlite3ExprDup( db, pWhere, EXPRDUP_REDUCE );
519
+ pTriggerStep.orconf = OE_Default;
520
+ //}
521
+ sqlite3ExprDelete( db, ref pWhere );
522
+ return pTriggerStep;
523
+ }
524
+
525
+
526
+
527
+ /*
528
+ ** Recursively delete a Trigger structure
529
+ */
530
+ static void sqlite3DeleteTrigger( sqlite3 db, ref Trigger pTrigger )
531
+ {
532
+ if ( pTrigger == null ) return;
533
+ sqlite3DeleteTriggerStep( db, ref pTrigger.step_list );
534
+ sqlite3DbFree( db, ref pTrigger.zName );
535
+ sqlite3DbFree( db, ref pTrigger.table );
536
+ sqlite3ExprDelete( db, ref pTrigger.pWhen );
537
+ sqlite3IdListDelete( db, ref pTrigger.pColumns );
538
+ pTrigger = null;sqlite3DbFree( db, ref pTrigger );
539
+ }
540
+
541
+ /*
542
+ ** This function is called to drop a trigger from the database schema.
543
+ **
544
+ ** This may be called directly from the parser and therefore identifies
545
+ ** the trigger by name. The sqlite3DropTriggerPtr() routine does the
546
+ ** same job as this routine except it takes a pointer to the trigger
547
+ ** instead of the trigger name.
548
+ **/
549
+ static void sqlite3DropTrigger( Parse pParse, SrcList pName, int noErr )
550
+ {
551
+ Trigger pTrigger = null;
552
+ int i;
553
+ string zDb;
554
+ string zName;
555
+ int nName;
556
+ sqlite3 db = pParse.db;
557
+
558
+ // if ( db.mallocFailed != 0 ) goto drop_trigger_cleanup;
559
+ if ( SQLITE_OK != sqlite3ReadSchema( pParse ) )
560
+ {
561
+ goto drop_trigger_cleanup;
562
+ }
563
+
564
+ Debug.Assert( pName.nSrc == 1 );
565
+ zDb = pName.a[0].zDatabase;
566
+ zName = pName.a[0].zName;
567
+ nName = sqlite3Strlen30( zName );
568
+ for ( i = OMIT_TEMPDB ; i < db.nDb ; i++ )
569
+ {
570
+ int j = ( i < 2 ) ? i ^ 1 : i; /* Search TEMP before MAIN */
571
+ if ( zDb != null && sqlite3StrICmp( db.aDb[j].zName, zDb ) != 0 ) continue;
572
+ pTrigger = (Trigger)sqlite3HashFind( ( db.aDb[j].pSchema.trigHash ), zName, nName );
573
+ if ( pTrigger != null ) break;
574
+ }
575
+ if ( pTrigger == null )
576
+ {
577
+ if ( noErr == 0 )
578
+ {
579
+ sqlite3ErrorMsg( pParse, "no such trigger: %S", pName, 0 );
580
+ }
581
+ goto drop_trigger_cleanup;
582
+ }
583
+ sqlite3DropTriggerPtr( pParse, pTrigger );
584
+
585
+ drop_trigger_cleanup:
586
+ sqlite3SrcListDelete( db, ref pName );
587
+ }
588
+
589
+ /*
590
+ ** Return a pointer to the Table structure for the table that a trigger
591
+ ** is set on.
592
+ */
593
+ static Table tableOfTrigger( Trigger pTrigger )
594
+ {
595
+ int n = sqlite3Strlen30( pTrigger.table );
596
+ return (Table)sqlite3HashFind( pTrigger.pTabSchema.tblHash, pTrigger.table, n );
597
+ }
598
+
599
+
600
+ /*
601
+ ** Drop a trigger given a pointer to that trigger.
602
+ */
603
+ static void sqlite3DropTriggerPtr( Parse pParse, Trigger pTrigger )
604
+ {
605
+ Table pTable;
606
+ Vdbe v;
607
+ sqlite3 db = pParse.db;
608
+ int iDb;
609
+
610
+ iDb = sqlite3SchemaToIndex( pParse.db, pTrigger.pSchema );
611
+ Debug.Assert( iDb >= 0 && iDb < db.nDb );
612
+ pTable = tableOfTrigger( pTrigger );
613
+ Debug.Assert( pTable != null );
614
+ Debug.Assert( pTable.pSchema == pTrigger.pSchema || iDb == 1 );
615
+ #if !SQLITE_OMIT_AUTHORIZATION
616
+ {
617
+ int code = SQLITE_DROP_TRIGGER;
618
+ string zDb = db.aDb[iDb].zName;
619
+ string zTab = SCHEMA_TABLE(iDb);
620
+ if( iDb==1 ) code = SQLITE_DROP_TEMP_TRIGGER;
621
+ if( sqlite3AuthCheck(pParse, code, pTrigger.name, pTable.zName, zDb) ||
622
+ sqlite3AuthCheck(pParse, SQLITE_DELETE, zTab, 0, zDb) ){
623
+ return;
624
+ }
625
+ }
626
+ #endif
627
+
628
+ /* Generate code to destroy the database record of the trigger.
629
+ */
630
+ Debug.Assert( pTable != null );
631
+ if ( ( v = sqlite3GetVdbe( pParse ) ) != null )
632
+ {
633
+ int _base;
634
+ VdbeOpList[] dropTrigger = new VdbeOpList[] {
635
+ new VdbeOpList( OP_Rewind, 0, ADDR(9), 0),
636
+ new VdbeOpList( OP_String8, 0, 1, 0), /* 1 */
637
+ new VdbeOpList( OP_Column, 0, 1, 2),
638
+ new VdbeOpList( OP_Ne, 2, ADDR(8), 1),
639
+ new VdbeOpList( OP_String8, 0, 1, 0), /* 4: "trigger" */
640
+ new VdbeOpList( OP_Column, 0, 0, 2),
641
+ new VdbeOpList( OP_Ne, 2, ADDR(8), 1),
642
+ new VdbeOpList( OP_Delete, 0, 0, 0),
643
+ new VdbeOpList( OP_Next, 0, ADDR(1), 0), /* 8 */
644
+ };
645
+
646
+ sqlite3BeginWriteOperation( pParse, 0, iDb );
647
+ sqlite3OpenMasterTable( pParse, iDb );
648
+ _base = sqlite3VdbeAddOpList( v, dropTrigger.Length, dropTrigger );
649
+ sqlite3VdbeChangeP4( v, _base + 1, pTrigger.zName, 0 );
650
+ sqlite3VdbeChangeP4( v, _base + 4, "trigger", P4_STATIC );
651
+ sqlite3ChangeCookie( pParse, iDb );
652
+ sqlite3VdbeAddOp2( v, OP_Close, 0, 0 );
653
+ sqlite3VdbeAddOp4( v, OP_DropTrigger, iDb, 0, 0, pTrigger.zName, 0 );
654
+ if ( pParse.nMem < 3 )
655
+ {
656
+ pParse.nMem = 3;
657
+ }
658
+ }
659
+ }
660
+
661
+ /*
662
+ ** Remove a trigger from the hash tables of the sqlite* pointer.
663
+ */
664
+ static void sqlite3UnlinkAndDeleteTrigger( sqlite3 db, int iDb, string zName )
665
+ {
666
+ Hash pHash = db.aDb[iDb].pSchema.trigHash;
667
+ Trigger pTrigger;
668
+ pTrigger = (Trigger)sqlite3HashInsert( ref pHash, zName, sqlite3Strlen30( zName ), null );
669
+ if ( ALWAYS( pTrigger != null ) )
670
+ {
671
+ if ( pTrigger.pSchema == pTrigger.pTabSchema )
672
+ {
673
+ Table pTab = tableOfTrigger( pTrigger );
674
+ //Trigger** pp;
675
+ //for ( pp = &pTab.pTrigger ; *pp != pTrigger ; pp = &( (*pp).pNext ) ) ;
676
+ //*pp = (*pp).pNext;
677
+ if ( pTab.pTrigger == pTrigger )
678
+ {
679
+ pTab.pTrigger = pTrigger.pNext;
680
+ }
681
+ else
682
+ {
683
+ Trigger cc = pTab.pTrigger;
684
+ while ( cc != null )
685
+ {
686
+ if ( cc.pNext == pTrigger )
687
+ {
688
+ cc.pNext = cc.pNext.pNext;
689
+ break;
690
+ }
691
+ cc = cc.pNext;
692
+ }
693
+ Debug.Assert( cc != null );
694
+ }
695
+ }
696
+ sqlite3DeleteTrigger( db, ref pTrigger );
697
+ db.flags |= SQLITE_InternChanges;
698
+ }
699
+ }
700
+
701
+ /*
702
+ ** pEList is the SET clause of an UPDATE statement. Each entry
703
+ ** in pEList is of the format <id>=<expr>. If any of the entries
704
+ ** in pEList have an <id> which matches an identifier in pIdList,
705
+ ** then return TRUE. If pIdList==NULL, then it is considered a
706
+ ** wildcard that matches anything. Likewise if pEList==NULL then
707
+ ** it matches anything so always return true. Return false only
708
+ ** if there is no match.
709
+ */
710
+ static int checkColumnOverlap( IdList pIdList, ExprList pEList )
711
+ {
712
+ int e;
713
+ if ( pIdList == null || NEVER( pEList == null ) ) return 1;
714
+ for ( e = 0 ; e < pEList.nExpr ; e++ )
715
+ {
716
+ if ( sqlite3IdListIndex( pIdList, pEList.a[e].zName ) >= 0 ) return 1;
717
+ }
718
+ return 0;
719
+ }
720
+
721
+ /*
722
+ ** Return a list of all triggers on table pTab if there exists at least
723
+ ** one trigger that must be fired when an operation of type 'op' is
724
+ ** performed on the table, and, if that operation is an UPDATE, if at
725
+ ** least one of the columns in pChanges is being modified.
726
+ */
727
+ static Trigger sqlite3TriggersExist(
728
+ Parse pParse, /* Parse context */
729
+ Table pTab, /* The table the contains the triggers */
730
+ int op, /* one of TK_DELETE, TK_INSERT, TK_UPDATE */
731
+ ExprList pChanges, /* Columns that change in an UPDATE statement */
732
+ ref int pMask /* OUT: Mask of TRIGGER_BEFORE|TRIGGER_AFTER */
733
+ )
734
+ {
735
+ int mask = 0;
736
+ Trigger pList = sqlite3TriggerList( pParse, pTab );
737
+ Trigger p;
738
+ Debug.Assert( pList == null || IsVirtual( pTab ) == false );
739
+ for ( p = pList ; p != null ; p = p.pNext )
740
+ {
741
+ if ( p.op == op && checkColumnOverlap( p.pColumns, pChanges ) != 0 )
742
+ {
743
+ mask |= p.tr_tm;
744
+ }
745
+ }
746
+ //if ( pMask != 0 )
747
+ {
748
+ pMask = mask;
749
+ }
750
+ return ( mask != 0 ? pList : null );
751
+ }
752
+
753
+
754
+ /*
755
+ ** Convert the pStep.target token into a SrcList and return a pointer
756
+ ** to that SrcList.
757
+ **
758
+ ** This routine adds a specific database name, if needed, to the target when
759
+ ** forming the SrcList. This prevents a trigger in one database from
760
+ ** referring to a target in another database. An exception is when the
761
+ ** trigger is in TEMP in which case it can refer to any other database it
762
+ ** wants.
763
+ */
764
+ static SrcList targetSrcList(
765
+ Parse pParse, /* The parsing context */
766
+ TriggerStep pStep /* The trigger containing the target token */
767
+ )
768
+ {
769
+ int iDb; /* Index of the database to use */
770
+ SrcList pSrc; /* SrcList to be returned */
771
+
772
+ pSrc = sqlite3SrcListAppend( pParse.db, 0, pStep.target, 0 );
773
+ //if ( pSrc != null )
774
+ //{
775
+ Debug.Assert( pSrc.nSrc > 0 );
776
+ Debug.Assert( pSrc.a != null );
777
+ iDb = sqlite3SchemaToIndex( pParse.db, pStep.pTrig.pSchema );
778
+ if ( iDb == 0 || iDb >= 2 )
779
+ {
780
+ sqlite3 db = pParse.db;
781
+ Debug.Assert( iDb < pParse.db.nDb );
782
+ pSrc.a[pSrc.nSrc - 1].zDatabase = db.aDb[iDb].zName;// sqlite3DbStrDup( db, db.aDb[iDb].zName );
783
+ }
784
+ //}
785
+ return pSrc;
786
+ }
787
+
788
+ /*
789
+ ** Generate VDBE code for the statements inside the body of a single
790
+ ** trigger.
791
+ */
792
+ static int codeTriggerProgram(
793
+ Parse pParse, /* The parser context */
794
+ TriggerStep pStepList, /* List of statements inside the trigger body */
795
+ int orconf /* Conflict algorithm. (OE_Abort, etc) */
796
+ )
797
+ {
798
+ TriggerStep pStep;
799
+ Vdbe v = pParse.pVdbe;
800
+ sqlite3 db = pParse.db;
801
+
802
+ Debug.Assert( pParse.pTriggerTab != null && pParse.pToplevel != null );
803
+ Debug.Assert( pStepList!=null );
804
+ Debug.Assert( v!=null );
805
+ for(pStep=pStepList; pStep!=null; pStep=pStep.pNext){
806
+ /* Figure out the ON CONFLICT policy that will be used for this step
807
+ ** of the trigger program. If the statement that caused this trigger
808
+ ** to fire had an explicit ON CONFLICT, then use it. Otherwise, use
809
+ ** the ON CONFLICT policy that was specified as part of the trigger
810
+ ** step statement. Example:
811
+ **
812
+ ** CREATE TRIGGER AFTER INSERT ON t1 BEGIN;
813
+ ** INSERT OR REPLACE INTO t2 VALUES(new.a, new.b);
814
+ ** END;
815
+ **
816
+ ** INSERT INTO t1 ... ; -- insert into t2 uses REPLACE policy
817
+ ** INSERT OR IGNORE INTO t1 ... ; -- insert into t2 uses IGNORE policy
818
+ */
819
+ pParse.eOrconf = (orconf==OE_Default)?pStep.orconf:(u8)orconf;
820
+
821
+ switch( pStep.op ){
822
+ case TK_UPDATE: {
823
+ sqlite3Update(pParse,
824
+ targetSrcList(pParse, pStep),
825
+ sqlite3ExprListDup(db, pStep.pExprList, 0),
826
+ sqlite3ExprDup(db, pStep.pWhere, 0),
827
+ pParse.eOrconf
828
+ );
829
+ break;
830
+ }
831
+ case TK_INSERT: {
832
+ sqlite3Insert(pParse,
833
+ targetSrcList(pParse, pStep),
834
+ sqlite3ExprListDup(db, pStep.pExprList, 0),
835
+ sqlite3SelectDup(db, pStep.pSelect, 0),
836
+ sqlite3IdListDup(db, pStep.pIdList),
837
+ pParse.eOrconf
838
+ );
839
+ break;
840
+ }
841
+ case TK_DELETE: {
842
+ sqlite3DeleteFrom(pParse,
843
+ targetSrcList(pParse, pStep),
844
+ sqlite3ExprDup(db, pStep.pWhere, 0)
845
+ );
846
+ break;
847
+ }
848
+ default: Debug.Assert( pStep.op==TK_SELECT ); {
849
+ SelectDest sDest = new SelectDest();
850
+ Select pSelect = sqlite3SelectDup(db, pStep.pSelect, 0);
851
+ sqlite3SelectDestInit(sDest, SRT_Discard, 0);
852
+ sqlite3Select(pParse, pSelect, ref sDest);
853
+ sqlite3SelectDelete(db, ref pSelect);
854
+ break;
855
+ }
856
+ }
857
+ if( pStep.op!=TK_SELECT ){
858
+ sqlite3VdbeAddOp0(v, OP_ResetCount);
859
+ }
860
+ }
861
+
862
+ return 0;
863
+ }
864
+
865
+ #if SQLITE_DEBUG
866
+ /*
867
+ ** This function is used to add VdbeComment() annotations to a VDBE
868
+ ** program. It is not used in production code, only for debugging.
869
+ */
870
+ static string onErrorText(int onError){
871
+ switch( onError ){
872
+ case OE_Abort: return "abort";
873
+ case OE_Rollback: return "rollback";
874
+ case OE_Fail: return "fail";
875
+ case OE_Replace: return "replace";
876
+ case OE_Ignore: return "ignore";
877
+ case OE_Default: return "default";
878
+ }
879
+ return "n/a";
880
+ }
881
+ #endif
882
+
883
+ /*
884
+ ** Parse context structure pFrom has just been used to create a sub-vdbe
885
+ ** (trigger program). If an error has occurred, transfer error information
886
+ ** from pFrom to pTo.
887
+ */
888
+ static void transferParseError(Parse pTo, Parse pFrom){
889
+ Debug.Assert( String.IsNullOrEmpty(pFrom.zErrMsg )|| pFrom.nErr!=0 );
890
+ Debug.Assert( String.IsNullOrEmpty( pTo.zErrMsg ) || pTo.nErr != 0 );
891
+ if( pTo.nErr==0 ){
892
+ pTo.zErrMsg = pFrom.zErrMsg;
893
+ pTo.nErr = pFrom.nErr;
894
+ }else{
895
+ sqlite3DbFree(pFrom.db, ref pFrom.zErrMsg);
896
+ }
897
+ }
898
+
899
+ /*
900
+ ** Create and populate a new TriggerPrg object with a sub-program
901
+ ** implementing trigger pTrigger with ON CONFLICT policy orconf.
902
+ */
903
+ static TriggerPrg codeRowTrigger(
904
+ Parse pParse, /* Current parse context */
905
+ Trigger pTrigger, /* Trigger to code */
906
+ Table pTab, /* The table pTrigger is attached to */
907
+ int orconf /* ON CONFLICT policy to code trigger program with */
908
+ ){
909
+ Parse pTop = sqlite3ParseToplevel(pParse);
910
+ sqlite3 db = pParse.db; /* Database handle */
911
+ TriggerPrg pPrg; /* Value to return */
912
+ Expr pWhen = null; /* Duplicate of trigger WHEN expression */
913
+ Vdbe v; /* Temporary VM */
914
+ NameContext sNC; /* Name context for sub-vdbe */
915
+ SubProgram pProgram = null; /* Sub-vdbe for trigger program */
916
+ Parse pSubParse; /* Parse context for sub-vdbe */
917
+ int iEndTrigger = 0; /* Label to jump to if WHEN is false */
918
+
919
+ Debug.Assert( pTrigger.zName==null ||pTab==tableOfTrigger(pTrigger) );
920
+
921
+ /* Allocate the TriggerPrg and SubProgram objects. To ensure that they
922
+ ** are freed if an error occurs, link them into the Parse.pTriggerPrg
923
+ ** list of the top-level Parse object sooner rather than later. */
924
+ pPrg = new TriggerPrg();// sqlite3DbMallocZero( db, sizeof( TriggerPrg ) );
925
+ //if ( null == pPrg ) return 0;
926
+ pPrg.pNext = pTop.pTriggerPrg;
927
+ pTop.pTriggerPrg = pPrg;
928
+ pPrg.pProgram = pProgram = new SubProgram();// sqlite3DbMallocZero( db, sizeof( SubProgram ) );
929
+ //if( null==pProgram ) return 0;
930
+ pProgram.nRef = 1;
931
+ pPrg.pTrigger = pTrigger;
932
+ pPrg.orconf = orconf;
933
+ pPrg.aColmask[0] = 0xffffffff;
934
+ pPrg.aColmask[1] = 0xffffffff;
935
+
936
+
937
+ /* Allocate and populate a new Parse context to use for coding the
938
+ ** trigger sub-program. */
939
+ pSubParse = new Parse();// sqlite3StackAllocZero( db, sizeof( Parse ) );
940
+ //if ( null == pSubParse ) return null;
941
+ sNC = new NameContext();// memset( &sNC, 0, sizeof( sNC ) );
942
+ sNC.pParse = pSubParse;
943
+ pSubParse.db = db;
944
+ pSubParse.pTriggerTab = pTab;
945
+ pSubParse.pToplevel = pTop;
946
+ pSubParse.zAuthContext = pTrigger.zName;
947
+ pSubParse.eTriggerOp = pTrigger.op;
948
+
949
+ v = sqlite3GetVdbe(pSubParse);
950
+ if ( v != null )
951
+ {
952
+ #if SQLITE_DEBUG
953
+ VdbeComment(v, "Start: %s.%s (%s %s%s%s ON %s)",
954
+ pTrigger.zName, onErrorText(orconf),
955
+ (pTrigger.tr_tm==TRIGGER_BEFORE ? "BEFORE" : "AFTER"),
956
+ (pTrigger.op==TK_UPDATE ? "UPDATE" : ""),
957
+ (pTrigger.op==TK_INSERT ? "INSERT" : ""),
958
+ (pTrigger.op==TK_DELETE ? "DELETE" : ""),
959
+ pTab.zName
960
+ );
961
+ #endif
962
+ #if !SQLITE_OMIT_TRACE
963
+ sqlite3VdbeChangeP4(v, -1,
964
+ sqlite3MPrintf(db, "-- TRIGGER %s", pTrigger.zName), P4_DYNAMIC
965
+ );
966
+ #endif
967
+
968
+ /* If one was specified, code the WHEN clause. If it evaluates to false
969
+ ** (or NULL) the sub-vdbe is immediately halted by jumping to the
970
+ ** OP_Halt inserted at the end of the program. */
971
+ if( pTrigger.pWhen !=null){
972
+ pWhen = sqlite3ExprDup(db, pTrigger.pWhen, 0);
973
+ if( SQLITE_OK==sqlite3ResolveExprNames(sNC, ref pWhen)
974
+ //&& db.mallocFailed==0
975
+ ){
976
+ iEndTrigger = sqlite3VdbeMakeLabel(v);
977
+ sqlite3ExprIfFalse(pSubParse, pWhen, iEndTrigger, SQLITE_JUMPIFNULL);
978
+ }
979
+ sqlite3ExprDelete(db,ref pWhen);
980
+ }
981
+
982
+ /* Code the trigger program into the sub-vdbe. */
983
+ codeTriggerProgram(pSubParse, pTrigger.step_list, orconf);
984
+
985
+ /* Insert an OP_Halt at the end of the sub-program. */
986
+ if( iEndTrigger !=0){
987
+ sqlite3VdbeResolveLabel(v, iEndTrigger);
988
+ }
989
+ sqlite3VdbeAddOp0(v, OP_Halt);
990
+ #if SQLITE_DEBUG
991
+ VdbeComment(v, "End: %s.%s", pTrigger.zName, onErrorText(orconf));
992
+ #endif
993
+ transferParseError(pParse, pSubParse);
994
+ //if( db.mallocFailed==0 ){
995
+ pProgram.aOp = sqlite3VdbeTakeOpArray(v, ref pProgram.nOp, ref pTop.nMaxArg);
996
+ //}
997
+ pProgram.nMem = pSubParse.nMem;
998
+ pProgram.nCsr = pSubParse.nTab;
999
+ pProgram.token = pTrigger.GetHashCode();
1000
+ pPrg.aColmask[0] = pSubParse.oldmask;
1001
+ pPrg.aColmask[1] = pSubParse.newmask;
1002
+ sqlite3VdbeDelete(ref v);
1003
+ }
1004
+
1005
+ Debug.Assert( null==pSubParse.pAinc && null==pSubParse.pZombieTab );
1006
+ Debug.Assert( null == pSubParse.pTriggerPrg && 0==pSubParse.nMaxArg );
1007
+ //sqlite3StackFree(db, pSubParse);
1008
+
1009
+ return pPrg;
1010
+ }
1011
+
1012
+ /*
1013
+ ** Return a pointer to a TriggerPrg object containing the sub-program for
1014
+ ** trigger pTrigger with default ON CONFLICT algorithm orconf. If no such
1015
+ ** TriggerPrg object exists, a new object is allocated and populated before
1016
+ ** being returned.
1017
+ */
1018
+ static TriggerPrg getRowTrigger(
1019
+ Parse pParse, /* Current parse context */
1020
+ Trigger pTrigger, /* Trigger to code */
1021
+ Table pTab, /* The table trigger pTrigger is attached to */
1022
+ int orconf /* ON CONFLICT algorithm. */
1023
+ ){
1024
+ Parse pRoot = sqlite3ParseToplevel(pParse);
1025
+ TriggerPrg pPrg;
1026
+
1027
+ Debug.Assert( pTrigger.zName==null || pTab==tableOfTrigger(pTrigger) );
1028
+
1029
+ /* It may be that this trigger has already been coded (or is in the
1030
+ ** process of being coded). If this is the case, then an entry with
1031
+ ** a matching TriggerPrg.pTrigger field will be present somewhere
1032
+ ** in the Parse.pTriggerPrg list. Search for such an entry. */
1033
+ for(pPrg=pRoot.pTriggerPrg;
1034
+ pPrg !=null&& (pPrg.pTrigger!=pTrigger || pPrg.orconf!=orconf);
1035
+ pPrg=pPrg.pNext
1036
+ );
1037
+
1038
+ /* If an existing TriggerPrg could not be located, create a new one. */
1039
+ if( null==pPrg ){
1040
+ pPrg = codeRowTrigger(pParse, pTrigger, pTab, orconf);
1041
+ }
1042
+
1043
+ return pPrg;
1044
+ }
1045
+
1046
+ /*
1047
+ ** Generate code for the trigger program associated with trigger p on
1048
+ ** table pTab. The reg, orconf and ignoreJump parameters passed to this
1049
+ ** function are the same as those described in the header function for
1050
+ ** sqlite3CodeRowTrigger()
1051
+ */
1052
+ static void sqlite3CodeRowTriggerDirect(
1053
+ Parse pParse, /* Parse context */
1054
+ Trigger p, /* Trigger to code */
1055
+ Table pTab, /* The table to code triggers from */
1056
+ int reg, /* Reg array containing OLD.* and NEW.* values */
1057
+ int orconf, /* ON CONFLICT policy */
1058
+ int ignoreJump /* Instruction to jump to for RAISE(IGNORE) */
1059
+ ){
1060
+ Vdbe v = sqlite3GetVdbe(pParse); /* Main VM */
1061
+ TriggerPrg pPrg;
1062
+ pPrg = getRowTrigger(pParse, p, pTab, orconf);
1063
+ Debug.Assert( pPrg !=null|| pParse.nErr !=0);//|| pParse.db.mallocFailed );
1064
+
1065
+ /* Code the OP_Program opcode in the parent VDBE. P4 of the OP_Program
1066
+ ** is a pointer to the sub-vdbe containing the trigger program. */
1067
+ if( pPrg !=null){
1068
+ sqlite3VdbeAddOp3(v, OP_Program, reg, ignoreJump, ++pParse.nMem);
1069
+ pPrg.pProgram.nRef++;
1070
+ sqlite3VdbeChangeP4(v, -1, pPrg.pProgram, P4_SUBPROGRAM);
1071
+ #if SQLITE_DEBUG
1072
+ VdbeComment
1073
+ (v, "Call: %s.%s", (!String.IsNullOrEmpty(p.zName)?p.zName:"fkey"), onErrorText(orconf));
1074
+ #endif
1075
+
1076
+ /* Set the P5 operand of the OP_Program instruction to non-zero if
1077
+ ** recursive invocation of this trigger program is disallowed. Recursive
1078
+ ** invocation is disallowed if (a) the sub-program is really a trigger,
1079
+ ** not a foreign key action, and (b) the flag to enable recursive triggers
1080
+ ** is clear. */
1081
+ sqlite3VdbeChangeP5( v, (u8)( !String.IsNullOrEmpty( p.zName ) && 0 == ( pParse.db.flags & SQLITE_RecTriggers ) ? 1 : 0 ) );
1082
+ }
1083
+ }
1084
+
1085
+ /*
1086
+ ** This is called to code the required FOR EACH ROW triggers for an operation
1087
+ ** on table pTab. The operation to code triggers for (INSERT, UPDATE or DELETE)
1088
+ ** is given by the op paramater. The tr_tm parameter determines whether the
1089
+ ** BEFORE or AFTER triggers are coded. If the operation is an UPDATE, then
1090
+ ** parameter pChanges is passed the list of columns being modified.
1091
+ **
1092
+ ** If there are no triggers that fire at the specified time for the specified
1093
+ ** operation on pTab, this function is a no-op.
1094
+ **
1095
+ ** The reg argument is the address of the first in an array of registers
1096
+ ** that contain the values substituted for the new.* and old.* references
1097
+ ** in the trigger program. If N is the number of columns in table pTab
1098
+ ** (a copy of pTab.nCol), then registers are populated as follows:
1099
+ **
1100
+ ** Register Contains
1101
+ ** ------------------------------------------------------
1102
+ ** reg+0 OLD.rowid
1103
+ ** reg+1 OLD.* value of left-most column of pTab
1104
+ ** ... ...
1105
+ ** reg+N OLD.* value of right-most column of pTab
1106
+ ** reg+N+1 NEW.rowid
1107
+ ** reg+N+2 OLD.* value of left-most column of pTab
1108
+ ** ... ...
1109
+ ** reg+N+N+1 NEW.* value of right-most column of pTab
1110
+ **
1111
+ ** For ON DELETE triggers, the registers containing the NEW.* values will
1112
+ ** never be accessed by the trigger program, so they are not allocated or
1113
+ ** populated by the caller (there is no data to populate them with anyway).
1114
+ ** Similarly, for ON INSERT triggers the values stored in the OLD.* registers
1115
+ ** are never accessed, and so are not allocated by the caller. So, for an
1116
+ ** ON INSERT trigger, the value passed to this function as parameter reg
1117
+ ** is not a readable register, although registers (reg+N) through
1118
+ ** (reg+N+N+1) are.
1119
+ **
1120
+ ** Parameter orconf is the default conflict resolution algorithm for the
1121
+ ** trigger program to use (REPLACE, IGNORE etc.). Parameter ignoreJump
1122
+ ** is the instruction that control should jump to if a trigger program
1123
+ ** raises an IGNORE exception.
1124
+ */
1125
+ static void sqlite3CodeRowTrigger(
1126
+ Parse pParse, /* Parse context */
1127
+ Trigger pTrigger, /* List of triggers on table pTab */
1128
+ int op, /* One of TK_UPDATE, TK_INSERT, TK_DELETE */
1129
+ ExprList pChanges, /* Changes list for any UPDATE OF triggers */
1130
+ int tr_tm, /* One of TRIGGER_BEFORE, TRIGGER_AFTER */
1131
+ Table pTab, /* The table to code triggers from */
1132
+ int reg, /* The first in an array of registers (see above) */
1133
+ int orconf, /* ON CONFLICT policy */
1134
+ int ignoreJump /* Instruction to jump to for RAISE(IGNORE) */
1135
+ )
1136
+ {
1137
+ Trigger p; /* Used to iterate through pTrigger list */
1138
+
1139
+ Debug.Assert(op == TK_UPDATE || op == TK_INSERT || op == TK_DELETE);
1140
+ Debug.Assert(tr_tm == TRIGGER_BEFORE || tr_tm == TRIGGER_AFTER );
1141
+ Debug.Assert( (op==TK_UPDATE)==(pChanges!=null) );
1142
+
1143
+ for(p=pTrigger; p!=null; p=p.pNext){
1144
+
1145
+ /* Sanity checking: The schema for the trigger and for the table are
1146
+ ** always defined. The trigger must be in the same schema as the table
1147
+ ** or else it must be a TEMP trigger. */
1148
+ Debug.Assert( p.pSchema != null );
1149
+ Debug.Assert( p.pTabSchema != null );
1150
+ Debug.Assert( p.pSchema == p.pTabSchema
1151
+ || p.pSchema==pParse.db.aDb[1].pSchema );
1152
+
1153
+ /* Determine whether we should code this trigger */
1154
+ if( p.op==op
1155
+ && p.tr_tm==tr_tm
1156
+ && checkColumnOverlap(p.pColumns,pChanges)!=0
1157
+ ){
1158
+ sqlite3CodeRowTriggerDirect(pParse, p, pTab, reg, orconf, ignoreJump);
1159
+ }
1160
+ }
1161
+ }
1162
+
1163
+ /*
1164
+ ** Triggers may access values stored in the old.* or new.* pseudo-table.
1165
+ ** This function returns a 32-bit bitmask indicating which columns of the
1166
+ ** old.* or new.* tables actually are used by triggers. This information
1167
+ ** may be used by the caller, for example, to avoid having to load the entire
1168
+ ** old.* record into memory when executing an UPDATE or DELETE command.
1169
+ **
1170
+ ** Bit 0 of the returned mask is set if the left-most column of the
1171
+ ** table may be accessed using an [old|new].<col> reference. Bit 1 is set if
1172
+ ** the second leftmost column value is required, and so on. If there
1173
+ ** are more than 32 columns in the table, and at least one of the columns
1174
+ ** with an index greater than 32 may be accessed, 0xffffffff is returned.
1175
+ **
1176
+ ** It is not possible to determine if the old.rowid or new.rowid column is
1177
+ ** accessed by triggers. The caller must always assume that it is.
1178
+ **
1179
+ ** Parameter isNew must be either 1 or 0. If it is 0, then the mask returned
1180
+ ** applies to the old.* table. If 1, the new.* table.
1181
+ **
1182
+ ** Parameter tr_tm must be a mask with one or both of the TRIGGER_BEFORE
1183
+ ** and TRIGGER_AFTER bits set. Values accessed by BEFORE triggers are only
1184
+ ** included in the returned mask if the TRIGGER_BEFORE bit is set in the
1185
+ ** tr_tm parameter. Similarly, values accessed by AFTER triggers are only
1186
+ ** included in the returned mask if the TRIGGER_AFTER bit is set in tr_tm.
1187
+ */
1188
+ static u32 sqlite3TriggerColmask(
1189
+ Parse pParse, /* Parse context */
1190
+ Trigger pTrigger, /* List of triggers on table pTab */
1191
+ ExprList pChanges, /* Changes list for any UPDATE OF triggers */
1192
+ int isNew, /* 1 for new.* ref mask, 0 for old.* ref mask */
1193
+ int tr_tm, /* Mask of TRIGGER_BEFORE|TRIGGER_AFTER */
1194
+ Table pTab, /* The table to code triggers from */
1195
+ int orconf /* Default ON CONFLICT policy for trigger steps */
1196
+ ){
1197
+ int op = pChanges !=null ? TK_UPDATE : TK_DELETE;
1198
+ u32 mask = 0;
1199
+ Trigger p;
1200
+
1201
+ Debug.Assert( isNew==1 || isNew==0 );
1202
+ for(p=pTrigger; p!=null ; p=p.pNext){
1203
+ if( p.op==op && (tr_tm&p.tr_tm)!=0
1204
+ && checkColumnOverlap(p.pColumns,pChanges)!=0
1205
+ ){
1206
+ TriggerPrg pPrg;
1207
+ pPrg = getRowTrigger(pParse, p, pTab, orconf);
1208
+ if( pPrg !=null){
1209
+ mask |= pPrg.aColmask[isNew];
1210
+ }
1211
+ }
1212
+ }
1213
+
1214
+ return mask;
1215
+ }
1216
+ #endif // * !SQLITE_OMIT_TRIGGER) */
1217
+
1218
+ }
1219
+ }