rhodes 3.2.3 → 3.3.0.beta.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (368) hide show
  1. data/CHANGELOG +10 -0
  2. data/Rakefile +153 -46
  3. data/doc/build.txt +261 -102
  4. data/doc/configuration.txt +5 -2
  5. data/doc/device-caps.txt +134 -23
  6. data/doc/extensions.txt +922 -69
  7. data/doc/generator.txt +96 -39
  8. data/doc/install.txt +35 -19
  9. data/doc/jqt-jqm-transition.txt +17 -1
  10. data/doc/rhom.txt +23 -2
  11. data/doc/rhostudio-eclipse.txt +49 -0
  12. data/doc/rhostudio-test-plan.txt +440 -0
  13. data/doc/simulator.txt +1 -1
  14. data/doc/synchronization.txt +40 -1
  15. data/lib/build/jake.rb +108 -7
  16. data/lib/extensions/barcode/ext/barcode/platform/android/Rakefile +0 -35
  17. data/lib/extensions/barcode/ext/barcode/platform/iphone/Barcode.xcodeproj/project.pbxproj +8 -2
  18. data/lib/extensions/barcode/ext/barcode/platform/iphone/Classes/BarcodeCallbackHelper.mm +195 -195
  19. data/lib/extensions/barcode/ext/barcode/platform/iphone/Classes/BarcodeViewController.m +6 -0
  20. data/lib/extensions/barcode/ext/barcode/platform/iphone/Rakefile +5 -0
  21. data/lib/extensions/barcode/ext/barcode/shared/ruby/barcode_wrap.c +64 -20
  22. data/lib/extensions/debugger/CHANGELOG +3 -0
  23. data/lib/extensions/debugger/debugger.rb +26 -21
  24. data/lib/extensions/digest-md5/ext/Rakefile +5 -5
  25. data/lib/extensions/digest-md5/ext/build +10 -1
  26. data/lib/extensions/digest-md5/ext/defs.h +19 -0
  27. data/lib/extensions/digest-md5/ext/digest-md5.vcproj +317 -9
  28. data/lib/extensions/digest-md5/ext/iphone/Dmd5.xcodeproj/project.pbxproj +290 -0
  29. data/lib/extensions/digest-md5/ext/iphone/Dmd5_Prefix.pch +7 -0
  30. data/lib/extensions/digest-md5/ext/iphone/Rakefile +79 -0
  31. data/lib/extensions/digest-sha1/ext/Rakefile +5 -5
  32. data/lib/extensions/digest-sha1/ext/build +10 -1
  33. data/lib/extensions/digest-sha1/ext/defs.h +19 -0
  34. data/lib/extensions/digest-sha1/ext/digest-sha1.vcproj +317 -9
  35. data/lib/extensions/digest-sha1/ext/iphone/Dsha1.xcodeproj/project.pbxproj +278 -0
  36. data/lib/extensions/digest-sha1/ext/iphone/Dsha1_Prefix.pch +7 -0
  37. data/lib/extensions/digest-sha1/ext/iphone/Rakefile +79 -0
  38. data/lib/extensions/digest/ext/Rakefile +5 -5
  39. data/lib/extensions/digest/ext/build +10 -1
  40. data/lib/extensions/digest/ext/digest.vcproj +317 -9
  41. data/lib/extensions/digest/ext/iphone/Digest.xcodeproj/project.pbxproj +270 -0
  42. data/lib/extensions/digest/ext/iphone/Digest_Prefix.pch +7 -0
  43. data/lib/extensions/digest/ext/iphone/Rakefile +79 -0
  44. data/lib/extensions/esri/ext/esri/platform/iphone/ESRI.xcodeproj/project.pbxproj +10 -2
  45. data/lib/extensions/esri/ext/esri/platform/iphone/Rakefile +6 -0
  46. data/lib/extensions/fcntl/ext/Rakefile +5 -5
  47. data/lib/extensions/fcntl/ext/build +9 -1
  48. data/lib/extensions/fcntl/ext/iphone/Fcntl.xcodeproj/project.pbxproj +262 -0
  49. data/lib/extensions/fcntl/ext/iphone/Fcntl_Prefix.pch +7 -0
  50. data/lib/extensions/fcntl/ext/iphone/Rakefile +79 -0
  51. data/lib/extensions/net-http/net/http.rb +9 -7
  52. data/lib/extensions/nfc/ext/nfc/shared/ruby/nfc_wrap.c +64 -20
  53. data/lib/extensions/rhoxml/rexml/document.rb +3 -2
  54. data/lib/extensions/rhoxml/rexml/instruction.rb +70 -0
  55. data/lib/framework/builtinME.rb +9 -0
  56. data/lib/framework/date/format.rb +1 -1
  57. data/lib/framework/dateME.rb +19 -2
  58. data/lib/framework/rho/rho.rb +15 -4
  59. data/lib/framework/rho/rhoapplication.rb +1 -0
  60. data/lib/framework/rho/rhocontact.rb +10 -27
  61. data/lib/framework/rho/rhoevent_c.rb +8 -2
  62. data/lib/framework/rho/rhosupport.rb +25 -0
  63. data/lib/framework/rhodes.rb +1 -1
  64. data/lib/framework/rhoframework.rb +15 -0
  65. data/lib/framework/rholang/localization_simplified.rb +8 -10
  66. data/lib/framework/rhom/rhom_object_factory.rb +8 -2
  67. data/lib/framework/version.rb +1 -1
  68. data/lib/rhodes.rb +1 -1
  69. data/platform/android/Rhodes/jni/Application.mk +2 -1
  70. data/platform/android/Rhodes/jni/include/rhodes.h +9 -0
  71. data/platform/android/Rhodes/jni/src/callbacks.cpp +31 -1
  72. data/platform/android/Rhodes/jni/src/event.cpp +75 -31
  73. data/platform/android/Rhodes/jni/src/nativeview.cpp +1 -1
  74. data/platform/android/Rhodes/jni/src/phonebook.cpp +73 -9
  75. data/platform/android/Rhodes/jni/src/rhodes.cpp +21 -0
  76. data/platform/android/Rhodes/jni/src/rhodesapp.cpp +16 -24
  77. data/platform/android/Rhodes/jni/src/signature.cpp +27 -1
  78. data/platform/android/Rhodes/{default.properties → project.properties} +2 -2
  79. data/platform/android/Rhodes/src/com/rhomobile/rhodes/Capabilities.java +14 -12
  80. data/platform/android/Rhodes/src/com/rhomobile/rhodes/NativeBar.java +14 -12
  81. data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesActivity.java +38 -115
  82. data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesService.java +69 -52
  83. data/platform/android/Rhodes/src/com/rhomobile/rhodes/camera/Camera.java +9 -0
  84. data/platform/android/Rhodes/src/com/rhomobile/rhodes/camera/CameraNewService.java +21 -1
  85. data/platform/android/Rhodes/src/com/rhomobile/rhodes/camera/CameraOldService.java +1 -1
  86. data/platform/android/Rhodes/src/com/rhomobile/rhodes/camera/CameraSemiService.java +1 -1
  87. data/platform/android/Rhodes/src/com/rhomobile/rhodes/camera/CameraService.java +1 -1
  88. data/platform/android/Rhodes/src/com/rhomobile/rhodes/camera/ImageCapture.java +38 -6
  89. data/platform/android/Rhodes/src/com/rhomobile/rhodes/event/Event.java +212 -1
  90. data/platform/android/Rhodes/src/com/rhomobile/rhodes/event/EventStore.java +82 -125
  91. data/platform/android/Rhodes/src/com/rhomobile/rhodes/geolocation/GeoLocationImpl.java +1 -1
  92. data/platform/android/Rhodes/src/com/rhomobile/rhodes/mainview/MainView.java +2 -1
  93. data/platform/android/Rhodes/src/com/rhomobile/rhodes/mainview/SimpleMainView.java +39 -19
  94. data/platform/android/Rhodes/src/com/rhomobile/rhodes/mainview/SplashScreen.java +106 -136
  95. data/platform/android/Rhodes/src/com/rhomobile/rhodes/mainview/TabbedMainView.java +26 -25
  96. data/platform/android/Rhodes/src/com/rhomobile/rhodes/nativeview/RhoNativeViewManager.java +1 -1
  97. data/platform/android/Rhodes/src/com/rhomobile/rhodes/osfunctionality/AndroidFunctionality.java +40 -0
  98. data/platform/android/Rhodes/src/com/rhomobile/rhodes/osfunctionality/AndroidFunctionality01.java +47 -0
  99. data/platform/android/Rhodes/src/com/rhomobile/rhodes/osfunctionality/AndroidFunctionality02.java +33 -0
  100. data/platform/android/Rhodes/src/com/rhomobile/rhodes/osfunctionality/AndroidFunctionality03.java +33 -0
  101. data/platform/android/Rhodes/src/com/rhomobile/rhodes/osfunctionality/AndroidFunctionality04.java +34 -0
  102. data/platform/android/Rhodes/src/com/rhomobile/rhodes/osfunctionality/AndroidFunctionality05.java +75 -0
  103. data/platform/android/Rhodes/src/com/rhomobile/rhodes/osfunctionality/AndroidFunctionality06.java +34 -0
  104. data/platform/android/Rhodes/src/com/rhomobile/rhodes/osfunctionality/AndroidFunctionality07.java +34 -0
  105. data/platform/android/Rhodes/src/com/rhomobile/rhodes/osfunctionality/AndroidFunctionality08.java +44 -0
  106. data/platform/android/Rhodes/src/com/rhomobile/rhodes/osfunctionality/AndroidFunctionality09.java +34 -0
  107. data/platform/android/Rhodes/src/com/rhomobile/rhodes/osfunctionality/AndroidFunctionality10.java +34 -0
  108. data/platform/android/Rhodes/src/com/rhomobile/rhodes/osfunctionality/AndroidFunctionalityManager.java +73 -0
  109. data/platform/android/Rhodes/src/com/rhomobile/rhodes/phonebook/Contact.java +57 -6
  110. data/platform/android/Rhodes/src/com/rhomobile/rhodes/phonebook/ContactAccessor.java +2 -2
  111. data/platform/android/Rhodes/src/com/rhomobile/rhodes/phonebook/ContactAccessorNew.java +322 -76
  112. data/platform/android/Rhodes/src/com/rhomobile/rhodes/phonebook/ContactAccessorOld.java +11 -6
  113. data/platform/android/Rhodes/src/com/rhomobile/rhodes/phonebook/Phonebook.java +5 -5
  114. data/platform/android/Rhodes/src/com/rhomobile/rhodes/webview/ChromeClientOld.java +2 -1
  115. data/platform/android/Rhodes/src/com/rhomobile/rhodes/webview/GoogleWebView.java +125 -0
  116. data/platform/android/Rhodes/src/com/rhomobile/rhodes/webview/RhoWebSettingsOld.java +2 -3
  117. data/platform/android/Rhodes/src/com/rhomobile/rhodes/webview/WebView.java +16 -0
  118. data/platform/android/build/RhodesSRC_build.files +14 -0
  119. data/platform/android/build/android.rake +149 -147
  120. data/platform/android/build/android_tools.rb +58 -0
  121. data/platform/android/build/librhocommon_build.files +1 -0
  122. data/platform/android/build/libruby_build.files +3 -0
  123. data/platform/bb/RubyVM/src/com/rho/RhoConf.java +11 -1
  124. data/platform/bb/RubyVM/src/com/rho/db/DBAdapter.java +11 -5
  125. data/platform/bb/RubyVM/src/com/rho/db/DBAttrManager.java +3 -2
  126. data/platform/bb/RubyVM/src/com/rho/file/RhoFile.java +2 -0
  127. data/platform/bb/RubyVM/src/com/rho/net/RhoConnection.java +20 -8
  128. data/platform/bb/RubyVM/src/com/rho/sync/SyncEngine.java +9 -6
  129. data/platform/bb/RubyVM/src/com/rho/sync/SyncSource.java +45 -18
  130. data/platform/bb/RubyVM/src/com/rho/sync/SyncThread.java +1 -2
  131. data/platform/bb/build/bb.rake +84 -70
  132. data/platform/bb/rhodes/platform/5.0/com/rho/BrowserAdapter5.java +106 -14
  133. data/platform/bb/rhodes/src/com/rho/BrowserAdapter.java +1 -1
  134. data/platform/bb/rhodes/src/com/rho/BrowserAdapter5.java +108 -16
  135. data/platform/bb/rhodes/src/rhomobile/RhodesApplication.java +10 -5
  136. data/platform/bb/rhodes/src/rhomobile/camera/CameraScreen.java +21 -4
  137. data/platform/bb/rhodes/src/rhomobile/mapview/Annotation.java +17 -0
  138. data/platform/bb/rhodes/src/rhomobile/mapview/MapView.java +8 -5
  139. data/platform/bb/rhodes/src/rhomobile/mapview/MapViewScreen.java +3 -1
  140. data/platform/iphone/Classes/AppManager/AppManager.m +15 -3
  141. data/platform/iphone/Classes/Event/Event.m +45 -2
  142. data/platform/iphone/Classes/MapView/MapViewController.m +8 -4
  143. data/platform/iphone/Classes/Phonebook/phonebook.m +30 -7
  144. data/platform/iphone/Classes/Rhodes.h +11 -1
  145. data/platform/iphone/Classes/Rhodes.m +141 -9
  146. data/platform/iphone/Classes/Signature/SignatureDelegate.m +27 -1
  147. data/platform/iphone/Classes/SimpleMainView.h +1 -0
  148. data/platform/iphone/Classes/SimpleMainView.m +4 -0
  149. data/platform/iphone/RhoLib/RhoLib.xcodeproj/project.pbxproj +31 -1
  150. data/platform/iphone/curl/curl.xcodeproj/project.pbxproj +10 -0
  151. data/platform/iphone/rbuild/iphone.rake +33 -6
  152. data/platform/iphone/rhoextlib/rhoextlib.xcodeproj/project.pbxproj +10 -2
  153. data/platform/iphone/rhorubylib/rhorubylib.xcodeproj/project.pbxproj +22 -2
  154. data/platform/iphone/rhorunner.xcodeproj/project.pbxproj +14 -0
  155. data/platform/iphone/rhosynclib/rhosynclib.xcodeproj/project.pbxproj +10 -0
  156. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/Info.plist +1 -1
  157. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/MacOS/RhoSimulator +0 -0
  158. data/platform/osx/build/osx.rake +58 -7
  159. data/platform/shared/RhoConnectClient/RhoConnectClient.cpp +427 -69
  160. data/platform/shared/RhoConnectClient/RhoConnectClient.h +21 -2
  161. data/platform/shared/common/Android.mk +2 -1
  162. data/platform/shared/common/AutoPointer.h +23 -0
  163. data/platform/shared/common/BundleManager.cpp +333 -0
  164. data/platform/shared/common/RhoFile.cpp +206 -23
  165. data/platform/shared/common/RhoFile.h +14 -4
  166. data/platform/shared/common/RhoFilePath.h +18 -0
  167. data/platform/shared/common/RhoStd.h +11 -1
  168. data/platform/shared/common/RhoThread.h +4 -1
  169. data/platform/shared/common/RhodesApp.cpp +31 -8
  170. data/platform/shared/common/RhodesApp.h +14 -0
  171. data/platform/shared/common/RhodesAppBase.cpp +6 -6
  172. data/platform/shared/common/RhodesAppBase.h +1 -1
  173. data/platform/shared/common/emml.h +34 -0
  174. data/platform/shared/common/iphone/RhoFileImpl.m +30 -2
  175. data/platform/shared/common/map/BaseMapEngine.cpp +3 -3
  176. data/platform/shared/common/map/GeocodingMapEngine.cpp +205 -14
  177. data/platform/shared/common/map/GeocodingMapEngine.h +25 -2
  178. data/platform/shared/common/map/MapEngine.cpp +24 -2
  179. data/platform/shared/common/map/MapEngine.h +23 -12
  180. data/platform/shared/common/phonebook/PhonebookParams.cpp +99 -0
  181. data/platform/shared/common/phonebook/PhonebookParams.h +52 -0
  182. data/platform/shared/common/rhoparams.cpp +14 -0
  183. data/platform/shared/common/rhoparams.h +1 -0
  184. data/platform/shared/db/DBAdapter.cpp +43 -24
  185. data/platform/shared/db/DBAdapter.h +6 -1
  186. data/platform/shared/db/DBAttrManager.cpp +50 -1
  187. data/platform/shared/logging/RhoLog.h +3 -0
  188. data/platform/shared/logging/RhoLogSink.cpp +5 -1
  189. data/platform/shared/net/CURLNetRequest.cpp +2 -0
  190. data/platform/shared/qt/rhodes/QtMainWindow.cpp +14 -1
  191. data/platform/shared/qt/rhodes/impl/PhonebookImpl.cpp +2 -2
  192. data/platform/shared/qt/rhodes/impl/RhoFileImpl.cpp +1 -1
  193. data/platform/shared/qt/rhodes/impl/SignatureImpl.cpp +14 -2
  194. data/platform/shared/qt/rhodes/impl/SystemImpl.cpp +16 -2
  195. data/platform/shared/qt/rhodes/main.cpp +28 -0
  196. data/platform/shared/qt/rhodes/rhodes.pro +3 -0
  197. data/platform/shared/qt/rholib/rholib.pro +2 -1
  198. data/platform/shared/qt/rubylib/rubylib.pro +2 -1
  199. data/platform/shared/ruby/Android.mk +3 -0
  200. data/platform/shared/ruby/class.c +7 -0
  201. data/platform/shared/ruby/compile.c +18 -10
  202. data/platform/shared/ruby/encdb.h +18 -8
  203. data/platform/shared/ruby/eval.c +108 -2
  204. data/platform/shared/ruby/ext/alert/alert_wrap.c +64 -20
  205. data/platform/shared/ruby/ext/asynchttp/asynchttp_wrap.c +64 -20
  206. data/platform/shared/ruby/ext/bluetooth/bluetooth_wrap.c +67 -23
  207. data/platform/shared/ruby/ext/calendar/calendar_wrap.c +64 -20
  208. data/platform/shared/ruby/ext/calendar/event_wrap.c +64 -20
  209. data/platform/shared/ruby/ext/camera/camera_wrap.c +64 -20
  210. data/platform/shared/ruby/ext/datetimepicker/datetimepicker_wrap.c +64 -20
  211. data/platform/shared/ruby/ext/geolocation/geolocation.i +16 -0
  212. data/platform/shared/ruby/ext/geolocation/geolocation_wrap.c +127 -26
  213. data/platform/shared/ruby/ext/mapview/mapview_wrap.c +64 -20
  214. data/platform/shared/ruby/ext/nativebar/nativebar_wrap.c +65 -21
  215. data/platform/shared/ruby/ext/nativeviewmanager/nativeviewmanager_wrap.c +64 -20
  216. data/platform/shared/ruby/ext/navbar/navbar_wrap.c +64 -20
  217. data/platform/shared/ruby/ext/phonebook/phonebook.i +7 -7
  218. data/platform/shared/ruby/ext/phonebook/phonebook_wrap.c +95 -120
  219. data/platform/shared/ruby/ext/rho/rhoruby.c +4 -4
  220. data/platform/shared/ruby/ext/rho/rhoruby.h +2 -0
  221. data/platform/shared/ruby/ext/rho/rhosupport.c +39 -6
  222. data/platform/shared/ruby/ext/rhoconf/rhoconf_wrap.c +65 -21
  223. data/platform/shared/ruby/ext/ringtones/ringtones_wrap.c +64 -20
  224. data/platform/shared/ruby/ext/signature/signature.i +37 -5
  225. data/platform/shared/ruby/ext/signature/signature_wrap.c +274 -45
  226. data/platform/shared/ruby/ext/syncengine/syncengine_wrap.c +65 -21
  227. data/platform/shared/ruby/ext/system/system.i +14 -2
  228. data/platform/shared/ruby/ext/system/system_wrap.c +146 -25
  229. data/platform/shared/ruby/ext/webview/webview_wrap.c +65 -21
  230. data/platform/shared/ruby/include/ruby/ruby.h +15 -4
  231. data/platform/shared/ruby/inits.c +1 -0
  232. data/platform/shared/ruby/io.c +13 -3
  233. data/platform/shared/ruby/win32/win32.c +3 -3
  234. data/platform/shared/ruby/wince/io_wce.c +2 -2
  235. data/platform/shared/rubyext/System.cpp +9 -5
  236. data/platform/shared/sync/ClientRegister.cpp +18 -8
  237. data/platform/shared/sync/SyncEngine.cpp +25 -11
  238. data/platform/shared/sync/SyncEngine.h +2 -0
  239. data/platform/shared/sync/SyncSource.cpp +40 -15
  240. data/platform/shared/sync/SyncSource.h +3 -2
  241. data/platform/shared/sync/SyncThread.cpp +9 -4
  242. data/platform/shared/sync/SyncThread.h +3 -1
  243. data/platform/symbian/build/symbian.rake +14 -9
  244. data/platform/symbian/rhodes/rhodes.pro +11 -8
  245. data/platform/symbian/rhodes/src/phonebook/ruby_phonebook.cpp +2 -2
  246. data/platform/symbian/rubylib/rubylib.pro +3 -0
  247. data/platform/win32/RhoSimulator/RhoSimulator.exe +0 -0
  248. data/platform/wm/RhoLib/RhoLib.vcproj +315 -2
  249. data/platform/wm/build/build_inf.js +235 -187
  250. data/platform/wm/build/wm.rake +388 -233
  251. data/platform/wm/rhodes.sln +56 -0
  252. data/platform/wm/rhodes/MainWindow.cpp +139 -77
  253. data/platform/wm/rhodes/MainWindow.h +27 -22
  254. data/platform/wm/rhodes/MapView/{Graphics.cpp → Bitmap.cpp} +15 -253
  255. data/platform/wm/rhodes/MapView/Bitmap.h +86 -0
  256. data/platform/wm/rhodes/MapView/MapViewManager.cpp +7 -2
  257. data/platform/wm/rhodes/MapView/MapViewManager.h +1 -1
  258. data/platform/wm/rhodes/MapView/Win32Graphics.cpp +263 -0
  259. data/platform/wm/rhodes/MapView/Win32Graphics.h +133 -0
  260. data/platform/wm/rhodes/MapView/WmGraphics.cpp +291 -0
  261. data/platform/wm/rhodes/MapView/{Graphics.h → WmGraphics.h} +14 -56
  262. data/platform/wm/rhodes/Rhodes.cpp +128 -32
  263. data/platform/wm/rhodes/Rhodes.rc +6 -2
  264. data/platform/wm/rhodes/camera/Camera.cpp +1 -0
  265. data/platform/wm/rhodes/phonebook/phonebook.cpp +2 -2
  266. data/platform/wm/rhodes/phonebook/phonebook.h +2 -2
  267. data/platform/wm/rhodes/resource.h +3 -2
  268. data/platform/wm/rhodes/rho/net/NetRequestImpl.cpp +6 -0
  269. data/platform/wm/rhodes/rho/rubyext/NativeToolbar.cpp +4 -0
  270. data/platform/wm/rhodes/rho/rubyext/RhoSignature.cpp +675 -0
  271. data/platform/wm/rhodes/rho/rubyext/RhoSignature.h +123 -0
  272. data/platform/wm/rhodes/rho/rubyext/SystemImpl.cpp +12 -2
  273. data/platform/wm/rhodes/rhodes.vcproj +2732 -1113
  274. data/platform/wm/rhodes/simulator/MainWindowQt.h +1 -1
  275. data/platform/wm/rhodes/stdafx.h +1 -0
  276. data/platform/wm/rhoelements.sln +118 -62
  277. data/platform/wm/rubylib/rubylib.vcproj +345 -16
  278. data/platform/wm/sqlite3/sqlite3.vcproj +305 -0
  279. data/platform/wm/syncengine/syncengine.vcproj +309 -0
  280. data/platform/wm/tools/detool/LogServer.cpp +19 -2
  281. data/platform/wm/tools/detool/detool.cpp +131 -6
  282. data/platform/wm/tools/detool/detool.vcproj +3 -1
  283. data/platform/wm/tools/detool/stdafx.h +1 -0
  284. data/platform/wp7/IronRuby/Languages/Ruby/Libraries/Builtins/RangeOps.cs +589 -0
  285. data/platform/wp7/IronRuby/Languages/Ruby/Ruby/Builtins/RubyEncoding.cs +678 -0
  286. data/platform/wp7/IronRuby/Languages/Ruby/Ruby/Runtime/RubyExceptionData.cs +271 -0
  287. data/platform/wp7/IronRuby/Languages/Ruby/Ruby/Runtime/RubyUtils.cs +31 -1
  288. data/platform/wp7/IronRuby/bin/Silverlight3Release/IronRuby.Libraries.dll +0 -0
  289. data/platform/wp7/IronRuby/bin/Silverlight3Release/IronRuby.dll +0 -0
  290. data/platform/wp7/RhoRubyLib/common/RhoStd.cs +6 -0
  291. data/platform/wp7/RhoRubyLib/common/RhodesApp.cs +16 -2
  292. data/platform/wp7/RhoRubyLib/net/NetRequest.cs +2 -0
  293. data/platform/wp7/RhoRubyLib/rubyext/RhoSyncEngine.cs +1 -2
  294. data/platform/wp7/RhoRubyLib/sync/SyncEngine.cs +13 -10
  295. data/platform/wp7/RhoRubyLib/sync/SyncSource.cs +30 -8
  296. data/platform/wp7/build/wp.rake +5 -0
  297. data/rakefile.rb +153 -46
  298. data/res/build-tools/detool.exe +0 -0
  299. data/res/build-tools/swig_patch/Lib/ruby/rubyerrors.swg +155 -0
  300. data/res/build-tools/swig_patch/Lib/ruby/rubyhead.swg +158 -0
  301. data/res/build-tools/swig_patch/Lib/ruby/rubyiterators.swg +932 -0
  302. data/res/build-tools/swig_patch/Lib/ruby/rubyrun.swg +448 -0
  303. data/res/build-tools/swig_patch/Lib/ruby/rubystdfunctors.swg +162 -0
  304. data/res/build-tools/swig_patch/Lib/ruby/rubytracking.swg +159 -0
  305. data/res/build-tools/swig_patch/Lib/ruby/std_basic_string.i +97 -0
  306. data/res/build-tools/swig_patch/Lib/ruby/std_map.i +418 -0
  307. data/res/build-tools/swig_patch/Lib/ruby/std_multimap.i +227 -0
  308. data/res/build-tools/swig_patch/Lib/swiginit.swg +269 -0
  309. data/res/build-tools/swig_patch/README +7 -0
  310. data/res/generators/templates/application/app/Settings/controller.rb +42 -1
  311. data/res/generators/templates/application/app/Settings/wait.erb +1 -1
  312. data/res/generators/templates/application/app/application.rb +1 -1
  313. data/res/generators/templates/application/app/layout.erb +8 -8
  314. data/res/generators/templates/application/build.yml +0 -1
  315. data/res/generators/templates/application/public/css/android.css +6 -0
  316. data/res/generators/templates/application/public/css/blackberry.css +6 -0
  317. data/res/generators/templates/application/public/css/iphone.css +6 -0
  318. data/res/generators/templates/application/public/css/jqmobile-patch.css +14 -0
  319. data/res/generators/templates/application/public/jqmobile/images/ajax-loader.png +0 -0
  320. data/res/generators/templates/application/public/jqmobile/images/icons-18-black.png +0 -0
  321. data/res/generators/templates/application/public/jqmobile/images/icons-18-white.png +0 -0
  322. data/res/generators/templates/application/public/jqmobile/images/icons-36-black.png +0 -0
  323. data/res/generators/templates/application/public/jqmobile/images/icons-36-white.png +0 -0
  324. data/res/generators/templates/application/public/jqmobile/{jquery.mobile-1.0rc1.css → jquery.mobile-1.0.css} +452 -354
  325. data/res/generators/templates/application/public/jqmobile/{jquery.mobile-1.0rc1.js → jquery.mobile-1.0.js} +629 -442
  326. data/res/generators/templates/application/public/jqmobile/jquery.mobile-1.0.min.css +2 -0
  327. data/res/generators/templates/application/public/jqmobile/jquery.mobile-1.0.min.js +172 -0
  328. data/res/generators/templates/application/public/jqmobile/jquery.mobile.structure-1.0.css +714 -0
  329. data/res/generators/templates/application/public/jqmobile/jquery.mobile.structure-1.0.min.css +2 -0
  330. data/res/generators/templates/application/public/js/jqmobile-patch.js +136 -7
  331. data/res/generators/templates/extension/app/MontanaTest/controller.rb +20 -20
  332. data/res/generators/templates/extension/app/MontanaTest/index.erb +17 -17
  333. data/res/generators/templates/extension/extensions/montana/ext/montana/platform/iphone/Montana.xcodeproj/project.pbxproj +8 -2
  334. data/res/generators/templates/extension/extensions/montana/ext/montana/platform/iphone/Rakefile +5 -0
  335. data/res/generators/templates/extension/extensions/montana/ext/montana/shared/ruby/montana_wrap.c +64 -20
  336. data/rhomobile-debug.gemspec +1 -1
  337. data/spec/framework_spec/app/layout.erb +1 -1
  338. data/spec/framework_spec/app/spec/core/rational/Rational_spec.rb +1 -1
  339. data/spec/framework_spec/app/spec/library/stringio/shared/each_char.rb +6 -2
  340. data/spec/framework_spec/app/spec/shared/rational/{Rational.rb → rational_main.rb} +0 -0
  341. data/spec/framework_spec/build.yml +0 -3
  342. data/spec/perfomance_spec/app/Benchmark/controller.rb +1 -1
  343. data/spec/perfomance_spec/app/layout.erb +1 -1
  344. data/spec/phone_spec/app/BlobTest_s/blob_test_s.rb +13 -0
  345. data/spec/phone_spec/app/BlobTest_s/test.png +0 -0
  346. data/spec/phone_spec/app/BlobTest_s/test2.png +0 -0
  347. data/spec/phone_spec/app/spec/blobsync_spec.rb +27 -15
  348. data/spec/phone_spec/app/spec/date_spec.rb +27 -1
  349. data/spec/phone_spec/app/spec/rho_spec.rb +6 -0
  350. data/spec/phone_spec/app/spec/rhom_object_spec.rb +64 -26
  351. data/spec/phone_spec/app/spec/syncengine_spec.rb +28 -7
  352. data/spec/phone_spec/app/spec/uri_spec.rb +4 -4
  353. data/spec/phone_spec/app/spec_runner.rb +4 -2
  354. data/spec/phone_spec/build.yml +7 -9
  355. data/spec/phone_spec/rhoconfig.txt +1 -0
  356. data/version +1 -1
  357. metadata +75 -22
  358. data/Manifest.txt +0 -7853
  359. data/platform/wm/rhodes/rhoelements/RhoWKBrowserEngine.cpp +0 -384
  360. data/platform/wm/rhodes/rhoelements/RhoWKBrowserEngine.h +0 -41
  361. data/platform/wm/rhodes/signature/Signature.cpp +0 -396
  362. data/platform/wm/rhodes/signature/Signature.h +0 -84
  363. data/platform/wm/rubylib/rubylib.vcproj.VLAD.Vladimir.user +0 -429
  364. data/platform/wm/sqlite3/sqlite3.vcproj.VLAD.Vladimir.user +0 -429
  365. data/platform/wm/syncengine/syncengine.vcproj.VLAD.Vladimir.user +0 -429
  366. data/res/generators/templates/application/public/jqmobile/jquery.mobile-1.0rc1.min.css +0 -12
  367. data/res/generators/templates/application/public/jqmobile/jquery.mobile-1.0rc1.min.js +0 -170
  368. data/rhomobile-debug-1.0.5.gem +0 -0
