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.
- data/CHANGELOG +18 -0
- data/CREDITS +38 -0
- data/README.md +2 -2
- data/Rakefile +60 -2
- data/bin/set-rhodes-sdk.bat +1 -0
- data/doc/application.txt +11 -0
- data/doc/build.txt +156 -39
- data/doc/configuration.txt +1 -10
- data/doc/connect-to-web-services.txt +6 -6
- data/doc/device-caps.txt +48 -5
- data/doc/extensions.txt +8 -1
- data/doc/rhom.txt +16 -0
- data/doc/synchronization.txt +56 -14
- data/doc/ui.txt +23 -2
- data/installer/instant-rhodes.nsi +6 -6
- data/lib/extensions/barcode/ext/barcode/platform/iphone/Barcode.xcodeproj/project.pbxproj +4 -2
- data/lib/extensions/barcode/ext/barcode/platform/wm/Rakefile +1 -1
- data/lib/extensions/digest-md5/ext/Rakefile +3 -3
- data/lib/extensions/digest-md5/ext/build +0 -1
- data/lib/extensions/digest-sha1/ext/Rakefile +1 -1
- data/lib/extensions/digest-sha1/ext/build +0 -1
- data/lib/extensions/digest/ext/Rakefile +3 -3
- data/lib/extensions/digest/ext/build +0 -1
- data/lib/extensions/fcntl/ext/Rakefile +1 -1
- data/lib/extensions/mspec/mspec/guards/guard.rb +4 -0
- data/lib/extensions/mspec/mspec/helpers/environment.rb +4 -0
- data/lib/extensions/nfc/ext.yml +2 -0
- data/lib/extensions/nfc/ext/build +12 -0
- data/lib/extensions/nfc/ext/build.bat +8 -0
- data/lib/extensions/nfc/ext/nfc/platform/android/AndroidManifest.xml +25 -0
- data/lib/extensions/nfc/ext/nfc/platform/android/Rakefile +94 -0
- data/lib/extensions/nfc/ext/nfc/platform/android/ext_build.files +4 -0
- data/lib/extensions/nfc/ext/nfc/platform/android/jni/src/nfc.cpp +404 -0
- data/lib/extensions/nfc/ext/nfc/platform/android/src/com/nfc/Nfc.java +138 -0
- data/lib/extensions/nfc/ext/nfc/platform/android/src/com/nfc/NfcMessage.java +34 -0
- data/lib/extensions/nfc/ext/nfc/platform/android/src/com/nfc/NfcMessagePack.java +33 -0
- data/lib/extensions/nfc/ext/nfc/platform/android/src/com/nfc/NfcRecord.java +149 -0
- data/lib/extensions/nfc/ext/nfc/shared/ruby/nfc.i +22 -0
- data/lib/extensions/nfc/ext/nfc/shared/ruby/nfc_wrap.c +2034 -0
- data/lib/extensions/nfc/nfc.rb +120 -0
- data/lib/extensions/rholang/{lang_ca.rb → rholang/lang_ca.rb} +0 -0
- data/lib/extensions/rholang/{lang_cf.rb → rholang/lang_cf.rb} +0 -0
- data/lib/extensions/rholang/{lang_chef.rb → rholang/lang_chef.rb} +0 -0
- data/lib/extensions/rholang/{lang_cs.rb → rholang/lang_cs.rb} +0 -0
- data/lib/extensions/rholang/{lang_da.rb → rholang/lang_da.rb} +0 -0
- data/lib/extensions/rholang/{lang_de.rb → rholang/lang_de.rb} +0 -0
- data/lib/extensions/rholang/{lang_es.rb → rholang/lang_es.rb} +0 -0
- data/lib/extensions/rholang/{lang_es_ar.rb → rholang/lang_es_ar.rb} +0 -0
- data/lib/extensions/rholang/{lang_fi.rb → rholang/lang_fi.rb} +0 -0
- data/lib/extensions/rholang/{lang_fr.rb → rholang/lang_fr.rb} +0 -0
- data/lib/extensions/rholang/{lang_it.rb → rholang/lang_it.rb} +0 -0
- data/lib/extensions/rholang/{lang_ko.rb → rholang/lang_ko.rb} +0 -0
- data/lib/extensions/rholang/{lang_nl.rb → rholang/lang_nl.rb} +0 -0
- data/lib/extensions/rholang/{lang_no.rb → rholang/lang_no.rb} +0 -0
- data/lib/extensions/rholang/{lang_pt.rb → rholang/lang_pt.rb} +0 -0
- data/lib/extensions/rholang/{lang_pt_br.rb → rholang/lang_pt_br.rb} +0 -0
- data/lib/extensions/rholang/{lang_ru.rb → rholang/lang_ru.rb} +0 -0
- data/lib/extensions/rholang/{lang_se.rb → rholang/lang_se.rb} +0 -0
- data/lib/extensions/rholang/{lang_sr.rb → rholang/lang_sr.rb} +0 -0
- data/lib/extensions/rholang/{rhoerror_ru.rb → rholang/rhoerror_ru.rb} +0 -0
- data/lib/extensions/rholang/{rhomsg_ru.rb → rholang/rhomsg_ru.rb} +0 -0
- data/lib/framework/date/format.rb +2 -0
- data/lib/framework/dateOrig.rb +17 -8
- data/lib/framework/rational18.rb +532 -0
- data/lib/framework/res/back_btn.wp7.png +0 -0
- data/lib/framework/res/blue_pushpin.wp7.png +0 -0
- data/lib/framework/res/blue_pushpin_small.wp7.png +0 -0
- data/lib/framework/res/callout.wp7.png +0 -0
- data/lib/framework/res/callout_link.wp7.png +0 -0
- data/lib/framework/res/esri.wp7.png +0 -0
- data/lib/framework/res/forward_btn.wp7.png +0 -0
- data/lib/framework/res/home_btn.wp7.png +0 -0
- data/lib/framework/res/options_btn.wp7.png +0 -0
- data/lib/framework/res/refresh_btn.wp7.png +0 -0
- data/lib/framework/rho/render.rb +8 -1
- data/lib/framework/rho/rho.rb +30 -7
- data/lib/framework/rho/rhoapplication.rb +9 -4
- data/lib/framework/rho/rhofsconnector.rb +5 -1
- data/lib/framework/rho/rhotabbar.rb +8 -0
- data/lib/framework/rho/rhotoolbar.rb +1 -1
- data/lib/framework/rho/rhoviewhelpers.rb +18 -1
- data/lib/framework/rhodes.rb +1 -1
- data/lib/framework/rhoframework.rb +46 -1
- data/lib/framework/rholang/localization_simplified.rb +17 -16
- data/lib/framework/rhom/rhom_db_adapter.rb +2 -2
- data/lib/framework/rhom/rhom_object_factory.rb +115 -12
- data/lib/framework/rhosystem.rb +135 -0
- data/lib/framework/version.rb +1 -1
- data/lib/rhodes.rb +1 -1
- data/lib/test/apps/rhoconfig.txt +23 -23
- data/platform/android/Rhodes/AndroidManifest.full.xml +101 -0
- data/platform/android/Rhodes/AndroidManifest.xml +10 -15
- data/platform/android/Rhodes/default.properties +11 -0
- data/platform/android/Rhodes/gen/com/rhomobile/rhodes/R.java +59 -53
- data/platform/android/Rhodes/jni/include/rhodes.h +1 -0
- data/platform/android/Rhodes/jni/include/rhodes/jni/com_rhomobile_rhodes_RhodesApplication.h +21 -0
- data/platform/android/Rhodes/jni/include/rhodes/jni/com_rhomobile_rhodes_alert_PopupActivity.h +21 -0
- data/platform/android/Rhodes/jni/include/rhodes/jni/com_rhomobile_rhodes_file_RhoFileApi.h +10 -2
- data/platform/android/Rhodes/jni/src/alert.cpp +2 -1
- data/platform/android/Rhodes/jni/src/datetimepicker.cpp +2 -0
- data/platform/android/Rhodes/jni/src/fileapi.cpp +671 -84
- data/platform/android/Rhodes/jni/src/nativebar.cpp +18 -0
- data/platform/android/Rhodes/jni/src/rhodes.cpp +92 -1
- data/platform/android/Rhodes/res/values/styles.xml +7 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/BaseActivity.java +35 -2
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/Capabilities.java +12 -13
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/LocalFileProvider.java +130 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/NativeBar.java +6 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/PushReceiver.java +5 -1
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/PushService.java +6 -2
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhoMenu.java +7 -36
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesActivity.java +43 -20
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesApplication.java +2 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesService.java +63 -28
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/Utils.java +2 -2
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/WebView.java +6 -2
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/alert/Alert.java +19 -282
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/alert/PopupActivity.java +354 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/datetime/DateTimePickerScreen.java +4 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/event/EventStore.java +1 -2
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/file/RhoFileApi.java +71 -5
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/geolocation/GeoLocationImpl.java +107 -37
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/mainview/SimpleMainView.java +10 -7
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/mainview/TabbedMainView.java +156 -56
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/mapview/MapView.java +0 -1
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/phonebook/ContactAccessorNew.java +40 -32
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/signature/SignatureView.java +1 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/uri/ExternalHttpHandler.java +14 -6
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/uri/LocalFileHandler.java +46 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/uri/MailUriHandler.java +4 -24
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/uri/UriHandler.java +3 -1
- data/platform/android/build/RhodesSRC_build.files +28 -25
- data/platform/android/build/android.rake +230 -54
- data/platform/android/build/androidcommon.rb +1 -1
- data/platform/android/build/librhocommon_build.files +1 -0
- data/platform/bb/Hsqldb/BlackBerry_App_Descriptor.xml +20 -0
- data/platform/bb/Hsqldb/src/com/rho/db/HsqlDBResult.java +1 -5
- data/platform/bb/Hsqldb/src/com/rho/db/HsqlDBStorage.java +6 -1
- data/platform/bb/Hsqldb/src/org/hsqldb/rowio/RowOutputBase.java +1 -1
- data/platform/bb/Hsqldb/src/org/hsqldb/rowio/RowOutputBinary.java +1 -1
- data/platform/bb/RubyVM/BlackBerry_App_Descriptor.xml +20 -0
- data/platform/bb/RubyVM/src/com/rho/IRhoRubyHelper.java +2 -0
- data/platform/bb/RubyVM/src/com/rho/RhoLogOutputSink.java +0 -1
- data/platform/bb/RubyVM/src/com/rho/RhoLogger.java +12 -10
- data/platform/bb/RubyVM/src/com/rho/RhoThread.java +16 -0
- data/platform/bb/RubyVM/src/com/rho/RhoTimer.java +89 -0
- data/platform/bb/RubyVM/src/com/rho/RhodesApp.java +20 -13
- data/platform/bb/RubyVM/src/com/rho/SplashScreen.java +1 -2
- data/platform/bb/RubyVM/src/com/rho/ThreadQueue.java +2 -2
- data/platform/bb/RubyVM/src/com/rho/TimeInterval.java +5 -0
- data/platform/bb/RubyVM/src/com/rho/db/DBAdapter.java +54 -48
- data/platform/bb/RubyVM/src/com/rho/db/IDBResult.java +0 -1
- data/platform/bb/RubyVM/src/com/rho/db/IDBStorage.java +1 -0
- data/platform/bb/RubyVM/src/com/rho/net/AsyncHttp.java +1 -1
- data/platform/bb/RubyVM/src/com/rho/sync/ClientRegister.java +1 -1
- data/platform/bb/RubyVM/src/com/rho/sync/JSONStructIterator.java +1 -1
- data/platform/bb/RubyVM/src/com/rho/sync/SyncEngine.java +16 -8
- data/platform/bb/RubyVM/src/com/rho/sync/SyncNotify.java +2 -2
- data/platform/bb/RubyVM/src/com/rho/sync/SyncSource.java +52 -29
- data/platform/bb/RubyVM/src/com/rho/sync/SyncThread.java +1 -3
- data/platform/bb/build/RubyVM_build.files +1 -0
- data/platform/bb/build/bb.rake +29 -9
- data/platform/bb/rhodes/BlackBerry_App_Descriptor.xml +23 -0
- data/platform/bb/rhodes/platform/5.0/com/rho/RhodesApplicationPlatform.java +1 -1
- data/platform/bb/rhodes/platform/5.0/com/rho/db/SqliteCopyResult.java +0 -4
- data/platform/bb/rhodes/platform/5.0/com/rho/db/SqliteResult.java +13 -20
- data/platform/bb/rhodes/platform/5.0/com/rho/db/SqliteStorage.java +183 -157
- data/platform/bb/rhodes/src/com/rho/RhoRubyHelper.java +22 -0
- data/platform/bb/rhodes/src/com/rho/RhodesApplicationPlatform.java +1 -1
- data/platform/bb/rhodes/src/com/rho/db/SqliteCopyResult.java +0 -4
- data/platform/bb/rhodes/src/com/rho/db/SqliteResult.java +13 -20
- data/platform/bb/rhodes/src/com/rho/db/SqliteStorage.java +183 -157
- data/platform/bb/rhodes/src/com/rho/rubyext/System.java +46 -1
- data/platform/bb/rhodes/src/rhomobile/RhodesApplication.java +8 -1
- data/platform/bb/rhodes/src/rhomobile/camera/CameraFilesListener.java +13 -3
- data/platform/iphone/Classes/AppManager/AppManager.h +5 -1
- data/platform/iphone/Classes/AppManager/AppManager.m +170 -7
- data/platform/iphone/Classes/DateTimePicker.m +14 -1
- data/platform/iphone/Classes/DateTimePickerDelegate.h +2 -0
- data/platform/iphone/Classes/DateTimePickerDelegate.m +36 -2
- data/platform/iphone/Classes/NativeBar.h +1 -0
- data/platform/iphone/Classes/NativeBar.m +15 -3
- data/platform/iphone/Classes/Phonebook/phonebook.m +8 -9
- data/platform/iphone/Classes/Rhodes.m +50 -6
- data/platform/iphone/Classes/SimpleMainView.m +7 -6
- data/platform/iphone/Classes/SplitView/RightViewController.h +3 -1
- data/platform/iphone/Classes/SplitView/RightViewController.m +14 -1
- data/platform/iphone/Classes/TabbedMainView.h +4 -0
- data/platform/iphone/Classes/TabbedMainView.m +43 -26
- data/platform/iphone/Info.plist +1 -1
- data/platform/iphone/RhoLib/RhoLib.xcodeproj/project.pbxproj +4 -0
- data/platform/iphone/curl/curl.xcodeproj/project.pbxproj +3 -3
- data/platform/iphone/rbuild/iphone.rake +168 -119
- data/platform/iphone/rhoextlib/rhoextlib.xcodeproj/project.pbxproj +4 -2
- data/platform/iphone/rhorubylib/rhorubylib.xcodeproj/project.pbxproj +3 -3
- data/platform/iphone/rhorunner.xcodeproj/project.pbxproj +2 -2
- data/platform/iphone/rhosynclib/rhosynclib.xcodeproj/project.pbxproj +3 -3
- data/platform/shared/SyncClient/SyncClient.cpp +20 -8
- data/platform/shared/SyncClient/SyncClient.h +2 -1
- data/platform/shared/common/RhoDefs.h +4 -0
- data/platform/shared/common/RhoPort.h +22 -0
- data/platform/shared/common/RhoStd.h +5 -0
- data/platform/shared/common/RhoTime.cpp +73 -0
- data/platform/shared/common/RhoTime.h +26 -53
- data/platform/shared/common/RhodesApp.cpp +29 -28
- data/platform/shared/common/RhodesApp.h +4 -1
- data/platform/shared/common/StringConverter.h +37 -10
- data/platform/shared/common/app_build_capabilities.h +2 -0
- data/platform/shared/common/rhoparams.cpp +25 -12
- data/platform/shared/common/rhoparams.h +10 -8
- data/platform/shared/db/DBAdapter.cpp +0 -22
- data/platform/shared/json/RJSONTokener.c +15 -23
- data/platform/shared/net/AsyncHttp.cpp +9 -8
- data/platform/shared/net/HttpServer.cpp +61 -19
- data/platform/shared/net/HttpServer.h +2 -0
- data/platform/shared/ruby/ext/datetimepicker/datetimepicker.i +3 -0
- data/platform/shared/ruby/ext/datetimepicker/datetimepicker_wrap.c +151 -402
- data/platform/shared/ruby/ext/nativebar/nativebar.i +3 -0
- data/platform/shared/ruby/ext/nativebar/nativebar_wrap.c +154 -403
- data/platform/shared/ruby/ext/rho/rhoruby.c +4 -0
- data/platform/shared/ruby/ext/rho/rhoruby.h +2 -0
- data/platform/shared/ruby/ext/system/system.i +8 -0
- data/platform/shared/ruby/ext/system/system_wrap.c +80 -5
- data/platform/shared/ruby/file.c +6 -4
- data/platform/shared/ruby/gc.c +1 -1
- data/platform/shared/ruby/linux/ruby/config.h +7 -2
- data/platform/shared/ruby/missing/acosh.c +3 -3
- data/platform/shared/ruby/wince/_time.h +1 -1
- data/platform/shared/ruby/wince/stdlib.c +1 -1
- data/platform/shared/ruby/wince/string_wce.c +2 -2
- data/platform/shared/ruby/wince/sys/timeb.c +1 -0
- data/platform/shared/ruby/wince/time_wce.c +8 -0
- data/platform/shared/ruby/wince/wince.c +7 -7
- data/platform/shared/ruby/wince/wince.h +22 -0
- data/platform/shared/rubyext/System.cpp +19 -1
- data/platform/shared/sqlite/sqlite3.c +18993 -8129
- data/platform/shared/sqlite/sqlite3.h +953 -358
- data/platform/shared/sqlite/sqlite3ext.h +42 -0
- data/platform/shared/sync/SyncEngine.cpp +10 -0
- data/platform/shared/sync/SyncSource.cpp +41 -19
- data/platform/shared/sync/SyncSource.h +1 -1
- data/platform/shared/tcmalloc/rhomem.h +7 -2
- data/platform/shared/tcmalloc/windows/port.h +2 -0
- data/platform/shared/unzip/unzip.cpp +1 -0
- data/platform/shared/xruby/src/com/xruby/compiler/parser/RubyParser.java +11 -1
- data/platform/wm/RhoLib/RhoLib.vcproj +182 -24
- data/platform/wm/build/wm.rake +16 -3
- data/platform/wm/rhodes.sln +106 -113
- data/platform/wm/rhodes/Alert.cpp +6 -7
- data/platform/wm/rhodes/AppManager.cpp +8 -17
- data/platform/wm/rhodes/DateTimePicker.cpp +3 -0
- data/platform/wm/rhodes/DateTimePicker.h +2 -0
- data/platform/wm/rhodes/MainWindow.cpp +36 -16
- data/platform/wm/rhodes/MainWindow.h +6 -3
- data/platform/wm/rhodes/OutlookApp.cpp +3 -3
- data/platform/wm/rhodes/Rhodes.cpp +46 -27
- data/platform/wm/rhodes/Rhodes.rc +16 -3
- data/platform/wm/rhodes/RingtoneManager.cpp +7 -7
- data/platform/wm/rhodes/RingtoneManager.h +1 -1
- data/platform/wm/rhodes/Utils.cpp +2 -1
- data/platform/wm/rhodes/bluetooth/Bluetooth.cpp +1 -13
- data/platform/wm/rhodes/bluetooth/Bluetooth.h +1 -2
- data/platform/wm/rhodes/camera/Camera.cpp +6 -12
- data/platform/wm/rhodes/phonebook/phonebook.cpp +11 -11
- data/platform/wm/rhodes/phonebook/phonebook.h +1 -1
- data/platform/wm/rhodes/resource.h +3 -1
- data/platform/wm/rhodes/rho/net/NetRequestImpl.cpp +7 -5
- data/platform/wm/rhodes/rho/rubyext/GeoLocationImpl.cpp +6 -6
- data/platform/wm/rhodes/rho/rubyext/GeoLocationImpl.h +1 -1
- data/platform/wm/rhodes/rho/rubyext/NativeToolbar.cpp +6 -1
- data/platform/wm/rhodes/rho/rubyext/SystemImpl.cpp +84 -19
- data/platform/wm/rhodes/rho/rubyext/calendar.cpp +2 -2
- data/platform/wm/rhodes/rhodes.vcproj +316 -73
- data/platform/wm/rhodes/signature/Signature.cpp +336 -6
- data/platform/wm/rhodes/signature/Signature.h +55 -0
- data/platform/wm/rhodes/stdafx.h +7 -4
- data/platform/wm/rubylib/rubylib.vcproj +261 -91
- data/platform/wm/sqlite3/sqlite3.vcproj +223 -69
- data/platform/wm/syncengine/syncengine.vcproj +220 -66
- data/platform/wm/tcmalloc/tcmalloc.vcproj +197 -43
- data/platform/wp7/IronRuby/Languages/Ruby/Ruby/Builtins/ConsoleStream.cs +107 -0
- data/platform/wp7/IronRuby/Languages/Ruby/Ruby/Runtime/Loader.cs +1037 -0
- data/platform/wp7/IronRuby/Languages/Ruby/Ruby/Runtime/RubyUtils.cs +1476 -0
- data/platform/wp7/RhoAppRunner/Program.cs +55 -0
- data/platform/wp7/RhoAppRunner/Properties/AssemblyInfo.cs +36 -0
- data/platform/wp7/RhoAppRunner/RhoAppRunner.csproj +69 -0
- data/platform/wp7/RhoRubyExtGen/GenerateInitializers.cmd +7 -0
- data/platform/wp7/RhoRubyExtGen/Properties/AssemblyInfo.cs +36 -0
- data/platform/wp7/RhoRubyExtGen/RhoAsyncHttp.cs +38 -0
- data/platform/wp7/RhoRubyExtGen/RhoDatabase.cs +93 -0
- data/platform/wp7/RhoRubyExtGen/RhoJSON.cs +37 -0
- data/platform/wp7/RhoRubyExtGen/RhoNativeBar.cs +106 -0
- data/platform/wp7/RhoRubyExtGen/RhoRubyExtGen.csproj +75 -0
- data/platform/wp7/RhoRubyExtGen/RhoSyncEngine.cs +123 -0
- data/platform/wp7/RhoRubyExtGen/RhoWebView.cs +42 -0
- data/platform/wp7/RhoRubyLib/Initializers.Generated.cs +309 -0
- data/platform/wp7/RhoRubyLib/Properties/AssemblyInfo.cs +36 -0
- data/platform/wp7/RhoRubyLib/RhoAppAdapter.cs +96 -0
- data/platform/wp7/RhoRubyLib/RhoRuby.cs +296 -0
- data/platform/wp7/RhoRubyLib/RhoRubyLib.csproj +155 -0
- data/platform/wp7/RhoRubyLib/WP_PlatformAdaptationLayer.cs +107 -0
- data/platform/wp7/RhoRubyLib/common/IInputStream.cs +21 -0
- data/platform/wp7/RhoRubyLib/common/Mutex.cs +30 -0
- data/platform/wp7/RhoRubyLib/common/RhoConf.cs +389 -0
- data/platform/wp7/RhoRubyLib/common/RhoEmptyProfiler.cs +27 -0
- data/platform/wp7/RhoRubyLib/common/RhoFile.cs +332 -0
- data/platform/wp7/RhoRubyLib/common/RhoFilePath.cs +89 -0
- data/platform/wp7/RhoRubyLib/common/RhoParamArray.cs +33 -0
- data/platform/wp7/RhoRubyLib/common/RhoParams.cs +66 -0
- data/platform/wp7/RhoRubyLib/common/RhoProfiler.cs +145 -0
- data/platform/wp7/RhoRubyLib/common/RhoResourceMap.cs +68 -0
- data/platform/wp7/RhoRubyLib/common/RhoStd.cs +205 -0
- data/platform/wp7/RhoRubyLib/common/RhoThread.cs +114 -0
- data/platform/wp7/RhoRubyLib/common/RhodesApp.cs +504 -0
- data/platform/wp7/RhoRubyLib/common/ThreadQueue.cs +199 -0
- data/platform/wp7/RhoRubyLib/common/TimeInterval.cs +56 -0
- data/platform/wp7/RhoRubyLib/common/Tokenizer.cs +52 -0
- data/platform/wp7/RhoRubyLib/db/DBAdapter.cs +1129 -0
- data/platform/wp7/RhoRubyLib/db/DBAttrManager.cs +92 -0
- data/platform/wp7/RhoRubyLib/db/DBException.cs +35 -0
- data/platform/wp7/RhoRubyLib/db/IDBCallback.cs +10 -0
- data/platform/wp7/RhoRubyLib/db/IDBResult.cs +33 -0
- data/platform/wp7/RhoRubyLib/db/IDBStorage.cs +32 -0
- data/platform/wp7/RhoRubyLib/db/SqliteCopyResult.cs +79 -0
- data/platform/wp7/RhoRubyLib/db/SqliteResult.cs +267 -0
- data/platform/wp7/RhoRubyLib/db/SqliteStorage.cs +319 -0
- data/platform/wp7/RhoRubyLib/json/JSONArrayIterator.cs +63 -0
- data/platform/wp7/RhoRubyLib/json/JSONEntry.cs +96 -0
- data/platform/wp7/RhoRubyLib/json/JSONStructIterator.cs +77 -0
- data/platform/wp7/RhoRubyLib/json/JsonParser.cs +483 -0
- data/platform/wp7/RhoRubyLib/json/RJSONTokener.cs +406 -0
- data/platform/wp7/RhoRubyLib/logging/IRhoLogSink.cs +12 -0
- data/platform/wp7/RhoRubyLib/logging/RhoLogConf.cs +161 -0
- data/platform/wp7/RhoRubyLib/logging/RhoLogFileSink.cs +174 -0
- data/platform/wp7/RhoRubyLib/logging/RhoLogger.cs +320 -0
- data/platform/wp7/RhoRubyLib/net/AsyncHttp.cs +362 -0
- data/platform/wp7/RhoRubyLib/net/HttpServer.cs +466 -0
- data/platform/wp7/RhoRubyLib/net/NetRequest.cs +717 -0
- data/platform/wp7/RhoRubyLib/net/NetResponse.cs +64 -0
- data/platform/wp7/RhoRubyLib/net/URI.cs +187 -0
- data/platform/wp7/RhoRubyLib/rubyext/RhoAsyncHttp.cs +43 -0
- data/platform/wp7/RhoRubyLib/rubyext/RhoDatabase.cs +177 -0
- data/platform/wp7/RhoRubyLib/rubyext/RhoJSON.cs +39 -0
- data/platform/wp7/RhoRubyLib/rubyext/RhoKernelOps.cs +19 -0
- data/platform/wp7/RhoRubyLib/rubyext/RhoNativeBar.cs +117 -0
- data/platform/wp7/RhoRubyLib/rubyext/RhoSyncEngine.cs +199 -0
- data/platform/wp7/RhoRubyLib/rubyext/RhoWebView.cs +49 -0
- data/platform/wp7/RhoRubyLib/sync/ClientRegister.cs +142 -0
- data/platform/wp7/RhoRubyLib/sync/ISyncProtocol.cs +23 -0
- data/platform/wp7/RhoRubyLib/sync/ISyncStatusListener.cs +10 -0
- data/platform/wp7/RhoRubyLib/sync/SyncEngine.cs +1051 -0
- data/platform/wp7/RhoRubyLib/sync/SyncNotify.cs +651 -0
- data/platform/wp7/RhoRubyLib/sync/SyncProtocol_3.cs +79 -0
- data/platform/wp7/RhoRubyLib/sync/SyncSource.cs +1105 -0
- data/platform/wp7/RhoRubyLib/sync/SyncThread.cs +301 -0
- data/platform/wp7/WPApplication.sln +50 -0
- data/platform/wp7/WPApplication/App.xaml +19 -0
- data/platform/wp7/WPApplication/App.xaml.cs +211 -0
- data/platform/wp7/WPApplication/ApplicationIcon.png +0 -0
- data/platform/wp7/WPApplication/Background.png +0 -0
- data/platform/wp7/WPApplication/MainPage.xaml +44 -0
- data/platform/wp7/WPApplication/MainPage.xaml.cs +132 -0
- data/platform/wp7/WPApplication/Properties/AppManifest.xml +6 -0
- data/platform/wp7/WPApplication/Properties/AssemblyInfo.cs +35 -0
- data/platform/wp7/WPApplication/Properties/WMAppManifest.xml +32 -0
- data/platform/wp7/WPApplication/SplashScreenImage.jpg +0 -0
- data/platform/wp7/WPApplication/WPApplication.csproj +201 -0
- data/platform/wp7/WPApplication/WP_PlatformAdaptationLayer.cs +88 -0
- data/platform/wp7/WPApplication/app_manifest.txt +1 -0
- data/platform/wp7/WPApplication/readme.htm +40 -0
- data/platform/wp7/WPApplication/readme2.htm +37 -0
- data/platform/wp7/WPApplication/rho/apps/app/Model1/edit.bb.erb +29 -0
- data/platform/wp7/WPApplication/rho/apps/app/Model1/edit.erb +32 -0
- data/platform/wp7/WPApplication/rho/apps/app/Model1/index.bb.erb +21 -0
- data/platform/wp7/WPApplication/rho/apps/app/Model1/index.erb +26 -0
- data/platform/wp7/WPApplication/rho/apps/app/Model1/model1.rb +10 -0
- data/platform/wp7/WPApplication/rho/apps/app/Model1/model1_controller.rb +58 -0
- data/platform/wp7/WPApplication/rho/apps/app/Model1/new.bb.erb +29 -0
- data/platform/wp7/WPApplication/rho/apps/app/Model1/new.erb +31 -0
- data/platform/wp7/WPApplication/rho/apps/app/Model1/show.bb.erb +26 -0
- data/platform/wp7/WPApplication/rho/apps/app/Model1/show.erb +28 -0
- data/platform/wp7/WPApplication/rho/apps/app/Settings/controller.rb +75 -0
- data/platform/wp7/WPApplication/rho/apps/app/Settings/home.bb.erb +17 -0
- data/platform/wp7/WPApplication/rho/apps/app/Settings/home.erb +20 -0
- data/platform/wp7/WPApplication/rho/apps/app/Settings/index.bb.erb +32 -0
- data/platform/wp7/WPApplication/rho/apps/app/Settings/index.erb +30 -0
- data/platform/wp7/WPApplication/rho/apps/app/Settings/login.bb.erb +35 -0
- data/platform/wp7/WPApplication/rho/apps/app/Settings/login.erb +27 -0
- data/platform/wp7/WPApplication/rho/apps/app/Settings/reset.bb.erb +15 -0
- data/platform/wp7/WPApplication/rho/apps/app/Settings/reset.erb +17 -0
- data/platform/wp7/WPApplication/rho/apps/app/Settings/wait.bb.erb +3 -0
- data/platform/wp7/WPApplication/rho/apps/app/Settings/wait.erb +5 -0
- data/platform/wp7/WPApplication/rho/apps/app/application.rb +16 -0
- data/platform/wp7/WPApplication/rho/apps/app/helpers/application_helper.rb +126 -0
- data/platform/wp7/WPApplication/rho/apps/app/helpers/browser_helper.rb +18 -0
- data/platform/wp7/WPApplication/rho/apps/app/index.bb.erb +26 -0
- data/platform/wp7/WPApplication/rho/apps/app/index.erb +26 -0
- data/platform/wp7/WPApplication/rho/apps/app/layout.erb +45 -0
- data/platform/wp7/WPApplication/rho/apps/app/loading.html +11 -0
- data/platform/wp7/WPApplication/rho/apps/app_manifest.txt +1 -0
- data/platform/wp7/WPApplication/rho/apps/public/css/android.css +330 -0
- data/platform/wp7/WPApplication/rho/apps/public/css/blackberry.css +115 -0
- data/platform/wp7/WPApplication/rho/apps/public/css/iphone.css +410 -0
- data/platform/wp7/WPApplication/rho/apps/public/css/windows_mobile.css +222 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/IUI_LICENSE.txt +21 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/android/btn_check_off.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/android/btn_check_on.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/android/btn_radio_off.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/android/btn_radio_on.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/android/disclosure.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/android/ic_menu_more.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/backButton.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/blueButton.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/cancel.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/grayButton.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/iphone/disclosure.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/iphone/disclosure_detail.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/iphone/jqtouch/backButton.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/iphone/jqtouch/blueButton.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/iphone/jqtouch/cancel.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/iphone/jqtouch/chevron.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/iphone/jqtouch/grayButton.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/iphone/jqtouch/listArrowSel.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/iphone/jqtouch/listGroup.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/iphone/jqtouch/loading.gif +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/iphone/jqtouch/on_off.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/iphone/jqtouch/pinstripes.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/iphone/jqtouch/selection.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/iphone/jqtouch/thumb.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/iphone/jqtouch/toggle.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/iphone/jqtouch/toggleOn.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/iphone/jqtouch/toolButton.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/iphone/jqtouch/toolbar.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/iphone/jqtouch/whiteButton.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/iphone/radiobutton.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/iphone/select.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/iphone/switch.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/iui-logo-touch-icon.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/listArrow.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/listArrowDown.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/listArrowSel.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/listGroup.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/loading.gif +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/pinstripes.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/right_button.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/selection.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/thumb.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/toggle.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/toggleOn.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/toolButton.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/toolButton_new.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/toolbar.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/whiteButton.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/jqtouch/jqtouch-iphone.css +9 -0
- data/platform/wp7/WPApplication/rho/apps/public/jqtouch/jqtouch.css +374 -0
- data/platform/wp7/WPApplication/rho/apps/public/jqtouch/jqtouch.js +742 -0
- data/platform/wp7/WPApplication/rho/apps/public/jqtouch/jqtouch.transitions.js +60 -0
- data/platform/wp7/WPApplication/rho/apps/public/jqtouch/jquery.1.3.2.min.js +19 -0
- data/platform/wp7/WPApplication/rho/apps/public/js/application.js +1 -0
- data/platform/wp7/WPApplication/rho/apps/public/js/rho.js +4 -0
- data/platform/wp7/WPApplication/rho/apps/public/js/rhogeolocation-wm.js +59 -0
- data/platform/wp7/WPApplication/rho/apps/public/js/rhogeolocation.js +11 -0
- data/platform/wp7/WPApplication/rho/apps/rhoconfig.txt +32 -0
- data/platform/wp7/WPApplication/rhoconfig.txt +32 -0
- data/platform/wp7/WPApplication/windows_mobile.css +222 -0
- data/platform/wp7/build/wp.rake +261 -0
- data/platform/wp7/rhodes.sln +79 -0
- data/platform/wp7/rhodes/App.xaml +19 -0
- data/platform/wp7/rhodes/App.xaml.cs +144 -0
- data/platform/wp7/rhodes/Background.png +0 -0
- data/platform/wp7/rhodes/MainPage.xaml +44 -0
- data/platform/wp7/rhodes/MainPage.xaml.cs +98 -0
- data/platform/wp7/rhodes/Properties/AppManifest.xml +6 -0
- data/platform/wp7/rhodes/Properties/AssemblyInfo.cs +35 -0
- data/platform/wp7/rhodes/Properties/WMAppManifest.xml +31 -0
- data/platform/wp7/rhodes/Rhodes.csproj +127 -0
- data/platform/wp7/rhodes/SplashScreenImage.jpg +0 -0
- data/platform/wp7/rhodes/icon.png +0 -0
- data/platform/wp7/sqlite3/Properties/AssemblyInfo.cs +35 -0
- data/platform/wp7/sqlite3/SQLiteClient.cs +550 -0
- data/platform/wp7/sqlite3/SqliteWrapper/BtreeInt_h.cs +774 -0
- data/platform/wp7/sqlite3/SqliteWrapper/Btree_h.cs +280 -0
- data/platform/wp7/sqlite3/SqliteWrapper/ClassDiagram1.cd +1306 -0
- data/platform/wp7/sqlite3/SqliteWrapper/Delagates.cs +365 -0
- data/platform/wp7/sqlite3/SqliteWrapper/Hash_h.cs +133 -0
- data/platform/wp7/sqlite3/SqliteWrapper/VdbeInt_h.cs +620 -0
- data/platform/wp7/sqlite3/SqliteWrapper/Vdbe_h.cs +302 -0
- data/platform/wp7/sqlite3/SqliteWrapper/_Custom.cs +449 -0
- data/platform/wp7/sqlite3/SqliteWrapper/alter_c.cs +872 -0
- data/platform/wp7/sqlite3/SqliteWrapper/analyze_c.cs +757 -0
- data/platform/wp7/sqlite3/SqliteWrapper/attach_c.cs +628 -0
- data/platform/wp7/sqlite3/SqliteWrapper/auth_c.cs +268 -0
- data/platform/wp7/sqlite3/SqliteWrapper/backup_c.cs +737 -0
- data/platform/wp7/sqlite3/SqliteWrapper/bitvec_c.cs +509 -0
- data/platform/wp7/sqlite3/SqliteWrapper/btmutex_c.cs +379 -0
- data/platform/wp7/sqlite3/SqliteWrapper/btree_c.cs +9138 -0
- data/platform/wp7/sqlite3/SqliteWrapper/build_c.cs +4189 -0
- data/platform/wp7/sqlite3/SqliteWrapper/callback_c.cs +548 -0
- data/platform/wp7/sqlite3/SqliteWrapper/complete_c.cs +342 -0
- data/platform/wp7/sqlite3/SqliteWrapper/ctime_cs.cs +408 -0
- data/platform/wp7/sqlite3/SqliteWrapper/date_c.cs +1317 -0
- data/platform/wp7/sqlite3/SqliteWrapper/delete_c.cs +726 -0
- data/platform/wp7/sqlite3/SqliteWrapper/expr_c.cs +4406 -0
- data/platform/wp7/sqlite3/SqliteWrapper/fault_c.cs +115 -0
- data/platform/wp7/sqlite3/SqliteWrapper/fkey_c.cs +1330 -0
- data/platform/wp7/sqlite3/SqliteWrapper/func_c.cs +2025 -0
- data/platform/wp7/sqlite3/SqliteWrapper/global_c.cs +228 -0
- data/platform/wp7/sqlite3/SqliteWrapper/hash_c.cs +351 -0
- data/platform/wp7/sqlite3/SqliteWrapper/hwtime_c.cs +101 -0
- data/platform/wp7/sqlite3/SqliteWrapper/insert_c.cs +2122 -0
- data/platform/wp7/sqlite3/SqliteWrapper/journal_c.cs +247 -0
- data/platform/wp7/sqlite3/SqliteWrapper/keywordhash_h.cs +302 -0
- data/platform/wp7/sqlite3/SqliteWrapper/legacy_c.cs +223 -0
- data/platform/wp7/sqlite3/SqliteWrapper/loadext_c.cs +683 -0
- data/platform/wp7/sqlite3/SqliteWrapper/main_c.cs +2716 -0
- data/platform/wp7/sqlite3/SqliteWrapper/malloc_c.cs +977 -0
- data/platform/wp7/sqlite3/SqliteWrapper/mem_Pool.cs +394 -0
- data/platform/wp7/sqlite3/SqliteWrapper/memjournal_c.cs +315 -0
- data/platform/wp7/sqlite3/SqliteWrapper/mutex_c.cs +182 -0
- data/platform/wp7/sqlite3/SqliteWrapper/mutex_h.cs +91 -0
- data/platform/wp7/sqlite3/SqliteWrapper/mutex_noop_c.cs +202 -0
- data/platform/wp7/sqlite3/SqliteWrapper/mutex_w32.cs +344 -0
- data/platform/wp7/sqlite3/SqliteWrapper/notify_c.cs +347 -0
- data/platform/wp7/sqlite3/SqliteWrapper/opcodes_c.cs +171 -0
- data/platform/wp7/sqlite3/SqliteWrapper/opcodes_h.cs +346 -0
- data/platform/wp7/sqlite3/SqliteWrapper/os_c.cs +367 -0
- data/platform/wp7/sqlite3/SqliteWrapper/os_common_h.cs +174 -0
- data/platform/wp7/sqlite3/SqliteWrapper/os_h.cs +295 -0
- data/platform/wp7/sqlite3/SqliteWrapper/os_win_c.cs +1255 -0
- data/platform/wp7/sqlite3/SqliteWrapper/pager_c.cs +6078 -0
- data/platform/wp7/sqlite3/SqliteWrapper/pager_h.cs +188 -0
- data/platform/wp7/sqlite3/SqliteWrapper/parse_c.cs +4045 -0
- data/platform/wp7/sqlite3/SqliteWrapper/parse_h.cs +331 -0
- data/platform/wp7/sqlite3/SqliteWrapper/pcache1_c.cs +969 -0
- data/platform/wp7/sqlite3/SqliteWrapper/pcache_c.cs +712 -0
- data/platform/wp7/sqlite3/SqliteWrapper/pcache_h.cs +213 -0
- data/platform/wp7/sqlite3/SqliteWrapper/pragma_c.cs +1767 -0
- data/platform/wp7/sqlite3/SqliteWrapper/prepare_c.cs +1015 -0
- data/platform/wp7/sqlite3/SqliteWrapper/printf_c.cs +1300 -0
- data/platform/wp7/sqlite3/SqliteWrapper/random_c.cs +201 -0
- data/platform/wp7/sqlite3/SqliteWrapper/resolve_c.cs +1396 -0
- data/platform/wp7/sqlite3/SqliteWrapper/rowset_c.cs +519 -0
- data/platform/wp7/sqlite3/SqliteWrapper/select_c.cs +4878 -0
- data/platform/wp7/sqlite3/SqliteWrapper/sqlite3_h.cs +6253 -0
- data/platform/wp7/sqlite3/SqliteWrapper/sqlite3ext_h.cs +397 -0
- data/platform/wp7/sqlite3/SqliteWrapper/sqliteInt_h.cs +4075 -0
- data/platform/wp7/sqlite3/SqliteWrapper/sqliteLimit_h.cs +214 -0
- data/platform/wp7/sqlite3/SqliteWrapper/sqliteicu_h.cs +39 -0
- data/platform/wp7/sqlite3/SqliteWrapper/status_c.cs +155 -0
- data/platform/wp7/sqlite3/SqliteWrapper/table_c.cs +222 -0
- data/platform/wp7/sqlite3/SqliteWrapper/tokenize_c.cs +673 -0
- data/platform/wp7/sqlite3/SqliteWrapper/trigger_c.cs +1219 -0
- data/platform/wp7/sqlite3/SqliteWrapper/update_c.cs +766 -0
- data/platform/wp7/sqlite3/SqliteWrapper/utf_c.cs +612 -0
- data/platform/wp7/sqlite3/SqliteWrapper/util_c.cs +1476 -0
- data/platform/wp7/sqlite3/SqliteWrapper/vacuum_c.cs +382 -0
- data/platform/wp7/sqlite3/SqliteWrapper/vdbe_c.cs +6566 -0
- data/platform/wp7/sqlite3/SqliteWrapper/vdbeapi_c.cs +1557 -0
- data/platform/wp7/sqlite3/SqliteWrapper/vdbeaux_c.cs +4019 -0
- data/platform/wp7/sqlite3/SqliteWrapper/vdbeblob_c.cs +396 -0
- data/platform/wp7/sqlite3/SqliteWrapper/vdbemem_c.cs +1480 -0
- data/platform/wp7/sqlite3/SqliteWrapper/vdbetrace_c.cs +181 -0
- data/platform/wp7/sqlite3/SqliteWrapper/vtab_c.cs +957 -0
- data/platform/wp7/sqlite3/SqliteWrapper/walker_c.cs +174 -0
- data/platform/wp7/sqlite3/SqliteWrapper/where_c.cs +4651 -0
- data/platform/wp7/sqlite3/sqlite3.csproj +155 -0
- data/rakefile.rb +60 -2
- data/res/build-tools/7za.exe +0 -0
- data/res/build-tools/RhoAppRunner.exe +0 -0
- data/res/build-tools/xruby-0.3.3.jar +0 -0
- data/res/generators/rhogen.rb +9 -1
- data/res/generators/templates/application/app/Settings/reset.erb +1 -1
- data/res/generators/templates/application/app/layout.erb +17 -10
- data/res/generators/templates/application/build.yml +5 -3
- data/res/generators/templates/application/public/jqtouch/changes.txt +20 -0
- data/res/generators/templates/application/public/jqtouch/jqtouch.js +12 -4
- data/res/generators/templates/application/public/jqtouch/jquery.1.3.2.min.js +1 -1
- data/res/generators/templates/application/public/js/wp7.js +7 -0
- data/res/generators/templates/model/controller.rb +5 -6
- data/rhobuild.yml.example +1 -0
- data/rhodes.gemspec +2 -1
- data/spec/framework_spec/app/spec/core/dir/close_spec.rb +1 -1
- data/spec/framework_spec/app/spec/core/dir/shared/pwd.rb +13 -11
- data/spec/framework_spec/app/spec/core/env/shared/store.rb +12 -10
- data/spec/framework_spec/app/spec/core/env/update_spec.rb +1 -0
- data/spec/framework_spec/app/spec/core/file/expand_path_spec.rb +3 -2
- data/spec/framework_spec/app/spec/core/file/fixtures/file_types.rb +7 -1
- data/spec/framework_spec/app/spec/core/file/flock_spec.rb +8 -1
- data/spec/framework_spec/app/spec/core/file/ftype_spec.rb +5 -3
- data/spec/framework_spec/app/spec/core/file/lchmod_spec.rb +1 -1
- data/spec/framework_spec/app/spec/core/file/setgid_spec.rb +1 -1
- data/spec/framework_spec/app/spec/core/file/setuid_spec.rb +1 -1
- data/spec/framework_spec/app/spec/core/file/stat/ftype_spec.rb +6 -4
- data/spec/framework_spec/app/spec/core/file/truncate_spec.rb +5 -1
- data/spec/framework_spec/app/spec/core/float/to_s_spec.rb +1 -1
- data/spec/framework_spec/app/spec/core/process/gid_spec.rb +5 -3
- data/spec/framework_spec/app/spec/core/process/groups_spec.rb +11 -9
- data/spec/framework_spec/app/spec/core/process/uid_spec.rb +5 -3
- data/spec/framework_spec/app/spec/language/execution_spec.rb +10 -6
- data/spec/framework_spec/app/spec/shared/file/directory.rb +6 -1
- data/spec/framework_spec/app/spec/shared/file/executable.rb +7 -1
- data/spec/framework_spec/app/spec/shared/file/file.rb +6 -1
- data/spec/framework_spec/app/spec/shared/file/readable.rb +13 -4
- data/spec/framework_spec/app/spec/shared/file/writable.rb +6 -1
- data/spec/phone_spec/app/spec/rho_controller_spec.rb +11 -0
- data/spec/phone_spec/app/spec/rho_spec.rb +11 -0
- data/spec/phone_spec/app/spec/rhom_object_spec.rb +102 -6
- data/spec/phone_spec/app/spec/string/end_with_spec.rb +4 -1
- data/spec/phone_spec/app/spec/string/slice_spec.rb +5 -1
- data/spec/phone_spec/app/spec/string/start_with_spec.rb +4 -0
- data/spec/phone_spec/app/spec/syncengine_spec.rb +73 -6
- data/spec/phone_spec/app/spec_runner.rb +7 -3
- metadata +380 -41
- data/Manifest.txt +0 -5819
- data/platform/bb/Hsqldb/Hsqldb.cso +0 -5
- data/platform/bb/Hsqldb/Hsqldb.jdp +0 -197
- data/platform/bb/RhoBundle/RhoBundle.cso +0 -5
- data/platform/bb/RhoBundle/RhoBundle.jdp +0 -42
- data/platform/bb/RubyVM/RubyVM.cso +0 -5
- data/platform/bb/RubyVM/RubyVM.jdp +0 -467
- data/platform/bb/rhodes/rhodes.csl +0 -3
- data/platform/bb/rhodes/rhodes.cso +0 -5
- data/platform/bb/rhodes/rhodes.jdp +0 -104
@@ -0,0 +1,1476 @@
|
|
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.Diagnostics;
|
25
|
+
using System.IO;
|
26
|
+
using System.Reflection;
|
27
|
+
using System.Runtime.CompilerServices;
|
28
|
+
using System.Runtime.Serialization;
|
29
|
+
using System.Text;
|
30
|
+
using System.Threading;
|
31
|
+
using IronRuby.Builtins;
|
32
|
+
using IronRuby.Compiler;
|
33
|
+
using IronRuby.Runtime.Calls;
|
34
|
+
using Microsoft.Scripting;
|
35
|
+
using Microsoft.Scripting.Math;
|
36
|
+
using Microsoft.Scripting.Runtime;
|
37
|
+
using Microsoft.Scripting.Utils;
|
38
|
+
using IronRuby.Runtime.Conversions;
|
39
|
+
|
40
|
+
namespace IronRuby.Runtime {
|
41
|
+
using EvalEntryPointDelegate = Func<RubyScope, object, RubyModule, Proc, object>;
|
42
|
+
using Microsoft.Scripting.Actions.Calls;
|
43
|
+
|
44
|
+
public static class RubyUtils {
|
45
|
+
#region Objects
|
46
|
+
|
47
|
+
public static readonly int FalseObjectId = 0;
|
48
|
+
public static readonly int TrueObjectId = 2;
|
49
|
+
public static readonly int NilObjectId = 4;
|
50
|
+
|
51
|
+
/// <summary>
|
52
|
+
/// Ruby value types:
|
53
|
+
///
|
54
|
+
/// NilClass
|
55
|
+
/// TrueClass
|
56
|
+
/// FalseClass
|
57
|
+
/// Fixnum
|
58
|
+
/// Symbol
|
59
|
+
/// + CLR structs
|
60
|
+
/// </summary>
|
61
|
+
public static bool IsRubyValueType(object obj) {
|
62
|
+
return (obj == null || obj is ValueType || obj is RubySymbol) && !(obj is float || obj is double);
|
63
|
+
}
|
64
|
+
|
65
|
+
/// <summary>
|
66
|
+
/// The object maintains a state (frozen, tainted flags and instance variables).
|
67
|
+
/// <code>
|
68
|
+
/// obj.instance_variable_set(:@foo, 'bar')
|
69
|
+
/// puts obj.instance_variable_get(:@foo) # => 'bar'
|
70
|
+
/// puts obj.taint.tainted? # => true
|
71
|
+
/// </code>
|
72
|
+
/// </summary>
|
73
|
+
public static bool HasObjectState(object obj) {
|
74
|
+
return !IsRubyValueType(obj);
|
75
|
+
}
|
76
|
+
|
77
|
+
/// <summary>
|
78
|
+
/// Can the object be cloned?
|
79
|
+
/// </summary>
|
80
|
+
public static bool CanClone(object obj) {
|
81
|
+
return !IsRubyValueType(obj);
|
82
|
+
}
|
83
|
+
|
84
|
+
/// <summary>
|
85
|
+
/// Is it allowed to define a sigleton method for the object?
|
86
|
+
/// </summary>
|
87
|
+
public static bool CanDefineSingletonMethod(object obj) {
|
88
|
+
return !(obj is ValueType || obj is RubySymbol || obj is BigInteger) || obj is bool;
|
89
|
+
}
|
90
|
+
|
91
|
+
/// <summary>
|
92
|
+
/// Does the object have a sigleton class?
|
93
|
+
/// </summary>
|
94
|
+
public static bool HasSingletonClass(object obj) {
|
95
|
+
return !(obj is int || obj is RubySymbol);
|
96
|
+
}
|
97
|
+
|
98
|
+
public static MutableString/*!*/ InspectObject(UnaryOpStorage/*!*/ inspectStorage, ConversionStorage<MutableString>/*!*/ tosConversion,
|
99
|
+
object obj) {
|
100
|
+
|
101
|
+
var context = tosConversion.Context;
|
102
|
+
using (IDisposable handle = RubyUtils.InfiniteInspectTracker.TrackObject(obj)) {
|
103
|
+
if (handle == null) {
|
104
|
+
return MutableString.CreateAscii("...");
|
105
|
+
}
|
106
|
+
|
107
|
+
MutableString str = MutableString.CreateMutable(context.GetIdentifierEncoding());
|
108
|
+
str.Append("#<");
|
109
|
+
str.Append(context.GetClassDisplayName(obj));
|
110
|
+
|
111
|
+
// Ruby prints 2*object_id for objects
|
112
|
+
str.Append(':');
|
113
|
+
AppendFormatHexObjectId(str, GetObjectId(context, obj));
|
114
|
+
|
115
|
+
RubyInstanceData data = context.TryGetInstanceData(obj);
|
116
|
+
if (data != null) {
|
117
|
+
var vars = data.GetInstanceVariablePairs();
|
118
|
+
bool first = true;
|
119
|
+
foreach (KeyValuePair<string, object> var in vars) {
|
120
|
+
if (first) {
|
121
|
+
str.Append(' ');
|
122
|
+
first = false;
|
123
|
+
} else {
|
124
|
+
str.Append(", ");
|
125
|
+
}
|
126
|
+
// TODO (encoding):
|
127
|
+
str.Append(var.Key);
|
128
|
+
str.Append('=');
|
129
|
+
|
130
|
+
var inspectSite = inspectStorage.GetCallSite("inspect");
|
131
|
+
object inspectedValue = inspectSite.Target(inspectSite, var.Value);
|
132
|
+
|
133
|
+
var tosSite = tosConversion.GetSite(ConvertToSAction.Make(context));
|
134
|
+
str.Append(tosSite.Target(tosSite, inspectedValue));
|
135
|
+
|
136
|
+
str.TaintBy(var.Value, context);
|
137
|
+
}
|
138
|
+
}
|
139
|
+
str.Append(">");
|
140
|
+
|
141
|
+
str.TaintBy(obj, context);
|
142
|
+
return str;
|
143
|
+
}
|
144
|
+
}
|
145
|
+
|
146
|
+
public static MutableString/*!*/ FormatObjectPrefix(RubyContext/*!*/ context, string/*!*/ className, long objectId, bool isTainted, bool isUntrusted) {
|
147
|
+
MutableString str = MutableString.CreateMutable(context.GetIdentifierEncoding());
|
148
|
+
str.Append("#<");
|
149
|
+
str.Append(className);
|
150
|
+
|
151
|
+
// Ruby prints 2*object_id for objects
|
152
|
+
str.Append(':');
|
153
|
+
AppendFormatHexObjectId(str, objectId);
|
154
|
+
|
155
|
+
str.IsTainted |= isTainted;
|
156
|
+
str.IsUntrusted |= isUntrusted;
|
157
|
+
return str;
|
158
|
+
}
|
159
|
+
|
160
|
+
public static MutableString/*!*/ FormatObject(RubyContext/*!*/ context, string/*!*/ className, long objectId, bool isTainted, bool isUntrusted) {
|
161
|
+
return FormatObjectPrefix(context, className, objectId, isTainted, isUntrusted).Append(">");
|
162
|
+
}
|
163
|
+
|
164
|
+
public static MutableString/*!*/ ObjectToMutableString(RubyContext/*!*/ context, object obj) {
|
165
|
+
bool tainted, untrusted;
|
166
|
+
context.GetObjectTrust(obj, out tainted, out untrusted);
|
167
|
+
return FormatObject(context, context.GetClassDisplayName(obj), GetObjectId(context, obj), tainted, untrusted);
|
168
|
+
}
|
169
|
+
|
170
|
+
public static MutableString/*!*/ ObjectToMutableStringPrefix(RubyContext/*!*/ context, object obj) {
|
171
|
+
bool tainted, untrusted;
|
172
|
+
context.GetObjectTrust(obj, out tainted, out untrusted);
|
173
|
+
return FormatObjectPrefix(context, context.GetClassDisplayName(obj), GetObjectId(context, obj), tainted, untrusted);
|
174
|
+
}
|
175
|
+
|
176
|
+
public static MutableString/*!*/ AppendFormatHexObjectId(MutableString/*!*/ str, long objectId) {
|
177
|
+
return str.AppendFormat("0x{0:x7}", 2 * objectId);
|
178
|
+
}
|
179
|
+
|
180
|
+
public static MutableString/*!*/ ObjectToMutableString(IRubyObject/*!*/ self) {
|
181
|
+
return RubyUtils.FormatObject(
|
182
|
+
self.ImmediateClass.Context,
|
183
|
+
self.ImmediateClass.GetNonSingletonClass().Name,
|
184
|
+
self.GetInstanceData().ObjectId,
|
185
|
+
self.IsTainted,
|
186
|
+
self.IsUntrusted
|
187
|
+
);
|
188
|
+
}
|
189
|
+
|
190
|
+
public static MutableString/*!*/ ObjectBaseToMutableString(IRubyObject/*!*/ self) {
|
191
|
+
if (self is RubyObject) {
|
192
|
+
return RubyUtils.ObjectToMutableString(self);
|
193
|
+
} else {
|
194
|
+
return MutableString.CreateMutable(self.BaseToString(), RubyEncoding.UTF8);
|
195
|
+
}
|
196
|
+
}
|
197
|
+
|
198
|
+
public static bool TryDuplicateObject(
|
199
|
+
CallSiteStorage<Func<CallSite, object, object, object>>/*!*/ initializeCopyStorage,
|
200
|
+
CallSiteStorage<Func<CallSite, RubyClass, object>>/*!*/ allocateStorage,
|
201
|
+
object obj, bool cloneSemantics, out object copy) {
|
202
|
+
|
203
|
+
// Ruby value types can't be cloned
|
204
|
+
if (!RubyUtils.CanClone(obj)) {
|
205
|
+
copy = null;
|
206
|
+
return false;
|
207
|
+
}
|
208
|
+
|
209
|
+
var context = allocateStorage.Context;
|
210
|
+
|
211
|
+
IDuplicable clonable = obj as IDuplicable;
|
212
|
+
if (clonable != null) {
|
213
|
+
copy = clonable.Duplicate(context, cloneSemantics);
|
214
|
+
} else {
|
215
|
+
// .NET and library classes that don't implement IDuplicable:
|
216
|
+
var allocateSite = allocateStorage.GetCallSite("allocate", 0);
|
217
|
+
copy = allocateSite.Target(allocateSite, context.GetClassOf(obj));
|
218
|
+
|
219
|
+
context.CopyInstanceData(obj, copy, cloneSemantics);
|
220
|
+
}
|
221
|
+
|
222
|
+
var initializeCopySite = initializeCopyStorage.GetCallSite("initialize_copy", 1);
|
223
|
+
initializeCopySite.Target(initializeCopySite, copy, obj);
|
224
|
+
if (cloneSemantics) {
|
225
|
+
context.FreezeObjectBy(copy, obj);
|
226
|
+
}
|
227
|
+
|
228
|
+
return true;
|
229
|
+
}
|
230
|
+
|
231
|
+
public static long GetFixnumId(int number) {
|
232
|
+
return ((long)number << 1) + 1;
|
233
|
+
}
|
234
|
+
|
235
|
+
public static long GetObjectId(RubyContext/*!*/ context, object obj) {
|
236
|
+
if (obj == null) return NilObjectId;
|
237
|
+
if (obj is bool) return (bool)obj ? TrueObjectId : FalseObjectId;
|
238
|
+
if (obj is int) return GetFixnumId((int)obj);
|
239
|
+
|
240
|
+
return context.GetInstanceData(obj).ObjectId;
|
241
|
+
}
|
242
|
+
|
243
|
+
private const int CachedCharCount = 256;
|
244
|
+
private static object[] _charCache = new object[CachedCharCount];
|
245
|
+
|
246
|
+
public static object/*!*/ CharToObject(char ch) {
|
247
|
+
return (ch < CachedCharCount) ? (_charCache[(int)ch] ?? (_charCache[(int)ch] = (object)ch)) : (object)ch;
|
248
|
+
}
|
249
|
+
|
250
|
+
|
251
|
+
|
252
|
+
#endregion
|
253
|
+
|
254
|
+
#region Names
|
255
|
+
|
256
|
+
public static bool HasUnmangledName(string/*!*/ name) {
|
257
|
+
return !NotUnmangledObject.Contains(name);
|
258
|
+
}
|
259
|
+
|
260
|
+
public static string TryUnmangleMethodName(string/*!*/ name) {
|
261
|
+
return HasUnmangledName(name) ? TryUnmangleName(name) : null;
|
262
|
+
}
|
263
|
+
|
264
|
+
/// <summary>
|
265
|
+
/// Converts a Ruby name to PascalCase name (foo_bar -> FooBar).
|
266
|
+
/// Returns null if the name is not a well-formed Ruby name (it contains upper-case latter or subsequent underscores).
|
267
|
+
/// Characters that are not upper case letters are treated as lower-case letters.
|
268
|
+
/// </summary>
|
269
|
+
public static string TryUnmangleName(string/*!*/ name) {
|
270
|
+
ContractUtils.RequiresNotNull(name, "name");
|
271
|
+
if (name.Length == 0) {
|
272
|
+
return null;
|
273
|
+
}
|
274
|
+
|
275
|
+
StringBuilder mangled = new StringBuilder();
|
276
|
+
|
277
|
+
bool lastWasSpecial = false;
|
278
|
+
int i = 0, j = 0;
|
279
|
+
while (i < name.Length) {
|
280
|
+
char c;
|
281
|
+
while (j < name.Length && (c = name[j]) != '_') {
|
282
|
+
if (Char.IsUpper(c)) {
|
283
|
+
return null;
|
284
|
+
}
|
285
|
+
j++;
|
286
|
+
}
|
287
|
+
|
288
|
+
if (j == i || j == name.Length - 1) {
|
289
|
+
return null;
|
290
|
+
}
|
291
|
+
|
292
|
+
if (j - i == 1) {
|
293
|
+
// "ip_f_xxx" -/-> "IPFXxx"
|
294
|
+
if (lastWasSpecial) {
|
295
|
+
return null;
|
296
|
+
}
|
297
|
+
mangled.Append(name[i].ToUpperInvariant());
|
298
|
+
lastWasSpecial = false;
|
299
|
+
} else {
|
300
|
+
string special = MapSpecialWord(name, i, j - i);
|
301
|
+
if (special != null) {
|
302
|
+
// "ip_ip" -/-> "IPIP"
|
303
|
+
if (lastWasSpecial) {
|
304
|
+
return null;
|
305
|
+
}
|
306
|
+
mangled.Append(special.ToUpperInvariant());
|
307
|
+
lastWasSpecial = true;
|
308
|
+
} else {
|
309
|
+
mangled.Append(name[i].ToUpperInvariant());
|
310
|
+
mangled.Append(name, i + 1, j - i - 1);
|
311
|
+
lastWasSpecial = false;
|
312
|
+
}
|
313
|
+
}
|
314
|
+
|
315
|
+
i = ++j;
|
316
|
+
}
|
317
|
+
|
318
|
+
return mangled.ToString();
|
319
|
+
}
|
320
|
+
|
321
|
+
public static bool HasMangledName(string/*!*/ name) {
|
322
|
+
return !NotMangledObject.Contains(name);
|
323
|
+
}
|
324
|
+
|
325
|
+
public static string TryMangleMethodName(string/*!*/ name) {
|
326
|
+
return HasMangledName(name) ? TryMangleName(name) : null;
|
327
|
+
}
|
328
|
+
|
329
|
+
/// <summary>
|
330
|
+
/// Converts a camelCase or PascalCase name to a Ruby name (FooBar -> foo_bar).
|
331
|
+
/// Returns null if the name is not in camelCase or PascalCase (FooBAR, foo, etc.).
|
332
|
+
/// Characters that are not upper case letters are treated as lower-case letters.
|
333
|
+
/// </summary>
|
334
|
+
public static string TryMangleName(string/*!*/ name) {
|
335
|
+
ContractUtils.RequiresNotNull(name, "name");
|
336
|
+
|
337
|
+
StringBuilder mangled = null;
|
338
|
+
int i = 0;
|
339
|
+
while (i < name.Length) {
|
340
|
+
char c = name[i];
|
341
|
+
if (Char.IsUpper(c)) {
|
342
|
+
int j = i + 1;
|
343
|
+
while (j < name.Length && Char.IsUpper(name, j)) {
|
344
|
+
j++;
|
345
|
+
}
|
346
|
+
|
347
|
+
if (j < name.Length) {
|
348
|
+
j--;
|
349
|
+
}
|
350
|
+
|
351
|
+
if (mangled == null) {
|
352
|
+
mangled = new StringBuilder();
|
353
|
+
mangled.Append(name, 0, i);
|
354
|
+
}
|
355
|
+
|
356
|
+
if (i > 0) {
|
357
|
+
mangled.Append('_');
|
358
|
+
}
|
359
|
+
|
360
|
+
int count = j - i;
|
361
|
+
if (count == 0) {
|
362
|
+
// NaN{end}, NaNXxx
|
363
|
+
if (i + 2 < name.Length &&
|
364
|
+
Char.IsUpper(name[i + 2]) &&
|
365
|
+
(i + 3 == name.Length || Char.IsUpper(name[i + 3]) &&
|
366
|
+
(i + 4 < name.Length && !Char.IsUpper(name[i + 4])))) {
|
367
|
+
return null;
|
368
|
+
} else {
|
369
|
+
// X{end}, In, NaN, Xml, Html, ...
|
370
|
+
mangled.Append(c.ToLowerInvariant());
|
371
|
+
i++;
|
372
|
+
}
|
373
|
+
} else if (count == 1) {
|
374
|
+
// FXx
|
375
|
+
mangled.Append(c.ToLowerInvariant());
|
376
|
+
i++;
|
377
|
+
} else {
|
378
|
+
// FOXxx, FOOXxx, FOOOXxx, ...
|
379
|
+
string special = MapSpecialWord(name, i, count);
|
380
|
+
if (special != null) {
|
381
|
+
mangled.Append(special.ToLowerInvariant());
|
382
|
+
i = j;
|
383
|
+
} else {
|
384
|
+
return null;
|
385
|
+
}
|
386
|
+
}
|
387
|
+
} else if (c == '_') {
|
388
|
+
return null;
|
389
|
+
} else {
|
390
|
+
if (mangled != null) {
|
391
|
+
mangled.Append(c);
|
392
|
+
}
|
393
|
+
i++;
|
394
|
+
}
|
395
|
+
}
|
396
|
+
|
397
|
+
return mangled != null ? mangled.ToString() : null;
|
398
|
+
}
|
399
|
+
|
400
|
+
private static string MapSpecialWord(string/*!*/ name, int start, int count) {
|
401
|
+
if (count == 2) {
|
402
|
+
return IsTwoLetterWord(name, start) ? null : name.Substring(start, count);
|
403
|
+
}
|
404
|
+
|
405
|
+
return null;
|
406
|
+
}
|
407
|
+
|
408
|
+
private static bool IsTwoLetterWord(string/*!*/ str, int index) {
|
409
|
+
int c = LetterPair(str, index);
|
410
|
+
switch (c) {
|
411
|
+
case ('a' << 8) | 't':
|
412
|
+
case ('a' << 8) | 's':
|
413
|
+
case ('b' << 8) | 'y':
|
414
|
+
case ('d' << 8) | 'o':
|
415
|
+
case ('i' << 8) | 'd':
|
416
|
+
case ('i' << 8) | 't':
|
417
|
+
case ('i' << 8) | 'f':
|
418
|
+
case ('i' << 8) | 'n':
|
419
|
+
case ('i' << 8) | 's':
|
420
|
+
case ('g' << 8) | 'o':
|
421
|
+
case ('m' << 8) | 'e':
|
422
|
+
case ('m' << 8) | 'y':
|
423
|
+
case ('n' << 8) | 'o':
|
424
|
+
case ('o' << 8) | 'f':
|
425
|
+
case ('o' << 8) | 'k':
|
426
|
+
case ('o' << 8) | 'n':
|
427
|
+
case ('o' << 8) | 'r':
|
428
|
+
case ('t' << 8) | 'o':
|
429
|
+
case ('u' << 8) | 'p':
|
430
|
+
return true;
|
431
|
+
}
|
432
|
+
return false;
|
433
|
+
}
|
434
|
+
|
435
|
+
private static int LetterPair(string/*!*/ str, int index) {
|
436
|
+
return (str[index + 1] & 0xff00) == 0 ? (str[index].ToLowerInvariant() << 8) | str[index + 1].ToLowerInvariant() : -1;
|
437
|
+
}
|
438
|
+
|
439
|
+
/// <summary>
|
440
|
+
/// A list of Kernel/Object methods that are expected by common Ruby libraries to work on all objects.
|
441
|
+
/// We don't unmangled them to allow Ruby programs work with .NET objects that define e.g. Class property.
|
442
|
+
/// </summary>
|
443
|
+
internal static readonly HashSet<string> NotUnmangledObject = new HashSet<string>() {
|
444
|
+
// Kernel
|
445
|
+
"class",
|
446
|
+
"clone",
|
447
|
+
"display",
|
448
|
+
"dup",
|
449
|
+
"extend",
|
450
|
+
"freeze",
|
451
|
+
"hash",
|
452
|
+
// "id", Kernel#id is deprecated
|
453
|
+
"initialize",
|
454
|
+
"inspect",
|
455
|
+
"instance_eval",
|
456
|
+
"instance_exec",
|
457
|
+
"instance_variable_get",
|
458
|
+
"instance_variable_set",
|
459
|
+
"instance_variables",
|
460
|
+
"method",
|
461
|
+
"methods",
|
462
|
+
"object_id",
|
463
|
+
"private_methods",
|
464
|
+
"protected_methods",
|
465
|
+
"public_methods",
|
466
|
+
"send",
|
467
|
+
"singleton_methods",
|
468
|
+
"taint",
|
469
|
+
// "type", Kernel#type is deprecated
|
470
|
+
"untaint",
|
471
|
+
};
|
472
|
+
|
473
|
+
internal static readonly HashSet<string> NotMangledObject = new HashSet<string>() {
|
474
|
+
"Class",
|
475
|
+
"Clone",
|
476
|
+
"Display",
|
477
|
+
"Dup",
|
478
|
+
"Extend",
|
479
|
+
"Freeze",
|
480
|
+
"Hash",
|
481
|
+
// "Id", Kernel#id is deprecated
|
482
|
+
"Initialize",
|
483
|
+
"Inspect",
|
484
|
+
"InstanceEval",
|
485
|
+
"InstanceExec",
|
486
|
+
"InstanceVariableGet",
|
487
|
+
"InstanceVariableSet",
|
488
|
+
"InstanceVariables",
|
489
|
+
"Method",
|
490
|
+
"Methods",
|
491
|
+
"ObjectId",
|
492
|
+
"PrivateMethods",
|
493
|
+
"ProtectedMethods",
|
494
|
+
"PublicMethods",
|
495
|
+
"Send",
|
496
|
+
"SingletonMethods",
|
497
|
+
"Taint",
|
498
|
+
// "Type", Kernel#type is deprecated
|
499
|
+
"Untaint",
|
500
|
+
};
|
501
|
+
|
502
|
+
public static void CheckConstantName(string name) {
|
503
|
+
if (!Tokenizer.IsConstantName(name)) {
|
504
|
+
throw RubyExceptions.CreateNameError(String.Format("`{0}' is not allowed as a constant name", name));
|
505
|
+
}
|
506
|
+
}
|
507
|
+
|
508
|
+
public static void CheckClassVariableName(string name) {
|
509
|
+
if (!Tokenizer.IsClassVariableName(name)) {
|
510
|
+
throw RubyExceptions.CreateNameError(String.Format("`{0}' is not allowed as a class variable name", name));
|
511
|
+
}
|
512
|
+
}
|
513
|
+
|
514
|
+
public static void CheckInstanceVariableName(string name) {
|
515
|
+
if (!Tokenizer.IsInstanceVariableName(name)) {
|
516
|
+
throw RubyExceptions.CreateNameError(String.Format("`{0}' is not allowed as an instance variable name", name));
|
517
|
+
}
|
518
|
+
}
|
519
|
+
|
520
|
+
#endregion
|
521
|
+
|
522
|
+
#region Constants
|
523
|
+
|
524
|
+
// thread-safe:
|
525
|
+
public static object GetConstant(RubyGlobalScope/*!*/ globalScope, RubyModule/*!*/ owner, string/*!*/ name, bool lookupObject) {
|
526
|
+
Assert.NotNull(globalScope, owner, name);
|
527
|
+
|
528
|
+
using (owner.Context.ClassHierarchyLocker()) {
|
529
|
+
ConstantStorage storage;
|
530
|
+
if (owner.TryResolveConstantNoLock(globalScope, name, out storage)) {
|
531
|
+
return storage.Value;
|
532
|
+
}
|
533
|
+
|
534
|
+
RubyClass objectClass = owner.Context.ObjectClass;
|
535
|
+
if (owner != objectClass && lookupObject && objectClass.TryResolveConstantNoLock(globalScope, name, out storage)) {
|
536
|
+
return storage.Value;
|
537
|
+
}
|
538
|
+
}
|
539
|
+
|
540
|
+
RubyUtils.CheckConstantName(name);
|
541
|
+
return owner.ConstantMissing(name);
|
542
|
+
}
|
543
|
+
|
544
|
+
public static void SetConstant(RubyModule/*!*/ owner, string/*!*/ name, object value) {
|
545
|
+
Assert.NotNull(owner, name);
|
546
|
+
|
547
|
+
if (owner.SetConstantChecked(name, value)) {
|
548
|
+
owner.Context.ReportWarning(String.Format("already initialized constant {0}", name));
|
549
|
+
}
|
550
|
+
|
551
|
+
// Initializes anonymous module's name, publishes the module:
|
552
|
+
RubyModule module = value as RubyModule;
|
553
|
+
if (module != null) {
|
554
|
+
if (module.Name == null) {
|
555
|
+
module.Name = owner.MakeNestedModuleName(name);
|
556
|
+
}
|
557
|
+
if (owner.IsObjectClass) {
|
558
|
+
module.Publish(name);
|
559
|
+
}
|
560
|
+
}
|
561
|
+
}
|
562
|
+
|
563
|
+
#endregion
|
564
|
+
|
565
|
+
#region Methods
|
566
|
+
|
567
|
+
public static RubyMethodVisibility GetSpecialMethodVisibility(RubyMethodVisibility/*!*/ visibility, string/*!*/ methodName) {
|
568
|
+
return (methodName == Symbols.Initialize || methodName == Symbols.InitializeCopy) ? RubyMethodVisibility.Private : visibility;
|
569
|
+
}
|
570
|
+
|
571
|
+
internal static string ToClrOperatorName(string/*!*/ rubyName) {
|
572
|
+
switch (rubyName) {
|
573
|
+
case "+": return "op_Addition";
|
574
|
+
case "-": return "op_Subtraction";
|
575
|
+
case "/": return "op_Division";
|
576
|
+
case "*": return "op_Multiply";
|
577
|
+
case "%": return "op_Modulus";
|
578
|
+
case "==": return "op_Equality";
|
579
|
+
case "!=": return "op_Inequality";
|
580
|
+
case ">": return "op_GreaterThan";
|
581
|
+
case ">=": return "op_GreaterThanOrEqual";
|
582
|
+
case "<": return "op_LessThan";
|
583
|
+
case "<=": return "op_LessThanOrEqual";
|
584
|
+
case "-@": return "op_UnaryNegation";
|
585
|
+
case "+@": return "op_UnaryPlus";
|
586
|
+
case "<<": return "op_LeftShift";
|
587
|
+
case ">>": return "op_RightShift";
|
588
|
+
case "^": return "op_ExclusiveOr";
|
589
|
+
case "~": return "op_OnesComplement";
|
590
|
+
case "&": return "op_BitwiseAnd";
|
591
|
+
case "|": return "op_BitwiseOr";
|
592
|
+
|
593
|
+
case "**": return "Power";
|
594
|
+
case "<=>": return "Compare";
|
595
|
+
|
596
|
+
default:
|
597
|
+
return null;
|
598
|
+
}
|
599
|
+
}
|
600
|
+
|
601
|
+
internal static string ToRubyOperatorName(string/*!*/ clrName) {
|
602
|
+
switch (clrName) {
|
603
|
+
case "op_Addition": return "+";
|
604
|
+
case "op_Subtraction": return "-";
|
605
|
+
case "op_Division": return "/";
|
606
|
+
case "op_Multiply": return "*";
|
607
|
+
case "op_Modulus": return "%";
|
608
|
+
case "op_Equality": return "==";
|
609
|
+
case "op_Inequality": return "!=";
|
610
|
+
case "op_GreaterThan": return ">";
|
611
|
+
case "op_GreaterThanOrEqual": return ">=";
|
612
|
+
case "op_LessThan": return "<";
|
613
|
+
case "op_LessThanOrEqual": return "<=";
|
614
|
+
case "op_UnaryNegation": return "-@";
|
615
|
+
case "op_UnaryPlus": return "+@";
|
616
|
+
case "op_LeftShift": return "<<";
|
617
|
+
case "op_RightShift": return ">>";
|
618
|
+
case "op_BitwiseAnd": return "&";
|
619
|
+
case "op_BitwiseOr": return "|";
|
620
|
+
case "op_ExclusiveOr": return "^";
|
621
|
+
case "op_OnesComplement": return "~";
|
622
|
+
|
623
|
+
case "Power": return "**";
|
624
|
+
case "Compare": return "<=>";
|
625
|
+
|
626
|
+
default:
|
627
|
+
return null;
|
628
|
+
}
|
629
|
+
}
|
630
|
+
|
631
|
+
internal static string MapOperator(OverloadInfo/*!*/ method) {
|
632
|
+
return method.IsStatic && method.IsSpecialName ? ToRubyOperatorName(method.Name) : null;
|
633
|
+
}
|
634
|
+
|
635
|
+
internal static string MapOperator(MethodInfo/*!*/ method) {
|
636
|
+
return method.IsStatic && method.IsSpecialName ? ToRubyOperatorName(method.Name) : null;
|
637
|
+
}
|
638
|
+
|
639
|
+
internal static bool IsOperator(OverloadInfo/*!*/ method) {
|
640
|
+
return MapOperator(method) != null;
|
641
|
+
}
|
642
|
+
|
643
|
+
internal static string MapOperator(ExpressionType op) {
|
644
|
+
string methodName;
|
645
|
+
TryMapOperator(op, out methodName);
|
646
|
+
return methodName;
|
647
|
+
}
|
648
|
+
|
649
|
+
internal static int TryMapOperator(ExpressionType op, out string methodName) {
|
650
|
+
switch (op) {
|
651
|
+
case ExpressionType.Add: methodName = "+"; return 2;
|
652
|
+
case ExpressionType.Subtract: methodName = "-"; return 2;
|
653
|
+
case ExpressionType.Divide: methodName = "/"; return 2;
|
654
|
+
case ExpressionType.Multiply: methodName = "*"; return 2;
|
655
|
+
case ExpressionType.Modulo: methodName = "%"; return 2;
|
656
|
+
case ExpressionType.Equal: methodName = "=="; return 2;
|
657
|
+
case ExpressionType.NotEqual: methodName = "!="; return 2;
|
658
|
+
case ExpressionType.GreaterThan: methodName = ">"; return 2;
|
659
|
+
case ExpressionType.GreaterThanOrEqual: methodName = ">="; return 2;
|
660
|
+
case ExpressionType.LessThan: methodName = "<"; return 2;
|
661
|
+
case ExpressionType.LessThanOrEqual: methodName = "<="; return 2;
|
662
|
+
case ExpressionType.LeftShift: methodName = "<<"; return 2;
|
663
|
+
case ExpressionType.RightShift: methodName = ">>"; return 2;
|
664
|
+
case ExpressionType.And: methodName = "&"; return 2;
|
665
|
+
case ExpressionType.Or: methodName = "|"; return 2;
|
666
|
+
case ExpressionType.ExclusiveOr: methodName = "^"; return 2;
|
667
|
+
case ExpressionType.Power: methodName = "**"; return 2;
|
668
|
+
|
669
|
+
case ExpressionType.Negate: methodName = "-@"; return 1;
|
670
|
+
case ExpressionType.UnaryPlus: methodName = "+@"; return 1;
|
671
|
+
case ExpressionType.OnesComplement: methodName = "~"; return 1;
|
672
|
+
case ExpressionType.Not: methodName = "!"; return 1;
|
673
|
+
}
|
674
|
+
|
675
|
+
methodName = null;
|
676
|
+
return 0;
|
677
|
+
}
|
678
|
+
|
679
|
+
internal static int TryMapOperator(string/*!*/ methodName, out ExpressionType op) {
|
680
|
+
switch (methodName) {
|
681
|
+
case "+": op = ExpressionType.Add; return 2;
|
682
|
+
case "-": op = ExpressionType.Subtract; return 2;
|
683
|
+
case "/": op = ExpressionType.Divide; return 2;
|
684
|
+
case "*": op = ExpressionType.Multiply; return 2;
|
685
|
+
case "%": op = ExpressionType.Modulo; return 2;
|
686
|
+
case "==": op = ExpressionType.Equal; return 2;
|
687
|
+
case "!=": op = ExpressionType.NotEqual; return 2;
|
688
|
+
case ">": op = ExpressionType.GreaterThan; return 2;
|
689
|
+
case ">=": op = ExpressionType.GreaterThanOrEqual; return 2;
|
690
|
+
case "<": op = ExpressionType.LessThan; return 2;
|
691
|
+
case "<=": op = ExpressionType.LessThanOrEqual; return 2;
|
692
|
+
case "<<": op = ExpressionType.LeftShift; return 2;
|
693
|
+
case ">>": op = ExpressionType.RightShift; return 2;
|
694
|
+
case "&": op = ExpressionType.And; return 2;
|
695
|
+
case "|": op = ExpressionType.Or; return 2;
|
696
|
+
case "^": op = ExpressionType.ExclusiveOr; return 2;
|
697
|
+
case "**": op = ExpressionType.Power; return 2;
|
698
|
+
|
699
|
+
case "-@": op = ExpressionType.Negate; return 1;
|
700
|
+
case "+@": op = ExpressionType.UnaryPlus; return 1;
|
701
|
+
case "~": op = ExpressionType.OnesComplement; return 1;
|
702
|
+
case "!": op = ExpressionType.Not; return 1;
|
703
|
+
}
|
704
|
+
|
705
|
+
op = default(ExpressionType);
|
706
|
+
return 0;
|
707
|
+
}
|
708
|
+
|
709
|
+
#endregion
|
710
|
+
|
711
|
+
#region Modules, Classes
|
712
|
+
|
713
|
+
internal static RubyModule/*!*/ GetModuleFromObject(RubyScope/*!*/ scope, object obj) {
|
714
|
+
RubyModule module = obj as RubyModule;
|
715
|
+
if (module == null) {
|
716
|
+
throw CreateNotModuleException(scope, obj);
|
717
|
+
}
|
718
|
+
return module;
|
719
|
+
}
|
720
|
+
|
721
|
+
internal static Exception/*!*/ CreateNotModuleException(RubyScope/*!*/ scope, object obj) {
|
722
|
+
return RubyExceptions.CreateTypeError(String.Format("{0} is not a class/module", scope.RubyContext.GetClassOf(obj)));
|
723
|
+
}
|
724
|
+
|
725
|
+
public static void RequireMixins(RubyModule/*!*/ target, params RubyModule[]/*!*/ modules) {
|
726
|
+
foreach (RubyModule module in modules) {
|
727
|
+
if (module == null) {
|
728
|
+
throw RubyExceptions.CreateTypeError("wrong argument type nil (expected Module)");
|
729
|
+
}
|
730
|
+
|
731
|
+
if (module == target) {
|
732
|
+
throw RubyExceptions.CreateArgumentError("cyclic include detected");
|
733
|
+
}
|
734
|
+
|
735
|
+
if (module.IsClass) {
|
736
|
+
throw RubyExceptions.CreateTypeError("wrong argument type Class (expected Module)");
|
737
|
+
}
|
738
|
+
|
739
|
+
if (module.Context != target.Context) {
|
740
|
+
throw RubyExceptions.CreateTypeError(String.Format("cannot mix a foreign module `{0}' into `{1}' (runtime mismatch)",
|
741
|
+
module.GetName(target.Context), target.GetName(module.Context)
|
742
|
+
));
|
743
|
+
}
|
744
|
+
}
|
745
|
+
}
|
746
|
+
|
747
|
+
#endregion
|
748
|
+
|
749
|
+
#region Tracking operations that have the potential for infinite recursion
|
750
|
+
|
751
|
+
public static readonly MutableString InfiniteRecursionMarker = MutableString.CreateAscii("[...]").Freeze();
|
752
|
+
|
753
|
+
public class RecursionTracker {
|
754
|
+
[ThreadStatic]
|
755
|
+
private Dictionary<object, bool> _infiniteTracker;
|
756
|
+
|
757
|
+
private Dictionary<object, bool> TryPushInfinite(object obj) {
|
758
|
+
if (_infiniteTracker == null) {
|
759
|
+
_infiniteTracker = new Dictionary<object, bool>(ReferenceEqualityComparer<object>.Instance);
|
760
|
+
}
|
761
|
+
Dictionary<object, bool> infinite = _infiniteTracker;
|
762
|
+
if (infinite.ContainsKey(obj)) {
|
763
|
+
return null;
|
764
|
+
}
|
765
|
+
infinite.Add(obj, true);
|
766
|
+
return infinite;
|
767
|
+
}
|
768
|
+
|
769
|
+
public IDisposable TrackObject(object obj) {
|
770
|
+
obj = CustomStringDictionary.NullToObj(obj);
|
771
|
+
Dictionary<object, bool> tracker = TryPushInfinite(obj);
|
772
|
+
return (tracker == null) ? null : new RecursionHandle(tracker, obj);
|
773
|
+
}
|
774
|
+
|
775
|
+
private class RecursionHandle : IDisposable {
|
776
|
+
private readonly Dictionary<object, bool>/*!*/ _tracker;
|
777
|
+
private readonly object _obj;
|
778
|
+
|
779
|
+
internal RecursionHandle(Dictionary<object, bool>/*!*/ tracker, object obj) {
|
780
|
+
_tracker = tracker;
|
781
|
+
_obj = obj;
|
782
|
+
}
|
783
|
+
|
784
|
+
public void Dispose() {
|
785
|
+
_tracker.Remove(_obj);
|
786
|
+
}
|
787
|
+
}
|
788
|
+
}
|
789
|
+
|
790
|
+
[MultiRuntimeAware]
|
791
|
+
private static readonly RecursionTracker _infiniteInspectTracker = new RecursionTracker();
|
792
|
+
|
793
|
+
public static RecursionTracker InfiniteInspectTracker {
|
794
|
+
get { return _infiniteInspectTracker; }
|
795
|
+
}
|
796
|
+
|
797
|
+
[MultiRuntimeAware]
|
798
|
+
private static readonly RecursionTracker _infiniteToSTracker = new RecursionTracker();
|
799
|
+
|
800
|
+
public static RecursionTracker InfiniteToSTracker {
|
801
|
+
get { return _infiniteToSTracker; }
|
802
|
+
}
|
803
|
+
|
804
|
+
#endregion
|
805
|
+
|
806
|
+
#region Arrays, Hashes
|
807
|
+
|
808
|
+
// MRI checks for a subtype of RubyArray of subtypes of MutableString.
|
809
|
+
internal static RubyArray AsArrayOfStrings(object value) {
|
810
|
+
RubyArray array = value as RubyArray;
|
811
|
+
if (array != null) {
|
812
|
+
foreach (object obj in array) {
|
813
|
+
MutableString str = obj as MutableString;
|
814
|
+
if (str == null) {
|
815
|
+
return null;
|
816
|
+
}
|
817
|
+
}
|
818
|
+
return array;
|
819
|
+
}
|
820
|
+
return null;
|
821
|
+
}
|
822
|
+
|
823
|
+
public static object SetHashElement(RubyContext/*!*/ context, IDictionary<object, object>/*!*/ obj, object key, object value) {
|
824
|
+
MutableString str = key as MutableString;
|
825
|
+
if (str != null) {
|
826
|
+
key = str.Duplicate(context, false, str.Clone()).Freeze();
|
827
|
+
} else {
|
828
|
+
key = CustomStringDictionary.NullToObj(key);
|
829
|
+
}
|
830
|
+
return obj[key] = value;
|
831
|
+
}
|
832
|
+
|
833
|
+
public static Hash/*!*/ SetHashElements(RubyContext/*!*/ context, Hash/*!*/ hash, object[]/*!*/ items) {
|
834
|
+
Assert.NotNull(context, hash, items);
|
835
|
+
Debug.Assert(items != null && items.Length % 2 == 0);
|
836
|
+
|
837
|
+
for (int i = 0; i < items.Length; i += 2) {
|
838
|
+
Debug.Assert(i + 1 < items.Length);
|
839
|
+
SetHashElement(context, hash, items[i], items[i + 1]);
|
840
|
+
}
|
841
|
+
|
842
|
+
return hash;
|
843
|
+
}
|
844
|
+
|
845
|
+
#endregion
|
846
|
+
|
847
|
+
#region Evals
|
848
|
+
|
849
|
+
// scope parent scope self
|
850
|
+
// M.module_eval {} block current M
|
851
|
+
// x.instance_eval {} block current x
|
852
|
+
// M.module_eval "" ModEval(module: M) current M
|
853
|
+
// x.instance_eval "" ModEval(module: S(x)) current x
|
854
|
+
// eval "", binding binding.scope binding.scope.parent binding.scope.self
|
855
|
+
//
|
856
|
+
|
857
|
+
#if DEBUG
|
858
|
+
private static int _stringEvalCounter;
|
859
|
+
#endif
|
860
|
+
|
861
|
+
public static RubyCompilerOptions/*!*/ CreateCompilerOptionsForEval(RubyScope/*!*/ targetScope, int line) {
|
862
|
+
return CreateCompilerOptionsForEval(targetScope, targetScope.GetInnerMostMethodScope(), false, line);
|
863
|
+
}
|
864
|
+
|
865
|
+
private static RubyCompilerOptions/*!*/ CreateCompilerOptionsForEval(RubyScope/*!*/ targetScope, RubyMethodScope methodScope,
|
866
|
+
bool isModuleEval, int line) {
|
867
|
+
|
868
|
+
return new RubyCompilerOptions(targetScope.RubyContext.RubyOptions) {
|
869
|
+
IsEval = true,
|
870
|
+
FactoryKind = isModuleEval ? TopScopeFactoryKind.ModuleEval : TopScopeFactoryKind.None,
|
871
|
+
LocalNames = targetScope.GetVisibleLocalNames(),
|
872
|
+
TopLevelMethodName = (methodScope != null) ? methodScope.DefinitionName : null,
|
873
|
+
TopLevelParameterNames = (methodScope != null) ? methodScope.GetVisibleParameterNames() : null,
|
874
|
+
TopLevelHasUnsplatParameter = (methodScope != null) ? methodScope.HasUnsplatParameter : false,
|
875
|
+
InitialLocation = new SourceLocation(0, line <= 0 ? 1 : line, 1),
|
876
|
+
};
|
877
|
+
}
|
878
|
+
|
879
|
+
private static SourceUnit/*!*/ CreateRubySourceUnit(RubyContext/*!*/ context, MutableString/*!*/ code, string path) {
|
880
|
+
return context.CreateSourceUnit(new BinaryContentProvider(code.ToByteArray()), path, code.Encoding.Encoding, SourceCodeKind.File);
|
881
|
+
}
|
882
|
+
|
883
|
+
public static object Evaluate(MutableString/*!*/ code, RubyScope/*!*/ targetScope, object self, RubyModule module, MutableString file, int line) {
|
884
|
+
Assert.NotNull(code, targetScope);
|
885
|
+
|
886
|
+
RubyContext context = targetScope.RubyContext;
|
887
|
+
RubyMethodScope methodScope = targetScope.GetInnerMostMethodScope();
|
888
|
+
|
889
|
+
#if DEBUG
|
890
|
+
Utils.Log(Interlocked.Increment(ref _stringEvalCounter).ToString() + ": " + (file != null ? file.ToString() : "?") + " : " + line, "EVAL");
|
891
|
+
#endif
|
892
|
+
|
893
|
+
// we want to create a new top-level local scope:
|
894
|
+
var options = CreateCompilerOptionsForEval(targetScope, methodScope, module != null, line);
|
895
|
+
var source = CreateRubySourceUnit(context, code, file != null ? file.ConvertToString() : "(eval)");
|
896
|
+
|
897
|
+
Expression<EvalEntryPointDelegate> lambda;
|
898
|
+
try {
|
899
|
+
lambda = context.ParseSourceCode<EvalEntryPointDelegate>(source, options, context.RuntimeErrorSink);
|
900
|
+
} catch (SyntaxError e) {
|
901
|
+
Utils.Log(e.Message, "EVAL_ERROR");
|
902
|
+
Utils.Log(new String('-', 50), "EVAL_ERROR");
|
903
|
+
Utils.Log(source.GetCode(), "EVAL_ERROR");
|
904
|
+
Utils.Log(new String('-', 50), "EVAL_ERROR");
|
905
|
+
throw;
|
906
|
+
}
|
907
|
+
Debug.Assert(lambda != null);
|
908
|
+
|
909
|
+
// module-eval:
|
910
|
+
if (module != null) {
|
911
|
+
targetScope = CreateModuleEvalScope(targetScope, self, module);
|
912
|
+
}
|
913
|
+
|
914
|
+
return ((EvalEntryPointDelegate)RubyScriptCode.CompileLambda(lambda, context))(
|
915
|
+
targetScope,
|
916
|
+
self,
|
917
|
+
module,
|
918
|
+
(methodScope != null) ? methodScope.BlockParameter : null
|
919
|
+
);
|
920
|
+
}
|
921
|
+
|
922
|
+
private static RubyScope/*!*/ CreateModuleEvalScope(RubyScope/*!*/ parent, object self, RubyModule/*!*/ module) {
|
923
|
+
var scope = new RubyModuleEvalScope(parent, module, self);
|
924
|
+
scope.SetDebugName("instance/module-eval");
|
925
|
+
return scope;
|
926
|
+
}
|
927
|
+
|
928
|
+
public static object EvaluateInModule(RubyModule/*!*/ self, BlockParam/*!*/ block, object[] args) {
|
929
|
+
object result;
|
930
|
+
EvaluateBlock(block, self, self, args, out result);
|
931
|
+
return result;
|
932
|
+
}
|
933
|
+
|
934
|
+
public static object EvaluateInModule(RubyModule/*!*/ self, BlockParam/*!*/ block, object[] args, object defaultReturnValue) {
|
935
|
+
object result;
|
936
|
+
return EvaluateBlock(block, self, self, args, out result) ? result : defaultReturnValue;
|
937
|
+
}
|
938
|
+
|
939
|
+
public static object EvaluateInSingleton(object self, BlockParam/*!*/ block, object[] args) {
|
940
|
+
// TODO: this is checked in method definition, if no method is defined it is ok.
|
941
|
+
// => singleton is created in method definition also.
|
942
|
+
if (!RubyUtils.CanDefineSingletonMethod(self)) {
|
943
|
+
throw RubyExceptions.CreateTypeError("can't define singleton method for literals");
|
944
|
+
}
|
945
|
+
|
946
|
+
object result;
|
947
|
+
EvaluateBlock(block, block.RubyContext.GetOrCreateSingletonClass(self), self, args, out result);
|
948
|
+
return result;
|
949
|
+
}
|
950
|
+
|
951
|
+
private static bool EvaluateBlock(BlockParam/*!*/ block, RubyModule/*!*/ module, object self, object[] args, out object result) {
|
952
|
+
Assert.NotNull(block, module);
|
953
|
+
block.MethodLookupModule = module;
|
954
|
+
|
955
|
+
if (args != null) {
|
956
|
+
result = RubyOps.Yield(args, null, self, block);
|
957
|
+
} else {
|
958
|
+
result = RubyOps.Yield0(null, self, block);
|
959
|
+
}
|
960
|
+
|
961
|
+
return block.BlockJumped(result);
|
962
|
+
}
|
963
|
+
|
964
|
+
#endregion
|
965
|
+
|
966
|
+
#region Object Construction
|
967
|
+
|
968
|
+
private static readonly Type[] _ccTypes1 = new Type[] { typeof(RubyClass) };
|
969
|
+
private static readonly Type[] _ccTypes2 = new Type[] { typeof(RubyContext) };
|
970
|
+
#if !SILVERLIGHT // serialization
|
971
|
+
private static readonly Type[] _serializableTypeSignature = new Type[] { typeof(SerializationInfo), typeof(StreamingContext) };
|
972
|
+
#endif
|
973
|
+
|
974
|
+
public static readonly string SerializationInfoClassKey = "#immediateClass";
|
975
|
+
|
976
|
+
public static object/*!*/ CreateObject(RubyClass/*!*/ theclass, IEnumerable<KeyValuePair<string, object>>/*!*/ attributes) {
|
977
|
+
Assert.NotNull(theclass, attributes);
|
978
|
+
|
979
|
+
Type baseType = theclass.GetUnderlyingSystemType();
|
980
|
+
object obj;
|
981
|
+
if (typeof(ISerializable).IsAssignableFrom(baseType)) {
|
982
|
+
#if !SILVERLIGHT // serialization
|
983
|
+
BindingFlags bindingFlags = BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance;
|
984
|
+
ConstructorInfo ci = baseType.GetConstructor(bindingFlags, null, _serializableTypeSignature, null);
|
985
|
+
if (ci == null) {
|
986
|
+
#endif
|
987
|
+
string message = String.Format("Class {0} does not have a valid deserializing constructor", baseType.FullName);
|
988
|
+
throw new NotSupportedException(message);
|
989
|
+
#if !SILVERLIGHT // serialization
|
990
|
+
}
|
991
|
+
SerializationInfo info = new SerializationInfo(baseType, new FormatterConverter());
|
992
|
+
info.AddValue(SerializationInfoClassKey, theclass);
|
993
|
+
foreach (var pair in attributes) {
|
994
|
+
info.AddValue(pair.Key, pair.Value);
|
995
|
+
}
|
996
|
+
obj = ci.Invoke(new object[2] { info, new StreamingContext(StreamingContextStates.Other, theclass) });
|
997
|
+
#endif
|
998
|
+
} else {
|
999
|
+
obj = CreateObject(theclass);
|
1000
|
+
foreach (var pair in attributes) {
|
1001
|
+
theclass.Context.SetInstanceVariable(obj, pair.Key, pair.Value);
|
1002
|
+
}
|
1003
|
+
}
|
1004
|
+
return obj;
|
1005
|
+
}
|
1006
|
+
|
1007
|
+
private static bool IsAvailable(MethodBase method) {
|
1008
|
+
return method != null && !method.IsPrivate && !method.IsAssembly && !method.IsFamilyAndAssembly;
|
1009
|
+
}
|
1010
|
+
|
1011
|
+
// TODO: remove
|
1012
|
+
public static object/*!*/ CreateObject(RubyClass/*!*/ theClass) {
|
1013
|
+
Assert.NotNull(theClass);
|
1014
|
+
|
1015
|
+
Type baseType = theClass.GetUnderlyingSystemType();
|
1016
|
+
if (baseType == typeof(RubyStruct)) {
|
1017
|
+
return RubyStruct.Create(theClass);
|
1018
|
+
}
|
1019
|
+
|
1020
|
+
object result;
|
1021
|
+
BindingFlags bindingFlags = BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance;
|
1022
|
+
ConstructorInfo ci;
|
1023
|
+
if (IsAvailable(ci = baseType.GetConstructor(bindingFlags, null, Type.EmptyTypes, null))) {
|
1024
|
+
result = ci.Invoke(new object[0] { });
|
1025
|
+
} else if (IsAvailable(ci = baseType.GetConstructor(bindingFlags, null, _ccTypes1, null))) {
|
1026
|
+
result = ci.Invoke(new object[1] { theClass });
|
1027
|
+
} else if (IsAvailable(ci = baseType.GetConstructor(bindingFlags, null, _ccTypes2, null))) {
|
1028
|
+
result = ci.Invoke(new object[1] { theClass.Context });
|
1029
|
+
} else {
|
1030
|
+
string message = String.Format("Class {0} does not have a valid constructor", theClass.Name);
|
1031
|
+
throw new NotSupportedException(message);
|
1032
|
+
}
|
1033
|
+
return result;
|
1034
|
+
}
|
1035
|
+
|
1036
|
+
#endregion
|
1037
|
+
|
1038
|
+
#region Call Site Storage Extensions
|
1039
|
+
|
1040
|
+
public static CallSite<TCallSiteFunc>/*!*/ GetCallSite<TCallSiteFunc>(ref CallSite<TCallSiteFunc>/*!*/ site, RubyContext/*!*/ context,
|
1041
|
+
string/*!*/ methodName, int argumentCount) where TCallSiteFunc : class {
|
1042
|
+
|
1043
|
+
if (site == null) {
|
1044
|
+
Interlocked.CompareExchange(ref site,
|
1045
|
+
CallSite<TCallSiteFunc>.Create(RubyCallAction.Make(context, methodName, RubyCallSignature.WithImplicitSelf(argumentCount))), null);
|
1046
|
+
}
|
1047
|
+
return site;
|
1048
|
+
}
|
1049
|
+
|
1050
|
+
public static CallSite<TCallSiteFunc>/*!*/ GetCallSite<TCallSiteFunc>(ref CallSite<TCallSiteFunc>/*!*/ site, RubyContext/*!*/ context,
|
1051
|
+
string/*!*/ methodName, RubyCallSignature signature) where TCallSiteFunc : class {
|
1052
|
+
|
1053
|
+
if (site == null) {
|
1054
|
+
Interlocked.CompareExchange(ref site,
|
1055
|
+
CallSite<TCallSiteFunc>.Create(RubyCallAction.Make(context, methodName, signature)), null);
|
1056
|
+
}
|
1057
|
+
return site;
|
1058
|
+
}
|
1059
|
+
|
1060
|
+
public static CallSite<Func<CallSite, object, TResult>>/*!*/ GetCallSite<TResult>(
|
1061
|
+
ref CallSite<Func<CallSite, object, TResult>>/*!*/ site, RubyConversionAction/*!*/ conversion) {
|
1062
|
+
|
1063
|
+
if (site == null) {
|
1064
|
+
Interlocked.CompareExchange(ref site, CallSite<Func<CallSite, object, TResult>>.Create(conversion), null);
|
1065
|
+
}
|
1066
|
+
return site;
|
1067
|
+
}
|
1068
|
+
|
1069
|
+
#endregion
|
1070
|
+
|
1071
|
+
#region Exceptions
|
1072
|
+
|
1073
|
+
#if SILVERLIGHT // Thread.ExceptionState, Thread.Abort(stateInfo)
|
1074
|
+
public static Exception GetVisibleException(Exception e) { return e; }
|
1075
|
+
|
1076
|
+
public static void ExitThread(Thread/*!*/ thread) {
|
1077
|
+
thread.Abort();
|
1078
|
+
}
|
1079
|
+
|
1080
|
+
public static bool IsRubyThreadExit(Exception e) {
|
1081
|
+
return e is ThreadAbortException;
|
1082
|
+
}
|
1083
|
+
#else
|
1084
|
+
/// <summary>
|
1085
|
+
/// Thread#raise is implemented on top of System.Threading.Thread.ThreadAbort, and squirreling
|
1086
|
+
/// the Ruby exception expected by the use in ThreadAbortException.ExceptionState.
|
1087
|
+
/// </summary>
|
1088
|
+
private class AsyncExceptionMarker {
|
1089
|
+
internal Exception Exception { get; set; }
|
1090
|
+
internal AsyncExceptionMarker(Exception e) {
|
1091
|
+
this.Exception = e;
|
1092
|
+
}
|
1093
|
+
}
|
1094
|
+
|
1095
|
+
public static void RaiseAsyncException(Thread thread, Exception e) {
|
1096
|
+
thread.Abort(new AsyncExceptionMarker(e));
|
1097
|
+
}
|
1098
|
+
|
1099
|
+
// TODO: This is redundant with ThreadOps.RubyThreadInfo.ExitRequested. However, we cannot access that
|
1100
|
+
// from here as it is in a separate assembly.
|
1101
|
+
private class ThreadExitMarker {
|
1102
|
+
}
|
1103
|
+
|
1104
|
+
public static void ExitThread(Thread/*!*/ thread) {
|
1105
|
+
thread.Abort(new ThreadExitMarker());
|
1106
|
+
}
|
1107
|
+
|
1108
|
+
/// <summary>
|
1109
|
+
/// Thread#exit is implemented by calling Thread.Abort. However, we need to distinguish a call to Thread#exit
|
1110
|
+
/// from a raw call to Thread.Abort.
|
1111
|
+
///
|
1112
|
+
/// Note that if a finally block raises an exception while an Abort is pending, that exception can be propagated instead of a ThreadAbortException.
|
1113
|
+
/// </summary>
|
1114
|
+
public static bool IsRubyThreadExit(Exception e) {
|
1115
|
+
ThreadAbortException tae = e as ThreadAbortException;
|
1116
|
+
if (tae != null) {
|
1117
|
+
if (tae.ExceptionState is ThreadExitMarker) {
|
1118
|
+
return true;
|
1119
|
+
}
|
1120
|
+
}
|
1121
|
+
return false;
|
1122
|
+
}
|
1123
|
+
|
1124
|
+
/// <summary>
|
1125
|
+
/// Can return null for Thread#kill
|
1126
|
+
/// </summary>
|
1127
|
+
public static Exception GetVisibleException(Exception e) {
|
1128
|
+
ThreadAbortException tae = e as ThreadAbortException;
|
1129
|
+
if (tae != null) {
|
1130
|
+
if (IsRubyThreadExit(e)) {
|
1131
|
+
return null;
|
1132
|
+
}
|
1133
|
+
AsyncExceptionMarker asyncExceptionMarker = tae.ExceptionState as AsyncExceptionMarker;
|
1134
|
+
if (asyncExceptionMarker != null) {
|
1135
|
+
return asyncExceptionMarker.Exception;
|
1136
|
+
}
|
1137
|
+
}
|
1138
|
+
return e;
|
1139
|
+
}
|
1140
|
+
|
1141
|
+
#endif
|
1142
|
+
|
1143
|
+
#endregion
|
1144
|
+
|
1145
|
+
#region Paths
|
1146
|
+
|
1147
|
+
public static MutableString CanonicalizePath(MutableString path) {
|
1148
|
+
for (int i = 0; i < path.Length; i++) {
|
1149
|
+
if (path.GetChar(i) == '\\')
|
1150
|
+
path.SetChar(i, '/');
|
1151
|
+
}
|
1152
|
+
return path;
|
1153
|
+
}
|
1154
|
+
|
1155
|
+
public static String CanonicalizePath(string path) {
|
1156
|
+
return path.Replace('\\', '/');
|
1157
|
+
}
|
1158
|
+
|
1159
|
+
public static String CombinePaths(string basePath, string path) {
|
1160
|
+
return basePath.Length == 0 || basePath.EndsWith("\\", StringComparison.Ordinal) || basePath.EndsWith("/", StringComparison.Ordinal) ?
|
1161
|
+
basePath + path :
|
1162
|
+
basePath + "/" + path;
|
1163
|
+
}
|
1164
|
+
|
1165
|
+
// TODO: virtualize via PAL
|
1166
|
+
//RHO
|
1167
|
+
#if !SILVERLIGHT
|
1168
|
+
public static bool FileSystemUsesDriveLetters { get { return Path.DirectorySeparatorChar == '\\'; } }
|
1169
|
+
#else
|
1170
|
+
public static bool FileSystemUsesDriveLetters { get { return false; } }
|
1171
|
+
#endif
|
1172
|
+
//RHO
|
1173
|
+
|
1174
|
+
// Is path something like "/foo/bar" (or "c:/foo/bar" on Windows)
|
1175
|
+
// We need this instead of Path.IsPathRooted since we need to be able to deal with Unix-style path names even on Windows
|
1176
|
+
public static bool IsAbsolutePath(string path) {
|
1177
|
+
if (IsAbsoluteDriveLetterPath(path)) {
|
1178
|
+
return true;
|
1179
|
+
}
|
1180
|
+
|
1181
|
+
if (String.IsNullOrEmpty(path)) {
|
1182
|
+
return false;
|
1183
|
+
}
|
1184
|
+
|
1185
|
+
return path[0] == '/';
|
1186
|
+
}
|
1187
|
+
|
1188
|
+
// Is path something like "c:/foo/bar" (on Windows)
|
1189
|
+
public static bool IsAbsoluteDriveLetterPath(string path) {
|
1190
|
+
if (String.IsNullOrEmpty(path)) {
|
1191
|
+
return false;
|
1192
|
+
}
|
1193
|
+
|
1194
|
+
if (!FileSystemUsesDriveLetters) {
|
1195
|
+
return false;
|
1196
|
+
}
|
1197
|
+
|
1198
|
+
return Tokenizer.IsLetter(path[0]) && path.Length >= 2 && path[1] == ':' && path[2] == '/';
|
1199
|
+
}
|
1200
|
+
|
1201
|
+
// returns "//", "///", ... or something like "c:/"
|
1202
|
+
public static string GetPathRoot(PlatformAdaptationLayer/*!*/ platform, string path, out string pathAfterRoot) {
|
1203
|
+
Debug.Assert(IsAbsolutePath(path));
|
1204
|
+
if (IsAbsoluteDriveLetterPath(path)) {
|
1205
|
+
pathAfterRoot = path.Substring(3);
|
1206
|
+
return path.Substring(0, 3);
|
1207
|
+
} else {
|
1208
|
+
Debug.Assert(path[0] == '/');
|
1209
|
+
|
1210
|
+
// The root for "////foo" is "/////"
|
1211
|
+
string withoutInitialSlashes = path.TrimStart('/');
|
1212
|
+
int initialSlashesCount = path.Length - withoutInitialSlashes.Length;
|
1213
|
+
string initialSlashes = path.Substring(0, initialSlashesCount);
|
1214
|
+
pathAfterRoot = path.Substring(initialSlashesCount);
|
1215
|
+
|
1216
|
+
if (!FileSystemUsesDriveLetters || initialSlashesCount > 1) {
|
1217
|
+
return initialSlashes;
|
1218
|
+
} else {
|
1219
|
+
string currentDirectory = RubyUtils.CanonicalizePath(platform.CurrentDirectory);
|
1220
|
+
Debug.Assert(IsAbsoluteDriveLetterPath(currentDirectory));
|
1221
|
+
string temp;
|
1222
|
+
return GetPathRoot(platform, currentDirectory, out temp);
|
1223
|
+
}
|
1224
|
+
}
|
1225
|
+
}
|
1226
|
+
|
1227
|
+
// Is path something like "c:foo" (note that this is not "c:/foo")
|
1228
|
+
public static bool HasPartialDriveLetter(string path, out char partialDriveLetter, out string relativePath) {
|
1229
|
+
partialDriveLetter = '\0';
|
1230
|
+
relativePath = null;
|
1231
|
+
|
1232
|
+
if (String.IsNullOrEmpty(path)) {
|
1233
|
+
return false;
|
1234
|
+
}
|
1235
|
+
|
1236
|
+
if (!FileSystemUsesDriveLetters) {
|
1237
|
+
return false;
|
1238
|
+
}
|
1239
|
+
|
1240
|
+
if (Tokenizer.IsLetter(path[0]) && path.Length >= 2 && path[1] == ':' && (path.Length == 2 || path[2] != '/')) {
|
1241
|
+
partialDriveLetter = path[0];
|
1242
|
+
relativePath = path.Substring(2);
|
1243
|
+
return true;
|
1244
|
+
} else {
|
1245
|
+
return false;
|
1246
|
+
}
|
1247
|
+
}
|
1248
|
+
|
1249
|
+
#region expand_path
|
1250
|
+
|
1251
|
+
// Algorithm to find HOME equivalents under Windows. This is equivalent to Ruby 1.9 behavior:
|
1252
|
+
//
|
1253
|
+
// 1. Try get HOME
|
1254
|
+
// 2. Try to generate HOME equivalent using HOMEDRIVE + HOMEPATH
|
1255
|
+
// 3. Try to generate HOME equivalent from USERPROFILE
|
1256
|
+
// 4. Try to generate HOME equivalent from Personal special folder
|
1257
|
+
|
1258
|
+
public static string/*!*/ GetHomeDirectory(PlatformAdaptationLayer/*!*/ pal) {
|
1259
|
+
string result = pal.GetEnvironmentVariable("HOME");
|
1260
|
+
if (result == null) {
|
1261
|
+
string homeDrive = pal.GetEnvironmentVariable("HOMEDRIVE");
|
1262
|
+
string homePath = pal.GetEnvironmentVariable("HOMEPATH");
|
1263
|
+
if (homeDrive == null && homePath == null) {
|
1264
|
+
string userEnvironment = pal.GetEnvironmentVariable("USERPROFILE");
|
1265
|
+
if (userEnvironment == null) {
|
1266
|
+
// This will always succeed with a non-null string, but it can fail
|
1267
|
+
// if the Personal folder was renamed or deleted. In this case it returns
|
1268
|
+
// an empty string.
|
1269
|
+
result = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
|
1270
|
+
} else {
|
1271
|
+
result = userEnvironment;
|
1272
|
+
}
|
1273
|
+
} else if (homeDrive == null) {
|
1274
|
+
result = homePath;
|
1275
|
+
} else if (homePath == null) {
|
1276
|
+
result = homeDrive + Path.DirectorySeparatorChar;
|
1277
|
+
} else {
|
1278
|
+
result = homeDrive + homePath;
|
1279
|
+
}
|
1280
|
+
|
1281
|
+
if (result != null) {
|
1282
|
+
result = ExpandPath(pal, result);
|
1283
|
+
}
|
1284
|
+
}
|
1285
|
+
|
1286
|
+
return result;
|
1287
|
+
}
|
1288
|
+
|
1289
|
+
class PathExpander {
|
1290
|
+
List<string> _pathComponents = new List<string>(); // does not include the root
|
1291
|
+
string _root; // Typically "c:/" on Windows, and "/" on Unix
|
1292
|
+
|
1293
|
+
internal PathExpander(PlatformAdaptationLayer/*!*/ platform, string absoluteBasePath) {
|
1294
|
+
Debug.Assert(RubyUtils.IsAbsolutePath(absoluteBasePath));
|
1295
|
+
|
1296
|
+
string basePathAfterRoot = null;
|
1297
|
+
_root = RubyUtils.GetPathRoot(platform, absoluteBasePath, out basePathAfterRoot);
|
1298
|
+
|
1299
|
+
// Normally, basePathAfterRoot[0] will not be '/', but here we deal with cases like "c:////foo"
|
1300
|
+
basePathAfterRoot = basePathAfterRoot.TrimStart('/');
|
1301
|
+
|
1302
|
+
AddRelativePath(basePathAfterRoot);
|
1303
|
+
}
|
1304
|
+
|
1305
|
+
internal void AddRelativePath(string relPath) {
|
1306
|
+
Debug.Assert(!RubyUtils.IsAbsolutePath(relPath));
|
1307
|
+
|
1308
|
+
string[] relPathComponents = relPath.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
|
1309
|
+
|
1310
|
+
foreach (string pathComponent in relPathComponents) {
|
1311
|
+
if (pathComponent == "..") {
|
1312
|
+
if (_pathComponents.Count == 0) {
|
1313
|
+
// MRI allows more pops than the base path components
|
1314
|
+
continue;
|
1315
|
+
}
|
1316
|
+
_pathComponents.RemoveAt(_pathComponents.Count - 1);
|
1317
|
+
} else if (pathComponent == ".") {
|
1318
|
+
continue;
|
1319
|
+
} else {
|
1320
|
+
_pathComponents.Add(pathComponent);
|
1321
|
+
}
|
1322
|
+
}
|
1323
|
+
}
|
1324
|
+
|
1325
|
+
internal string/*!*/ GetResult() {
|
1326
|
+
StringBuilder result = new StringBuilder(_root);
|
1327
|
+
|
1328
|
+
if (_pathComponents.Count >= 1) {
|
1329
|
+
// Here we make this work:
|
1330
|
+
// File.expand_path("c:/..a..") -> "c:/..a"
|
1331
|
+
string lastComponent = _pathComponents[_pathComponents.Count - 1];
|
1332
|
+
if (RubyUtils.FileSystemUsesDriveLetters && !String.IsNullOrEmpty(lastComponent.TrimEnd('.'))) {
|
1333
|
+
_pathComponents[_pathComponents.Count - 1] = lastComponent.TrimEnd('.');
|
1334
|
+
}
|
1335
|
+
}
|
1336
|
+
|
1337
|
+
for (int i = 0; i < _pathComponents.Count; i++) {
|
1338
|
+
result.Append(_pathComponents[i]);
|
1339
|
+
if (i < (_pathComponents.Count - 1)) {
|
1340
|
+
result.Append('/');
|
1341
|
+
}
|
1342
|
+
}
|
1343
|
+
#if DEBUG
|
1344
|
+
_pathComponents = null;
|
1345
|
+
_root = null;
|
1346
|
+
#endif
|
1347
|
+
return result.ToString();
|
1348
|
+
}
|
1349
|
+
}
|
1350
|
+
|
1351
|
+
// Expand directory path - these cases exist:
|
1352
|
+
//
|
1353
|
+
// 1. Empty string or nil means return current directory
|
1354
|
+
// 2. ~ with non-existent HOME directory throws exception
|
1355
|
+
// 3. ~, ~/ or ~\ which expands to HOME
|
1356
|
+
// 4. ~foo is left unexpanded
|
1357
|
+
// 5. Expand to full path if path is a relative path
|
1358
|
+
//
|
1359
|
+
// No attempt is made to determine whether the path is valid or not
|
1360
|
+
// Returned path is always canonicalized to forward slashes
|
1361
|
+
|
1362
|
+
public static string/*!*/ ExpandPath(PlatformAdaptationLayer/*!*/ platform, string/*!*/ path) {
|
1363
|
+
return ExpandPath(platform, path, platform.CurrentDirectory, true);
|
1364
|
+
}
|
1365
|
+
|
1366
|
+
public static string/*!*/ ExpandPath(PlatformAdaptationLayer/*!*/ platform, string/*!*/ path, string/*!*/ basePath, bool expandHome) {
|
1367
|
+
return ExpandPath(platform, path, basePath, expandHome, true);
|
1368
|
+
}
|
1369
|
+
|
1370
|
+
private static string/*!*/ ExpandPath(PlatformAdaptationLayer/*!*/ platform, string/*!*/ path, string/*!*/ basePath, bool expandHome, bool expandBase) {
|
1371
|
+
Assert.NotNull(platform, path, basePath);
|
1372
|
+
|
1373
|
+
if (expandHome) {
|
1374
|
+
int length = path.Length;
|
1375
|
+
if (length > 0 && path[0] == '~') {
|
1376
|
+
if (length == 1 || (path[1] == '/' || path[1] == '\\')) {
|
1377
|
+
string homeDirectory = platform.GetEnvironmentVariable("HOME");
|
1378
|
+
if (homeDirectory == null) {
|
1379
|
+
throw RubyExceptions.CreateArgumentError("couldn't find HOME environment -- expanding `~'");
|
1380
|
+
}
|
1381
|
+
|
1382
|
+
if (length <= 2) {
|
1383
|
+
path = homeDirectory;
|
1384
|
+
} else {
|
1385
|
+
path = Path.Combine(homeDirectory, path.Substring(2));
|
1386
|
+
}
|
1387
|
+
} else {
|
1388
|
+
// MRI doesn't expand path that starts with ~, seems like a bug
|
1389
|
+
// http://redmine.ruby-lang.org/issues/show/3629
|
1390
|
+
return path;
|
1391
|
+
}
|
1392
|
+
}
|
1393
|
+
// MRI deosn't expand content of HOME variable (could be a relative path). We do.
|
1394
|
+
// See http://redmine.ruby-lang.org/issues/show/3630
|
1395
|
+
}
|
1396
|
+
|
1397
|
+
path = RubyUtils.CanonicalizePath(path);
|
1398
|
+
basePath = RubyUtils.CanonicalizePath(basePath);
|
1399
|
+
|
1400
|
+
if (RubyUtils.IsAbsolutePath(path)) {
|
1401
|
+
// "basePath" can be ignored if "path" is an absolute path
|
1402
|
+
return new PathExpander(platform, path).GetResult();
|
1403
|
+
}
|
1404
|
+
|
1405
|
+
// expand base path:
|
1406
|
+
string expandedBasePath = expandBase ? ExpandPath(platform, basePath, platform.CurrentDirectory, expandHome, false) : basePath;
|
1407
|
+
|
1408
|
+
char drive;
|
1409
|
+
string relativePath;
|
1410
|
+
if (RubyUtils.HasPartialDriveLetter(path, out drive, out relativePath)) {
|
1411
|
+
string _;
|
1412
|
+
string root = RubyUtils.GetPathRoot(platform, expandedBasePath, out _);
|
1413
|
+
if (root[0].ToLowerInvariant() != drive.ToLowerInvariant()) {
|
1414
|
+
expandedBasePath = RubyUtils.CanonicalizePath(platform.CurrentDirectory);
|
1415
|
+
root = RubyUtils.GetPathRoot(platform, expandedBasePath, out _);
|
1416
|
+
if (root[0].ToLowerInvariant() != drive.ToLowerInvariant()) {
|
1417
|
+
// MRI: Converts "X:path" to "X:/path" if X != base drive or current drive:
|
1418
|
+
return new PathExpander(platform, drive.ToString() + ":/" + relativePath).GetResult();
|
1419
|
+
}
|
1420
|
+
}
|
1421
|
+
path = relativePath;
|
1422
|
+
}
|
1423
|
+
|
1424
|
+
PathExpander pathExpander = new PathExpander(platform, expandedBasePath);
|
1425
|
+
pathExpander.AddRelativePath(path);
|
1426
|
+
return pathExpander.GetResult();
|
1427
|
+
}
|
1428
|
+
|
1429
|
+
/// <summary>
|
1430
|
+
/// Returns the extension of given path.
|
1431
|
+
/// Equivalent to <see cref="Path.GetExtension"/> but it doesn't check for an invalid path and
|
1432
|
+
/// it considers ".foo" to be a file name with no extension rather than an extension with an empty file name.
|
1433
|
+
/// </summary>
|
1434
|
+
/// <returns>Null iff path is null. Empty string if the path doesn't have any extension.</returns>
|
1435
|
+
public static string GetExtension(string path) {
|
1436
|
+
if (path == null) {
|
1437
|
+
return null;
|
1438
|
+
}
|
1439
|
+
|
1440
|
+
int length = path.Length;
|
1441
|
+
int i = length;
|
1442
|
+
while (--i >= 0) {
|
1443
|
+
char c = path[i];
|
1444
|
+
if (c == '.') {
|
1445
|
+
if (i != length - 1 && i > 0) {
|
1446
|
+
return path.Substring(i, length - i);
|
1447
|
+
}
|
1448
|
+
return String.Empty;
|
1449
|
+
}
|
1450
|
+
if (c == Path.DirectorySeparatorChar || c == Path.AltDirectorySeparatorChar || c == Path.VolumeSeparatorChar) {
|
1451
|
+
break;
|
1452
|
+
}
|
1453
|
+
}
|
1454
|
+
return String.Empty;
|
1455
|
+
}
|
1456
|
+
|
1457
|
+
#endregion
|
1458
|
+
|
1459
|
+
#endregion
|
1460
|
+
|
1461
|
+
#region Streams
|
1462
|
+
|
1463
|
+
/// <summary>
|
1464
|
+
/// Writes binary content of <see cref="MutableString"/> into the given buffer.
|
1465
|
+
/// </summary>
|
1466
|
+
public static void Write(this Stream/*!*/ stream, MutableString/*!*/ str, int start, int count) {
|
1467
|
+
int byteCount;
|
1468
|
+
byte[] bytes = str.GetByteArray(out byteCount);
|
1469
|
+
if (start < byteCount) {
|
1470
|
+
stream.Write(bytes, start, Math.Min(byteCount - start, count));
|
1471
|
+
}
|
1472
|
+
}
|
1473
|
+
|
1474
|
+
#endregion
|
1475
|
+
}
|
1476
|
+
}
|