Skip to content

Commit 606cb27

Browse files
Merge pull request #266 from swiftwasm/katei/embedded-followup
Resolve warnings
2 parents b78f3ca + b1b3024 commit 606cb27

File tree

6 files changed

+37
-38
lines changed

6 files changed

+37
-38
lines changed

Sources/JavaScriptBigIntSupport/Int64+I64.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import JavaScriptKit
22

3-
extension UInt64: ConvertibleToJSValue, TypedArrayElement {
3+
extension UInt64: JavaScriptKit.ConvertibleToJSValue, JavaScriptKit.TypedArrayElement {
44
public static var typedArrayClass = JSObject.global.BigUint64Array.function!
55

66
public var jsValue: JSValue { .bigInt(JSBigInt(unsigned: self)) }
77
}
88

9-
extension Int64: ConvertibleToJSValue, TypedArrayElement {
9+
extension Int64: JavaScriptKit.ConvertibleToJSValue, JavaScriptKit.TypedArrayElement {
1010
public static var typedArrayClass = JSObject.global.BigInt64Array.function!
1111

1212
public var jsValue: JSValue { .bigInt(JSBigInt(self)) }

Sources/JavaScriptBigIntSupport/JSBigInt+I64.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import _CJavaScriptBigIntSupport
22
@_spi(JSObject_id) import JavaScriptKit
33

4-
extension JSBigInt: JSBigIntExtended {
4+
extension JSBigInt: JavaScriptKit.JSBigIntExtended {
55
public var int64Value: Int64 {
66
swjs_bigint_to_i64(id, true)
77
}

Sources/JavaScriptKit/BasicObjects/JSTimer.swift

+4
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@ public final class JSTimer {
2727
case .oneshot(let closure):
2828
closure.release()
2929
case .repeating(let closure):
30+
#if JAVASCRIPTKIT_WITHOUT_WEAKREFS
3031
closure.release()
32+
#else
33+
break // no-op
34+
#endif
3135
}
3236
}
3337
}

Sources/JavaScriptKit/BasicObjects/JSTypedArray.swift

+2-2
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
public convenience init(_ array: [Element]) {
4949
let jsArrayRef = array.withUnsafeBufferPointer { ptr in
50-
swjs_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
}
@@ -187,4 +187,4 @@ extension Float32: TypedArrayElement {
187187
extension Float64: TypedArrayElement {
188188
public static var typedArrayClass = JSObject.global.Float64Array.function!
189189
}
190-
#endif
190+
#endif

Sources/JavaScriptKit/FundamentalObjects/JSFunction.swift

+2-7
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import _CJavaScriptKit
1010
/// alert("Hello, world")
1111
/// ```
1212
///
13-
public class JSFunction: JSObject, _JSFunctionProtocol {
13+
public class JSFunction: JSObject {
1414
#if !hasFeature(Embedded)
1515
/// Call this function with given `arguments` and binding given `this` as context.
1616
/// - Parameters:
@@ -163,14 +163,9 @@ public class JSFunction: JSObject, _JSFunctionProtocol {
163163
}
164164
}
165165

166-
/// Internal protocol to support generic arguments for `JSFunction`.
167-
///
168-
/// In Swift Embedded, non-final classes cannot have generic methods.
169-
public protocol _JSFunctionProtocol: JSFunction {}
170-
171166
#if hasFeature(Embedded)
172167
// NOTE: once embedded supports variadic generics, we can remove these overloads
173-
public extension _JSFunctionProtocol {
168+
public extension JSFunction {
174169

175170
@discardableResult
176171
func callAsFunction(this: JSObject) -> JSValue {

Sources/_CJavaScriptKit/include/_CJavaScriptKit.h

+26-26
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ IMPORT_JS_FUNCTION(swjs_set_prop, void, (const JavaScriptObjectRef _this,
105105
/// @return A `JavaScriptValueKind` bits represented as 32bit integer for the returned value.
106106
IMPORT_JS_FUNCTION(swjs_get_prop, uint32_t, (const JavaScriptObjectRef _this,
107107
const JavaScriptObjectRef prop,
108-
JavaScriptPayload1 *payload1,
109-
JavaScriptPayload2 *payload2))
108+
JavaScriptPayload1 * _Nonnull payload1,
109+
JavaScriptPayload2 * _Nonnull payload2))
110110

111111
/// Sets a value of `_this` JavaScript object.
112112
///
@@ -131,29 +131,29 @@ IMPORT_JS_FUNCTION(swjs_set_subscript, void, (const JavaScriptObjectRef _this,
131131
/// get a value of `_this` JavaScript object.
132132
IMPORT_JS_FUNCTION(swjs_get_subscript, uint32_t, (const JavaScriptObjectRef _this,
133133
const int index,
134-
JavaScriptPayload1 *payload1,
135-
JavaScriptPayload2 *payload2))
134+
JavaScriptPayload1 * _Nonnull payload1,
135+
JavaScriptPayload2 * _Nonnull payload2))
136136

137137
/// Encodes the `str_obj` to bytes sequence and returns the length of bytes.
138138
///
139139
/// @param str_obj A JavaScript string object ref to encode.
140140
/// @param bytes_result A result pointer of bytes sequence representation in JavaScript.
141141
/// This value will be used to load the actual bytes using `_load_string`.
142142
/// @result The length of bytes sequence. This value will be used to allocate Swift side string buffer to load the actual bytes.
143-
IMPORT_JS_FUNCTION(swjs_encode_string, int, (const JavaScriptObjectRef str_obj, JavaScriptObjectRef *bytes_result))
143+
IMPORT_JS_FUNCTION(swjs_encode_string, int, (const JavaScriptObjectRef str_obj, JavaScriptObjectRef * _Nonnull bytes_result))
144144

145145
/// Decodes the given bytes sequence into JavaScript string object.
146146
///
147147
/// @param bytes_ptr A `uint8_t` byte sequence to decode.
148148
/// @param length The length of `bytes_ptr`.
149149
/// @result The decoded JavaScript string object.
150-
IMPORT_JS_FUNCTION(swjs_decode_string, JavaScriptObjectRef, (const unsigned char *bytes_ptr, const int length))
150+
IMPORT_JS_FUNCTION(swjs_decode_string, JavaScriptObjectRef, (const unsigned char * _Nonnull bytes_ptr, const int length))
151151

152152
/// Loads the actual bytes sequence of `bytes` into `buffer` which is a Swift side memory address.
153153
///
154154
/// @param bytes A bytes sequence representation in JavaScript to load. This value should be derived from `_encode_string`.
155155
/// @param buffer A Swift side string buffer to load the bytes.
156-
IMPORT_JS_FUNCTION(swjs_load_string, void, (const JavaScriptObjectRef bytes, unsigned char *buffer))
156+
IMPORT_JS_FUNCTION(swjs_load_string, void, (const JavaScriptObjectRef bytes, unsigned char * _Nonnull buffer))
157157

158158
/// Converts the provided Int64 or UInt64 to a BigInt in slow path by splitting 64bit integer to two 32bit integers
159159
/// to avoid depending on [JS-BigInt-integration](https://github.com/WebAssembly/JS-BigInt-integration) feature
@@ -172,10 +172,10 @@ IMPORT_JS_FUNCTION(swjs_i64_to_bigint_slow, JavaScriptObjectRef, (unsigned int l
172172
/// @param result_payload2 A result pointer of second payload of JavaScript value of returned result or thrown exception.
173173
/// @return A `JavaScriptValueKindAndFlags` bits represented as 32bit integer for the returned value.
174174
IMPORT_JS_FUNCTION(swjs_call_function, uint32_t, (const JavaScriptObjectRef ref,
175-
const RawJSValue *argv,
175+
const RawJSValue * _Nullable argv,
176176
const int argc,
177-
JavaScriptPayload1 *result_payload1,
178-
JavaScriptPayload2 *result_payload2))
177+
JavaScriptPayload1 * _Nonnull result_payload1,
178+
JavaScriptPayload2 * _Nonnull result_payload2))
179179

180180
/// Calls JavaScript function with given arguments list without capturing any exception
181181
///
@@ -186,10 +186,10 @@ IMPORT_JS_FUNCTION(swjs_call_function, uint32_t, (const JavaScriptObjectRef ref,
186186
/// @param result_payload2 A result pointer of second payload of JavaScript value of returned result or thrown exception.
187187
/// @return A `JavaScriptValueKindAndFlags` bits represented as 32bit integer for the returned value.
188188
IMPORT_JS_FUNCTION(swjs_call_function_no_catch, uint32_t, (const JavaScriptObjectRef ref,
189-
const RawJSValue *argv,
189+
const RawJSValue * _Nullable argv,
190190
const int argc,
191-
JavaScriptPayload1 *result_payload1,
192-
JavaScriptPayload2 *result_payload2))
191+
JavaScriptPayload1 * _Nonnull result_payload1,
192+
JavaScriptPayload2 * _Nonnull result_payload2))
193193

194194
/// Calls JavaScript function with given arguments list and given `_this`.
195195
///
@@ -202,10 +202,10 @@ IMPORT_JS_FUNCTION(swjs_call_function_no_catch, uint32_t, (const JavaScriptObjec
202202
/// @return A `JavaScriptValueKindAndFlags` bits represented as 32bit integer for the returned value.
203203
IMPORT_JS_FUNCTION(swjs_call_function_with_this, uint32_t, (const JavaScriptObjectRef _this,
204204
const JavaScriptObjectRef func_ref,
205-
const RawJSValue *argv,
205+
const RawJSValue * _Nullable argv,
206206
const int argc,
207-
JavaScriptPayload1 *result_payload1,
208-
JavaScriptPayload2 *result_payload2))
207+
JavaScriptPayload1 * _Nonnull result_payload1,
208+
JavaScriptPayload2 * _Nonnull result_payload2))
209209

210210
/// Calls JavaScript function with given arguments list and given `_this` without capturing any exception.
211211
///
@@ -218,10 +218,10 @@ IMPORT_JS_FUNCTION(swjs_call_function_with_this, uint32_t, (const JavaScriptObje
218218
/// @return A `JavaScriptValueKindAndFlags` bits represented as 32bit integer for the returned value.
219219
IMPORT_JS_FUNCTION(swjs_call_function_with_this_no_catch, uint32_t, (const JavaScriptObjectRef _this,
220220
const JavaScriptObjectRef func_ref,
221-
const RawJSValue *argv,
221+
const RawJSValue * _Nullable argv,
222222
const int argc,
223-
JavaScriptPayload1 *result_payload1,
224-
JavaScriptPayload2 *result_payload2))
223+
JavaScriptPayload1 * _Nonnull result_payload1,
224+
JavaScriptPayload2 * _Nonnull result_payload2))
225225

226226
/// Calls JavaScript object constructor with given arguments list.
227227
///
@@ -230,7 +230,7 @@ IMPORT_JS_FUNCTION(swjs_call_function_with_this_no_catch, uint32_t, (const JavaS
230230
/// @param argc The length of `argv``.
231231
/// @returns A reference to the constructed object.
232232
IMPORT_JS_FUNCTION(swjs_call_new, JavaScriptObjectRef, (const JavaScriptObjectRef ref,
233-
const RawJSValue *argv,
233+
const RawJSValue * _Nullable argv,
234234
const int argc))
235235

236236
/// Calls JavaScript object constructor with given arguments list.
@@ -243,11 +243,11 @@ IMPORT_JS_FUNCTION(swjs_call_new, JavaScriptObjectRef, (const JavaScriptObjectRe
243243
/// @param exception_payload2 A result pointer of second payload of JavaScript value of thrown exception.
244244
/// @returns A reference to the constructed object.
245245
IMPORT_JS_FUNCTION(swjs_call_throwing_new, JavaScriptObjectRef, (const JavaScriptObjectRef ref,
246-
const RawJSValue *argv,
246+
const RawJSValue * _Nullable argv,
247247
const int argc,
248-
JavaScriptRawValueKindAndFlags *exception_kind,
249-
JavaScriptPayload1 *exception_payload1,
250-
JavaScriptPayload2 *exception_payload2))
248+
JavaScriptRawValueKindAndFlags * _Nonnull exception_kind,
249+
JavaScriptPayload1 * _Nonnull exception_payload1,
250+
JavaScriptPayload2 * _Nonnull exception_payload2))
251251

252252
/// Acts like JavaScript `instanceof` operator.
253253
///
@@ -276,14 +276,14 @@ IMPORT_JS_FUNCTION(swjs_create_function, JavaScriptObjectRef, (const JavaScriptH
276276
/// @param length The length of `elements_ptr`
277277
/// @returns A reference to the constructed typed array
278278
IMPORT_JS_FUNCTION(swjs_create_typed_array, JavaScriptObjectRef, (const JavaScriptObjectRef constructor,
279-
const void *elements_ptr,
279+
const void * _Nullable elements_ptr,
280280
const int length))
281281

282282
/// Copies the byte contents of a typed array into a Swift side memory buffer.
283283
///
284284
/// @param ref A JavaScript typed array object.
285285
/// @param buffer A Swift side buffer into which to copy the bytes.
286-
IMPORT_JS_FUNCTION(swjs_load_typed_array, void, (const JavaScriptObjectRef ref, unsigned char *buffer))
286+
IMPORT_JS_FUNCTION(swjs_load_typed_array, void, (const JavaScriptObjectRef ref, unsigned char * _Nonnull buffer))
287287

288288
/// Decrements reference count of `ref` retained by `SwiftRuntimeHeap` in JavaScript side.
289289
///

0 commit comments

Comments
 (0)