Skip to content

Commit df7884d

Browse files
committed
Add documentation for OGDebugServer
1 parent f5fa82a commit df7884d

File tree

3 files changed

+86
-4
lines changed

3 files changed

+86
-4
lines changed

Package.resolved

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Sources/OpenGraphCxx/include/OpenGraph/OGDebugServer.h

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,32 +12,113 @@
1212

1313
#if OG_TARGET_OS_DARWIN
1414

15+
/**
16+
* @header OGDebugServer.h
17+
* @abstract OpenGraph Debug Server API for runtime debugging and inspection.
18+
* @discussion The debug server provides runtime debugging capabilities for OpenGraph applications,
19+
* allowing external tools to connect and inspect graph state, dependencies, and execution.
20+
* This API is only available on Darwin platforms and requires network interface access
21+
* when used in network mode.
22+
*/
23+
1524
OG_ASSUME_NONNULL_BEGIN
1625

1726
OG_IMPLICIT_BRIDGING_ENABLED
1827

28+
/**
29+
* @typedef OGDebugServerRef
30+
* @abstract An opaque reference to a debug server instance.
31+
* @discussion The debug server manages a connection endpoint that external debugging tools
32+
* can use to inspect OpenGraph runtime state. Only one debug server instance
33+
* can be active at a time.
34+
*/
1935
typedef struct OGDebugServerStorage *OGDebugServerRef OG_SWIFT_STRUCT OG_SWIFT_NAME(DebugServer);
2036

37+
/**
38+
* @typedef OGDebugServerMode
39+
* @abstract Configuration modes for the debug server.
40+
* @discussion These flags control how the debug server operates and what interfaces it exposes.
41+
* Multiple modes can be combined using bitwise OR operations.
42+
*/
2143
typedef OG_OPTIONS(uint32_t, OGDebugServerMode) {
44+
/**
45+
* @abstract No debug server functionality.
46+
* @discussion Use this mode to disable all debug server operations.
47+
*/
2248
OGDebugServerModeNone = 0,
49+
50+
/**
51+
* @abstract Enable basic debug server validation and setup.
52+
* @discussion This mode enables the debug server with minimal functionality and is required
53+
* for any debug server operation. All other modes must be combined with this flag.
54+
*/
2355
OGDebugServerModeValid = 1 << 0,
56+
57+
/**
58+
* @abstract Enable network interface for remote debugging.
59+
* @discussion When enabled, the debug server will listen on a network interface, allowing
60+
* remote debugging tools to connect. Requires OGDebugServerModeValid to be set.
61+
*/
2462
OGDebugServerModeNetworkInterface = 1 << 1,
2563
} OG_SWIFT_NAME(OGDebugServerRef.Mode);
2664

2765
// MARK: - Exported C functions
2866

2967
OG_EXTERN_C_BEGIN
3068

69+
/**
70+
* @function OGDebugServerStart
71+
* @abstract Starts the shared debug server with the specified mode.
72+
* @discussion Creates and starts a new shared debug server instance. If a server is already
73+
* running, this function will return the existing instance.
74+
*
75+
* The returned reference should not be manually managed. Use OGDebugServerStop()
76+
* to properly shut down the shared server.
77+
* @param mode Configuration flags controlling server behavior.
78+
* Must include OGDebugServerModeValid for basic operation.
79+
* @result A reference to the started shared debug server, or NULL if the server
80+
* could not be started (e.g., due to network permissions, conflicts, or existing server).
81+
*/
3182
OG_EXPORT
83+
OG_REFINED_FOR_SWIFT
3284
OGDebugServerRef _Nullable OGDebugServerStart(OGDebugServerMode mode) OG_SWIFT_NAME(OGDebugServerRef.start(mode:));
3385

86+
/**
87+
* @function OGDebugServerStop
88+
* @abstract Stops and deletes the running shared debug server.
89+
* @discussion Shuts down the active shared debug server instance and cleans up all associated
90+
* resources. If no shared debug server is currently running, this function has no effect.
91+
*
92+
* This function should be called before application termination to ensure
93+
* proper cleanup of network resources and connections.
94+
*/
3495
OG_EXPORT
96+
OG_REFINED_FOR_SWIFT
3597
void OGDebugServerStop(void) OG_SWIFT_NAME(OGDebugServerRef.stop());
3698

99+
/**
100+
* @function OGDebugServerCopyURL
101+
* @abstract Returns the URL for connecting to the shared debug server.
102+
* @discussion Returns the URL that external debugging tools should use to connect to
103+
* the currently running shared debug server. The URL format depends on the server
104+
* configuration and may be a local or network address.
105+
*
106+
* The returned URL is only valid while the shared debug server is running.
107+
* It may change if the server is restarted.
108+
* @result A CFURLRef containing the connection URL, or NULL if no shared debug server
109+
* is currently running or if the server doesn't expose a connectable interface.
110+
* The caller is responsible for releasing the returned URL.
111+
*/
37112
OG_EXPORT
113+
OG_REFINED_FOR_SWIFT
38114
CFURLRef _Nullable OGDebugServerCopyURL(void) OG_SWIFT_NAME(OGDebugServerRef.copyURL());
39115

116+
/**
117+
* @function OGDebugServerRun
118+
* @abstract Runs the shared debug server event loop.
119+
*/
40120
OG_EXPORT
121+
OG_REFINED_FOR_SWIFT
41122
void OGDebugServerRun(int timeout) OG_SWIFT_NAME(OGDebugServerRef.run(timeout:));
42123

43124
OG_EXTERN_C_END

Sources/OpenGraphCxx/include/OpenGraphCxx/DebugServer/DebugServer.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,12 @@ class DebugServer {
7979
/// @return true if a shared server is active, false otherwise
8080
static OG_INLINE bool has_shared_server() { return _shared_server != nullptr; }
8181

82-
/// Starts a new shared debug server on the specified port.
82+
/// Starts a new shared debug server with the specified mode.
8383
///
84-
/// @param port The TCP port number to bind the server to
84+
/// @param mode Configuration flags controlling server behavior.
85+
/// Must include OGDebugServerModeValid for basic operation.
8586
/// @return Pointer to the started server, or nullptr if startup failed
86-
static DebugServer *_Nullable start(unsigned int port);
87+
static DebugServer *_Nullable start(OGDebugServerMode mode);
8788

8889
/// Stops the shared debug server and releases all resources.
8990
/// This will close all client connections and shut down the server.

0 commit comments

Comments
 (0)