aboutsummaryrefslogtreecommitdiffstats
path: root/docs/types.rst
diff options
context:
space:
mode:
authorChase McDermott <chasemcd1745@tamu.edu>2018-07-15 05:42:01 +0800
committerChase McDermott <chasemcd1745@tamu.edu>2018-07-15 05:42:43 +0800
commit3267adcd14ba10e27a4b177e771fca9c9ab39646 (patch)
tree1c9b69f82d2af0e7eaf56b17188014b541b66ce8 /docs/types.rst
parent31e56f9f9976cee44f000226318dca566f0f0b79 (diff)
downloaddexon-solidity-3267adcd14ba10e27a4b177e771fca9c9ab39646.tar.gz
dexon-solidity-3267adcd14ba10e27a4b177e771fca9c9ab39646.tar.zst
dexon-solidity-3267adcd14ba10e27a4b177e771fca9c9ab39646.zip
Added default data locations to docs and other external tests.
Diffstat (limited to 'docs/types.rst')
-rw-r--r--docs/types.rst20
1 files changed, 10 insertions, 10 deletions
diff --git a/docs/types.rst b/docs/types.rst
index 16445a34..46e1a869 100644
--- a/docs/types.rst
+++ b/docs/types.rst
@@ -471,11 +471,11 @@ Another example that uses external function types::
}
Request[] requests;
event NewRequest(uint);
- function query(bytes data, function(bytes memory) external callback) public {
+ function query(bytes memory data, function(bytes memory) external callback) public {
requests.push(Request(data, callback));
emit NewRequest(requests.length - 1);
}
- function reply(uint requestID, bytes response) public {
+ function reply(uint requestID, bytes memory response) public {
// Here goes the check that the reply comes from a trusted source
requests[requestID].callback(response);
}
@@ -486,7 +486,7 @@ Another example that uses external function types::
function buySomething() {
oracle.query("USD", this.oracleResponse);
}
- function oracleResponse(bytes response) public {
+ function oracleResponse(bytes memory response) public {
require(
msg.sender == address(oracle),
"Only oracle can call this."
@@ -540,7 +540,7 @@ memory-stored reference type do not create a copy.
uint[] x; // the data location of x is storage
// the data location of memoryArray is memory
- function f(uint[] memoryArray) public {
+ function f(uint[] memory memoryArray) public {
x = memoryArray; // works, copies the whole array to storage
uint[] storage y = x; // works, assigns a pointer, data location of y is storage
y[7]; // fine, returns the 8th element
@@ -557,7 +557,7 @@ memory-stored reference type do not create a copy.
}
function g(uint[] storage storageArray) internal {}
- function h(uint[] memoryArray) public {}
+ function h(uint[] memory memoryArray) public {}
}
Summary
@@ -646,7 +646,7 @@ assigned to a variable right away.
function f() public pure {
g([uint(1), 2, 3]);
}
- function g(uint[3] _data) public pure {
+ function g(uint[3] memory _data) public pure {
// ...
}
}
@@ -713,7 +713,7 @@ Members
bool[2][] m_pairsOfFlags;
// newPairs is stored in memory - the default for function arguments
- function setAllFlagPairs(bool[2][] newPairs) public {
+ function setAllFlagPairs(bool[2][] memory newPairs) public {
// assignment to a storage array replaces the complete array
m_pairsOfFlags = newPairs;
}
@@ -739,7 +739,7 @@ Members
bytes m_byteData;
- function byteArrays(bytes data) public {
+ function byteArrays(bytes memory data) public {
// byte arrays ("bytes") are different as they are stored without padding,
// but can be treated identical to "uint8[]"
m_byteData = data;
@@ -748,11 +748,11 @@ Members
delete m_byteData[2];
}
- function addFlag(bool[2] flag) public returns (uint) {
+ function addFlag(bool[2] memory flag) public returns (uint) {
return m_pairsOfFlags.push(flag);
}
- function createMemoryArray(uint size) public pure returns (bytes) {
+ function createMemoryArray(uint size) public pure returns (bytes memory) {
// Dynamic memory arrays are created using `new`:
uint[2][] memory arrayOfPairs = new uint[2][](size);
// Create a dynamic byte array: