Skip to content

Commit 396c227

Browse files
committed
[CASTBridging] Typedefs for opaque pointer types
1 parent e840409 commit 396c227

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

include/swift/AST/CASTBridging.h

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -289,26 +289,29 @@ void Type_dump(void *);
289289
// Plugins
290290
//===----------------------------------------------------------------------===//
291291

292+
typedef void *PluginHandle;
293+
typedef const void *PluginCapabilityPtr;
294+
292295
/// Set a capability data to the plugin object. Since the data is just a opaque
293296
/// pointer, it's not used in AST at all.
294-
void Plugin_setCapability(void *handle, const void *data);
297+
void Plugin_setCapability(PluginHandle handle, PluginCapabilityPtr data);
295298

296-
/// Get a coapability data set by \c Plugin_setCapability .
297-
const void *_Nullable Plugin_getCapability(void *handle);
299+
/// Get a capability data set by \c Plugin_setCapability .
300+
PluginCapabilityPtr _Nullable Plugin_getCapability(PluginHandle handle);
298301

299302
/// Lock the plugin. Clients should lock it during sending and recving the
300303
/// response.
301-
void Plugin_lock(void *handle);
304+
void Plugin_lock(PluginHandle handle);
302305

303306
/// Unlock the plugin.
304-
void Plugin_unlock(void *handle);
307+
void Plugin_unlock(PluginHandle handle);
305308

306309
/// Sends the message to the plugin, returns true if there was an error.
307310
/// Clients should receive the response by \c Plugin_waitForNextMessage .
308-
_Bool Plugin_sendMessage(void *handle, const BridgedData data);
311+
_Bool Plugin_sendMessage(PluginHandle handle, const BridgedData data);
309312

310313
/// Receive a message from the plugin.
311-
_Bool Plugin_waitForNextMessage(void *handle, BridgedData *data);
314+
_Bool Plugin_waitForNextMessage(PluginHandle handle, BridgedData *data);
312315

313316
#ifdef __cplusplus
314317
}

lib/AST/CASTBridging.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -628,33 +628,33 @@ void Type_dump(void *expr) { ((TypeRepr *)expr)->dump(); }
628628
// Plugins
629629
//===----------------------------------------------------------------------===//
630630

631-
const void *Plugin_getCapability(void *handle) {
631+
PluginCapabilityPtr Plugin_getCapability(PluginHandle handle) {
632632
auto *plugin = static_cast<LoadedExecutablePlugin *>(handle);
633633
return plugin->getCapability();
634634
}
635635

636-
void Plugin_setCapability(void *handle, const void *data) {
636+
void Plugin_setCapability(PluginHandle handle, PluginCapabilityPtr data) {
637637
auto *plugin = static_cast<LoadedExecutablePlugin *>(handle);
638638
plugin->setCapability(data);
639639
}
640640

641-
void Plugin_lock(void *handle) {
641+
void Plugin_lock(PluginHandle handle) {
642642
auto *plugin = static_cast<LoadedExecutablePlugin *>(handle);
643643
plugin->lock();
644644
}
645645

646-
void Plugin_unlock(void *handle) {
646+
void Plugin_unlock(PluginHandle handle) {
647647
auto *plugin = static_cast<LoadedExecutablePlugin *>(handle);
648648
plugin->unlock();
649649
}
650650

651-
bool Plugin_sendMessage(void *handle, const BridgedData data) {
651+
bool Plugin_sendMessage(PluginHandle handle, const BridgedData data) {
652652
auto *plugin = static_cast<LoadedExecutablePlugin *>(handle);
653653
StringRef message(data.baseAddress, data.size);
654654
return plugin->sendMessage(message);
655655
}
656656

657-
bool Plugin_waitForNextMessage(void *handle, BridgedData *out) {
657+
bool Plugin_waitForNextMessage(PluginHandle handle, BridgedData *out) {
658658
auto *plugin = static_cast<LoadedExecutablePlugin *>(handle);
659659
auto result = plugin->waitForNextMessage();
660660
auto outPtr = malloc(result.size());

0 commit comments

Comments
 (0)