Skip to content
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -493,3 +493,4 @@ src/ChibiRuby.Unity/UserSettings

src/ChibiRuby.Unity/Assets/Packages/*

.tools
54 changes: 54 additions & 0 deletions src/ChibiRuby.Debugger.Dap/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Regenerate the DAP protocol types + UTF-8 JSON serializer from the DAP JSON Schema.
#
# make schema # fetch upstream DAP schema + merge our overlay -> Schema/dap-schema.json
# make codegen # run NoJsonSchema over dap-schema.json -> Protocol/*.g.cs
# make regen # codegen only (schema is committed; no network)
# make test # run the DAP test suite
# make all # schema + codegen + test
#
# `codegen` uses the *released* NoJsonSchema.Cli dotnet tool from NuGet (pinned below),
# NOT the local ~/dev/NoJsonSchema source. Bump NOJSONSCHEMA_VERSION to adopt a newer release.

NOJSONSCHEMA_VERSION := 1.2.0

NAMESPACE := ChibiRuby.Debugger.Dap.Protocol
SCHEMA := Schema/dap-schema.json
OUT := Protocol
TOOL_DIR := .tools
NOJSONSCHEMA := $(TOOL_DIR)/nojsonschema
TEST_PROJECT := ../../tests/ChibiRuby.Debugger.Dap.Tests/ChibiRuby.Debugger.Dap.Tests.csproj

# $defs roots to generate. Synthesized *Body / inline-enum types come along transitively.
INCLUDE_TYPES := AttachRequest,AttachRequestArguments,AttachResponse,Breakpoint,BreakpointMode,Capabilities,Checksum,ChecksumAlgorithm,ColumnDescriptor,ConfigurationDoneArguments,ConfigurationDoneRequest,ConfigurationDoneResponse,ContinueArguments,ContinueRequest,ContinueResponse,ContinuedEvent,DisconnectArguments,DisconnectRequest,DisconnectResponse,ErrorResponse,EvaluateArguments,EvaluateRequest,EvaluateResponse,Event,ExceptionBreakpointsFilter,InitializeRequest,InitializeRequestArguments,InitializeResponse,InitializedEvent,LaunchRequest,LaunchRequestArguments,LaunchResponse,Message,NextArguments,NextRequest,NextResponse,OutputEvent,PauseArguments,PauseRequest,PauseResponse,ProtocolMessage,Request,Response,Scope,ScopesArguments,ScopesRequest,ScopesResponse,SetBreakpointsArguments,SetBreakpointsRequest,SetBreakpointsResponse,Source,SourceBreakpoint,StackFrame,StackFrameFormat,StackTraceArguments,StackTraceRequest,StackTraceResponse,StepInArguments,StepInRequest,StepInResponse,StepOutArguments,StepOutRequest,StepOutResponse,SteppingGranularity,StoppedEvent,TerminateArguments,TerminateRequest,TerminateResponse,TerminatedEvent,Thread,ThreadsRequest,ThreadsResponse,ValueFormat,Variable,VariablePresentationHint,VariablesArguments,VariablesRequest,VariablesResponse

# $defs (and synthesized bodies) emitted as `readonly partial record struct` value objects.
VALUE_OBJECTS := Checksum,ConfigurationDoneArguments,ContinueArguments,ContinueResponseBody,ContinuedEventBody,DisconnectArguments,ErrorResponseBody,NextArguments,PauseArguments,ScopesArguments,ScopesResponseBody,SetBreakpointsResponseBody,StackTraceResponseBody,StepOutArguments,TerminateArguments,TerminatedEventBody,Thread,ThreadsResponseBody,VariablesResponseBody

.PHONY: all schema codegen regen test tool clean-tool

all: schema codegen test

schema:
./Schema/build-schema.sh

# Install the pinned released tool into a local (gitignored) tool-path, idempotently.
tool:
@if [ ! -x "$(NOJSONSCHEMA)" ] || [ "$$($(NOJSONSCHEMA) --version 2>/dev/null)" != "$(NOJSONSCHEMA_VERSION)" ]; then \
echo "installing NoJsonSchema.Cli $(NOJSONSCHEMA_VERSION) -> $(TOOL_DIR)"; \
rm -rf "$(TOOL_DIR)"; \
dotnet tool install NoJsonSchema.Cli --version $(NOJSONSCHEMA_VERSION) --tool-path $(TOOL_DIR); \
fi

codegen regen: tool
$(NOJSONSCHEMA) generate \
-i $(SCHEMA) \
-o $(OUT) \
-n $(NAMESPACE) \
--value-object "$(VALUE_OBJECTS)" \
--include-type "$(INCLUDE_TYPES)"

test:
dotnet test $(TEST_PROJECT)

clean-tool:
rm -rf $(TOOL_DIR)
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,15 @@ internal static void ReadInto(ref Utf8JsonTokenizer tokenizer, BreakpointMode va

{
tokenizer.ReadStartArray();
var list_AppliesTo = new global::System.Collections.Generic.List<string>();
var buf_AppliesTo = global::System.Array.Empty<string>();
var count_AppliesTo = 0;
while (!tokenizer.TryReadEndArray())
{
list_AppliesTo.Add(tokenizer.ReadString());
if (count_AppliesTo == buf_AppliesTo.Length) global::System.Array.Resize(ref buf_AppliesTo, buf_AppliesTo.Length == 0 ? 4 : buf_AppliesTo.Length * 2);
buf_AppliesTo[count_AppliesTo++] = tokenizer.ReadString();
}
value.AppliesTo = list_AppliesTo.ToArray();
if (count_AppliesTo != buf_AppliesTo.Length) global::System.Array.Resize(ref buf_AppliesTo, count_AppliesTo);
value.AppliesTo = buf_AppliesTo;
}
else

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,18 @@ internal static void ReadInto(ref Utf8JsonTokenizer tokenizer, Capabilities valu

{
tokenizer.ReadStartArray();
var list_BreakpointModes = new global::System.Collections.Generic.List<BreakpointMode>();
var buf_BreakpointModes = global::System.Array.Empty<BreakpointMode>();
var count_BreakpointModes = 0;
while (!tokenizer.TryReadEndArray())
{
if (count_BreakpointModes == buf_BreakpointModes.Length) global::System.Array.Resize(ref buf_BreakpointModes, buf_BreakpointModes.Length == 0 ? 4 : buf_BreakpointModes.Length * 2);
tokenizer.ReadStartObject();
var elem = new BreakpointMode();
BreakpointModeFormatter.ReadInto(ref tokenizer, elem, options);
list_BreakpointModes.Add(elem);
buf_BreakpointModes[count_BreakpointModes++] = elem;
}
value.BreakpointModes = list_BreakpointModes.ToArray();
if (count_BreakpointModes != buf_BreakpointModes.Length) global::System.Array.Resize(ref buf_BreakpointModes, count_BreakpointModes);
value.BreakpointModes = buf_BreakpointModes;
}
}
else
Expand Down Expand Up @@ -287,15 +290,18 @@ internal static void ReadInto(ref Utf8JsonTokenizer tokenizer, Capabilities valu

{
tokenizer.ReadStartArray();
var list_AdditionalModuleColumns = new global::System.Collections.Generic.List<ColumnDescriptor>();
var buf_AdditionalModuleColumns = global::System.Array.Empty<ColumnDescriptor>();
var count_AdditionalModuleColumns = 0;
while (!tokenizer.TryReadEndArray())
{
if (count_AdditionalModuleColumns == buf_AdditionalModuleColumns.Length) global::System.Array.Resize(ref buf_AdditionalModuleColumns, buf_AdditionalModuleColumns.Length == 0 ? 4 : buf_AdditionalModuleColumns.Length * 2);
tokenizer.ReadStartObject();
var elem = new ColumnDescriptor();
ColumnDescriptorFormatter.ReadInto(ref tokenizer, elem, options);
list_AdditionalModuleColumns.Add(elem);
buf_AdditionalModuleColumns[count_AdditionalModuleColumns++] = elem;
}
value.AdditionalModuleColumns = list_AdditionalModuleColumns.ToArray();
if (count_AdditionalModuleColumns != buf_AdditionalModuleColumns.Length) global::System.Array.Resize(ref buf_AdditionalModuleColumns, count_AdditionalModuleColumns);
value.AdditionalModuleColumns = buf_AdditionalModuleColumns;
}
}
else if (__name.SequenceEqual("supportsDataBreakpoints"u8))
Expand Down Expand Up @@ -424,15 +430,18 @@ internal static void ReadInto(ref Utf8JsonTokenizer tokenizer, Capabilities valu

{
tokenizer.ReadStartArray();
var list_ExceptionBreakpointFilters = new global::System.Collections.Generic.List<ExceptionBreakpointsFilter>();
var buf_ExceptionBreakpointFilters = global::System.Array.Empty<ExceptionBreakpointsFilter>();
var count_ExceptionBreakpointFilters = 0;
while (!tokenizer.TryReadEndArray())
{
if (count_ExceptionBreakpointFilters == buf_ExceptionBreakpointFilters.Length) global::System.Array.Resize(ref buf_ExceptionBreakpointFilters, buf_ExceptionBreakpointFilters.Length == 0 ? 4 : buf_ExceptionBreakpointFilters.Length * 2);
tokenizer.ReadStartObject();
var elem = new ExceptionBreakpointsFilter();
ExceptionBreakpointsFilterFormatter.ReadInto(ref tokenizer, elem, options);
list_ExceptionBreakpointFilters.Add(elem);
buf_ExceptionBreakpointFilters[count_ExceptionBreakpointFilters++] = elem;
}
value.ExceptionBreakpointFilters = list_ExceptionBreakpointFilters.ToArray();
if (count_ExceptionBreakpointFilters != buf_ExceptionBreakpointFilters.Length) global::System.Array.Resize(ref buf_ExceptionBreakpointFilters, count_ExceptionBreakpointFilters);
value.ExceptionBreakpointFilters = buf_ExceptionBreakpointFilters;
}
}
else if (__name.SequenceEqual("supportsGotoTargetsRequest"u8))
Expand Down Expand Up @@ -519,12 +528,15 @@ internal static void ReadInto(ref Utf8JsonTokenizer tokenizer, Capabilities valu

{
tokenizer.ReadStartArray();
var list_CompletionTriggerCharacters = new global::System.Collections.Generic.List<string>();
var buf_CompletionTriggerCharacters = global::System.Array.Empty<string>();
var count_CompletionTriggerCharacters = 0;
while (!tokenizer.TryReadEndArray())
{
list_CompletionTriggerCharacters.Add(tokenizer.ReadString());
if (count_CompletionTriggerCharacters == buf_CompletionTriggerCharacters.Length) global::System.Array.Resize(ref buf_CompletionTriggerCharacters, buf_CompletionTriggerCharacters.Length == 0 ? 4 : buf_CompletionTriggerCharacters.Length * 2);
buf_CompletionTriggerCharacters[count_CompletionTriggerCharacters++] = tokenizer.ReadString();
}
value.CompletionTriggerCharacters = list_CompletionTriggerCharacters.ToArray();
if (count_CompletionTriggerCharacters != buf_CompletionTriggerCharacters.Length) global::System.Array.Resize(ref buf_CompletionTriggerCharacters, count_CompletionTriggerCharacters);
value.CompletionTriggerCharacters = buf_CompletionTriggerCharacters;
}
}
else if (__name.SequenceEqual("supportedChecksumAlgorithms"u8))
Expand All @@ -538,12 +550,15 @@ internal static void ReadInto(ref Utf8JsonTokenizer tokenizer, Capabilities valu

{
tokenizer.ReadStartArray();
var list_SupportedChecksumAlgorithms = new global::System.Collections.Generic.List<ChecksumAlgorithm>();
var buf_SupportedChecksumAlgorithms = global::System.Array.Empty<ChecksumAlgorithm>();
var count_SupportedChecksumAlgorithms = 0;
while (!tokenizer.TryReadEndArray())
{
list_SupportedChecksumAlgorithms.Add(ChecksumAlgorithmFormatter.ReadValue(ref tokenizer));
if (count_SupportedChecksumAlgorithms == buf_SupportedChecksumAlgorithms.Length) global::System.Array.Resize(ref buf_SupportedChecksumAlgorithms, buf_SupportedChecksumAlgorithms.Length == 0 ? 4 : buf_SupportedChecksumAlgorithms.Length * 2);
buf_SupportedChecksumAlgorithms[count_SupportedChecksumAlgorithms++] = ChecksumAlgorithmFormatter.ReadValue(ref tokenizer);
}
value.SupportedChecksumAlgorithms = list_SupportedChecksumAlgorithms.ToArray();
if (count_SupportedChecksumAlgorithms != buf_SupportedChecksumAlgorithms.Length) global::System.Array.Resize(ref buf_SupportedChecksumAlgorithms, count_SupportedChecksumAlgorithms);
value.SupportedChecksumAlgorithms = buf_SupportedChecksumAlgorithms;
}
}
else if (__name.SequenceEqual("supportsSteppingGranularity"u8))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,18 @@ internal static ScopesResponseBody ReadValue(ref Utf8JsonTokenizer tokenizer, No

{
tokenizer.ReadStartArray();
var list_Scopes = new global::System.Collections.Generic.List<Scope>();
var buf_Scopes = global::System.Array.Empty<Scope>();
var count_Scopes = 0;
while (!tokenizer.TryReadEndArray())
{
if (count_Scopes == buf_Scopes.Length) global::System.Array.Resize(ref buf_Scopes, buf_Scopes.Length == 0 ? 4 : buf_Scopes.Length * 2);
tokenizer.ReadStartObject();
var elem = new Scope();
ScopeFormatter.ReadInto(ref tokenizer, elem, options);
list_Scopes.Add(elem);
buf_Scopes[count_Scopes++] = elem;
}
__v_Scopes = list_Scopes.ToArray();
if (count_Scopes != buf_Scopes.Length) global::System.Array.Resize(ref buf_Scopes, count_Scopes);
__v_Scopes = buf_Scopes;
}
else

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,15 @@ internal static void ReadInto(ref Utf8JsonTokenizer tokenizer, SetBreakpointsArg

{
tokenizer.ReadStartArray();
var list_Lines = new global::System.Collections.Generic.List<ulong>();
var buf_Lines = global::System.Array.Empty<ulong>();
var count_Lines = 0;
while (!tokenizer.TryReadEndArray())
{
list_Lines.Add(tokenizer.ReadUInt64());
if (count_Lines == buf_Lines.Length) global::System.Array.Resize(ref buf_Lines, buf_Lines.Length == 0 ? 4 : buf_Lines.Length * 2);
buf_Lines[count_Lines++] = tokenizer.ReadUInt64();
}
value.Lines = list_Lines.ToArray();
if (count_Lines != buf_Lines.Length) global::System.Array.Resize(ref buf_Lines, count_Lines);
value.Lines = buf_Lines;
}
}
else
Expand Down Expand Up @@ -84,15 +87,18 @@ internal static void ReadInto(ref Utf8JsonTokenizer tokenizer, SetBreakpointsArg

{
tokenizer.ReadStartArray();
var list_Breakpoints = new global::System.Collections.Generic.List<SourceBreakpoint>();
var buf_Breakpoints = global::System.Array.Empty<SourceBreakpoint>();
var count_Breakpoints = 0;
while (!tokenizer.TryReadEndArray())
{
if (count_Breakpoints == buf_Breakpoints.Length) global::System.Array.Resize(ref buf_Breakpoints, buf_Breakpoints.Length == 0 ? 4 : buf_Breakpoints.Length * 2);
tokenizer.ReadStartObject();
var elem = new SourceBreakpoint();
SourceBreakpointFormatter.ReadInto(ref tokenizer, elem, options);
list_Breakpoints.Add(elem);
buf_Breakpoints[count_Breakpoints++] = elem;
}
value.Breakpoints = list_Breakpoints.ToArray();
if (count_Breakpoints != buf_Breakpoints.Length) global::System.Array.Resize(ref buf_Breakpoints, count_Breakpoints);
value.Breakpoints = buf_Breakpoints;
}
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,18 @@ internal static SetBreakpointsResponseBody ReadValue(ref Utf8JsonTokenizer token

{
tokenizer.ReadStartArray();
var list_Breakpoints = new global::System.Collections.Generic.List<Breakpoint>();
var buf_Breakpoints = global::System.Array.Empty<Breakpoint>();
var count_Breakpoints = 0;
while (!tokenizer.TryReadEndArray())
{
if (count_Breakpoints == buf_Breakpoints.Length) global::System.Array.Resize(ref buf_Breakpoints, buf_Breakpoints.Length == 0 ? 4 : buf_Breakpoints.Length * 2);
tokenizer.ReadStartObject();
var elem = new Breakpoint();
BreakpointFormatter.ReadInto(ref tokenizer, elem, options);
list_Breakpoints.Add(elem);
buf_Breakpoints[count_Breakpoints++] = elem;
}
__v_Breakpoints = list_Breakpoints.ToArray();
if (count_Breakpoints != buf_Breakpoints.Length) global::System.Array.Resize(ref buf_Breakpoints, count_Breakpoints);
__v_Breakpoints = buf_Breakpoints;
}
else

Expand Down
Loading
Loading