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

Start migrating imported functions to the new definition style#252

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
kateinoigakukun merged 3 commits intomainfromkatei/refactor-import-funcs
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletionsSources/JavaScriptBigIntSupport/JSBigInt+I64.swift
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,18 +3,18 @@ import _CJavaScriptBigIntSupport

extensionJSBigInt:JSBigIntExtended{
publicvarint64Value:Int64{
_bigint_to_i64(id,true)
swjs_bigint_to_i64(id,true)
}

publicvaruInt64Value:UInt64{
UInt64(bitPattern:_bigint_to_i64(id,false))
UInt64(bitPattern:swjs_bigint_to_i64(id,false))
}

publicconvenienceinit(_ value:Int64){
self.init(id:_i64_to_bigint(value,true))
self.init(id:swjs_i64_to_bigint(value,true))
}

publicconvenienceinit(unsigned value:UInt64){
self.init(id:_i64_to_bigint(Int64(bitPattern: value),false))
self.init(id:swjs_i64_to_bigint(Int64(bitPattern: value),false))
}
}
11 changes: 0 additions & 11 deletionsSources/JavaScriptBigIntSupport/XcodeSupport.swift
View file
Open in desktop

This file was deleted.

7 changes: 1 addition & 6 deletionsSources/JavaScriptEventLoop/JavaScriptEventLoop.swift
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -94,7 +94,7 @@ public final class JavaScriptEventLoop: SerialExecutor, @unchecked Sendable {
#if compiler(>=5.9)
typealias swift_task_asyncMainDrainQueue_hook_Fn = @convention(thin) (swift_task_asyncMainDrainQueue_original, swift_task_asyncMainDrainQueue_override) -> Void
let swift_task_asyncMainDrainQueue_hook_impl: swift_task_asyncMainDrainQueue_hook_Fn = { _, _ in
_unsafe_event_loop_yield()
swjs_unsafe_event_loop_yield()
}
swift_task_asyncMainDrainQueue_hook = unsafeBitCast(swift_task_asyncMainDrainQueue_hook_impl, to: UnsafeMutableRawPointer?.self)
#endif
Expand DownExpand Up@@ -225,8 +225,3 @@ public extension JSPromise {
}

#endif

// See `Sources/JavaScriptKit/XcodeSupport.swift` for rationale of the stub functions.
#if !arch(wasm32)
func _unsafe_event_loop_yield() { fatalError() }
#endif
6 changes: 3 additions & 3 deletionsSources/JavaScriptKit/BasicObjects/JSTypedArray.swift
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -47,7 +47,7 @@ public class JSTypedArray<Element>: JSBridgedClass, ExpressibleByArrayLiteral wh
/// - Parameter array: The array that will be copied to create a new instance of TypedArray
public convenience init(_ array: [Element]) {
let jsArrayRef = array.withUnsafeBufferPointer { ptr in
_create_typed_array(Self.constructor!.id, ptr.baseAddress!, Int32(array.count))
swjs_create_typed_array(Self.constructor!.id, ptr.baseAddress!, Int32(array.count))
}
self.init(unsafelyWrapping: JSObject(id: jsArrayRef))
}
Expand DownExpand Up@@ -82,7 +82,7 @@ public class JSTypedArray<Element>: JSBridgedClass, ExpressibleByArrayLiteral wh
let rawBuffer = UnsafeMutableBufferPointer<UInt8>.allocate(capacity: bytesLength)
defer { rawBuffer.deallocate() }
let baseAddress = rawBuffer.baseAddress!
_load_typed_array(jsObject.id, baseAddress)
swjs_load_typed_array(jsObject.id, baseAddress)
let length = bytesLength / MemoryLayout<Element>.size
let rawBaseAddress = UnsafeRawPointer(baseAddress)
let bufferPtr = UnsafeBufferPointer<Element>(
Expand DownExpand Up@@ -113,7 +113,7 @@ public class JSTypedArray<Element>: JSBridgedClass, ExpressibleByArrayLiteral wh
let rawBuffer = UnsafeMutableBufferPointer<UInt8>.allocate(capacity: bytesLength)
defer { rawBuffer.deallocate() }
let baseAddress = rawBuffer.baseAddress!
_load_typed_array(jsObject.id, baseAddress)
swjs_load_typed_array(jsObject.id, baseAddress)
let length = bytesLength / MemoryLayout<Element>.size
let rawBaseAddress = UnsafeRawPointer(baseAddress)
let bufferPtr = UnsafeBufferPointer<Element>(
Expand Down
4 changes: 2 additions & 2 deletionsSources/JavaScriptKit/FundamentalObjects/JSBigInt.swift
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,13 +15,13 @@ public final class JSBigInt: JSObject {
/// This doesn't require [JS-BigInt-integration](https://github.com/WebAssembly/JS-BigInt-integration) feature.
public init(_slowBridge value: Int64) {
let value = UInt64(bitPattern: value)
super.init(id:_i64_to_bigint_slow(UInt32(value & 0xffffffff), UInt32(value >> 32), true))
super.init(id:swjs_i64_to_bigint_slow(UInt32(value & 0xffffffff), UInt32(value >> 32), true))
}

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

override public var jsValue: JSValue {
Expand Down
4 changes: 2 additions & 2 deletionsSources/JavaScriptKit/FundamentalObjects/JSClosure.swift
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -22,7 +22,7 @@ public class JSOneshotClosure: JSObject, JSClosureProtocol {
// 2. Create a new JavaScript function which calls the given Swift function.
hostFuncRef = JavaScriptHostFuncRef(bitPattern: ObjectIdentifier(self))
id = withExtendedLifetime(JSString(file)) { file in
_create_function(hostFuncRef, line, file.asInternalJSRef())
swjs_create_function(hostFuncRef, line, file.asInternalJSRef())
}

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

// 3. Retain the given body in static storage by `funcRef`.
Expand Down
6 changes: 3 additions & 3 deletionsSources/JavaScriptKit/FundamentalObjects/JSFunction.swift
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -55,7 +55,7 @@ public class JSFunction: JSObject {
public func new(arguments: [ConvertibleToJSValue]) -> JSObject {
arguments.withRawJSValues { rawValues in
rawValues.withUnsafeBufferPointer { bufferPointer in
JSObject(id:_call_new(self.id, bufferPointer.baseAddress!, Int32(bufferPointer.count)))
JSObject(id:swjs_call_new(self.id, bufferPointer.baseAddress!, Int32(bufferPointer.count)))
}
}
}
Expand DownExpand Up@@ -101,7 +101,7 @@ public class JSFunction: JSObject {
let argc = bufferPointer.count
var payload1 = JavaScriptPayload1()
var payload2 = JavaScriptPayload2()
let resultBitPattern =_call_function_no_catch(
let resultBitPattern =swjs_call_function_no_catch(
id, argv, Int32(argc),
&payload1, &payload2
)
Expand All@@ -121,7 +121,7 @@ public class JSFunction: JSObject {
let argc = bufferPointer.count
var payload1 = JavaScriptPayload1()
var payload2 = JavaScriptPayload2()
let resultBitPattern =_call_function_with_this_no_catch(this.id,
let resultBitPattern =swjs_call_function_with_this_no_catch(this.id,
id, argv, Int32(argc),
&payload1, &payload2
)
Expand Down
4 changes: 2 additions & 2 deletionsSources/JavaScriptKit/FundamentalObjects/JSObject.swift
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -130,7 +130,7 @@ public class JSObject: Equatable {
/// - Parameter constructor: The constructor function to check.
/// - Returns: The result of `instanceof` in the JavaScript environment.
public func isInstanceOf(_ constructor: JSFunction) -> Bool {
_instanceof(id, constructor.id)
swjs_instanceof(id, constructor.id)
}

static let _JS_Predef_Value_Global: JavaScriptObjectRef = 0
Expand All@@ -139,7 +139,7 @@ public class JSObject: Equatable {
/// This allows access to the global properties and global names by accessing the `JSObject` returned.
public static let global = JSObject(id: _JS_Predef_Value_Global)

deinit {_release(id) }
deinit {swjs_release(id) }

/// Returns a Boolean value indicating whether two values point to same objects.
///
Expand Down
10 changes: 5 additions & 5 deletionsSources/JavaScriptKit/FundamentalObjects/JSString.swift
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -23,20 +23,20 @@ public struct JSString: LosslessStringConvertible, Equatable {
lazy var jsRef: JavaScriptObjectRef = {
self.shouldDealocateRef = true
return buffer.withUTF8 { bufferPtr in
return_decode_string(bufferPtr.baseAddress!, Int32(bufferPtr.count))
returnswjs_decode_string(bufferPtr.baseAddress!, Int32(bufferPtr.count))
}
}()

lazy var buffer: String = {
var bytesRef: JavaScriptObjectRef = 0
let bytesLength = Int(_encode_string(jsRef, &bytesRef))
let bytesLength = Int(swjs_encode_string(jsRef, &bytesRef))
// +1 for null terminator
let buffer = malloc(Int(bytesLength + 1))!.assumingMemoryBound(to: UInt8.self)
defer {
free(buffer)
_release(bytesRef)
swjs_release(bytesRef)
}
_load_string(bytesRef, buffer)
swjs_load_string(bytesRef, buffer)
buffer[bytesLength] = 0
return String(decodingCString: UnsafePointer(buffer), as: UTF8.self)
}()
Expand All@@ -52,7 +52,7 @@ public struct JSString: LosslessStringConvertible, Equatable {

deinit {
guard shouldDealocateRef else { return }
_release(jsRef)
swjs_release(jsRef)
}
}

Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -44,7 +44,7 @@ public class JSThrowingFunction {
var exceptionKind = JavaScriptValueKindAndFlags()
var exceptionPayload1 = JavaScriptPayload1()
var exceptionPayload2 = JavaScriptPayload2()
let resultObj =_call_throwing_new(
let resultObj =swjs_call_throwing_new(
self.base.id, argv, Int32(argc),
&exceptionKind, &exceptionPayload1, &exceptionPayload2
)
Expand DownExpand Up@@ -73,13 +73,13 @@ private func invokeJSFunction(_ jsFunc: JSFunction, arguments: [ConvertibleToJSV
var payload1 = JavaScriptPayload1()
var payload2 = JavaScriptPayload2()
if let thisId = this?.id {
let resultBitPattern =_call_function_with_this(
let resultBitPattern =swjs_call_function_with_this(
thisId, id, argv, Int32(argc),
&payload1, &payload2
)
kindAndFlags = unsafeBitCast(resultBitPattern, to: JavaScriptValueKindAndFlags.self)
} else {
let resultBitPattern =_call_function(
let resultBitPattern =swjs_call_function(
id, argv, Int32(argc),
&payload1, &payload2
)
Expand Down
12 changes: 6 additions & 6 deletionsSources/JavaScriptKit/JSValue.swift
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -196,7 +196,7 @@ extension JSValue: ExpressibleByNilLiteral {

public func getJSValue(this: JSObject, name: JSString) -> JSValue {
var rawValue = RawJSValue()
let rawBitPattern =_get_prop(
let rawBitPattern =swjs_get_prop(
this.id, name.asInternalJSRef(),
&rawValue.payload1, &rawValue.payload2
)
Expand All@@ -206,13 +206,13 @@ public func getJSValue(this: JSObject, name: JSString) -> JSValue {

public func setJSValue(this: JSObject, name: JSString, value: JSValue) {
value.withRawJSValue { rawValue in
_set_prop(this.id, name.asInternalJSRef(), rawValue.kind, rawValue.payload1, rawValue.payload2)
swjs_set_prop(this.id, name.asInternalJSRef(), rawValue.kind, rawValue.payload1, rawValue.payload2)
}
}

public func getJSValue(this: JSObject, index: Int32) -> JSValue {
var rawValue = RawJSValue()
let rawBitPattern =_get_subscript(
let rawBitPattern =swjs_get_subscript(
this.id, index,
&rawValue.payload1, &rawValue.payload2
)
Expand All@@ -222,15 +222,15 @@ public func getJSValue(this: JSObject, index: Int32) -> JSValue {

public func setJSValue(this: JSObject, index: Int32, value: JSValue) {
value.withRawJSValue { rawValue in
_set_subscript(this.id, index,
swjs_set_subscript(this.id, index,
rawValue.kind,
rawValue.payload1, rawValue.payload2)
}
}

public func getJSValue(this: JSObject, symbol: JSSymbol) -> JSValue {
var rawValue = RawJSValue()
let rawBitPattern =_get_prop(
let rawBitPattern =swjs_get_prop(
this.id, symbol.id,
&rawValue.payload1, &rawValue.payload2
)
Expand All@@ -240,7 +240,7 @@ public func getJSValue(this: JSObject, symbol: JSSymbol) -> JSValue {

public func setJSValue(this: JSObject, symbol: JSSymbol, value: JSValue) {
value.withRawJSValue { rawValue in
_set_prop(this.id, symbol.id, rawValue.kind, rawValue.payload1, rawValue.payload2)
swjs_set_prop(this.id, symbol.id, rawValue.kind, rawValue.payload1, rawValue.payload2)
}
}

Expand Down
102 changes: 0 additions & 102 deletionsSources/JavaScriptKit/XcodeSupport.swift
View file
Open in desktop

This file was deleted.

Loading

[8]ページ先頭

©2009-2025 Movatter.jp