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,201 @@
1
+ using System;
2
+ using System.Diagnostics;
3
+
4
+ using i64 = System.Int64;
5
+ using u8 = System.Byte;
6
+ using u32 = System.UInt32;
7
+ using u64 = System.UInt64;
8
+
9
+ namespace Community.CsharpSqlite
10
+ {
11
+ public partial class Sqlite3
12
+ {
13
+ /*
14
+ ** 2001 September 15
15
+ **
16
+ ** The author disclaims copyright to this source code. In place of
17
+ ** a legal notice, here is a blessing:
18
+ **
19
+ ** May you do good and not evil.
20
+ ** May you find forgiveness for yourself and forgive others.
21
+ ** May you share freely, never taking more than you give.
22
+ **
23
+ *************************************************************************
24
+ ** This file contains code to implement a pseudo-random number
25
+ ** generator (PRNG) for SQLite.
26
+ **
27
+ ** Random numbers are used by some of the database backends in order
28
+ ** to generate random integer keys for tables or random filenames.
29
+ *************************************************************************
30
+ ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart
31
+ ** C#-SQLite is an independent reimplementation of the SQLite software library
32
+ **
33
+ ** SQLITE_SOURCE_ID: 2009-12-07 16:39:13 1ed88e9d01e9eda5cbc622e7614277f29bcc551c
34
+ **
35
+ ** $Header$
36
+ *************************************************************************
37
+ */
38
+ //#include "sqliteInt.h"
39
+
40
+
41
+ /* All threads share a single random number generator.
42
+ ** This structure is the current state of the generator.
43
+ */
44
+ public class sqlite3PrngType
45
+ {
46
+ public bool isInit; /* True if initialized */
47
+ public int i;
48
+ public int j; /* State variables */
49
+ public u8[] s = new u8[256]; /* State variables */
50
+
51
+ public sqlite3PrngType Copy()
52
+ {
53
+ sqlite3PrngType cp = (sqlite3PrngType)MemberwiseClone();
54
+ cp.s = new u8[s.Length];
55
+ Array.Copy( s, cp.s, s.Length );
56
+ return cp;
57
+ }
58
+ }
59
+ public static sqlite3PrngType sqlite3Prng = new sqlite3PrngType();
60
+ /*
61
+ ** Get a single 8-bit random value from the RC4 PRNG. The Mutex
62
+ ** must be held while executing this routine.
63
+ **
64
+ ** Why not just use a library random generator like lrand48() for this?
65
+ ** Because the OP_NewRowid opcode in the VDBE depends on having a very
66
+ ** good source of random numbers. The lrand48() library function may
67
+ ** well be good enough. But maybe not. Or maybe lrand48() has some
68
+ ** subtle problems on some systems that could cause problems. It is hard
69
+ ** to know. To minimize the risk of problems due to bad lrand48()
70
+ ** implementations, SQLite uses this random number generator based
71
+ ** on RC4, which we know works very well.
72
+ **
73
+ ** (Later): Actually, OP_NewRowid does not depend on a good source of
74
+ ** randomness any more. But we will leave this code in all the same.
75
+ */
76
+ static u8 randomu8()
77
+ {
78
+ u8 t;
79
+
80
+ /* The "wsdPrng" macro will resolve to the pseudo-random number generator
81
+ ** state vector. If writable static data is unsupported on the target,
82
+ ** we have to locate the state vector at run-time. In the more common
83
+ ** case where writable static data is supported, wsdPrng can refer directly
84
+ ** to the "sqlite3Prng" state vector declared above.
85
+ */
86
+ #if SQLITE_OMIT_WSD
87
+ struct sqlite3PrngType *p = &GLOBAL(struct sqlite3PrngType, sqlite3Prng);
88
+ //# define wsdPrng p[0]
89
+ #else
90
+ //# define wsdPrng sqlite3Prng
91
+ sqlite3PrngType wsdPrng = sqlite3Prng;
92
+ #endif
93
+
94
+
95
+ /* Initialize the state of the random number generator once,
96
+ ** the first time this routine is called. The seed value does
97
+ ** not need to contain a lot of randomness since we are not
98
+ ** trying to do secure encryption or anything like that...
99
+ **
100
+ ** Nothing in this file or anywhere else in SQLite does any kind of
101
+ ** encryption. The RC4 algorithm is being used as a PRNG (pseudo-random
102
+ ** number generator) not as an encryption device.
103
+ */
104
+ if ( !wsdPrng.isInit )
105
+ {
106
+ int i;
107
+ u8[] k = new u8[256];
108
+ wsdPrng.j = 0;
109
+ wsdPrng.i = 0;
110
+ sqlite3OsRandomness( sqlite3_vfs_find( "" ), 256, ref k );
111
+ for ( i = 0; i < 255; i++ )
112
+ {
113
+ wsdPrng.s[i] = (u8)i;
114
+ }
115
+ for ( i = 0; i < 255; i++ )
116
+ {
117
+ wsdPrng.j = (u8)( wsdPrng.j + wsdPrng.s[i] + k[i] );
118
+ t = wsdPrng.s[wsdPrng.j];
119
+ wsdPrng.s[wsdPrng.j] = wsdPrng.s[i];
120
+ wsdPrng.s[i] = t;
121
+ }
122
+ wsdPrng.isInit = true;
123
+ }
124
+
125
+ /* Generate and return single random u8
126
+ */
127
+ wsdPrng.i++;
128
+ t = wsdPrng.s[(u8)wsdPrng.i];
129
+ wsdPrng.j = (u8)( wsdPrng.j + t );
130
+ wsdPrng.s[(u8)wsdPrng.i] = wsdPrng.s[wsdPrng.j];
131
+ wsdPrng.s[wsdPrng.j] = t;
132
+ t += wsdPrng.s[(u8)wsdPrng.i];
133
+ return wsdPrng.s[t];
134
+ }
135
+
136
+ /*
137
+ ** Return N random u8s.
138
+ */
139
+ static void sqlite3_randomness( int N, ref i64 pBuf )
140
+ {
141
+ //u8[] zBuf = new u8[N];
142
+ pBuf = 0;
143
+ #if SQLITE_THREADSAFE
144
+ sqlite3_mutex mutex = sqlite3MutexAlloc( SQLITE_MUTEX_STATIC_PRNG );
145
+ #endif
146
+ sqlite3_mutex_enter( mutex );
147
+ while ( N-- > 0 )
148
+ {
149
+ pBuf = (u32)( ( pBuf << 8 ) + randomu8() );// zBuf[N] = randomu8();
150
+ }
151
+ sqlite3_mutex_leave( mutex );
152
+ }
153
+
154
+ static void sqlite3_randomness(byte[] pBuf, int Offset, int N)
155
+ {
156
+ i64 iBuf = System.DateTime.Now.Ticks;
157
+ sqlite3_mutex_enter( mutex );
158
+ while ( N-- > 0 )
159
+ {
160
+ iBuf = (u32)( ( iBuf << 8 ) + randomu8() );// zBuf[N] = randomu8();
161
+ pBuf[Offset++] = (byte)iBuf;
162
+ }
163
+ sqlite3_mutex_leave( mutex );
164
+ }
165
+
166
+ #if !SQLITE_OMIT_BUILTIN_TEST
167
+ /*
168
+ ** For testing purposes, we sometimes want to preserve the state of
169
+ ** PRNG and restore the PRNG to its saved state at a later time, or
170
+ ** to reset the PRNG to its initial state. These routines accomplish
171
+ ** those tasks.
172
+ **
173
+ ** The sqlite3_test_control() interface calls these routines to
174
+ ** control the PRNG.
175
+ */
176
+ static sqlite3PrngType sqlite3SavedPrng = null;
177
+ static void sqlite3PrngSaveState()
178
+ {
179
+ sqlite3SavedPrng = sqlite3Prng.Copy();
180
+ // memcpy(
181
+ // &GLOBAL(struct sqlite3PrngType, sqlite3SavedPrng),
182
+ // &GLOBAL(struct sqlite3PrngType, sqlite3Prng),
183
+ // sizeof(sqlite3Prng)
184
+ //);
185
+ }
186
+ static void sqlite3PrngRestoreState()
187
+ {
188
+ sqlite3Prng = sqlite3SavedPrng.Copy();
189
+ //memcpy(
190
+ // &GLOBAL(struct sqlite3PrngType, sqlite3Prng),
191
+ // &GLOBAL(struct sqlite3PrngType, sqlite3SavedPrng),
192
+ // sizeof(sqlite3Prng)
193
+ //);
194
+ }
195
+ static void sqlite3PrngResetState()
196
+ {
197
+ sqlite3Prng.isInit = false;// GLOBAL(struct sqlite3PrngType, sqlite3Prng).isInit = 0;
198
+ }
199
+ #endif //* SQLITE_OMIT_BUILTIN_TEST */
200
+ }
201
+ }
@@ -0,0 +1,1396 @@
1
+ using System;
2
+ using System.Diagnostics;
3
+ using System.Text;
4
+
5
+ using Bitmask = System.UInt64;
6
+ using i16 = System.Int16;
7
+ using u8 = System.Byte;
8
+ using u16 = System.UInt16;
9
+ using u32 = System.UInt32;
10
+
11
+ #if !SQLITE_MAX_VARIABLE_NUMBER
12
+ using ynVar = System.Int16;
13
+ #else
14
+ using ynVar = System.Int32;
15
+ #endif
16
+
17
+ namespace Community.CsharpSqlite
18
+ {
19
+ using sqlite3_value = Sqlite3.Mem;
20
+
21
+ public partial class Sqlite3
22
+ {
23
+ /*
24
+ ** 2008 August 18
25
+ **
26
+ ** The author disclaims copyright to this source code. In place of
27
+ ** a legal notice, here is a blessing:
28
+ **
29
+ ** May you do good and not evil.
30
+ ** May you find forgiveness for yourself and forgive others.
31
+ ** May you share freely, never taking more than you give.
32
+ **
33
+ *************************************************************************
34
+ **
35
+ ** This file contains routines used for walking the parser tree and
36
+ ** resolve all identifiers by associating them with a particular
37
+ ** table and column.
38
+ *************************************************************************
39
+ ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart
40
+ ** C#-SQLite is an independent reimplementation of the SQLite software library
41
+ **
42
+ ** SQLITE_SOURCE_ID: 2010-03-09 19:31:43 4ae453ea7be69018d8c16eb8dabe05617397dc4d
43
+ **
44
+ ** $Header$
45
+ *************************************************************************
46
+ */
47
+ //#include "sqliteInt.h"
48
+ //#include <stdlib.h>
49
+ //#include <string.h>
50
+
51
+ /*
52
+ ** Turn the pExpr expression into an alias for the iCol-th column of the
53
+ ** result set in pEList.
54
+ **
55
+ ** If the result set column is a simple column reference, then this routine
56
+ ** makes an exact copy. But for any other kind of expression, this
57
+ ** routine make a copy of the result set column as the argument to the
58
+ ** TK_AS operator. The TK_AS operator causes the expression to be
59
+ ** evaluated just once and then reused for each alias.
60
+ **
61
+ ** The reason for suppressing the TK_AS term when the expression is a simple
62
+ ** column reference is so that the column reference will be recognized as
63
+ ** usable by indices within the WHERE clause processing logic.
64
+ **
65
+ ** Hack: The TK_AS operator is inhibited if zType[0]=='G'. This means
66
+ ** that in a GROUP BY clause, the expression is evaluated twice. Hence:
67
+ **
68
+ ** SELECT random()%5 AS x, count(*) FROM tab GROUP BY x
69
+ **
70
+ ** Is equivalent to:
71
+ **
72
+ ** SELECT random()%5 AS x, count(*) FROM tab GROUP BY random()%5
73
+ **
74
+ ** The result of random()%5 in the GROUP BY clause is probably different
75
+ ** from the result in the result-set. We might fix this someday. Or
76
+ ** then again, we might not...
77
+ */
78
+ static void resolveAlias(
79
+ Parse pParse, /* Parsing context */
80
+ ExprList pEList, /* A result set */
81
+ int iCol, /* A column in the result set. 0..pEList.nExpr-1 */
82
+ Expr pExpr, /* Transform this into an alias to the result set */
83
+ string zType /* "GROUP" or "ORDER" or "" */
84
+ )
85
+ {
86
+ Expr pOrig; /* The iCol-th column of the result set */
87
+ Expr pDup; /* Copy of pOrig */
88
+ sqlite3 db; /* The database connection */
89
+
90
+ Debug.Assert( iCol >= 0 && iCol < pEList.nExpr );
91
+ pOrig = pEList.a[iCol].pExpr;
92
+ Debug.Assert( pOrig != null );
93
+ Debug.Assert( ( pOrig.flags & EP_Resolved ) != 0 );
94
+ db = pParse.db;
95
+ if ( pOrig.op != TK_COLUMN && ( zType.Length == 0 || zType[0] != 'G' ) )
96
+ {
97
+ pDup = sqlite3ExprDup( db, pOrig, 0 );
98
+ pDup = sqlite3PExpr( pParse, TK_AS, pDup, null, null );
99
+ if ( pDup == null ) return;
100
+ if ( pEList.a[iCol].iAlias == 0 )
101
+ {
102
+ pEList.a[iCol].iAlias = (u16)( ++pParse.nAlias );
103
+ }
104
+ pDup.iTable = pEList.a[iCol].iAlias;
105
+ }
106
+ else if ( ExprHasProperty( pOrig, EP_IntValue ) || pOrig.u.zToken == null )
107
+ {
108
+ pDup = sqlite3ExprDup( db, pOrig, 0 );
109
+ if ( pDup == null ) return;
110
+ }
111
+ else
112
+ {
113
+ string zToken = pOrig.u.zToken;
114
+ Debug.Assert( zToken != null );
115
+ pOrig.u.zToken = null;
116
+ pDup = sqlite3ExprDup( db, pOrig, 0 );
117
+ pOrig.u.zToken = zToken;
118
+ if ( pDup == null ) return;
119
+ Debug.Assert( ( pDup.flags & ( EP_Reduced | EP_TokenOnly ) ) == 0 );
120
+ pDup.flags2 |= EP2_MallocedToken;
121
+ pDup.u.zToken = zToken;// sqlite3DbStrDup( db, zToken );
122
+ }
123
+ if ( ( pExpr.flags & EP_ExpCollate ) != 0 )
124
+ {
125
+ pDup.pColl = pExpr.pColl;
126
+ pDup.flags |= EP_ExpCollate;
127
+ }
128
+
129
+ /* Before calling sqlite3ExprDelete(), set the EP_Static flag. This
130
+ ** prevents ExprDelete() from deleting the Expr structure itself,
131
+ ** allowing it to be repopulated by the memcpy() on the following line.
132
+ */
133
+ ExprSetProperty( pExpr, EP_Static );
134
+ sqlite3ExprDelete( db, ref pExpr );
135
+ pExpr.CopyFrom( pDup ); //memcpy(pExpr, pDup, sizeof(*pExpr));
136
+ sqlite3DbFree( db, ref pDup );
137
+ }
138
+
139
+ /*
140
+ ** Given the name of a column of the form X.Y.Z or Y.Z or just Z, look up
141
+ ** that name in the set of source tables in pSrcList and make the pExpr
142
+ ** expression node refer back to that source column. The following changes
143
+ ** are made to pExpr:
144
+ **
145
+ ** pExpr->iDb Set the index in db->aDb[] of the database X
146
+ ** (even if X is implied).
147
+ ** pExpr->iTable Set to the cursor number for the table obtained
148
+ ** from pSrcList.
149
+ ** pExpr->pTab Points to the Table structure of X.Y (even if
150
+ ** X and/or Y are implied.)
151
+ ** pExpr->iColumn Set to the column number within the table.
152
+ ** pExpr->op Set to TK_COLUMN.
153
+ ** pExpr->pLeft Any expression this points to is deleted
154
+ ** pExpr->pRight Any expression this points to is deleted.
155
+ **
156
+ ** The zDb variable is the name of the database (the "X"). This value may be
157
+ ** NULL meaning that name is of the form Y.Z or Z. Any available database
158
+ ** can be used. The zTable variable is the name of the table (the "Y"). This
159
+ ** value can be NULL if zDb is also NULL. If zTable is NULL it
160
+ ** means that the form of the name is Z and that columns from any table
161
+ ** can be used.
162
+ **
163
+ ** If the name cannot be resolved unambiguously, leave an error message
164
+ ** in pParse and return WRC_Abort. Return WRC_Prune on success.
165
+ */
166
+ static int lookupName(
167
+ Parse pParse, /* The parsing context */
168
+ string zDb, /* Name of the database containing table, or NULL */
169
+ string zTab, /* Name of table containing column, or NULL */
170
+ string zCol, /* Name of the column. */
171
+ NameContext pNC, /* The name context used to resolve the name */
172
+ Expr pExpr /* Make this EXPR node point to the selected column */
173
+ )
174
+ {
175
+ int i, j; /* Loop counters */
176
+ int cnt = 0; /* Number of matching column names */
177
+ int cntTab = 0; /* Number of matching table names */
178
+ sqlite3 db = pParse.db; /* The database connection */
179
+ SrcList_item pItem; /* Use for looping over pSrcList items */
180
+ SrcList_item pMatch = null; /* The matching pSrcList item */
181
+ NameContext pTopNC = pNC; /* First namecontext in the list */
182
+ Schema pSchema = null; /* Schema of the expression */
183
+ int isTrigger = 0;
184
+
185
+ Debug.Assert( pNC != null ); /* the name context cannot be NULL. */
186
+ Debug.Assert( zCol != null ); /* The Z in X.Y.Z cannot be NULL */
187
+ Debug.Assert( !ExprHasAnyProperty( pExpr, EP_TokenOnly | EP_Reduced ) );
188
+
189
+ /* Initialize the node to no-match */
190
+ pExpr.iTable = -1;
191
+ pExpr.pTab = null;
192
+ ExprSetIrreducible( pExpr );
193
+
194
+ /* Start at the inner-most context and move outward until a match is found */
195
+ while ( pNC != null && cnt == 0 )
196
+ {
197
+ ExprList pEList;
198
+ SrcList pSrcList = pNC.pSrcList;
199
+
200
+ if ( pSrcList != null )
201
+ {
202
+ for ( i = 0; i < pSrcList.nSrc; i++ )//, pItem++ )
203
+ {
204
+ pItem = pSrcList.a[i];
205
+ Table pTab;
206
+ int iDb;
207
+ Column pCol;
208
+
209
+ pTab = pItem.pTab;
210
+ Debug.Assert( pTab != null && pTab.zName != null );
211
+ iDb = sqlite3SchemaToIndex( db, pTab.pSchema );
212
+ Debug.Assert( pTab.nCol > 0 );
213
+ if ( zTab != null )
214
+ {
215
+ if ( pItem.zAlias != null )
216
+ {
217
+ string zTabName = pItem.zAlias;
218
+ if ( sqlite3StrICmp( zTabName, zTab ) != 0 ) continue;
219
+ }
220
+ else
221
+ {
222
+ string zTabName = pTab.zName;
223
+ if ( NEVER( zTabName == null ) || sqlite3StrICmp( zTabName, zTab ) != 0 )
224
+ {
225
+ continue;
226
+ }
227
+ if ( zDb != null && sqlite3StrICmp( db.aDb[iDb].zName, zDb ) != 0 )
228
+ {
229
+ continue;
230
+ }
231
+ }
232
+ }
233
+ if ( 0 == ( cntTab++ ) )
234
+ {
235
+ pExpr.iTable = pItem.iCursor;
236
+ pExpr.pTab = pTab;
237
+ pSchema = pTab.pSchema;
238
+ pMatch = pItem;
239
+ }
240
+ for ( j = 0; j < pTab.nCol; j++ )//, pCol++ )
241
+ {
242
+ pCol = pTab.aCol[j];
243
+ if ( sqlite3StrICmp( pCol.zName, zCol ) == 0 )
244
+ {
245
+ IdList pUsing;
246
+ cnt++;
247
+ pExpr.iTable = pItem.iCursor;
248
+ pExpr.pTab = pTab;
249
+ pMatch = pItem;
250
+ pSchema = pTab.pSchema;
251
+ /* Substitute the rowid (column -1) for the INTEGER PRIMARY KEY */
252
+ pExpr.iColumn = (short)( j == pTab.iPKey ? -1 : j );
253
+ if ( i < pSrcList.nSrc - 1 )
254
+ {
255
+ if ( ( pSrcList.a[i + 1].jointype & JT_NATURAL ) != 0 )// pItem[1].jointype
256
+ {
257
+ /* If this match occurred in the left table of a natural join,
258
+ ** then skip the right table to avoid a duplicate match */
259
+ //pItem++;
260
+ i++;
261
+ }
262
+ else if ( ( pUsing = pSrcList.a[i + 1].pUsing ) != null )//pItem[1].pUsing
263
+ {
264
+ /* If this match occurs on a column that is in the USING clause
265
+ ** of a join, skip the search of the right table of the join
266
+ ** to avoid a duplicate match there. */
267
+ int k;
268
+ for ( k = 0; k < pUsing.nId; k++ )
269
+ {
270
+ if ( sqlite3StrICmp( pUsing.a[k].zName, zCol ) == 0 )
271
+ {
272
+ //pItem++;
273
+ i++;
274
+ break;
275
+ }
276
+ }
277
+ }
278
+ }
279
+ break;
280
+ }
281
+ }
282
+ }
283
+ }
284
+
285
+ #if !SQLITE_OMIT_TRIGGER
286
+ /* If we have not already resolved the name, then maybe
287
+ ** it is a new.* or old.* trigger argument reference
288
+ */
289
+ if ( zDb == null && zTab != null && cnt == 0 && pParse.pTriggerTab != null )
290
+ {
291
+ int op = pParse.eTriggerOp;
292
+ Table pTab = null;
293
+ Debug.Assert( op == TK_DELETE || op == TK_UPDATE || op == TK_INSERT );
294
+ if ( op != TK_DELETE && sqlite3StrICmp( "new", zTab ) == 0 )
295
+ {
296
+ pExpr.iTable = 1;
297
+ pTab = pParse.pTriggerTab;
298
+ }
299
+ else if ( op != TK_INSERT && sqlite3StrICmp( "old", zTab ) == 0 )
300
+ {
301
+ pExpr.iTable = 0;
302
+ pTab = pParse.pTriggerTab;
303
+ }
304
+
305
+ if ( pTab !=null)
306
+ {
307
+ int iCol;
308
+ pSchema = pTab.pSchema;
309
+ cntTab++;
310
+ for ( iCol = 0; iCol < pTab.nCol; iCol++ )
311
+ {
312
+ Column pCol = pTab.aCol[iCol];
313
+ if ( sqlite3StrICmp( pCol.zName, zCol ) == 0 )
314
+ {
315
+ if ( iCol == pTab.iPKey )
316
+ {
317
+ iCol = -1;
318
+ }
319
+ break;
320
+ }
321
+ }
322
+ if( iCol>=pTab.nCol && sqlite3IsRowid(zCol) ){
323
+ iCol = -1; /* IMP: R-44911-55124 */
324
+ }
325
+ if ( iCol < pTab.nCol )
326
+ {
327
+ cnt++;
328
+ if ( iCol < 0 )
329
+ {
330
+ pExpr.affinity = SQLITE_AFF_INTEGER;
331
+ }
332
+ else if ( pExpr.iTable == 0 )
333
+ {
334
+ testcase( iCol == 31 );
335
+ testcase( iCol == 32 );
336
+ pParse.oldmask |= ( iCol >= 32 ? 0xffffffff : ( ( (u32)1 ) << iCol ) );
337
+ }else{
338
+ testcase( iCol==31 );
339
+ testcase( iCol==32 );
340
+ pParse.newmask |= (iCol>=32 ? 0xffffffff : (((u32)1)<<iCol));
341
+ }
342
+ pExpr.iColumn = (i16)iCol;
343
+ pExpr.pTab = pTab;
344
+ isTrigger = 1;
345
+ }
346
+ }
347
+ }
348
+ #endif //* !SQLITE_OMIT_TRIGGER) */
349
+
350
+ /*
351
+ ** Perhaps the name is a reference to the ROWID
352
+ */
353
+ if ( cnt == 0 && cntTab == 1 && sqlite3IsRowid( zCol ) )
354
+ {
355
+ cnt = 1;
356
+ pExpr.iColumn = -1; /* IMP: R-44911-55124 */
357
+ pExpr.affinity = SQLITE_AFF_INTEGER;
358
+ }
359
+
360
+ /*
361
+ ** If the input is of the form Z (not Y.Z or X.Y.Z) then the name Z
362
+ ** might refer to an result-set alias. This happens, for example, when
363
+ ** we are resolving names in the WHERE clause of the following command:
364
+ **
365
+ ** SELECT a+b AS x FROM table WHERE x<10;
366
+ **
367
+ ** In cases like this, replace pExpr with a copy of the expression that
368
+ ** forms the result set entry ("a+b" in the example) and return immediately.
369
+ ** Note that the expression in the result set should have already been
370
+ ** resolved by the time the WHERE clause is resolved.
371
+ */
372
+ if ( cnt == 0 && ( pEList = pNC.pEList ) != null && zTab == null )
373
+ {
374
+ for ( j = 0; j < pEList.nExpr; j++ )
375
+ {
376
+ string zAs = pEList.a[j].zName;
377
+ if ( zAs != null && sqlite3StrICmp( zAs, zCol ) == 0 )
378
+ {
379
+ Expr pOrig;
380
+ Debug.Assert( pExpr.pLeft == null && pExpr.pRight == null );
381
+ Debug.Assert( pExpr.x.pList == null );
382
+ Debug.Assert( pExpr.x.pSelect == null );
383
+ pOrig = pEList.a[j].pExpr;
384
+ if ( 0 == pNC.allowAgg && ExprHasProperty( pOrig, EP_Agg ) )
385
+ {
386
+ sqlite3ErrorMsg( pParse, "misuse of aliased aggregate %s", zAs );
387
+ return WRC_Abort;
388
+ }
389
+ resolveAlias( pParse, pEList, j, pExpr, "" );
390
+ cnt = 1;
391
+ pMatch = null;
392
+ Debug.Assert( zTab == null && zDb == null );
393
+ goto lookupname_end;
394
+ }
395
+ }
396
+ }
397
+
398
+ /* Advance to the next name context. The loop will exit when either
399
+ ** we have a match (cnt>0) or when we run out of name contexts.
400
+ */
401
+ if ( cnt == 0 )
402
+ {
403
+ pNC = pNC.pNext;
404
+ }
405
+ }
406
+
407
+ /*
408
+ ** If X and Y are NULL (in other words if only the column name Z is
409
+ ** supplied) and the value of Z is enclosed in double-quotes, then
410
+ ** Z is a string literal if it doesn't match any column names. In that
411
+ ** case, we need to return right away and not make any changes to
412
+ ** pExpr.
413
+ **
414
+ ** Because no reference was made to outer contexts, the pNC.nRef
415
+ ** fields are not changed in any context.
416
+ */
417
+ if ( cnt == 0 && zTab == null && ExprHasProperty( pExpr, EP_DblQuoted ) )
418
+ {
419
+ pExpr.op = TK_STRING;
420
+ pExpr.pTab = null;
421
+ return WRC_Prune;
422
+ }
423
+
424
+ /*
425
+ ** cnt==0 means there was not match. cnt>1 means there were two or
426
+ ** more matches. Either way, we have an error.
427
+ */
428
+ if ( cnt != 1 )
429
+ {
430
+ string zErr;
431
+ zErr = cnt == 0 ? "no such column" : "ambiguous column name";
432
+ if ( zDb != null )
433
+ {
434
+ sqlite3ErrorMsg( pParse, "%s: %s.%s.%s", zErr, zDb, zTab, zCol );
435
+ }
436
+ else if ( zTab != null )
437
+ {
438
+ sqlite3ErrorMsg( pParse, "%s: %s.%s", zErr, zTab, zCol );
439
+ }
440
+ else
441
+ {
442
+ sqlite3ErrorMsg( pParse, "%s: %s", zErr, zCol );
443
+ }
444
+ pTopNC.nErr++;
445
+ }
446
+
447
+ /* If a column from a table in pSrcList is referenced, then record
448
+ ** this fact in the pSrcList.a[].colUsed bitmask. Column 0 causes
449
+ ** bit 0 to be set. Column 1 sets bit 1. And so forth. If the
450
+ ** column number is greater than the number of bits in the bitmask
451
+ ** then set the high-order bit of the bitmask.
452
+ */
453
+ if ( pExpr.iColumn >= 0 && pMatch != null )
454
+ {
455
+ int n = pExpr.iColumn;
456
+ testcase( n == BMS - 1 );
457
+ if ( n >= BMS )
458
+ {
459
+ n = BMS - 1;
460
+ }
461
+ Debug.Assert( pMatch.iCursor == pExpr.iTable );
462
+ pMatch.colUsed |= ( (Bitmask)1 ) << n;
463
+ }
464
+
465
+ /* Clean up and return
466
+ */
467
+ sqlite3ExprDelete( db, ref pExpr.pLeft );
468
+ pExpr.pLeft = null;
469
+ sqlite3ExprDelete( db, ref pExpr.pRight );
470
+ pExpr.pRight = null;
471
+ pExpr.op = (u8)( isTrigger != 0 ? TK_TRIGGER : TK_COLUMN );
472
+ lookupname_end:
473
+ if ( cnt == 1 )
474
+ {
475
+ Debug.Assert( pNC != null );
476
+ sqlite3AuthRead( pParse, pExpr, pSchema, pNC.pSrcList );
477
+ /* Increment the nRef value on all name contexts from TopNC up to
478
+ ** the point where the name matched. */
479
+ for ( ; ; )
480
+ {
481
+ Debug.Assert( pTopNC != null );
482
+ pTopNC.nRef++;
483
+ if ( pTopNC == pNC ) break;
484
+ pTopNC = pTopNC.pNext;
485
+ }
486
+ return WRC_Prune;
487
+ }
488
+ else
489
+ {
490
+ return WRC_Abort;
491
+ }
492
+ }
493
+
494
+ /*
495
+ ** Allocate and return a pointer to an expression to load the column iCol
496
+ ** from datasource iSrc datasource in SrcList pSrc.
497
+ */
498
+ static Expr sqlite3CreateColumnExpr( sqlite3 db, SrcList pSrc, int iSrc, int iCol )
499
+ {
500
+ Expr p = sqlite3ExprAlloc( db, TK_COLUMN, null, 0 );
501
+ if ( p != null )
502
+ {
503
+ SrcList_item pItem = pSrc.a[iSrc];
504
+ p.pTab = pItem.pTab;
505
+ p.iTable = pItem.iCursor;
506
+ if ( p.pTab.iPKey == iCol )
507
+ {
508
+ p.iColumn = -1;
509
+ }
510
+ else
511
+ {
512
+ p.iColumn = (ynVar)iCol;
513
+ pItem.colUsed |= ( (Bitmask)1 ) << ( iCol >= BMS ? BMS - 1 : iCol );
514
+ }
515
+ ExprSetProperty( p, EP_Resolved );
516
+ }
517
+ return p;
518
+ }
519
+
520
+ /*
521
+ ** This routine is callback for sqlite3WalkExpr().
522
+ **
523
+ ** Resolve symbolic names into TK_COLUMN operators for the current
524
+ ** node in the expression tree. Return 0 to continue the search down
525
+ ** the tree or 2 to abort the tree walk.
526
+ **
527
+ ** This routine also does error checking and name resolution for
528
+ ** function names. The operator for aggregate functions is changed
529
+ ** to TK_AGG_FUNCTION.
530
+ */
531
+ static int resolveExprStep( Walker pWalker, ref Expr pExpr )
532
+ {
533
+ NameContext pNC;
534
+ Parse pParse;
535
+
536
+ pNC = pWalker.u.pNC;
537
+ Debug.Assert( pNC != null );
538
+ pParse = pNC.pParse;
539
+ Debug.Assert( pParse == pWalker.pParse );
540
+
541
+ if ( ExprHasAnyProperty( pExpr, EP_Resolved ) ) return WRC_Prune;
542
+ ExprSetProperty( pExpr, EP_Resolved );
543
+ #if !NDEBUG
544
+ if ( pNC.pSrcList != null && pNC.pSrcList.nAlloc > 0 )
545
+ {
546
+ SrcList pSrcList = pNC.pSrcList;
547
+ int i;
548
+ for ( i = 0; i < pNC.pSrcList.nSrc; i++ )
549
+ {
550
+ Debug.Assert( pSrcList.a[i].iCursor >= 0 && pSrcList.a[i].iCursor < pParse.nTab );
551
+ }
552
+ }
553
+ #endif
554
+ switch ( pExpr.op )
555
+ {
556
+
557
+ #if (SQLITE_ENABLE_UPDATE_DELETE_LIMIT) && !(SQLITE_OMIT_SUBQUERY)
558
+ /* The special operator TK_ROW means use the rowid for the first
559
+ ** column in the FROM clause. This is used by the LIMIT and ORDER BY
560
+ ** clause processing on UPDATE and DELETE statements.
561
+ */
562
+ case TK_ROW: {
563
+ SrcList pSrcList = pNC.pSrcList;
564
+ SrcList_item pItem;
565
+ Debug.Assert( pSrcList !=null && pSrcList.nSrc==1 );
566
+ pItem = pSrcList.a[0];
567
+ pExpr.op = TK_COLUMN;
568
+ pExpr.pTab = pItem.pTab;
569
+ pExpr.iTable = pItem.iCursor;
570
+ pExpr.iColumn = -1;
571
+ pExpr.affinity = SQLITE_AFF_INTEGER;
572
+ break;
573
+ }
574
+ #endif //* defined(SQLITE_ENABLE_UPDATE_DELETE_LIMIT) && !defined(SQLITE_OMIT_SUBQUERY) /
575
+
576
+ /* A lone identifier is the name of a column.
577
+ */
578
+ case TK_ID:
579
+ {
580
+ return lookupName( pParse, null, null, pExpr.u.zToken, pNC, pExpr );
581
+ }
582
+
583
+ /* A table name and column name: ID.ID
584
+ ** Or a database, table and column: ID.ID.ID
585
+ */
586
+ case TK_DOT:
587
+ {
588
+ string zColumn;
589
+ string zTable;
590
+ string zDb;
591
+ Expr pRight;
592
+
593
+ /* if( pSrcList==0 ) break; */
594
+ pRight = pExpr.pRight;
595
+ if ( pRight.op == TK_ID )
596
+ {
597
+ zDb = null;
598
+ zTable = pExpr.pLeft.u.zToken;
599
+ zColumn = pRight.u.zToken;
600
+ }
601
+ else
602
+ {
603
+ Debug.Assert( pRight.op == TK_DOT );
604
+ zDb = pExpr.pLeft.u.zToken;
605
+ zTable = pRight.pLeft.u.zToken;
606
+ zColumn = pRight.pRight.u.zToken;
607
+ }
608
+ return lookupName( pParse, zDb, zTable, zColumn, pNC, pExpr );
609
+ }
610
+
611
+ /* Resolve function names
612
+ */
613
+ case TK_CONST_FUNC:
614
+ case TK_FUNCTION:
615
+ {
616
+ ExprList pList = pExpr.x.pList; /* The argument list */
617
+ int n = pList != null ? pList.nExpr : 0; /* Number of arguments */
618
+ bool no_such_func = false; /* True if no such function exists */
619
+ bool wrong_num_args = false; /* True if wrong number of arguments */
620
+ bool is_agg = false; /* True if is an aggregate function */
621
+ int auth; /* Authorization to use the function */
622
+ int nId; /* Number of characters in function name */
623
+ string zId; /* The function name. */
624
+ FuncDef pDef; /* Information about the function */
625
+ u8 enc = (u8)pParse.db.aDbStatic[0].pSchema.enc;// ENC( pParse.db ); /* The database encoding */
626
+
627
+ testcase( pExpr.op == TK_CONST_FUNC );
628
+ Debug.Assert( !ExprHasProperty( pExpr, EP_xIsSelect ) );
629
+ zId = pExpr.u.zToken;
630
+ nId = sqlite3Strlen30( zId );
631
+ pDef = sqlite3FindFunction( pParse.db, zId, nId, n, enc, 0 );
632
+ if ( pDef == null )
633
+ {
634
+ pDef = sqlite3FindFunction( pParse.db, zId, nId, -1, enc, 0 );
635
+ if ( pDef == null )
636
+ {
637
+ no_such_func = true;
638
+ }
639
+ else
640
+ {
641
+ wrong_num_args = true;
642
+ }
643
+ }
644
+ else
645
+ {
646
+ is_agg = pDef.xFunc == null;
647
+ }
648
+ #if !SQLITE_OMIT_AUTHORIZATION
649
+ if( pDef ){
650
+ auth = sqlite3AuthCheck(pParse, SQLITE_FUNCTION, 0, pDef.zName, 0);
651
+ if( auth!=SQLITE_OK ){
652
+ if( auth==SQLITE_DENY ){
653
+ sqlite3ErrorMsg(pParse, "not authorized to use function: %s",
654
+ pDef.zName);
655
+ pNC.nErr++;
656
+ }
657
+ pExpr.op = TK_NULL;
658
+ return WRC_Prune;
659
+ }
660
+ }
661
+ #endif
662
+ if ( is_agg && 0 == pNC.allowAgg )
663
+ {
664
+ sqlite3ErrorMsg( pParse, "misuse of aggregate function %.*s()", nId, zId );
665
+ pNC.nErr++;
666
+ is_agg = false;
667
+ }
668
+ else if ( no_such_func )
669
+ {
670
+ sqlite3ErrorMsg( pParse, "no such function: %.*s", nId, zId );
671
+ pNC.nErr++;
672
+ }
673
+ else if ( wrong_num_args )
674
+ {
675
+ sqlite3ErrorMsg( pParse, "wrong number of arguments to function %.*s()",
676
+ nId, zId );
677
+ pNC.nErr++;
678
+ }
679
+ if ( is_agg )
680
+ {
681
+ pExpr.op = TK_AGG_FUNCTION;
682
+ pNC.hasAgg = 1;
683
+ }
684
+ if ( is_agg ) pNC.allowAgg = 0;
685
+ sqlite3WalkExprList( pWalker, pList );
686
+ if ( is_agg ) pNC.allowAgg = 1;
687
+ /* FIX ME: Compute pExpr.affinity based on the expected return
688
+ ** type of the function
689
+ */
690
+ return WRC_Prune;
691
+ }
692
+ #if !SQLITE_OMIT_SUBQUERY
693
+ case TK_SELECT:
694
+ case TK_EXISTS:
695
+ {
696
+ testcase( pExpr.op == TK_EXISTS );
697
+ goto case TK_IN;
698
+ }
699
+ #endif
700
+ case TK_IN:
701
+ {
702
+ testcase( pExpr.op == TK_IN );
703
+ if ( ExprHasProperty( pExpr, EP_xIsSelect ) )
704
+ {
705
+ int nRef = pNC.nRef;
706
+ #if !SQLITE_OMIT_CHECK
707
+ if ( pNC.isCheck != 0 )
708
+ {
709
+ sqlite3ErrorMsg( pParse, "subqueries prohibited in CHECK constraints" );
710
+ }
711
+ #endif
712
+ sqlite3WalkSelect( pWalker, pExpr.x.pSelect );
713
+ Debug.Assert( pNC.nRef >= nRef );
714
+ if ( nRef != pNC.nRef )
715
+ {
716
+ ExprSetProperty( pExpr, EP_VarSelect );
717
+ }
718
+ }
719
+ break;
720
+ }
721
+ #if !SQLITE_OMIT_CHECK
722
+ case TK_VARIABLE:
723
+ {
724
+ if ( pNC.isCheck != 0 )
725
+ {
726
+ sqlite3ErrorMsg( pParse, "parameters prohibited in CHECK constraints" );
727
+ }
728
+ break;
729
+ }
730
+ #endif
731
+ }
732
+ return ( pParse.nErr != 0 /* || pParse.db.mallocFailed != 0 */ ) ? WRC_Abort : WRC_Continue;
733
+ }
734
+
735
+ /*
736
+ ** pEList is a list of expressions which are really the result set of the
737
+ ** a SELECT statement. pE is a term in an ORDER BY or GROUP BY clause.
738
+ ** This routine checks to see if pE is a simple identifier which corresponds
739
+ ** to the AS-name of one of the terms of the expression list. If it is,
740
+ ** this routine return an integer between 1 and N where N is the number of
741
+ ** elements in pEList, corresponding to the matching entry. If there is
742
+ ** no match, or if pE is not a simple identifier, then this routine
743
+ ** return 0.
744
+ **
745
+ ** pEList has been resolved. pE has not.
746
+ */
747
+ static int resolveAsName(
748
+ Parse pParse, /* Parsing context for error messages */
749
+ ExprList pEList, /* List of expressions to scan */
750
+ Expr pE /* Expression we are trying to match */
751
+ )
752
+ {
753
+ int i; /* Loop counter */
754
+
755
+ UNUSED_PARAMETER( pParse );
756
+
757
+ if ( pE.op == TK_ID )
758
+ {
759
+ string zCol = pE.u.zToken;
760
+
761
+ for ( i = 0; i < pEList.nExpr; i++ )
762
+ {
763
+ string zAs = pEList.a[i].zName;
764
+ if ( zAs != null && sqlite3StrICmp( zAs, zCol ) == 0 )
765
+ {
766
+ return i + 1;
767
+ }
768
+ }
769
+ }
770
+ return 0;
771
+ }
772
+
773
+ /*
774
+ ** pE is a pointer to an expression which is a single term in the
775
+ ** ORDER BY of a compound SELECT. The expression has not been
776
+ ** name resolved.
777
+ **
778
+ ** At the point this routine is called, we already know that the
779
+ ** ORDER BY term is not an integer index into the result set. That
780
+ ** case is handled by the calling routine.
781
+ **
782
+ ** Attempt to match pE against result set columns in the left-most
783
+ ** SELECT statement. Return the index i of the matching column,
784
+ ** as an indication to the caller that it should sort by the i-th column.
785
+ ** The left-most column is 1. In other words, the value returned is the
786
+ ** same integer value that would be used in the SQL statement to indicate
787
+ ** the column.
788
+ **
789
+ ** If there is no match, return 0. Return -1 if an error occurs.
790
+ */
791
+ static int resolveOrderByTermToExprList(
792
+ Parse pParse, /* Parsing context for error messages */
793
+ Select pSelect, /* The SELECT statement with the ORDER BY clause */
794
+ Expr pE /* The specific ORDER BY term */
795
+ )
796
+ {
797
+ int i = 0; /* Loop counter */
798
+ ExprList pEList; /* The columns of the result set */
799
+ NameContext nc; /* Name context for resolving pE */
800
+ sqlite3 db; /* Database connection */
801
+ int rc; /* Return code from subprocedures */
802
+ u8 savedSuppErr; /* Saved value of db->suppressErr */
803
+
804
+ Debug.Assert( sqlite3ExprIsInteger( pE, ref i ) == 0 );
805
+ pEList = pSelect.pEList;
806
+
807
+ /* Resolve all names in the ORDER BY term expression
808
+ */
809
+ nc = new NameContext();// memset( &nc, 0, sizeof( nc ) );
810
+ nc.pParse = pParse;
811
+ nc.pSrcList = pSelect.pSrc;
812
+ nc.pEList = pEList;
813
+ nc.allowAgg = 1;
814
+ nc.nErr = 0;
815
+ db = pParse.db;
816
+ savedSuppErr = db.suppressErr;
817
+ db.suppressErr = 1;
818
+ rc = sqlite3ResolveExprNames(nc, ref pE);
819
+ db.suppressErr = savedSuppErr;
820
+ if (rc != 0) return 0;
821
+
822
+ /* Try to match the ORDER BY expression against an expression
823
+ ** in the result set. Return an 1-based index of the matching
824
+ ** result-set entry.
825
+ */
826
+ for ( i = 0; i < pEList.nExpr; i++ )
827
+ {
828
+ if ( sqlite3ExprCompare( pEList.a[i].pExpr, pE ) < 2 )
829
+ {
830
+ return i + 1;
831
+ }
832
+ }
833
+
834
+ /* If no match, return 0. */
835
+ return 0;
836
+ }
837
+
838
+ /*
839
+ ** Generate an ORDER BY or GROUP BY term out-of-range error.
840
+ */
841
+ static void resolveOutOfRangeError(
842
+ Parse pParse, /* The error context into which to write the error */
843
+ string zType, /* "ORDER" or "GROUP" */
844
+ int i, /* The index (1-based) of the term out of range */
845
+ int mx /* Largest permissible value of i */
846
+ )
847
+ {
848
+ sqlite3ErrorMsg( pParse,
849
+ "%r %s BY term out of range - should be " +
850
+ "between 1 and %d", i, zType, mx );
851
+ }
852
+
853
+ /*
854
+ ** Analyze the ORDER BY clause in a compound SELECT statement. Modify
855
+ ** each term of the ORDER BY clause is a constant integer between 1
856
+ ** and N where N is the number of columns in the compound SELECT.
857
+ **
858
+ ** ORDER BY terms that are already an integer between 1 and N are
859
+ ** unmodified. ORDER BY terms that are integers outside the range of
860
+ ** 1 through N generate an error. ORDER BY terms that are expressions
861
+ ** are matched against result set expressions of compound SELECT
862
+ ** beginning with the left-most SELECT and working toward the right.
863
+ ** At the first match, the ORDER BY expression is transformed into
864
+ ** the integer column number.
865
+ **
866
+ ** Return the number of errors seen.
867
+ */
868
+ static int resolveCompoundOrderBy(
869
+ Parse pParse, /* Parsing context. Leave error messages here */
870
+ Select pSelect /* The SELECT statement containing the ORDER BY */
871
+ )
872
+ {
873
+ int i;
874
+ ExprList pOrderBy;
875
+ ExprList pEList;
876
+ sqlite3 db;
877
+ int moreToDo = 1;
878
+
879
+ pOrderBy = pSelect.pOrderBy;
880
+ if ( pOrderBy == null ) return 0;
881
+ db = pParse.db;
882
+ #if SQLITE_MAX_COLUMN
883
+ if( pOrderBy.nExpr>db.aLimit[SQLITE_LIMIT_COLUMN] ){
884
+ sqlite3ErrorMsg(pParse, "too many terms in ORDER BY clause");
885
+ return 1;
886
+ }
887
+ #endif
888
+ for ( i = 0; i < pOrderBy.nExpr; i++ )
889
+ {
890
+ pOrderBy.a[i].done = 0;
891
+ }
892
+ pSelect.pNext = null;
893
+ while ( pSelect.pPrior != null )
894
+ {
895
+ pSelect.pPrior.pNext = pSelect;
896
+ pSelect = pSelect.pPrior;
897
+ }
898
+ while ( pSelect != null && moreToDo != 0 )
899
+ {
900
+ ExprList_item pItem;
901
+ moreToDo = 0;
902
+ pEList = pSelect.pEList;
903
+ Debug.Assert( pEList != null );
904
+ for ( i = 0; i < pOrderBy.nExpr; i++ )//, pItem++)
905
+ {
906
+ pItem = pOrderBy.a[i];
907
+ int iCol = -1;
908
+ Expr pE, pDup;
909
+ if ( pItem.done != 0 ) continue;
910
+ pE = pItem.pExpr;
911
+ if ( sqlite3ExprIsInteger( pE, ref iCol ) != 0 )
912
+ {
913
+ if ( iCol <= 0 || iCol > pEList.nExpr )
914
+ {
915
+ resolveOutOfRangeError( pParse, "ORDER", i + 1, pEList.nExpr );
916
+ return 1;
917
+ }
918
+ }
919
+ else
920
+ {
921
+ iCol = resolveAsName( pParse, pEList, pE );
922
+ if ( iCol == 0 )
923
+ {
924
+ pDup = sqlite3ExprDup( db, pE, 0 );
925
+ ////if ( 0 == db.mallocFailed )
926
+ {
927
+ Debug.Assert( pDup != null );
928
+ iCol = resolveOrderByTermToExprList( pParse, pSelect, pDup );
929
+ }
930
+ sqlite3ExprDelete( db, ref pDup );
931
+ }
932
+ }
933
+ if ( iCol > 0 )
934
+ {
935
+ CollSeq pColl = pE.pColl;
936
+ int flags = pE.flags & EP_ExpCollate;
937
+ sqlite3ExprDelete( db, ref pE );
938
+ pItem.pExpr = pE = sqlite3Expr( db, TK_INTEGER, null );
939
+ if ( pE == null ) return 1;
940
+ pE.pColl = pColl;
941
+ pE.flags = (u16)( pE.flags | EP_IntValue | flags );
942
+ pE.u.iValue = iCol;
943
+ pItem.iCol = (u16)iCol;
944
+ pItem.done = 1;
945
+ }
946
+ else
947
+ {
948
+ moreToDo = 1;
949
+ }
950
+ }
951
+ pSelect = pSelect.pNext;
952
+ }
953
+ for ( i = 0; i < pOrderBy.nExpr; i++ )
954
+ {
955
+ if ( pOrderBy.a[i].done == 0 )
956
+ {
957
+ sqlite3ErrorMsg( pParse, "%r ORDER BY term does not match any " +
958
+ "column in the result set", i + 1 );
959
+ return 1;
960
+ }
961
+ }
962
+ return 0;
963
+ }
964
+
965
+ /*
966
+ ** Check every term in the ORDER BY or GROUP BY clause pOrderBy of
967
+ ** the SELECT statement pSelect. If any term is reference to a
968
+ ** result set expression (as determined by the ExprList.a.iCol field)
969
+ ** then convert that term into a copy of the corresponding result set
970
+ ** column.
971
+ **
972
+ ** If any errors are detected, add an error message to pParse and
973
+ ** return non-zero. Return zero if no errors are seen.
974
+ */
975
+ static int sqlite3ResolveOrderGroupBy(
976
+ Parse pParse, /* Parsing context. Leave error messages here */
977
+ Select pSelect, /* The SELECT statement containing the clause */
978
+ ExprList pOrderBy, /* The ORDER BY or GROUP BY clause to be processed */
979
+ string zType /* "ORDER" or "GROUP" */
980
+ )
981
+ {
982
+ int i;
983
+ sqlite3 db = pParse.db;
984
+ ExprList pEList;
985
+ ExprList_item pItem;
986
+
987
+ if ( pOrderBy == null /* || pParse.db.mallocFailed != 0 */ ) return 0;
988
+ #if SQLITE_MAX_COLUMN
989
+ if( pOrderBy.nExpr>db.aLimit[SQLITE_LIMIT_COLUMN] ){
990
+ sqlite3ErrorMsg(pParse, "too many terms in %s BY clause", zType);
991
+ return 1;
992
+ }
993
+ #endif
994
+ pEList = pSelect.pEList;
995
+ Debug.Assert( pEList != null ); /* sqlite3SelectNew() guarantees this */
996
+ for ( i = 0; i < pOrderBy.nExpr; i++ )//, pItem++)
997
+ {
998
+ pItem = pOrderBy.a[i];
999
+ if ( pItem.iCol != 0 )
1000
+ {
1001
+ if ( pItem.iCol > pEList.nExpr )
1002
+ {
1003
+ resolveOutOfRangeError( pParse, zType, i + 1, pEList.nExpr );
1004
+ return 1;
1005
+ }
1006
+ resolveAlias( pParse, pEList, pItem.iCol - 1, pItem.pExpr, zType );
1007
+ }
1008
+ }
1009
+ return 0;
1010
+ }
1011
+
1012
+ /*
1013
+ ** pOrderBy is an ORDER BY or GROUP BY clause in SELECT statement pSelect.
1014
+ ** The Name context of the SELECT statement is pNC. zType is either
1015
+ ** "ORDER" or "GROUP" depending on which type of clause pOrderBy is.
1016
+ **
1017
+ ** This routine resolves each term of the clause into an expression.
1018
+ ** If the order-by term is an integer I between 1 and N (where N is the
1019
+ ** number of columns in the result set of the SELECT) then the expression
1020
+ ** in the resolution is a copy of the I-th result-set expression. If
1021
+ ** the order-by term is an identify that corresponds to the AS-name of
1022
+ ** a result-set expression, then the term resolves to a copy of the
1023
+ ** result-set expression. Otherwise, the expression is resolved in
1024
+ ** the usual way - using sqlite3ResolveExprNames().
1025
+ **
1026
+ ** This routine returns the number of errors. If errors occur, then
1027
+ ** an appropriate error message might be left in pParse. (OOM errors
1028
+ ** excepted.)
1029
+ */
1030
+ static int resolveOrderGroupBy(
1031
+ NameContext pNC, /* The name context of the SELECT statement */
1032
+ Select pSelect, /* The SELECT statement holding pOrderBy */
1033
+ ExprList pOrderBy, /* An ORDER BY or GROUP BY clause to resolve */
1034
+ string zType /* Either "ORDER" or "GROUP", as appropriate */
1035
+ )
1036
+ {
1037
+ int i; /* Loop counter */
1038
+ int iCol; /* Column number */
1039
+ ExprList_item pItem; /* A term of the ORDER BY clause */
1040
+ Parse pParse; /* Parsing context */
1041
+ int nResult; /* Number of terms in the result set */
1042
+
1043
+ if ( pOrderBy == null ) return 0;
1044
+ nResult = pSelect.pEList.nExpr;
1045
+ pParse = pNC.pParse;
1046
+ for ( i = 0; i < pOrderBy.nExpr; i++ )//, pItem++ )
1047
+ {
1048
+ pItem = pOrderBy.a[i];
1049
+ Expr pE = pItem.pExpr;
1050
+ iCol = resolveAsName( pParse, pSelect.pEList, pE );
1051
+ if ( iCol > 0 )
1052
+ {
1053
+ /* If an AS-name match is found, mark this ORDER BY column as being
1054
+ ** a copy of the iCol-th result-set column. The subsequent call to
1055
+ ** sqlite3ResolveOrderGroupBy() will convert the expression to a
1056
+ ** copy of the iCol-th result-set expression. */
1057
+ pItem.iCol = (u16)iCol;
1058
+ continue;
1059
+ }
1060
+ if ( sqlite3ExprIsInteger( pE, ref iCol ) != 0 )
1061
+ {
1062
+ /* The ORDER BY term is an integer constant. Again, set the column
1063
+ ** number so that sqlite3ResolveOrderGroupBy() will convert the
1064
+ ** order-by term to a copy of the result-set expression */
1065
+ if ( iCol < 1 )
1066
+ {
1067
+ resolveOutOfRangeError( pParse, zType, i + 1, nResult );
1068
+ return 1;
1069
+ }
1070
+ pItem.iCol = (u16)iCol;
1071
+ continue;
1072
+ }
1073
+
1074
+ /* Otherwise, treat the ORDER BY term as an ordinary expression */
1075
+ pItem.iCol = 0;
1076
+ if ( sqlite3ResolveExprNames( pNC, ref pE ) != 0 )
1077
+ {
1078
+ return 1;
1079
+ }
1080
+ }
1081
+ return sqlite3ResolveOrderGroupBy( pParse, pSelect, pOrderBy, zType );
1082
+ }
1083
+
1084
+ /*
1085
+ ** Resolve names in the SELECT statement p and all of its descendents.
1086
+ */
1087
+ static int resolveSelectStep( Walker pWalker, Select p )
1088
+ {
1089
+ NameContext pOuterNC; /* Context that contains this SELECT */
1090
+ NameContext sNC; /* Name context of this SELECT */
1091
+ bool isCompound; /* True if p is a compound select */
1092
+ int nCompound; /* Number of compound terms processed so far */
1093
+ Parse pParse; /* Parsing context */
1094
+ ExprList pEList; /* Result set expression list */
1095
+ int i; /* Loop counter */
1096
+ ExprList pGroupBy; /* The GROUP BY clause */
1097
+ Select pLeftmost; /* Left-most of SELECT of a compound */
1098
+ sqlite3 db; /* Database connection */
1099
+
1100
+
1101
+ Debug.Assert( p != null );
1102
+ if ( ( p.selFlags & SF_Resolved ) != 0 )
1103
+ {
1104
+ return WRC_Prune;
1105
+ }
1106
+ pOuterNC = pWalker.u.pNC;
1107
+ pParse = pWalker.pParse;
1108
+ db = pParse.db;
1109
+
1110
+ /* Normally sqlite3SelectExpand() will be called first and will have
1111
+ ** already expanded this SELECT. However, if this is a subquery within
1112
+ ** an expression, sqlite3ResolveExprNames() will be called without a
1113
+ ** prior call to sqlite3SelectExpand(). When that happens, let
1114
+ ** sqlite3SelectPrep() do all of the processing for this SELECT.
1115
+ ** sqlite3SelectPrep() will invoke both sqlite3SelectExpand() and
1116
+ ** this routine in the correct order.
1117
+ */
1118
+ if ( ( p.selFlags & SF_Expanded ) == 0 )
1119
+ {
1120
+ sqlite3SelectPrep( pParse, p, pOuterNC );
1121
+ return ( pParse.nErr != 0 /*|| db.mallocFailed != 0 */ ) ? WRC_Abort : WRC_Prune;
1122
+ }
1123
+
1124
+ isCompound = p.pPrior != null;
1125
+ nCompound = 0;
1126
+ pLeftmost = p;
1127
+ while ( p != null )
1128
+ {
1129
+ Debug.Assert( ( p.selFlags & SF_Expanded ) != 0 );
1130
+ Debug.Assert( ( p.selFlags & SF_Resolved ) == 0 );
1131
+ p.selFlags |= SF_Resolved;
1132
+
1133
+ /* Resolve the expressions in the LIMIT and OFFSET clauses. These
1134
+ ** are not allowed to refer to any names, so pass an empty NameContext.
1135
+ */
1136
+ sNC = new NameContext();// memset( &sNC, 0, sizeof( sNC ) );
1137
+ sNC.pParse = pParse;
1138
+ if ( sqlite3ResolveExprNames( sNC, ref p.pLimit ) != 0 ||
1139
+ sqlite3ResolveExprNames( sNC, ref p.pOffset ) != 0 )
1140
+ {
1141
+ return WRC_Abort;
1142
+ }
1143
+
1144
+ /* Set up the local name-context to pass to sqlite3ResolveExprNames() to
1145
+ ** resolve the result-set expression list.
1146
+ */
1147
+ sNC.allowAgg = 1;
1148
+ sNC.pSrcList = p.pSrc;
1149
+ sNC.pNext = pOuterNC;
1150
+
1151
+ /* Resolve names in the result set. */
1152
+ pEList = p.pEList;
1153
+ Debug.Assert( pEList != null );
1154
+ for ( i = 0; i < pEList.nExpr; i++ )
1155
+ {
1156
+ Expr pX = pEList.a[i].pExpr;
1157
+ if ( sqlite3ResolveExprNames( sNC, ref pX ) != 0 )
1158
+ {
1159
+ return WRC_Abort;
1160
+ }
1161
+ }
1162
+
1163
+ /* Recursively resolve names in all subqueries
1164
+ */
1165
+ for ( i = 0; i < p.pSrc.nSrc; i++ )
1166
+ {
1167
+ SrcList_item pItem = p.pSrc.a[i];
1168
+ if ( pItem.pSelect != null )
1169
+ {
1170
+ string zSavedContext = pParse.zAuthContext;
1171
+ if ( pItem.zName != null ) pParse.zAuthContext = pItem.zName;
1172
+ sqlite3ResolveSelectNames( pParse, pItem.pSelect, pOuterNC );
1173
+ pParse.zAuthContext = zSavedContext;
1174
+ if ( pParse.nErr != 0 /*|| db.mallocFailed != 0 */ ) return WRC_Abort;
1175
+ }
1176
+ }
1177
+
1178
+ /* If there are no aggregate functions in the result-set, and no GROUP BY
1179
+ ** expression, do not allow aggregates in any of the other expressions.
1180
+ */
1181
+ Debug.Assert( ( p.selFlags & SF_Aggregate ) == 0 );
1182
+ pGroupBy = p.pGroupBy;
1183
+ if ( pGroupBy != null || sNC.hasAgg != 0 )
1184
+ {
1185
+ p.selFlags |= SF_Aggregate;
1186
+ }
1187
+ else
1188
+ {
1189
+ sNC.allowAgg = 0;
1190
+ }
1191
+
1192
+ /* If a HAVING clause is present, then there must be a GROUP BY clause.
1193
+ */
1194
+ if ( p.pHaving != null && pGroupBy == null )
1195
+ {
1196
+ sqlite3ErrorMsg( pParse, "a GROUP BY clause is required before HAVING" );
1197
+ return WRC_Abort;
1198
+ }
1199
+
1200
+ /* Add the expression list to the name-context before parsing the
1201
+ ** other expressions in the SELECT statement. This is so that
1202
+ ** expressions in the WHERE clause (etc.) can refer to expressions by
1203
+ ** aliases in the result set.
1204
+ **
1205
+ ** Minor point: If this is the case, then the expression will be
1206
+ ** re-evaluated for each reference to it.
1207
+ */
1208
+ sNC.pEList = p.pEList;
1209
+ if ( sqlite3ResolveExprNames( sNC, ref p.pWhere ) != 0 ||
1210
+ sqlite3ResolveExprNames( sNC, ref p.pHaving ) != 0
1211
+ )
1212
+ {
1213
+ return WRC_Abort;
1214
+ }
1215
+
1216
+ /* The ORDER BY and GROUP BY clauses may not refer to terms in
1217
+ ** outer queries
1218
+ */
1219
+ sNC.pNext = null;
1220
+ sNC.allowAgg = 1;
1221
+
1222
+ /* Process the ORDER BY clause for singleton SELECT statements.
1223
+ ** The ORDER BY clause for compounds SELECT statements is handled
1224
+ ** below, after all of the result-sets for all of the elements of
1225
+ ** the compound have been resolved.
1226
+ */
1227
+ if ( !isCompound && resolveOrderGroupBy( sNC, p, p.pOrderBy, "ORDER" ) != 0 )
1228
+ {
1229
+ return WRC_Abort;
1230
+ }
1231
+ //if ( db.mallocFailed != 0 )
1232
+ //{
1233
+ // return WRC_Abort;
1234
+ //}
1235
+
1236
+ /* Resolve the GROUP BY clause. At the same time, make sure
1237
+ ** the GROUP BY clause does not contain aggregate functions.
1238
+ */
1239
+ if ( pGroupBy != null )
1240
+ {
1241
+ ExprList_item pItem;
1242
+
1243
+ if ( resolveOrderGroupBy( sNC, p, pGroupBy, "GROUP" ) != 0 /*|| db.mallocFailed != 0 */ )
1244
+ {
1245
+ return WRC_Abort;
1246
+ }
1247
+ for ( i = 0; i < pGroupBy.nExpr; i++ )//, pItem++)
1248
+ {
1249
+ pItem = pGroupBy.a[i];
1250
+ if ( ( pItem.pExpr.flags & EP_Agg ) != 0 )//HasProperty(pItem.pExpr, EP_Agg) )
1251
+ {
1252
+ sqlite3ErrorMsg( pParse, "aggregate functions are not allowed in " +
1253
+ "the GROUP BY clause" );
1254
+ return WRC_Abort;
1255
+ }
1256
+ }
1257
+ }
1258
+
1259
+ /* Advance to the next term of the compound
1260
+ */
1261
+ p = p.pPrior;
1262
+ nCompound++;
1263
+ }
1264
+
1265
+ /* Resolve the ORDER BY on a compound SELECT after all terms of
1266
+ ** the compound have been resolved.
1267
+ */
1268
+ if ( isCompound && resolveCompoundOrderBy( pParse, pLeftmost ) != 0 )
1269
+ {
1270
+ return WRC_Abort;
1271
+ }
1272
+
1273
+ return WRC_Prune;
1274
+ }
1275
+
1276
+ /*
1277
+ ** This routine walks an expression tree and resolves references to
1278
+ ** table columns and result-set columns. At the same time, do error
1279
+ ** checking on function usage and set a flag if any aggregate functions
1280
+ ** are seen.
1281
+ **
1282
+ ** To resolve table columns references we look for nodes (or subtrees) of the
1283
+ ** form X.Y.Z or Y.Z or just Z where
1284
+ **
1285
+ ** X: The name of a database. Ex: "main" or "temp" or
1286
+ ** the symbolic name assigned to an ATTACH-ed database.
1287
+ **
1288
+ ** Y: The name of a table in a FROM clause. Or in a trigger
1289
+ ** one of the special names "old" or "new".
1290
+ **
1291
+ ** Z: The name of a column in table Y.
1292
+ **
1293
+ ** The node at the root of the subtree is modified as follows:
1294
+ **
1295
+ ** Expr.op Changed to TK_COLUMN
1296
+ ** Expr.pTab Points to the Table object for X.Y
1297
+ ** Expr.iColumn The column index in X.Y. -1 for the rowid.
1298
+ ** Expr.iTable The VDBE cursor number for X.Y
1299
+ **
1300
+ **
1301
+ ** To resolve result-set references, look for expression nodes of the
1302
+ ** form Z (with no X and Y prefix) where the Z matches the right-hand
1303
+ ** size of an AS clause in the result-set of a SELECT. The Z expression
1304
+ ** is replaced by a copy of the left-hand side of the result-set expression.
1305
+ ** Table-name and function resolution occurs on the substituted expression
1306
+ ** tree. For example, in:
1307
+ **
1308
+ ** SELECT a+b AS x, c+d AS y FROM t1 ORDER BY x;
1309
+ **
1310
+ ** The "x" term of the order by is replaced by "a+b" to render:
1311
+ **
1312
+ ** SELECT a+b AS x, c+d AS y FROM t1 ORDER BY a+b;
1313
+ **
1314
+ ** Function calls are checked to make sure that the function is
1315
+ ** defined and that the correct number of arguments are specified.
1316
+ ** If the function is an aggregate function, then the pNC.hasAgg is
1317
+ ** set and the opcode is changed from TK_FUNCTION to TK_AGG_FUNCTION.
1318
+ ** If an expression contains aggregate functions then the EP_Agg
1319
+ ** property on the expression is set.
1320
+ **
1321
+ ** An error message is left in pParse if anything is amiss. The number
1322
+ ** if errors is returned.
1323
+ */
1324
+ static int sqlite3ResolveExprNames(
1325
+ NameContext pNC, /* Namespace to resolve expressions in. */
1326
+ ref Expr pExpr /* The expression to be analyzed. */
1327
+ )
1328
+ {
1329
+ u8 savedHasAgg;
1330
+ Walker w = new Walker();
1331
+
1332
+ if ( pExpr == null ) return 0;
1333
+ #if SQLITE_MAX_EXPR_DEPTH//>0
1334
+ {
1335
+ Parse pParse = pNC.pParse;
1336
+ if( sqlite3ExprCheckHeight(pParse, pExpr.nHeight+pNC.pParse.nHeight) ){
1337
+ return 1;
1338
+ }
1339
+ pParse.nHeight += pExpr.nHeight;
1340
+ }
1341
+ #endif
1342
+ savedHasAgg = pNC.hasAgg;
1343
+ pNC.hasAgg = 0;
1344
+ w.xExprCallback = resolveExprStep;
1345
+ w.xSelectCallback = resolveSelectStep;
1346
+ w.pParse = pNC.pParse;
1347
+ w.u.pNC = pNC;
1348
+ sqlite3WalkExpr( w, ref pExpr );
1349
+ #if SQLITE_MAX_EXPR_DEPTH//>0
1350
+ pNC.pParse.nHeight -= pExpr.nHeight;
1351
+ #endif
1352
+ if ( pNC.nErr > 0 || w.pParse.nErr > 0 )
1353
+ {
1354
+ ExprSetProperty( pExpr, EP_Error );
1355
+ }
1356
+ if ( pNC.hasAgg != 0 )
1357
+ {
1358
+ ExprSetProperty( pExpr, EP_Agg );
1359
+ }
1360
+ else if ( savedHasAgg != 0 )
1361
+ {
1362
+ pNC.hasAgg = 1;
1363
+ }
1364
+ return ExprHasProperty( pExpr, EP_Error ) ? 1 : 0;
1365
+ }
1366
+
1367
+
1368
+ /*
1369
+ ** Resolve all names in all expressions of a SELECT and in all
1370
+ ** decendents of the SELECT, including compounds off of p.pPrior,
1371
+ ** subqueries in expressions, and subqueries used as FROM clause
1372
+ ** terms.
1373
+ **
1374
+ ** See sqlite3ResolveExprNames() for a description of the kinds of
1375
+ ** transformations that occur.
1376
+ **
1377
+ ** All SELECT statements should have been expanded using
1378
+ ** sqlite3SelectExpand() prior to invoking this routine.
1379
+ */
1380
+ static void sqlite3ResolveSelectNames(
1381
+ Parse pParse, /* The parser context */
1382
+ Select p, /* The SELECT statement being coded. */
1383
+ NameContext pOuterNC /* Name context for parent SELECT statement */
1384
+ )
1385
+ {
1386
+ Walker w = new Walker();
1387
+
1388
+ Debug.Assert( p != null );
1389
+ w.xExprCallback = resolveExprStep;
1390
+ w.xSelectCallback = resolveSelectStep;
1391
+ w.pParse = pParse;
1392
+ w.u.pNC = pOuterNC;
1393
+ sqlite3WalkSelect( w, p );
1394
+ }
1395
+ }
1396
+ }