diff --git a/src/Fable.Transforms/Babel/Fable2Babel.fs b/src/Fable.Transforms/Babel/Fable2Babel.fs index 1b62340a4f..89ad79c781 100644 --- a/src/Fable.Transforms/Babel/Fable2Babel.fs +++ b/src/Fable.Transforms/Babel/Fable2Babel.fs @@ -363,6 +363,7 @@ module Reflection = | Replacements.Util.BclDateTimeOffset | Replacements.Util.BclDateOnly | Replacements.Util.BclTimeOnly + | Replacements.Util.BclRune | Replacements.Util.BclTimer -> genericEntity fullName [||] | Replacements.Util.BclHashSet gen | Replacements.Util.FSharpSet gen -> @@ -774,6 +775,7 @@ module Annotation = makeFableLibImportTypeAnnotation com ctx [] "TimeOnlyTemporal" "PlainTime" else NumberTypeAnnotation + | Replacements.Util.BclRune -> NumberTypeAnnotation | Replacements.Util.BclTimer -> makeFableLibImportTypeAnnotation com ctx [] "Timer" "Timer" | Replacements.Util.BclHashSet key -> makeFableLibImportTypeAnnotation com ctx [ key ] "Util" "ISet" | Replacements.Util.BclDictionary(key, value) -> diff --git a/src/Fable.Transforms/Beam/Replacements.fs b/src/Fable.Transforms/Beam/Replacements.fs index c88a91dcb1..5ea619bb6f 100644 --- a/src/Fable.Transforms/Beam/Replacements.fs +++ b/src/Fable.Transforms/Beam/Replacements.fs @@ -6044,7 +6044,7 @@ let tryCall | "System.Diagnostics.Stopwatch" -> stopwatch com ctx r t info thisArg args | Types.nullable -> nullables com ctx r t info thisArg args | Types.guid -> guids com ctx r t info thisArg args - | "System.Random" -> randoms com ctx r t info thisArg args + | Types.random -> randoms com ctx r t info thisArg args | "System.Environment" -> match info.CompiledName with | "get_NewLine" -> makeStrConst "\n" |> Some diff --git a/src/Fable.Transforms/Dart/Fable2Dart.fs b/src/Fable.Transforms/Dart/Fable2Dart.fs index 658947e807..f5e9570c08 100644 --- a/src/Fable.Transforms/Dart/Fable2Dart.fs +++ b/src/Fable.Transforms/Dart/Fable2Dart.fs @@ -221,7 +221,7 @@ module Util = match entRef.FullName, genArgs with | Types.enum_, _ - | "System.Text.Rune", _ -> Integer + | Types.rune, _ -> Integer // F# Quotation types are modelled dynamically by the quotation runtime, // so map them to `dynamic` (the runtime returns plain tagged objects). | Types.fsharpExpr, _ @@ -243,7 +243,7 @@ module Util = | "Fable.Core.Dart.DartNullable`1", [ genArg ] -> Nullable genArg | Types.regexGroup, _ -> Nullable String | Types.regexMatch, _ -> makeTypeRefFromName "Match" [] - | "System.Random", _ -> libTypeRef com ctx "Random" "Random" [] + | Types.random, _ -> libTypeRef com ctx "Random" "Random" [] // We use `dynamic` for Exception because there is no single type that catches all errors in Dart // (except when inherited as base class, then it's getExceptionType, see transformInheritedClass) | Types.exception_, _ -> Dynamic // getExceptionType com ctx diff --git a/src/Fable.Transforms/Dart/Replacements.fs b/src/Fable.Transforms/Dart/Replacements.fs index 751d073d1c..4766a44f1a 100644 --- a/src/Fable.Transforms/Dart/Replacements.fs +++ b/src/Fable.Transforms/Dart/Replacements.fs @@ -248,7 +248,7 @@ let toString com (ctx: Context) r (args: Expr list) = match head.Type with | String -> head | Char -> charToString head - | DeclaredType({ FullName = "System.Text.Rune" }, _) -> charToString head + | DeclaredType({ FullName = Types.rune }, _) -> charToString head // | Builtin BclGuid when tail.IsEmpty -> head // | Builtin (BclGuid|BclTimeSpan|BclTimeOnly|BclDateOnly as bt) -> // Helper.LibCall(com, coreModFor bt, "toString", String, args) @@ -3966,7 +3966,7 @@ let private replacedModules = "System.Runtime.ExceptionServices.ExceptionDispatchInfo", exceptionDispatchInfo Types.char, chars Types.string, strings - "System.Text.Rune", runes + Types.rune, runes "Microsoft.FSharp.Core.StringModule", stringModule "System.FormattableString", formattableString "System.Runtime.CompilerServices.FormattableStringFactory", formattableString @@ -4051,10 +4051,10 @@ let private replacedModules = Types.dateOnly, dateOnly Types.timeOnly, timeOnly Types.timespan, timeSpans - "System.Timers.Timer", timers + Types.timer, timers "System.Environment", systemEnv "System.Globalization.CultureInfo", globalization - "System.Random", random + Types.random, random "System.Threading.CancellationToken", cancels "System.Threading.CancellationTokenSource", cancels "System.Threading.CancellationTokenRegistration", disposables @@ -4230,7 +4230,7 @@ let tryType typ = | BclDateTimeOffset -> Some(Types.datetimeOffset, dates, []) | BclDateOnly -> Some(Types.dateOnly, dateOnly, []) | BclTimeOnly -> Some(Types.timeOnly, timeOnly, []) - | BclTimer -> Some("System.Timers.Timer", timers, []) + | BclTimer -> Some(Types.timer, timers, []) | BclTimeSpan -> Some(Types.timespan, timeSpans, []) | BclHashSet genArg -> Some(Types.hashset, hashSets, [ genArg ]) | BclDictionary(key, value) -> Some(Types.dictionary, dictionaries, [ key; value ]) diff --git a/src/Fable.Transforms/Python/Replacements.fs b/src/Fable.Transforms/Python/Replacements.fs index 4d78c01fa2..2f18e27862 100644 --- a/src/Fable.Transforms/Python/Replacements.fs +++ b/src/Fable.Transforms/Python/Replacements.fs @@ -4218,14 +4218,14 @@ let private replacedModules = Types.dateOnly, dateOnly Types.timeOnly, timeOnly Types.timespan, timeSpans - "System.Timers.Timer", timers + Types.timer, timers "System.Environment", systemEnv "System.Globalization.CultureInfo", globalization "System.IO.File", files "System.IO.Directory", directories "System.IO.Path", paths "System.IO.TextWriter", textWriter - "System.Random", random + Types.random, random "System.Threading.CancellationToken", cancels "System.Threading.CancellationTokenSource", cancels "System.Threading.Monitor", monitor @@ -4386,7 +4386,7 @@ let tryType typ = | BclTimeSpan -> Some(Types.timespan, timeSpans, []) | BclDateTime -> Some(Types.datetime, dates, []) | BclDateTimeOffset -> Some(Types.datetimeOffset, dates, []) - | BclTimer -> Some("System.Timers.Timer", timers, []) + | BclTimer -> Some(Types.timer, timers, []) | BclHashSet genArg -> Some(Types.hashset, hashSets, [ genArg ]) | BclDictionary(key, value) -> Some(Types.dictionary, dictionaries, [ key; value ]) | BclKeyValuePair(key, value) -> Some(Types.keyValuePair, keyValuePairs, [ key; value ]) diff --git a/src/Fable.Transforms/Replacements.Util.fs b/src/Fable.Transforms/Replacements.Util.fs index fe3b8ddf50..30009f5914 100644 --- a/src/Fable.Transforms/Replacements.Util.fs +++ b/src/Fable.Transforms/Replacements.Util.fs @@ -315,7 +315,7 @@ let (|BuiltinDefinition|_|) = | Types.dateOnly -> ValueSome BclDateOnly | Types.timeOnly -> ValueSome BclTimeOnly | Types.rune -> ValueSome BclRune - | "System.Timers.Timer" -> ValueSome BclTimer + | Types.timer -> ValueSome BclTimer | Types.fsharpSet -> ValueSome(FSharpSet(Any)) | Types.fsharpMap -> ValueSome(FSharpMap(Any, Any)) | Types.hashset -> ValueSome(BclHashSet(Any)) diff --git a/src/Fable.Transforms/Replacements.fs b/src/Fable.Transforms/Replacements.fs index fd3de104f4..aec37196c9 100644 --- a/src/Fable.Transforms/Replacements.fs +++ b/src/Fable.Transforms/Replacements.fs @@ -4784,14 +4784,14 @@ let private replacedModules = Types.dateOnly, dateOnly Types.timeOnly, timeOnly Types.timespan, timeSpans - "System.Timers.Timer", timers + Types.timer, timers "System.IO.File", files "System.IO.Directory", directories "System.IO.Path", paths "System.IO.TextWriter", textWriter "System.Environment", systemEnv "System.Globalization.CultureInfo", globalization - "System.Random", random + Types.random, random "System.Threading.CancellationToken", cancels "System.Threading.CancellationTokenSource", cancels "System.Threading.Monitor", monitor diff --git a/src/Fable.Transforms/Rust/Fable2Rust.fs b/src/Fable.Transforms/Rust/Fable2Rust.fs index 9d9f4ae429..2b557b0bb3 100644 --- a/src/Fable.Transforms/Rust/Fable2Rust.fs +++ b/src/Fable.Transforms/Rust/Fable2Rust.fs @@ -1032,7 +1032,7 @@ module TypeInfo = mkEmitTy value genArgs | ent when ent.IsInterface -> transformInterfaceType com ctx entRef genArgs | ent when ent.IsAbstractClass -> transformAbstractClassType com ctx entRef genArgs - | _ when entRef.FullName = "System.Random" -> + | _ when entRef.FullName = Types.random -> let entName = getLibraryImportName com ctx "Random" "Random" let genArgsOpt = transformGenArgs com ctx genArgs makeFullNamePathTy entName genArgsOpt diff --git a/src/Fable.Transforms/Rust/Replacements.fs b/src/Fable.Transforms/Rust/Replacements.fs index c459022ef5..c242b41b0d 100644 --- a/src/Fable.Transforms/Rust/Replacements.fs +++ b/src/Fable.Transforms/Rust/Replacements.fs @@ -3509,12 +3509,12 @@ let private replacedModules = Types.timeOnly, timeOnly Types.rune, runes Types.timespan, timeSpans - "System.Timers.Timer", timers + Types.timer, timers "System.Environment", systemEnv "System.IO.File", files "System.IO.Path", paths Types.cultureInfo, globalization - "System.Random", random + Types.random, random "System.Threading.CancellationToken", cancels "System.Threading.CancellationTokenSource", cancels "System.Threading.Monitor", monitor @@ -3674,7 +3674,7 @@ let tryType typ = | BclDateOnly -> Some(Types.dateOnly, dateOnly, []) | BclTimeOnly -> Some(Types.timeOnly, timeOnly, []) | BclRune -> Some(Types.rune, runes, []) - | BclTimer -> Some("System.Timers.Timer", timers, []) + | BclTimer -> Some(Types.timer, timers, []) | BclTimeSpan -> Some(Types.timespan, timeSpans, []) | BclHashSet genArg -> Some(Types.hashset, hashSets, [ genArg ]) | BclDictionary(key, value) -> Some(Types.dictionary, dictionaries, [ key; value ]) diff --git a/src/fable-library-rust/src/print_no_std.rs b/src/fable-library-rust/src/print_no_std.rs index 63aa6356b2..f5f83facb6 100644 --- a/src/fable-library-rust/src/print_no_std.rs +++ b/src/fable-library-rust/src/print_no_std.rs @@ -4,7 +4,7 @@ const STDERR: i32 = 2; #[link(name = "c")] unsafe extern "C" { - fn write(filedes: i32, buf: *const core::ffi::c_void, nbyte: usize); + fn write(filedes: core::ffi::c_int, buf: *const core::ffi::c_void, nbyte: usize) -> isize; } pub fn write_to(filedes: i32, s: &str) {