Skip to content

Commit

Permalink
Renamed wapc_host to wapc-ffi
Browse files Browse the repository at this point in the history
Use better name to identify this portion of the code.
  • Loading branch information
flavio committed Apr 23, 2021
1 parent b0b2b01 commit 0183412
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 16 deletions.
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ let package = Package(
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages this package depends on.
.target(
name: "wapc-host",
name: "wapc-ffi",
dependencies: []
),
.target(
name: "wapc",
dependencies: ["wapc-host"]),
dependencies: ["wapc-ffi"]),
.testTarget(
name: "wapcTests",
dependencies: ["wapc"]),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef __WAPC_HOST_H__
#define __WAPC_HOST_H__
#ifndef __WAPC_FFI_H__
#define __WAPC_FFI_H__

#include <stdlib.h>
#include <stdbool.h>
Expand Down Expand Up @@ -35,4 +35,4 @@ __host_error(char *payload);
__attribute__((__import_module__("wapc"), __import_name__("__console_log"))) extern void
__console_log(const char *payload, size_t payload_len);

#endif
#endif
5 changes: 5 additions & 0 deletions Sources/wapc-ffi/module.modulemap
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module wapc {
header "include/wapc_ffi.h"
link "wapc_ffi"
export *
}
1 change: 1 addition & 0 deletions Sources/wapc-ffi/wapc_ffi.c
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "wapc_ffi.h"
5 changes: 0 additions & 5 deletions Sources/wapc-host/module.modulemap

This file was deleted.

1 change: 0 additions & 1 deletion Sources/wapc-host/wapc_host.c

This file was deleted.

9 changes: 4 additions & 5 deletions Sources/wapc/wapc.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import wapc_host
import wapc_ffi
import Foundation

public func handleCall(operation_size: UInt, payload_size: UInt) -> Bool {
Expand All @@ -7,7 +7,7 @@ public func handleCall(operation_size: UInt, payload_size: UInt) -> Bool {
defer {
operationBuf.deinitialize(count: Int(operation_size) + 1)
operationBuf.deallocate()

payloadBuf.deinitialize(count: Int(payload_size) + 1)
payloadBuf.deallocate()
}
Expand Down Expand Up @@ -68,7 +68,7 @@ public func hostCall(
// Add NULL terminations
let tailErrorBuf = errorBuf + Int(errorLen)
tailErrorBuf.pointee = 0

let error = String(cString: errorBuf)

consoleLog(msg: "Host error: \(error)")
Expand Down Expand Up @@ -100,5 +100,4 @@ public func registerFunction(name: String, fn: @escaping (String) -> String) {
wapcFunctions[name] = fn
}

var wapcFunctions:
Dictionary<String, (String) -> String> = [:]
var wapcFunctions: Dictionary<String, (String) -> String> = [:]

0 comments on commit 0183412

Please sign in to comment.