-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #938 from polywrap/chore/rollback-serial-as-json
Chore: Rollback JSON Serialization in AS
- Loading branch information
Showing
17 changed files
with
201 additions
and
218 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
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
7 changes: 0 additions & 7 deletions
7
packages/schema/bind/src/bindings/assemblyscript/wasm-as/templates/json_methods.mustache
This file was deleted.
Oops, something went wrong.
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
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
27 changes: 21 additions & 6 deletions
27
packages/test-cases/cases/wrappers/wasm-as/json-type/schema.graphql
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 |
---|---|---|
@@ -1,9 +1,24 @@ | ||
type Module { | ||
fromJson(json: JSON!): Pair! | ||
toJson(pair: Pair!): JSON! | ||
} | ||
parse( | ||
value: String! | ||
): JSON! | ||
|
||
stringify( | ||
values: [JSON!]! | ||
): String! | ||
|
||
type Pair { | ||
x: Int! | ||
y: Int! | ||
stringifyObject( | ||
object: Object! | ||
): String! | ||
|
||
methodJSON( | ||
valueA: Int! | ||
valueB: String! | ||
valueC: Boolean! | ||
): JSON! | ||
} | ||
|
||
type Object { | ||
jsonA: JSON! | ||
jsonB: JSON! | ||
} |
36 changes: 29 additions & 7 deletions
36
packages/test-cases/cases/wrappers/wasm-as/json-type/src/index.ts
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 |
---|---|---|
@@ -1,14 +1,36 @@ | ||
import { | ||
Input_fromJson, | ||
Input_toJson, | ||
Pair | ||
Input_parse, | ||
Input_stringify, | ||
Input_stringifyObject, | ||
Input_methodJSON | ||
} from "./wrap"; | ||
import { JSON } from "@polywrap/wasm-as"; | ||
|
||
export function fromJson(input: Input_fromJson): Pair { | ||
return Pair.fromJson(input.json); | ||
export function parse(input: Input_parse): JSON.Value { | ||
return JSON.parse(input.value); | ||
} | ||
|
||
export function toJson(input: Input_toJson): JSON.Value { | ||
return Pair.toJson(input.pair); | ||
export function stringify(input: Input_stringify): string { | ||
let str = ""; | ||
for (let i = 0; i < input.values.length; ++i) { | ||
const value = input.values[i]; | ||
str += value.stringify(); | ||
} | ||
return str; | ||
} | ||
|
||
export function stringifyObject(input: Input_stringifyObject): string { | ||
let str = ""; | ||
str += input.object.jsonA.stringify(); | ||
str += input.object.jsonB.stringify(); | ||
return str; | ||
} | ||
|
||
export function methodJSON(input: Input_methodJSON): JSON.Value { | ||
const result = JSON.Value.Object(); | ||
result.set("valueA", JSON.from(input.valueA)); | ||
result.set("valueB", JSON.from(input.valueB)); | ||
result.set("valueC", JSON.from(input.valueC)); | ||
|
||
return result; | ||
} |
Oops, something went wrong.