Skip to content

Commit

Permalink
Remove unhelpful Ptr types
Browse files Browse the repository at this point in the history
  • Loading branch information
stroiman committed Jan 3, 2025
1 parent df8b531 commit 50b0c4b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 20 deletions.
14 changes: 7 additions & 7 deletions inspector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,35 +46,35 @@ void InspectorClient::consoleAPIMessage(int contextGroupId,

extern "C" {

InspectorPtr CreateInspector(v8Isolate* iso, InspectorClientPtr client) {
InspectorPtr inspector = V8Inspector::create(iso, client).release();
v8Inspector* CreateInspector(v8Isolate* iso, v8InspectorClient* client) {
v8Inspector* inspector = V8Inspector::create(iso, client).release();
return inspector;
}

void DeleteInspector(InspectorPtr inspector) {
void DeleteInspector(v8Inspector* inspector) {
delete inspector;
}

/********** InspectorClient **********/

InspectorClientPtr NewInspectorClient(uintptr_t callbackRef) {
v8InspectorClient* NewInspectorClient(uintptr_t callbackRef) {
return new InspectorClient(callbackRef);
}

void InspectorContextCreated(InspectorPtr inspector, ContextPtr context) {
void InspectorContextCreated(v8Inspector* inspector, ContextPtr context) {
LOCAL_CONTEXT(context);
int groupId = 1;
StringView name = StringView((const uint8_t*)"Test", 4);
V8ContextInfo info = V8ContextInfo(local_ctx, groupId, name);
inspector->contextCreated(info);
}

void InspectorContextDestroyed(InspectorPtr inspector, ContextPtr context) {
void InspectorContextDestroyed(v8Inspector* inspector, ContextPtr context) {
LOCAL_CONTEXT(context);
inspector->contextDestroyed(local_ctx);
}

void DeleteInspectorClient(InspectorClientPtr client) {
void DeleteInspectorClient(v8InspectorClient* client) {
delete client;
}
}
4 changes: 2 additions & 2 deletions inspector.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ const (
//
// See also: https://v8.github.io/api/head/classv8__inspector_1_1V8Inspector.html
type Inspector struct {
ptr C.InspectorPtr
ptr *C.v8Inspector
}

// An InspectorClient is the bridge from the [Inspector] to your code.
type InspectorClient struct {
ptr C.InspectorClientPtr
ptr *C.v8InspectorClient
clientHandle cgo.Handle
}

Expand Down
19 changes: 8 additions & 11 deletions inspector.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,13 @@ class V8InspectorClient;
}; // namespace v8_inspector

typedef v8::Isolate v8Isolate;
typedef v8_inspector::V8Inspector* InspectorPtr;
typedef v8_inspector::V8InspectorClient* InspectorClientPtr;
typedef v8_inspector::V8Inspector v8Inspector;
typedef v8_inspector::V8InspectorClient v8InspectorClient;

extern "C" {
#else
typedef struct v8Inspector v8Inspector;
typedef v8Inspector* InspectorPtr;

typedef struct v8InspectorClient v8InspectorClient;
typedef v8InspectorClient* InspectorClientPtr;

typedef struct v8Isolate v8Isolate;

Expand All @@ -36,14 +33,14 @@ typedef _Bool bool;
typedef struct m_ctx m_ctx;
typedef m_ctx* ContextPtr;

extern InspectorPtr CreateInspector(v8Isolate* iso, InspectorClientPtr client);
extern void DeleteInspector(InspectorPtr inspector);
extern void InspectorContextCreated(InspectorPtr inspector, ContextPtr context);
extern void InspectorContextDestroyed(InspectorPtr inspector,
extern v8Inspector* CreateInspector(v8Isolate* iso, v8InspectorClient* client);
extern void DeleteInspector(v8Inspector* inspector);
extern void InspectorContextCreated(v8Inspector* inspector, ContextPtr context);
extern void InspectorContextDestroyed(v8Inspector* inspector,
ContextPtr context);

extern InspectorClientPtr NewInspectorClient(uintptr_t callbackRef);
extern void DeleteInspectorClient(InspectorClientPtr client);
extern v8InspectorClient* NewInspectorClient(uintptr_t callbackRef);
extern void DeleteInspectorClient(v8InspectorClient* client);

typedef struct StringViewData {
bool is8bit;
Expand Down

0 comments on commit 50b0c4b

Please sign in to comment.