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

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 3 additions & 1 deletion 4 Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ let package = Package(
"-Xlinker",
"--export=swjs_call_host_function",
"-Xlinker",
"--export=swjs_prepare_host_function_call"
"--export=swjs_prepare_host_function_call",
"-Xlinker",
"--export=swjs_cleanup_host_function_call"
])
]),
.target(
Expand Down
2 changes: 2 additions & 0 deletions 2 Runtime/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ declare const global: GlobalVariable;

interface SwiftRuntimeExportedFunctions {
swjs_prepare_host_function_call(size: number): pointer;
swjs_cleanup_host_function_call(argv: pointer): void;
swjs_call_host_function(
host_func_id: number,
argv: pointer, argc: number,
Expand Down Expand Up @@ -112,6 +113,7 @@ export class SwiftRuntime {
output = result
})
exports.swjs_call_host_function(host_func_id, argv, argc, callback_func_ref)
exports.swjs_cleanup_host_function_call(argv)
return output
}

Expand Down
5 changes: 5 additions & 0 deletions 5 Sources/JavaScriptKit/JSFunction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ public func _prepare_host_function_call(_ argc: Int32) -> UnsafeMutableRawPointe
return malloc(Int(argumentSize))!
}

@_cdecl("swjs_cleanup_host_function_call")
public func _cleanup_host_function_call(_ pointer: UnsafeMutableRawPointer) {
free(pointer)
}

@_cdecl("swjs_call_host_function")
public func _call_host_function(
_ hostFuncRef: JavaScriptHostFuncRef,
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.