forked from iotaledger/wasp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2921b99
commit 5993c65
Showing
25 changed files
with
581 additions
and
132 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// Copyright 2020 IOTA Stiftung | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// (Re-)generated by schema tool | ||
// >>>> DO NOT CHANGE THIS FILE! <<<< | ||
// Change the json schema instead | ||
|
||
package testwasmlib | ||
|
||
import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" | ||
|
||
type Location struct { | ||
X int32 | ||
Y int32 | ||
} | ||
|
||
func NewLocationFromBytes(bytes []byte) *Location { | ||
decode := wasmlib.NewBytesDecoder(bytes) | ||
data := &Location{} | ||
data.X = decode.Int32() | ||
data.Y = decode.Int32() | ||
decode.Close() | ||
return data | ||
} | ||
|
||
func (o *Location) Bytes() []byte { | ||
return wasmlib.NewBytesEncoder(). | ||
Int32(o.X). | ||
Int32(o.Y). | ||
Data() | ||
} | ||
|
||
type ImmutableLocation struct { | ||
objID int32 | ||
keyID wasmlib.Key32 | ||
} | ||
|
||
func (o ImmutableLocation) Exists() bool { | ||
return wasmlib.Exists(o.objID, o.keyID, wasmlib.TYPE_BYTES) | ||
} | ||
|
||
func (o ImmutableLocation) Value() *Location { | ||
return NewLocationFromBytes(wasmlib.GetBytes(o.objID, o.keyID, wasmlib.TYPE_BYTES)) | ||
} | ||
|
||
type MutableLocation struct { | ||
objID int32 | ||
keyID wasmlib.Key32 | ||
} | ||
|
||
func (o MutableLocation) Delete() { | ||
wasmlib.DelKey(o.objID, o.keyID, wasmlib.TYPE_BYTES) | ||
} | ||
|
||
func (o MutableLocation) Exists() bool { | ||
return wasmlib.Exists(o.objID, o.keyID, wasmlib.TYPE_BYTES) | ||
} | ||
|
||
func (o MutableLocation) SetValue(value *Location) { | ||
wasmlib.SetBytes(o.objID, o.keyID, wasmlib.TYPE_BYTES, value.Bytes()) | ||
} | ||
|
||
func (o MutableLocation) Value() *Location { | ||
return NewLocationFromBytes(wasmlib.GetBytes(o.objID, o.keyID, wasmlib.TYPE_BYTES)) | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// Copyright 2020 IOTA Stiftung | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// (Re-)generated by schema tool | ||
// >>>> DO NOT CHANGE THIS FILE! <<<< | ||
// Change the json schema instead | ||
|
||
#![allow(dead_code)] | ||
#![allow(unused_imports)] | ||
|
||
use wasmlib::*; | ||
use wasmlib::host::*; | ||
use crate::typedefs::*; | ||
|
||
pub struct Location { | ||
pub x : i32, | ||
pub y : i32, | ||
} | ||
|
||
impl Location { | ||
pub fn from_bytes(bytes: &[u8]) -> Location { | ||
let mut decode = BytesDecoder::new(bytes); | ||
Location { | ||
x : decode.int32(), | ||
y : decode.int32(), | ||
} | ||
} | ||
|
||
pub fn to_bytes(&self) -> Vec<u8> { | ||
let mut encode = BytesEncoder::new(); | ||
encode.int32(self.x); | ||
encode.int32(self.y); | ||
return encode.data(); | ||
} | ||
} | ||
|
||
pub struct ImmutableLocation { | ||
pub(crate) obj_id: i32, | ||
pub(crate) key_id: Key32, | ||
} | ||
|
||
impl ImmutableLocation { | ||
pub fn exists(&self) -> bool { | ||
exists(self.obj_id, self.key_id, TYPE_BYTES) | ||
} | ||
|
||
pub fn value(&self) -> Location { | ||
Location::from_bytes(&get_bytes(self.obj_id, self.key_id, TYPE_BYTES)) | ||
} | ||
} | ||
|
||
pub struct MutableLocation { | ||
pub(crate) obj_id: i32, | ||
pub(crate) key_id: Key32, | ||
} | ||
|
||
impl MutableLocation { | ||
pub fn delete(&self) { | ||
del_key(self.obj_id, self.key_id, TYPE_BYTES); | ||
} | ||
|
||
pub fn exists(&self) -> bool { | ||
exists(self.obj_id, self.key_id, TYPE_BYTES) | ||
} | ||
|
||
pub fn set_value(&self, value: &Location) { | ||
set_bytes(self.obj_id, self.key_id, TYPE_BYTES, &value.to_bytes()); | ||
} | ||
|
||
pub fn value(&self) -> Location { | ||
Location::from_bytes(&get_bytes(self.obj_id, self.key_id, TYPE_BYTES)) | ||
} | ||
} |
Oops, something went wrong.