Skip to content

Commit 9b69e5b

Browse files
authored
fix(all): Minor type const strings cleanup (#5029)
1 parent f3c0e80 commit 9b69e5b

10 files changed

Lines changed: 21 additions & 19 deletions

File tree

‎src/Fable.Transforms/Babel/Fable2Babel.fs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@ module Reflection =
363363
| Replacements.Util.BclDateTimeOffset
364364
| Replacements.Util.BclDateOnly
365365
| Replacements.Util.BclTimeOnly
366+
| Replacements.Util.BclRune
366367
| Replacements.Util.BclTimer -> genericEntity fullName [||]
367368
| Replacements.Util.BclHashSet gen
368369
| Replacements.Util.FSharpSet gen ->
@@ -774,6 +775,7 @@ module Annotation =
774775
makeFableLibImportTypeAnnotation com ctx [] "TimeOnlyTemporal" "PlainTime"
775776
else
776777
NumberTypeAnnotation
778+
| Replacements.Util.BclRune -> NumberTypeAnnotation
777779
| Replacements.Util.BclTimer -> makeFableLibImportTypeAnnotation com ctx [] "Timer" "Timer"
778780
| Replacements.Util.BclHashSet key -> makeFableLibImportTypeAnnotation com ctx [ key ] "Util" "ISet"
779781
| Replacements.Util.BclDictionary(key, value) ->

‎src/Fable.Transforms/Beam/Replacements.fs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6044,7 +6044,7 @@ let tryCall
60446044
| "System.Diagnostics.Stopwatch" -> stopwatch com ctx r t info thisArg args
60456045
| Types.nullable -> nullables com ctx r t info thisArg args
60466046
| Types.guid -> guids com ctx r t info thisArg args
6047-
| "System.Random" -> randoms com ctx r t info thisArg args
6047+
| Types.random -> randoms com ctx r t info thisArg args
60486048
| "System.Environment" ->
60496049
match info.CompiledName with
60506050
| "get_NewLine" -> makeStrConst "\n" |> Some

‎src/Fable.Transforms/Dart/Fable2Dart.fs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ module Util =
221221

222222
match entRef.FullName, genArgs with
223223
| Types.enum_, _
224-
| "System.Text.Rune", _ -> Integer
224+
| Types.rune, _ -> Integer
225225
// F# Quotation types are modelled dynamically by the quotation runtime,
226226
// so map them to `dynamic` (the runtime returns plain tagged objects).
227227
| Types.fsharpExpr, _
@@ -243,7 +243,7 @@ module Util =
243243
| "Fable.Core.Dart.DartNullable`1", [ genArg ] -> Nullable genArg
244244
| Types.regexGroup, _ -> Nullable String
245245
| Types.regexMatch, _ -> makeTypeRefFromName "Match" []
246-
| "System.Random", _ -> libTypeRef com ctx "Random" "Random" []
246+
| Types.random, _ -> libTypeRef com ctx "Random" "Random" []
247247
// We use `dynamic` for Exception because there is no single type that catches all errors in Dart
248248
// (except when inherited as base class, then it's getExceptionType, see transformInheritedClass)
249249
| Types.exception_, _ -> Dynamic // getExceptionType com ctx

‎src/Fable.Transforms/Dart/Replacements.fs‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ let toString com (ctx: Context) r (args: Expr list) =
248248
match head.Type with
249249
| String -> head
250250
| Char -> charToString head
251-
| DeclaredType({ FullName = "System.Text.Rune" }, _) -> charToString head
251+
| DeclaredType({ FullName = Types.rune }, _) -> charToString head
252252
// | Builtin BclGuid when tail.IsEmpty -> head
253253
// | Builtin (BclGuid|BclTimeSpan|BclTimeOnly|BclDateOnly as bt) ->
254254
// Helper.LibCall(com, coreModFor bt, "toString", String, args)
@@ -3966,7 +3966,7 @@ let private replacedModules =
39663966
"System.Runtime.ExceptionServices.ExceptionDispatchInfo", exceptionDispatchInfo
39673967
Types.char, chars
39683968
Types.string, strings
3969-
"System.Text.Rune", runes
3969+
Types.rune, runes
39703970
"Microsoft.FSharp.Core.StringModule", stringModule
39713971
"System.FormattableString", formattableString
39723972
"System.Runtime.CompilerServices.FormattableStringFactory", formattableString
@@ -4051,10 +4051,10 @@ let private replacedModules =
40514051
Types.dateOnly, dateOnly
40524052
Types.timeOnly, timeOnly
40534053
Types.timespan, timeSpans
4054-
"System.Timers.Timer", timers
4054+
Types.timer, timers
40554055
"System.Environment", systemEnv
40564056
"System.Globalization.CultureInfo", globalization
4057-
"System.Random", random
4057+
Types.random, random
40584058
"System.Threading.CancellationToken", cancels
40594059
"System.Threading.CancellationTokenSource", cancels
40604060
"System.Threading.CancellationTokenRegistration", disposables
@@ -4230,7 +4230,7 @@ let tryType typ =
42304230
| BclDateTimeOffset -> Some(Types.datetimeOffset, dates, [])
42314231
| BclDateOnly -> Some(Types.dateOnly, dateOnly, [])
42324232
| BclTimeOnly -> Some(Types.timeOnly, timeOnly, [])
4233-
| BclTimer -> Some("System.Timers.Timer", timers, [])
4233+
| BclTimer -> Some(Types.timer, timers, [])
42344234
| BclTimeSpan -> Some(Types.timespan, timeSpans, [])
42354235
| BclHashSet genArg -> Some(Types.hashset, hashSets, [ genArg ])
42364236
| BclDictionary(key, value) -> Some(Types.dictionary, dictionaries, [ key; value ])

‎src/Fable.Transforms/Python/Replacements.fs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4218,14 +4218,14 @@ let private replacedModules =
42184218
Types.dateOnly, dateOnly
42194219
Types.timeOnly, timeOnly
42204220
Types.timespan, timeSpans
4221-
"System.Timers.Timer", timers
4221+
Types.timer, timers
42224222
"System.Environment", systemEnv
42234223
"System.Globalization.CultureInfo", globalization
42244224
"System.IO.File", files
42254225
"System.IO.Directory", directories
42264226
"System.IO.Path", paths
42274227
"System.IO.TextWriter", textWriter
4228-
"System.Random", random
4228+
Types.random, random
42294229
"System.Threading.CancellationToken", cancels
42304230
"System.Threading.CancellationTokenSource", cancels
42314231
"System.Threading.Monitor", monitor
@@ -4386,7 +4386,7 @@ let tryType typ =
43864386
| BclTimeSpan -> Some(Types.timespan, timeSpans, [])
43874387
| BclDateTime -> Some(Types.datetime, dates, [])
43884388
| BclDateTimeOffset -> Some(Types.datetimeOffset, dates, [])
4389-
| BclTimer -> Some("System.Timers.Timer", timers, [])
4389+
| BclTimer -> Some(Types.timer, timers, [])
43904390
| BclHashSet genArg -> Some(Types.hashset, hashSets, [ genArg ])
43914391
| BclDictionary(key, value) -> Some(Types.dictionary, dictionaries, [ key; value ])
43924392
| BclKeyValuePair(key, value) -> Some(Types.keyValuePair, keyValuePairs, [ key; value ])

‎src/Fable.Transforms/Replacements.Util.fs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ let (|BuiltinDefinition|_|) =
315315
| Types.dateOnly -> ValueSome BclDateOnly
316316
| Types.timeOnly -> ValueSome BclTimeOnly
317317
| Types.rune -> ValueSome BclRune
318-
| "System.Timers.Timer" -> ValueSome BclTimer
318+
| Types.timer -> ValueSome BclTimer
319319
| Types.fsharpSet -> ValueSome(FSharpSet(Any))
320320
| Types.fsharpMap -> ValueSome(FSharpMap(Any, Any))
321321
| Types.hashset -> ValueSome(BclHashSet(Any))

‎src/Fable.Transforms/Replacements.fs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4784,14 +4784,14 @@ let private replacedModules =
47844784
Types.dateOnly, dateOnly
47854785
Types.timeOnly, timeOnly
47864786
Types.timespan, timeSpans
4787-
"System.Timers.Timer", timers
4787+
Types.timer, timers
47884788
"System.IO.File", files
47894789
"System.IO.Directory", directories
47904790
"System.IO.Path", paths
47914791
"System.IO.TextWriter", textWriter
47924792
"System.Environment", systemEnv
47934793
"System.Globalization.CultureInfo", globalization
4794-
"System.Random", random
4794+
Types.random, random
47954795
"System.Threading.CancellationToken", cancels
47964796
"System.Threading.CancellationTokenSource", cancels
47974797
"System.Threading.Monitor", monitor

‎src/Fable.Transforms/Rust/Fable2Rust.fs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1032,7 +1032,7 @@ module TypeInfo =
10321032
mkEmitTy value genArgs
10331033
| ent when ent.IsInterface -> transformInterfaceType com ctx entRef genArgs
10341034
| ent when ent.IsAbstractClass -> transformAbstractClassType com ctx entRef genArgs
1035-
| _ when entRef.FullName = "System.Random" ->
1035+
| _ when entRef.FullName = Types.random ->
10361036
let entName = getLibraryImportName com ctx "Random" "Random"
10371037
let genArgsOpt = transformGenArgs com ctx genArgs
10381038
makeFullNamePathTy entName genArgsOpt

‎src/Fable.Transforms/Rust/Replacements.fs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3509,12 +3509,12 @@ let private replacedModules =
35093509
Types.timeOnly, timeOnly
35103510
Types.rune, runes
35113511
Types.timespan, timeSpans
3512-
"System.Timers.Timer", timers
3512+
Types.timer, timers
35133513
"System.Environment", systemEnv
35143514
"System.IO.File", files
35153515
"System.IO.Path", paths
35163516
Types.cultureInfo, globalization
3517-
"System.Random", random
3517+
Types.random, random
35183518
"System.Threading.CancellationToken", cancels
35193519
"System.Threading.CancellationTokenSource", cancels
35203520
"System.Threading.Monitor", monitor
@@ -3674,7 +3674,7 @@ let tryType typ =
36743674
| BclDateOnly -> Some(Types.dateOnly, dateOnly, [])
36753675
| BclTimeOnly -> Some(Types.timeOnly, timeOnly, [])
36763676
| BclRune -> Some(Types.rune, runes, [])
3677-
| BclTimer -> Some("System.Timers.Timer", timers, [])
3677+
| BclTimer -> Some(Types.timer, timers, [])
36783678
| BclTimeSpan -> Some(Types.timespan, timeSpans, [])
36793679
| BclHashSet genArg -> Some(Types.hashset, hashSets, [ genArg ])
36803680
| BclDictionary(key, value) -> Some(Types.dictionary, dictionaries, [ key; value ])

‎src/fable-library-rust/src/print_no_std.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const STDERR: i32 = 2;
44

55
#[link(name = "c")]
66
unsafe extern "C" {
7-
fn write(filedes: i32, buf: *const core::ffi::c_void, nbyte: usize);
7+
fn write(filedes: core::ffi::c_int, buf: *const core::ffi::c_void, nbyte: usize) -> isize;
88
}
99

1010
pub fn write_to(filedes: i32, s: &str) {

0 commit comments

Comments
 (0)