Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: binary schema #299

Merged
merged 1 commit into from
Jan 27, 2024
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
12 changes: 11 additions & 1 deletion Core/IO/BinarySchemaWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,17 @@ private void WriteDecorator(SchemaDecorator decorator)
WriteString(decorator.Identifier);
var arguments = decorator.Arguments;
// argument count
_writer.Write((byte)arguments.Count);
var count = (byte)arguments.Count;
if (count == 0)
{
_writer.Write((byte)0);
return;
}
if (count > byte.MaxValue)
{
throw new CompilerException($"Decorator {decorator.Identifier} has too many arguments: {count}");
}
_writer.Write(count);
var definition = decorator.Definition;
foreach (var argument in arguments)
{
Expand Down
2 changes: 1 addition & 1 deletion Core/Meta/WellKnownTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public static class ReservedWords
public const string CompilerName = "bebopc";
public const string SchemaExt = "bop";

public const byte SchemaLangVersion = 2;
public const byte SchemaLangVersion = 3;

public static HashSet<string> Identifiers = new()
{
Expand Down
4 changes: 2 additions & 2 deletions Repl/Pages/Index.razor
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
if (_selectedGenerator != value)
{
_selectedGenerator = value;
ShowOutput();

Check warning on line 51 in Repl/Pages/Index.razor

View workflow job for this annotation

GitHub Actions / build-repl

Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the 'await' operator to the result of the call.

Check warning on line 51 in Repl/Pages/Index.razor

View workflow job for this annotation

GitHub Actions / build-repl

Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the 'await' operator to the result of the call.
}
}
}
Expand Down Expand Up @@ -112,7 +112,7 @@

@functions {

private static readonly CompilerHost host = CompilerHost.CompilerHostBuilder.Create().WithDefaults().Build();
private static readonly CompilerHost host = CompilerHost.CompilerHostBuilder.Create("").WithDefaults().Build();
[JSInvokable]
public static string GetExampleSchema()
{
Expand Down Expand Up @@ -196,7 +196,7 @@
return new Repl.CompilerOutput
{
IsOk = !hasErrorDiagonstics,
Result = hasErrorDiagonstics ? string.Empty : generator.Compile(schema, generatorConfig),
Result = hasErrorDiagonstics ? string.Empty : generator.Compile(schema, generatorConfig).GetAwaiter().GetResult(),
Diagonstics = diagonstics
};
}
Expand All @@ -218,7 +218,7 @@
var co = CompileSchema(_schema, SelectedGenerator);
if (co.IsOk)
{
var languageId = SelectedGenerator switch

Check warning on line 221 in Repl/Pages/Index.razor

View workflow job for this annotation

GitHub Actions / build-repl

The switch expression does not handle all possible values of its input type (it is not exhaustive). For example, the pattern '""' is not covered.

Check warning on line 221 in Repl/Pages/Index.razor

View workflow job for this annotation

GitHub Actions / build-repl

The switch expression does not handle all possible values of its input type (it is not exhaustive). For example, the pattern '""' is not covered.
{
"ts" => "typescript",
"cs" => "csharp",
Expand All @@ -234,7 +234,7 @@
{
ReadOnly = true
});
await Global.SetModelLanguage(model, languageId);

Check warning on line 237 in Repl/Pages/Index.razor

View workflow job for this annotation

GitHub Actions / build-repl

'Global.SetModelLanguage(TextModel, string)' is obsolete: 'This method is deprecated as it's WASM only. Use the overload that takes an IJSRuntime parameter.'

Check warning on line 237 in Repl/Pages/Index.razor

View workflow job for this annotation

GitHub Actions / build-repl

'Global.SetModelLanguage(TextModel, string)' is obsolete: 'This method is deprecated as it's WASM only. Use the overload that takes an IJSRuntime parameter.'
await _previewEditor.SetValue(co.Result);

}
Expand Down
Loading
Loading