Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2bb0694

Browse files
Start migrating imported functions to the new definition style (#252)
* Start migrating imported functions to the new definition styleUse of different function names for C-name and Wasm's import name is abit confusing. Also use of unprefixed function names in the C code isnot a good practice. This commit starts migrating imported functions tothe new naming convention and removes duplicated function definitionsjust for IDE support by using macro.* Migrate rest of imported functions* Migrate JavaScriptBigIntSupport module
1 parent3a81371 commit2bb0694

File tree

14 files changed

+136
-285
lines changed

14 files changed

+136
-285
lines changed

‎Sources/JavaScriptBigIntSupport/JSBigInt+I64.swift‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@ import _CJavaScriptBigIntSupport
33

44
extensionJSBigInt:JSBigIntExtended{
55
publicvarint64Value:Int64{
6-
_bigint_to_i64(id,true)
6+
swjs_bigint_to_i64(id,true)
77
}
88

99
publicvaruInt64Value:UInt64{
10-
UInt64(bitPattern:_bigint_to_i64(id,false))
10+
UInt64(bitPattern:swjs_bigint_to_i64(id,false))
1111
}
1212

1313
publicconvenienceinit(_ value:Int64){
14-
self.init(id:_i64_to_bigint(value,true))
14+
self.init(id:swjs_i64_to_bigint(value,true))
1515
}
1616

1717
publicconvenienceinit(unsigned value:UInt64){
18-
self.init(id:_i64_to_bigint(Int64(bitPattern: value),false))
18+
self.init(id:swjs_i64_to_bigint(Int64(bitPattern: value),false))
1919
}
2020
}

‎Sources/JavaScriptBigIntSupport/XcodeSupport.swift‎

Lines changed: 0 additions & 11 deletions
This file was deleted.

‎Sources/JavaScriptEventLoop/JavaScriptEventLoop.swift‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public final class JavaScriptEventLoop: SerialExecutor, @unchecked Sendable {
9494
#if compiler(>=5.9)
9595
typealiasswift_task_asyncMainDrainQueue_hook_Fn=@convention(thin)(swift_task_asyncMainDrainQueue_original,swift_task_asyncMainDrainQueue_override)->Void
9696
letswift_task_asyncMainDrainQueue_hook_impl:swift_task_asyncMainDrainQueue_hook_Fn={ _, _in
97-
_unsafe_event_loop_yield()
97+
swjs_unsafe_event_loop_yield()
9898
}
9999
swift_task_asyncMainDrainQueue_hook=unsafeBitCast(swift_task_asyncMainDrainQueue_hook_impl, to:UnsafeMutableRawPointer?.self)
100100
#endif
@@ -225,8 +225,3 @@ public extension JSPromise {
225225
}
226226

227227
#endif
228-
229-
// See `Sources/JavaScriptKit/XcodeSupport.swift` for rationale of the stub functions.
230-
#if !arch(wasm32)
231-
func _unsafe_event_loop_yield(){fatalError()}
232-
#endif

‎Sources/JavaScriptKit/BasicObjects/JSTypedArray.swift‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public class JSTypedArray<Element>: JSBridgedClass, ExpressibleByArrayLiteral wh
4747
/// - Parameter array: The array that will be copied to create a new instance of TypedArray
4848
publicconvenienceinit(_ array:[Element]){
4949
letjsArrayRef= array.withUnsafeBufferPointer{ ptrin
50-
_create_typed_array(Self.constructor!.id, ptr.baseAddress!,Int32(array.count))
50+
swjs_create_typed_array(Self.constructor!.id, ptr.baseAddress!,Int32(array.count))
5151
}
5252
self.init(unsafelyWrapping:JSObject(id: jsArrayRef))
5353
}
@@ -82,7 +82,7 @@ public class JSTypedArray<Element>: JSBridgedClass, ExpressibleByArrayLiteral wh
8282
letrawBuffer= UnsafeMutableBufferPointer<UInt8>.allocate(capacity: bytesLength)
8383
defer{ rawBuffer.deallocate()}
8484
letbaseAddress= rawBuffer.baseAddress!
85-
_load_typed_array(jsObject.id, baseAddress)
85+
swjs_load_typed_array(jsObject.id, baseAddress)
8686
letlength= bytesLength/ MemoryLayout<Element>.size
8787
letrawBaseAddress=UnsafeRawPointer(baseAddress)
8888
letbufferPtr=UnsafeBufferPointer<Element>(
@@ -113,7 +113,7 @@ public class JSTypedArray<Element>: JSBridgedClass, ExpressibleByArrayLiteral wh
113113
letrawBuffer= UnsafeMutableBufferPointer<UInt8>.allocate(capacity: bytesLength)
114114
defer{ rawBuffer.deallocate()}
115115
letbaseAddress= rawBuffer.baseAddress!
116-
_load_typed_array(jsObject.id, baseAddress)
116+
swjs_load_typed_array(jsObject.id, baseAddress)
117117
letlength= bytesLength/ MemoryLayout<Element>.size
118118
letrawBaseAddress=UnsafeRawPointer(baseAddress)
119119
letbufferPtr=UnsafeBufferPointer<Element>(

‎Sources/JavaScriptKit/FundamentalObjects/JSBigInt.swift‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ public final class JSBigInt: JSObject {
1515
/// This doesn't require [JS-BigInt-integration](https://github.com/WebAssembly/JS-BigInt-integration) feature.
1616
publicinit(_slowBridge value:Int64){
1717
letvalue=UInt64(bitPattern: value)
18-
super.init(id:_i64_to_bigint_slow(UInt32(value&0xffffffff),UInt32(value >>32),true))
18+
super.init(id:swjs_i64_to_bigint_slow(UInt32(value&0xffffffff),UInt32(value >>32),true))
1919
}
2020

2121
/// Instantiate a new `JSBigInt` with given UInt64 value in a slow path
2222
/// This doesn't require [JS-BigInt-integration](https://github.com/WebAssembly/JS-BigInt-integration) feature.
2323
publicinit(_slowBridge value:UInt64){
24-
super.init(id:_i64_to_bigint_slow(UInt32(value&0xffffffff),UInt32(value >>32),false))
24+
super.init(id:swjs_i64_to_bigint_slow(UInt32(value&0xffffffff),UInt32(value >>32),false))
2525
}
2626

2727
overridepublicvarjsValue:JSValue{

‎Sources/JavaScriptKit/FundamentalObjects/JSClosure.swift‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public class JSOneshotClosure: JSObject, JSClosureProtocol {
2222
// 2. Create a new JavaScript function which calls the given Swift function.
2323
hostFuncRef=JavaScriptHostFuncRef(bitPattern:ObjectIdentifier(self))
2424
id=withExtendedLifetime(JSString(file)){ filein
25-
_create_function(hostFuncRef, line, file.asInternalJSRef())
25+
swjs_create_function(hostFuncRef, line, file.asInternalJSRef())
2626
}
2727

2828
// 3. Retain the given body in static storage by `funcRef`.
@@ -88,7 +88,7 @@ public class JSClosure: JSFunction, JSClosureProtocol {
8888
// 2. Create a new JavaScript function which calls the given Swift function.
8989
hostFuncRef=JavaScriptHostFuncRef(bitPattern:ObjectIdentifier(self))
9090
id=withExtendedLifetime(JSString(file)){ filein
91-
_create_function(hostFuncRef, line, file.asInternalJSRef())
91+
swjs_create_function(hostFuncRef, line, file.asInternalJSRef())
9292
}
9393

9494
// 3. Retain the given body in static storage by `funcRef`.

‎Sources/JavaScriptKit/FundamentalObjects/JSFunction.swift‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public class JSFunction: JSObject {
5555
publicfunc new(arguments:[ConvertibleToJSValue])->JSObject{
5656
arguments.withRawJSValues{ rawValuesin
5757
rawValues.withUnsafeBufferPointer{ bufferPointerin
58-
JSObject(id:_call_new(self.id, bufferPointer.baseAddress!,Int32(bufferPointer.count)))
58+
JSObject(id:swjs_call_new(self.id, bufferPointer.baseAddress!,Int32(bufferPointer.count)))
5959
}
6060
}
6161
}
@@ -101,7 +101,7 @@ public class JSFunction: JSObject {
101101
letargc= bufferPointer.count
102102
varpayload1=JavaScriptPayload1()
103103
varpayload2=JavaScriptPayload2()
104-
letresultBitPattern=_call_function_no_catch(
104+
letresultBitPattern=swjs_call_function_no_catch(
105105
id, argv,Int32(argc),
106106
&payload1,&payload2
107107
)
@@ -121,7 +121,7 @@ public class JSFunction: JSObject {
121121
letargc= bufferPointer.count
122122
varpayload1=JavaScriptPayload1()
123123
varpayload2=JavaScriptPayload2()
124-
letresultBitPattern=_call_function_with_this_no_catch(this.id,
124+
letresultBitPattern=swjs_call_function_with_this_no_catch(this.id,
125125
id, argv,Int32(argc),
126126
&payload1,&payload2
127127
)

‎Sources/JavaScriptKit/FundamentalObjects/JSObject.swift‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ public class JSObject: Equatable {
130130
/// - Parameter constructor: The constructor function to check.
131131
/// - Returns: The result of `instanceof` in the JavaScript environment.
132132
publicfunc isInstanceOf(_ constructor:JSFunction)->Bool{
133-
_instanceof(id, constructor.id)
133+
swjs_instanceof(id, constructor.id)
134134
}
135135

136136
staticlet_JS_Predef_Value_Global:JavaScriptObjectRef=0
@@ -139,7 +139,7 @@ public class JSObject: Equatable {
139139
/// This allows access to the global properties and global names by accessing the `JSObject` returned.
140140
publicstaticletglobal=JSObject(id: _JS_Predef_Value_Global)
141141

142-
deinit{_release(id)}
142+
deinit{swjs_release(id)}
143143

144144
/// Returns a Boolean value indicating whether two values point to same objects.
145145
///

‎Sources/JavaScriptKit/FundamentalObjects/JSString.swift‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,20 @@ public struct JSString: LosslessStringConvertible, Equatable {
2323
lazyvarjsRef:JavaScriptObjectRef={
2424
self.shouldDealocateRef=true
2525
return buffer.withUTF8{ bufferPtrin
26-
return_decode_string(bufferPtr.baseAddress!,Int32(bufferPtr.count))
26+
returnswjs_decode_string(bufferPtr.baseAddress!,Int32(bufferPtr.count))
2727
}
2828
}()
2929

3030
lazyvarbuffer:String={
3131
varbytesRef:JavaScriptObjectRef=0
32-
letbytesLength=Int(_encode_string(jsRef,&bytesRef))
32+
letbytesLength=Int(swjs_encode_string(jsRef,&bytesRef))
3333
// +1 for null terminator
3434
letbuffer=malloc(Int(bytesLength+1))!.assumingMemoryBound(to:UInt8.self)
3535
defer{
3636
free(buffer)
37-
_release(bytesRef)
37+
swjs_release(bytesRef)
3838
}
39-
_load_string(bytesRef, buffer)
39+
swjs_load_string(bytesRef, buffer)
4040
buffer[bytesLength]=0
4141
returnString(decodingCString:UnsafePointer(buffer), as:UTF8.self)
4242
}()
@@ -52,7 +52,7 @@ public struct JSString: LosslessStringConvertible, Equatable {
5252

5353
deinit{
5454
guard shouldDealocateRefelse{return}
55-
_release(jsRef)
55+
swjs_release(jsRef)
5656
}
5757
}
5858

‎Sources/JavaScriptKit/FundamentalObjects/JSThrowingFunction.swift‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public class JSThrowingFunction {
4444
varexceptionKind=JavaScriptValueKindAndFlags()
4545
varexceptionPayload1=JavaScriptPayload1()
4646
varexceptionPayload2=JavaScriptPayload2()
47-
letresultObj=_call_throwing_new(
47+
letresultObj=swjs_call_throwing_new(
4848
self.base.id, argv,Int32(argc),
4949
&exceptionKind,&exceptionPayload1,&exceptionPayload2
5050
)
@@ -73,13 +73,13 @@ private func invokeJSFunction(_ jsFunc: JSFunction, arguments: [ConvertibleToJSV
7373
varpayload1=JavaScriptPayload1()
7474
varpayload2=JavaScriptPayload2()
7575
iflet thisId= this?.id{
76-
letresultBitPattern=_call_function_with_this(
76+
letresultBitPattern=swjs_call_function_with_this(
7777
thisId, id, argv,Int32(argc),
7878
&payload1,&payload2
7979
)
8080
kindAndFlags=unsafeBitCast(resultBitPattern, to:JavaScriptValueKindAndFlags.self)
8181
}else{
82-
letresultBitPattern=_call_function(
82+
letresultBitPattern=swjs_call_function(
8383
id, argv,Int32(argc),
8484
&payload1,&payload2
8585
)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp