-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds support for writing macros in IonManagedWriter_1_1 (#934)
- Loading branch information
Showing
24 changed files
with
1,422 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package com.amazon.ion | ||
|
||
import com.amazon.ion.impl.macro.* | ||
|
||
/** | ||
* Extension of the IonWriter interface that supports writing macros. | ||
* | ||
* TODO: Consider exposing this as a Facet. | ||
*/ | ||
interface MacroAwareIonWriter : IonWriter { | ||
|
||
/** | ||
* Adds a macro to the macro table, returning a MacroRef that can be used to invoke the macro. | ||
*/ | ||
fun addMacro(macro: Macro): MacroRef | ||
|
||
/** | ||
* Adds a macro to the macro table, returning a MacroRef that can be used to invoke the macro. | ||
*/ | ||
fun addMacro(name: String, macro: Macro): MacroRef | ||
|
||
/** | ||
* Starts writing a macro invocation, adding it to the macro table, if needed. | ||
*/ | ||
fun startMacro(macro: Macro) | ||
|
||
/** | ||
* Starts writing a macro using the given [MacroRef]. | ||
*/ | ||
fun startMacro(macro: MacroRef) | ||
|
||
/** | ||
* Ends and steps out of the current macro invocation. | ||
*/ | ||
fun endMacro() | ||
|
||
/** | ||
* Starts writing an expression group. May only be called while the writer is in a macro invocation. | ||
*/ | ||
fun startExpressionGroup() | ||
|
||
/** | ||
* Ends and steps out of the current expression group. | ||
*/ | ||
fun endExpressionGroup() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package com.amazon.ion | ||
|
||
/** | ||
* Indicates that the implementing class has a standardized/built-in way to serialize as Ion. | ||
*/ | ||
interface WriteAsIon { | ||
|
||
/** | ||
* Writes this object to an IonWriter capable of producing macro invocations. | ||
*/ | ||
fun writeToMacroAware(writer: MacroAwareIonWriter) = writeTo(writer as IonWriter) | ||
|
||
/** | ||
* Writes this object to a standard [IonWriter]. | ||
*/ | ||
fun writeTo(writer: IonWriter) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.