@@ -0,0 +1,678 @@
1
+ /* ****************************************************************************
2
+ *
3
+ * Copyright (c) Microsoft Corporation.
4
+ *
5
+ * This source code is subject to terms and conditions of the Apache License, Version 2.0. A
6
+ * copy of the license can be found in the License.html file at the root of this distribution. If
7
+ * you cannot locate the Apache License, Version 2.0, please send an email to
8
+ * ironruby@microsoft.com. By using this source code in any fashion, you are agreeing to be bound
9
+ * by the terms of the Apache License, Version 2.0.
10
+ *
11
+ * You must not remove this notice, or any other, from this software.
12
+ *
13
+ *
14
+ * ***************************************************************************/
15
+
16
+ #if !CLR2
17
+ using System.Linq.Expressions;
18
+ #else
19
+ using Microsoft.Scripting.Ast;
20
+ #endif
21
+
22
+ using System;
23
+ using System.Collections.Generic;
24
+ using System.Text;
25
+ using System.Diagnostics;
26
+ using System.Threading;
27
+ using System.Runtime.Serialization;
28
+ using System.Security.Permissions;
29
+ using Microsoft.Scripting.Utils;
30
+ using Microsoft.Scripting.Runtime;
31
+ using IronRuby.Runtime;
32
+ using IronRuby.Compiler;
33
+
34
+ namespace IronRuby.Builtins {
35
+
36
+ /// <summary>
37
+ /// All encodings in Ruby are represented by instances of a single class. Therefore we need to wrap .NET Encoding class in RubyEncoding.
38
+ /// Instances of this class are app-domain singletons. That's all right as far as the class is readonly and doesn't implement IRubyObject.
39
+ /// Taint, frozen flags and instance variables need to be stored in per-runtime lookaside table.
40
+ /// </summary>
41
+ [Serializable]
42
+ public class RubyEncoding : ISerializable, IExpressionSerializable {
43
+ #region Singletons
44
+
45
+ public const int CodePageBinary = 0;
46
+ public const int CodePageSJIS = 932;
47
+ public const int CodePageBig5 = 950;
48
+ public const int CodePageAscii = 20127;
49
+
50
+ // Windows returns 2 EUC-JP encodings (CP 20932 and CP 51932). Mono implements EUC-JP as 51932 and doesn't support 20932.
51
+ public const int CodePageEUCJP = 51932;
52
+
53
+ public const int CodePageUTF7 = 65000;
54
+ public const int CodePageUTF8 = 65001;
55
+ public const int CodePageUTF16BE = 1201;
56
+ public const int CodePageUTF16LE = 1200;
57
+ public const int CodePageUTF32BE = 12001;
58
+ public const int CodePageUTF32LE = 12000;
59
+
60
+ // TODO: how does MRI sort encodings?
61
+
62
+ public static readonly RubyEncoding/*!*/ Binary = new RubyEncoding(BinaryEncoding.Instance, BinaryEncoding.Instance, -4);
63
+ public static readonly RubyEncoding/*!*/ UTF8 = new RubyEncoding(CreateEncoding(CodePageUTF8, false), CreateEncoding(CodePageUTF8, true), -3);
64
+
65
+ #if SILVERLIGHT
66
+ public static readonly RubyEncoding/*!*/ Ascii = UTF8;
67
+ #else
68
+ public static readonly RubyEncoding/*!*/ Ascii = new RubyEncoding(CreateEncoding(CodePageAscii, false), CreateEncoding(CodePageAscii, true), -2);
69
+ public static readonly RubyEncoding/*!*/ EUCJP = new RubyEncoding(CreateEncoding(CodePageEUCJP, false), CreateEncoding(CodePageEUCJP, true), -1);
70
+ public static readonly RubyEncoding/*!*/ SJIS = new RubyEncoding(CreateEncoding(CodePageSJIS, false), CreateEncoding(CodePageSJIS, true), 0);
71
+ #endif
72
+
73
+ #endregion
74
+
75
+ private readonly Encoding/*!*/ _encoding;
76
+ private readonly Encoding/*!*/ _strictEncoding;
77
+ private Expression _expression;
78
+ private readonly int _ordinal;
79
+
80
+ // TODO: combine into a single integer (tables could be merged)
81
+ private readonly int _maxBytesPerChar;
82
+ private readonly bool _isAsciiIdentity;
83
+ #if !SILVERLIGHT
84
+ private bool? _isSingleByteCharacterSet;
85
+ private bool? _isDoubleByteCharacterSet;
86
+ #endif
87
+
88
+ private RubyEncoding(Encoding/*!*/ encoding, Encoding/*!*/ strictEncoding, int ordinal) {
89
+ Assert.NotNull(encoding, strictEncoding);
90
+ _ordinal = ordinal;
91
+ _encoding = encoding;
92
+ _strictEncoding = strictEncoding;
93
+ _maxBytesPerChar = strictEncoding.GetMaxByteCount(1);
94
+ _isAsciiIdentity = AsciiIdentity(encoding);
95
+ }
96
+
97
+ public override int GetHashCode() {
98
+ return _ordinal;
99
+ }
100
+
101
+ internal Expression/*!*/ Expression {
102
+ get { return _expression ?? (_expression = Expression.Constant(this)); }
103
+ }
104
+
105
+ public bool IsAsciiIdentity {
106
+ get { return _isAsciiIdentity; }
107
+ }
108
+
109
+ private static Encoding/*!*/ CreateEncoding(int codepage, bool throwOnError) {
110
+ #if SILVERLIGHT
111
+ return new UTF8Encoding(false, throwOnError);
112
+ #else
113
+ if (throwOnError) {
114
+ return Encoding.GetEncoding(codepage, EncoderFallback.ExceptionFallback, DecoderFallback.ExceptionFallback);
115
+ } else {
116
+ return Encoding.GetEncoding(codepage, EncoderFallback.ReplacementFallback, BinaryDecoderFallback.Instance);
117
+ }
118
+ #endif
119
+ }
120
+
121
+ #region Serialization
122
+ #if !SILVERLIGHT
123
+ private RubyEncoding(SerializationInfo/*!*/ info, StreamingContext context) {
124
+ throw Assert.Unreachable;
125
+ }
126
+
127
+ [Serializable]
128
+ internal sealed class Deserializer : ISerializable, IObjectReference {
129
+ private readonly int _codePage;
130
+
131
+ private Deserializer(SerializationInfo/*!*/ info, StreamingContext context) {
132
+ _codePage = info.GetInt32("CodePage");
133
+ }
134
+
135
+ public object GetRealObject(StreamingContext context) {
136
+ return GetRubyEncoding(_codePage);
137
+ }
138
+
139
+ void ISerializable.GetObjectData(SerializationInfo/*!*/ info, StreamingContext context) {
140
+ throw Assert.Unreachable;
141
+ }
142
+ }
143
+
144
+ void ISerializable.GetObjectData(SerializationInfo/*!*/ info, StreamingContext context) {
145
+ info.AddValue("CodePage", CodePage);
146
+ info.SetType(typeof(Deserializer));
147
+ }
148
+ #endif
149
+ #endregion
150
+
151
+ public int MaxBytesPerChar {
152
+ get { return _maxBytesPerChar; }
153
+ }
154
+
155
+ public Encoding/*!*/ Encoding {
156
+ get { return _encoding; }
157
+ }
158
+
159
+ public Encoding/*!*/ StrictEncoding {
160
+ get { return _strictEncoding; }
161
+ }
162
+
163
+ /// <summary>
164
+ /// Name as displayed by MRI.
165
+ /// </summary>
166
+ public string/*!*/ Name {
167
+ get {
168
+ return GetRubySpecificName(CodePage) ?? _encoding.WebName;
169
+ }
170
+ }
171
+
172
+ public static string GetRubySpecificName(int codepage) {
173
+ switch (codepage) {
174
+ case RubyEncoding.CodePageUTF8: return "UTF-8";
175
+ #if !SILVERLIGHT
176
+ case RubyEncoding.CodePageUTF7: return "UTF-7";
177
+ case RubyEncoding.CodePageUTF16BE: return "UTF-16BE";
178
+ case RubyEncoding.CodePageUTF16LE: return "UTF-16LE";
179
+ case RubyEncoding.CodePageUTF32BE: return "UTF-32BE";
180
+ case RubyEncoding.CodePageUTF32LE: return "UTF-32LE";
181
+ case RubyEncoding.CodePageSJIS: return "Shift_JIS";
182
+ case RubyEncoding.CodePageAscii: return "US-ASCII";
183
+
184
+ // disambiguates CP 20932 and CP 51932:
185
+ case RubyEncoding.CodePageEUCJP: return "EUC-JP";
186
+ case 20932: return "CP20932";
187
+
188
+ case 50220: return "ISO-2022-JP";
189
+ case 50222: return "CP50222";
190
+ #endif
191
+ default: return null;
192
+ }
193
+ }
194
+
195
+ public int CodePage {
196
+ get { return GetCodePage(_encoding); }
197
+ }
198
+
199
+ public override string/*!*/ ToString() {
200
+ return Name;
201
+ }
202
+
203
+ public int CompareTo(RubyEncoding/*!*/ other) {
204
+ return _ordinal - other._ordinal;
205
+ }
206
+
207
+ public static RubyRegexOptions ToRegexOption(RubyEncoding encoding) {
208
+ if (encoding == RubyEncoding.Binary) {
209
+ return RubyRegexOptions.FIXED;
210
+ }
211
+
212
+ if (encoding == null) {
213
+ return RubyRegexOptions.NONE;
214
+ }
215
+
216
+ switch (encoding.CodePage) {
217
+ #if !SILVERLIGHT
218
+ case RubyEncoding.CodePageSJIS: return RubyRegexOptions.SJIS;
219
+ case RubyEncoding.CodePageEUCJP: return RubyRegexOptions.EUC;
220
+ #endif
221
+ case RubyEncoding.CodePageUTF8: return RubyRegexOptions.UTF8;
222
+ }
223
+
224
+ throw Assert.Unreachable;
225
+ }
226
+
227
+ public static RubyEncoding GetRegexEncoding(RubyRegexOptions options) {
228
+ switch (options & RubyRegexOptions.EncodingMask) {
229
+ #if !SILVERLIGHT
230
+ case RubyRegexOptions.EUC: return RubyEncoding.EUCJP;
231
+ case RubyRegexOptions.SJIS: return RubyEncoding.SJIS;
232
+ #endif
233
+ case RubyRegexOptions.UTF8: return RubyEncoding.UTF8;
234
+ case RubyRegexOptions.FIXED: return RubyEncoding.Binary;
235
+ default: return null;
236
+ }
237
+ }
238
+
239
+ internal static int GetCodePage(int nameInitial) {
240
+ switch (nameInitial) {
241
+ #if !SILVERLIGHT
242
+ case 'E':
243
+ case 'e': return CodePageEUCJP;
244
+ case 'S':
245
+ case 's': return CodePageSJIS;
246
+ #endif
247
+ case 'U':
248
+ case 'u': return CodePageUTF8;
249
+ default:
250
+ return -1;
251
+ }
252
+ }
253
+
254
+ public static RubyEncoding GetEncodingByNameInitial(int initial) {
255
+ int codepage = GetCodePage(initial);
256
+ return codepage > 0 ? GetRubyEncoding(codepage) : null;
257
+ }
258
+
259
+ public void RequireAsciiIdentity() {
260
+ if (!_isAsciiIdentity) {
261
+ throw new NotSupportedException(String.Format("Encoding {0} (code page {1}) is not supported", Name, CodePage));
262
+ }
263
+ }
264
+
265
+ #if !SILVERLIGHT
266
+ private static Dictionary<int, RubyEncoding> _Encodings;
267
+
268
+ public static RubyEncoding/*!*/ GetRubyEncoding(Encoding/*!*/ encoding) {
269
+ ContractUtils.RequiresNotNull(encoding, "encoding");
270
+
271
+ if (encoding.CodePage == 0) {
272
+ if (encoding == BinaryEncoding.Instance) {
273
+ return Binary;
274
+ }
275
+
276
+ // TODO: allow custom encodings (without codepage)
277
+ }
278
+
279
+ return GetRubyEncoding(encoding.CodePage);
280
+ }
281
+
282
+ public static RubyEncoding/*!*/ GetRubyEncoding(int codepage) {
283
+ switch (codepage) {
284
+ case CodePageBinary: return Binary;
285
+ case CodePageAscii: return Ascii;
286
+ case CodePageUTF8: return UTF8;
287
+ case CodePageSJIS: return SJIS;
288
+ case CodePageEUCJP: return EUCJP;
289
+ }
290
+
291
+ if (_Encodings == null) {
292
+ Interlocked.CompareExchange(ref _Encodings, new Dictionary<int, RubyEncoding>(), null);
293
+ }
294
+
295
+ RubyEncoding result;
296
+ lock (_Encodings) {
297
+ if (!_Encodings.TryGetValue(codepage, out result)) {
298
+ result = new RubyEncoding(
299
+ CreateEncoding(codepage, false),
300
+ CreateEncoding(codepage, true),
301
+ codepage
302
+ );
303
+
304
+ _Encodings.Add(codepage, result);
305
+ }
306
+ }
307
+
308
+ return result;
309
+ }
310
+
311
+ private static int GetCodePage(Encoding/*!*/ encoding) {
312
+ return encoding.CodePage;
313
+ }
314
+
315
+ public static bool AsciiIdentity(Encoding/*!*/ encoding) {
316
+ if (encoding == BinaryEncoding.Instance) {
317
+ return true;
318
+ }
319
+
320
+ switch (encoding.CodePage) {
321
+ case 437: // OEM United States
322
+ case 708: // Arabic (ASMO 708)
323
+ case 720: // Arabic (DOS)
324
+ case 737: // Greek (DOS)
325
+ case 775: // Baltic (DOS)
326
+ case 850: // Western European (DOS)
327
+ case 852: // Central European (DOS)
328
+ case 855: // OEM Cyrillic
329
+ case 857: // Turkish (DOS)
330
+ case 858: // OEM Multilingual Latin I
331
+ case 860: // Portuguese (DOS)
332
+ case 861: // Icelandic (DOS)
333
+ case 862: // Hebrew (DOS)
334
+ case 863: // French Canadian (DOS)
335
+ case 864: // Arabic (864)
336
+ case 865: // Nordic (DOS)
337
+ case 866: // Cyrillic (DOS)
338
+ case 869: // Greek, Modern (DOS)
339
+ case 874: // Thai (Windows)
340
+ case 932: // Japanese (Shift-JIS)
341
+ case 936: // Chinese Simplified (GB2312)
342
+ case 949: // Korean
343
+ case 950: // Chinese Traditional (Big5)
344
+ case 1250: // Central European (Windows)
345
+ case 1251: // Cyrillic (Windows)
346
+ case 1252: // Western European (Windows)
347
+ case 1253: // Greek (Windows)
348
+ case 1254: // Turkish (Windows)
349
+ case 1255: // Hebrew (Windows)
350
+ case 1256: // Arabic (Windows)
351
+ case 1257: // Baltic (Windows)
352
+ case 1258: // Vietnamese (Windows)
353
+ case 1361: // Korean (Johab)
354
+ case 10000: // Western European (Mac)
355
+ case 10001: // Japanese (Mac)
356
+ case 10002: // Chinese Traditional (Mac)
357
+ case 10003: // Korean (Mac)
358
+ case 10004: // Arabic (Mac)
359
+ case 10005: // Hebrew (Mac)
360
+ case 10006: // Greek (Mac)
361
+ case 10007: // Cyrillic (Mac)
362
+ case 10008: // Chinese Simplified (Mac)
363
+ case 10010: // Romanian (Mac)
364
+ case 10017: // Ukrainian (Mac)
365
+ case 10029: // Central European (Mac)
366
+ case 10079: // Icelandic (Mac)
367
+ case 10081: // Turkish (Mac)
368
+ case 10082: // Croatian (Mac)
369
+ case 20000: // Chinese Traditional (CNS)
370
+ case 20001: // TCA Taiwan
371
+ case 20002: // Chinese Traditional (Eten)
372
+ case 20003: // IBM5550 Taiwan
373
+ case 20004: // TeleText Taiwan
374
+ case 20005: // Wang Taiwan
375
+ case 20127: // US-ASCII
376
+ case 20866: // Cyrillic (KOI8-R)
377
+ case 20932: // Japanese (JIS 0208-1990 and 0212-1990)
378
+ case 20936: // Chinese Simplified (GB2312-80)
379
+ case 20949: // Korean Wansung
380
+ case 21866: // Cyrillic (KOI8-U)
381
+ case 28591: // Western European (ISO)
382
+ case 28592: // Central European (ISO)
383
+ case 28593: // Latin 3 (ISO)
384
+ case 28594: // Baltic (ISO)
385
+ case 28595: // Cyrillic (ISO)
386
+ case 28596: // Arabic (ISO)
387
+ case 28597: // Greek (ISO)
388
+ case 28598: // Hebrew (ISO-Visual)
389
+ case 28599: // Turkish (ISO)
390
+ case 28603: // Estonian (ISO)
391
+ case 28605: // Latin 9 (ISO)
392
+ case 38598: // Hebrew (ISO-Logical)
393
+ case 50220: // Japanese (JIS)
394
+ case 50221: // Japanese (JIS-Allow 1 byte Kana)
395
+ case 50222: // Japanese (JIS-Allow 1 byte Kana - SO/SI)
396
+ case 50225: // Korean (ISO)
397
+ case 50227: // Chinese Simplified (ISO-2022)
398
+ case 51932: // Japanese (EUC)
399
+ case 51936: // Chinese Simplified (EUC)
400
+ case 51949: // Korean (EUC)
401
+ case 54936: // Chinese Simplified (GB18030)
402
+ case 57002: // ISCII Devanagari
403
+ case 57003: // ISCII Bengali
404
+ case 57004: // ISCII Tamil
405
+ case 57005: // ISCII Telugu
406
+ case 57006: // ISCII Assamese
407
+ case 57007: // ISCII Oriya
408
+ case 57008: // ISCII Kannada
409
+ case 57009: // ISCII Malayalam
410
+ case 57010: // ISCII Gujarati
411
+ case 57011: // ISCII Punjabi
412
+ case 65001: // Unicode (UTF-8)
413
+ Debug.Assert(IsAsciiIdentityFallback(encoding));
414
+ return true;
415
+
416
+ default:
417
+ return IsAsciiIdentityFallback(encoding);
418
+ }
419
+ }
420
+
421
+ private static string _AllAscii;
422
+
423
+ private static bool IsAsciiIdentityFallback(Encoding/*!*/ encoding) {
424
+ if (_AllAscii == null) {
425
+ // all ASCII characters:
426
+ var sb = new StringBuilder(0x80);
427
+ for (int i = 0; i < 0x80; i++) {
428
+ sb.Append((char)i);
429
+ }
430
+ _AllAscii = sb.ToString();
431
+ }
432
+
433
+ var bytes = encoding.GetBytes(_AllAscii);
434
+ if (bytes.Length != _AllAscii.Length) {
435
+ return false;
436
+ }
437
+
438
+ for (int i = 0; i < _AllAscii.Length; i++) {
439
+ if ((int)_AllAscii[i] != (int)bytes[i]) {
440
+ return false;
441
+ }
442
+ }
443
+
444
+ return true;
445
+ }
446
+
447
+ public bool IsSingleByteCharacterSet {
448
+ get {
449
+ if (!_isSingleByteCharacterSet.HasValue) {
450
+ _isSingleByteCharacterSet = IsSBCS(CodePage);
451
+ }
452
+
453
+ return _isSingleByteCharacterSet.Value;
454
+ }
455
+ }
456
+
457
+ public bool IsDoubleByteCharacterSet {
458
+ get {
459
+ if (!_isDoubleByteCharacterSet.HasValue) {
460
+ _isDoubleByteCharacterSet = IsDBCS(CodePage);
461
+ }
462
+
463
+ return _isDoubleByteCharacterSet.Value;
464
+ }
465
+ }
466
+
467
+ private static int[] _sbsc;
468
+ private static int[] _dbsc;
469
+
470
+ private static bool IsSBCS(int codepage) {
471
+ if (_sbsc == null) {
472
+ _sbsc = new int[] {
473
+ 0, 37, 437, 500, 708, 720, 737, 775, 850, 852, 855, 857, 858, 860, 861, 862, 863, 864, 865, 866, 869, 870, 874, 875, 1026,
474
+ 1047, 1140, 1141, 1142, 1143, 1144, 1145, 1146, 1147, 1148, 1149, 1250, 1251, 1252, 1253, 1254, 1255, 1256, 1257, 1258,
475
+ 10000, 10004, 10005, 10006, 10007, 10010, 10017, 10021, 10029, 10079, 10081, 10082, 20105, 20106, 20107, 20108, 20127,
476
+ 20269, 20273, 20277, 20278, 20280, 20284, 20285, 20290, 20297, 20420, 20423, 20424, 20833, 20838, 20866, 20871, 20880,
477
+ 20905, 20924, 21025, 21866, 28592, 28593, 28594, 28595, 28596, 28597, 28598, 28599, 28603, 28605, 29001, 38598
478
+ };
479
+ }
480
+
481
+ return Array.BinarySearch(_sbsc, codepage) >= 0;
482
+ }
483
+
484
+ private static bool IsDBCS(int codepage) {
485
+ if (_dbsc == null) {
486
+ _dbsc = new int[] {
487
+ 932, 936, 949, 950, 1361, 10001, 10002, 10003, 10008, 20000, 20001, 20002, 20003, 20004, 20005, 20261, 20932, 20936,
488
+ 20949, 50227, 51936, 51949
489
+ };
490
+ }
491
+
492
+ return Array.BinarySearch(_dbsc, codepage) >= 0;
493
+ }
494
+
495
+ public bool InUnicodeBasicPlane {
496
+ get {
497
+ // TODO: others
498
+ return this == Ascii || this == Binary;
499
+ }
500
+ }
501
+
502
+ public bool IsUnicodeEncoding {
503
+ get {
504
+ switch (CodePage) {
505
+ case CodePageUTF7:
506
+ case CodePageUTF8:
507
+ case CodePageUTF16BE:
508
+ case CodePageUTF16LE:
509
+ case CodePageUTF32BE:
510
+ case CodePageUTF32LE:
511
+ return true;
512
+ }
513
+ return false;
514
+ }
515
+ }
516
+
517
+ private static ReadOnlyDictionary<string, string> _aliases;
518
+
519
+ public static ReadOnlyDictionary<string, string> Aliases {
520
+ get { return _aliases ?? (_aliases = CreateAliases()); }
521
+ }
522
+
523
+ private static ReadOnlyDictionary<string, string> CreateAliases() {
524
+ return new ReadOnlyDictionary<string, string>(new Dictionary<string, string>(StringComparer.InvariantCultureIgnoreCase) {
525
+ { "646", "US-ASCII" },
526
+ { "ASCII", "US-ASCII" },
527
+ { "ANSI_X3.4-1968", "US-ASCII" },
528
+ { "BINARY", "ASCII-8BIT" },
529
+ { "CP437", "IBM437" },
530
+ { "CP737", "IBM737" },
531
+ { "CP775", "IBM775" },
532
+ { "CP857", "IBM857" },
533
+ { "CP860", "IBM860" },
534
+ { "CP861", "IBM861" },
535
+ { "CP862", "IBM862" },
536
+ { "CP863", "IBM863" },
537
+ { "CP864", "IBM864" },
538
+ { "CP865", "IBM865" },
539
+ { "CP866", "IBM866" },
540
+ { "CP869", "IBM869" },
541
+ { "CP874", "Windows-874" },
542
+ { "CP878", "KOI8-R" },
543
+ { "CP932", "Windows-31J" },
544
+ { "CP936", "GBK" },
545
+ { "CP950", "Big5" },
546
+ { "CP951", "Big5-HKSCS" },
547
+ { "CP1258", "Windows-1258" },
548
+ { "CP1252", "Windows-1252" },
549
+ { "CP1250", "Windows-1250" },
550
+ { "CP1256", "Windows-1256" },
551
+ { "CP1251", "Windows-1251" },
552
+ { "CP1253", "Windows-1253" },
553
+ { "CP1255", "Windows-1255" },
554
+ { "CP1254", "Windows-1254" },
555
+ { "CP1257", "Windows-1257" },
556
+ { "CP65000", "UTF-7" },
557
+ { "CP65001", "UTF-8" },
558
+ { "IBM850", "CP850" },
559
+ { "eucJP", "EUC-JP" },
560
+ { "eucKR", "EUC-KR" },
561
+ // { "eucTW", "EUC-TW" },
562
+ { "ISO2022-JP", "ISO-2022-JP" },
563
+ // { "ISO2022-JP2", "ISO-2022-JP-2" },
564
+ { "ISO8859-1", "ISO-8859-1" },
565
+ { "ISO8859-2", "ISO-8859-2" },
566
+ { "ISO8859-3", "ISO-8859-3" },
567
+ { "ISO8859-4", "ISO-8859-4" },
568
+ { "ISO8859-5", "ISO-8859-5" },
569
+ { "ISO8859-6", "ISO-8859-6" },
570
+ { "ISO8859-7", "ISO-8859-7" },
571
+ { "ISO8859-8", "ISO-8859-8" },
572
+ { "ISO8859-9", "ISO-8859-9" },
573
+ // { "ISO8859-10", "ISO-8859-10" },
574
+ { "ISO8859-11", "ISO-8859-11" },
575
+ { "ISO8859-13", "ISO-8859-13" },
576
+ // { "ISO8859-14", "ISO-8859-14" },
577
+ { "ISO8859-15", "ISO-8859-15" },
578
+ // { "ISO8859-16", "ISO-8859-16" },
579
+ { "SJIS", "Shift_JIS" },
580
+ { "csWindows31J", "Windows-31J" },
581
+ // { "MacJapan", "MacJapanese" },
582
+ // { "UTF-8-MAC", "UTF8-MAC" },
583
+ // { "UTF-8-HFS", "UTF8-MAC" },
584
+ { "UCS-2BE", "UTF-16BE" },
585
+ { "UCS-4BE", "UTF-32BE" },
586
+ { "UCS-4LE", "UTF-32LE" },
587
+ });
588
+ }
589
+
590
+ Expression/*!*/ IExpressionSerializable.CreateExpression() {
591
+ // TODO: use static fields
592
+ return Methods.CreateEncoding.OpCall(Expression.Constant(CodePage));
593
+ }
594
+ #else
595
+ public static bool AsciiIdentity(Encoding/*!*/ encoding) {
596
+ switch (GetCodePage(encoding)) {
597
+ case CodePageBinary:
598
+ case CodePageUTF8:
599
+ return true;
600
+ }
601
+
602
+ return false;
603
+ }
604
+
605
+ public bool IsSingleByteCharacterSet {
606
+ get {
607
+ return this == Binary;
608
+ }
609
+ }
610
+
611
+ public bool IsDoubleByteCharacterSet {
612
+ get {
613
+ return false;
614
+ }
615
+ }
616
+
617
+ public bool InUnicodeBasicPlane {
618
+ get {
619
+ return this == Binary;
620
+ }
621
+ }
622
+
623
+ public static RubyEncoding/*!*/ GetRubyEncoding(Encoding/*!*/ encoding) {
624
+ ContractUtils.RequiresNotNull(encoding, "encoding");
625
+ //RHO
626
+ /*
627
+ if (encoding == BinaryEncoding.Instance) {
628
+ return Binary;
629
+ }else if (encoding == Encoding.UTF8 || encoding == System.Text.UTF8Encoding.UTF8)
630
+ {
631
+ return UTF8;
632
+ } else {
633
+ throw new ArgumentException(String.Format("Unknown encoding: '{0}'", encoding));
634
+ }
635
+ */
636
+ switch (GetCodePage(encoding))
637
+ {
638
+ case CodePageBinary: return Binary;
639
+ case CodePageAscii: return Ascii;
640
+ case CodePageUTF8: return UTF8;
641
+ }
642
+
643
+ throw new ArgumentException(String.Format("Unknown encoding: '{0}'", encoding));
644
+ //RHO
645
+ }
646
+
647
+ internal static RubyEncoding/*!*/ GetRubyEncoding(int codepage) {
648
+ switch (codepage) {
649
+ case CodePageBinary: return Binary;
650
+ case CodePageUTF8: return UTF8;
651
+ default: throw new ArgumentException(String.Format("Unknown encoding codepage: {0}", codepage));
652
+ }
653
+ }
654
+
655
+ private static int GetCodePage(Encoding/*!*/ encoding) {
656
+ Debug.Assert(encoding != null);
657
+
658
+ if (encoding == BinaryEncoding.Instance) {
659
+ return CodePageBinary;
660
+ }
661
+
662
+ switch (encoding.WebName.ToUpperInvariant()) {
663
+ case "UTF-8": return CodePageUTF8;
664
+ case "UTF-16": return CodePageUTF16LE;
665
+ case "UTF-16BE": return CodePageUTF16BE;
666
+ }
667
+
668
+ throw new ArgumentException(String.Format("Unknown encoding: {0}", encoding));
669
+ }
670
+
671
+ Expression/*!*/ IExpressionSerializable.CreateExpression() {
672
+ // TODO: use a static fields, deal with KCODEs
673
+ return Expression.Constant(UTF8);
674
+ }
675
+ #endif
676
+ }
677
+
678
+ }