diff --git a/CMakeLists.txt b/CMakeLists.txt index 03f688791d6..a1369818777 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ project(eosio_cdt) set(VERSION_MAJOR 1) set(VERSION_MINOR 3) -set(VERSION_PATCH 1) +set(VERSION_PATCH 2) if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) message(WARNING "CMAKE_INSTALL_PREFIX is set to default path of ${CMAKE_INSTALL_PREFIX}, resetting to ${CMAKE_INSTALL_PREFIX}/eosio.cdt") diff --git a/README.md b/README.md index 0671ab874f9..a8e85feb5a2 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # EOSIO.CDT (Contract Development Toolkit) -## Version : 1.3.1 +## Version : 1.3.2 EOSIO.CDT is a toolchain for WebAssembly (WASM) and set of tools to facilitate contract writing for the EOSIO platform. In addition to being a general purpose WebAssembly toolchain, [EOSIO](https://github.com/eosio/eos) specific optimizations are available to support building EOSIO smart contracts. This new toolchain is built around [Clang 7](https://github.com/eosio/llvm), which means that EOSIO.CDT has the most currently available optimizations and analyses from LLVM, but as the WASM target is still considered experimental, some optimizations are not available or incomplete. @@ -22,18 +22,18 @@ $ brew remove eosio.cdt ``` #### Debian Package Install ```sh -$ wget https://github.com/eosio/eosio.cdt/releases/download/v1.3.1/eosio.cdt-1.3.1.x86_64.deb -$ sudo apt install ./eosio.cdt-1.3.1.x86_64.deb +$ wget https://github.com/eosio/eosio.cdt/releases/download/v1.3.2/eosio.cdt-1.3.2.x86_64.deb +$ sudo apt install ./eosio.cdt-1.3.2.x86_64.deb ``` #### Debian Package Uninstall ```sh -$ sudo apt uninstall eosio.cdt +$ sudo apt remove eosio.cdt ``` #### RPM Package Install ```sh -$ wget https://github.com/eosio/eosio.cdt/releases/download/v1.3.1/eosio.cdt-1.3.1.x86_64-0.x86_64.rpm -$ sudo yum install ./eosio.cdt-1.3.1.x86_64-0.x86_64.rpm +$ wget https://github.com/eosio/eosio.cdt/releases/download/v1.3.2/eosio.cdt-1.3.2.x86_64-0.x86_64.rpm +$ sudo yum install ./eosio.cdt-1.3.2.x86_64-0.x86_64.rpm ``` #### RPM Package Uninstall @@ -56,12 +56,12 @@ $ sudo ./install.sh $ eosio-cpp -abigen hello.cpp -o hello.wasm ``` - Or with CMake - ```sh - $ mkdir build - $ cd build - $ cmake .. - $ make - ``` +```sh +$ mkdir build +$ cd build +$ cmake .. +$ make +``` This will generate two files: * The compiled binary wasm (hello.wasm) * The generated ABI file (hello.abi) @@ -182,7 +182,7 @@ This will generate one file: - Added new type `ignore`: - This type acts as a placeholder for actions that don't want to deserialize their fields but want the types to be reflected in the ABI. ```c - ACTION action(ignore) { some_type st; _ds >> st; } + ACTION action(ignore) { some_type st; _ds >> st; } ``` - Added new type `ignore_wrapper`: - This allows for calling `SEND_INLINE_ACTION` with `ignore_wrapper(some_value)` against an action with an `ignore` of matching types. @@ -207,23 +207,28 @@ This will generate one file: ### attributes - Added `[[eosio::ignore]]` attribute to flag a type as being ignored by the deserializer. This attribute is primarily only used for internal use within eosiolib. -- Added `[[eosio::contract]]` attribute. This new attribute is used to mark a contract class as "contract" with the name being either the C++ name of the class or a user specified name (i.e. `[[eosio::contract("somecontract")]]`). This attribute can also be used in conjunction with the `eosio::action` and `eosio::table` attributes for tables that you would like to define outside of the `eosio::contract` class. This is used in conjunction with either the raw `eosio-cpp` option `--contract `, `-o /.wasm` or with CMake `add_contract`. It acts as a filter enabling contract developers to include a header file with attributes from another contract (e.g. eosio.token) while generating an ABI devoid of those actions and tables. - ```c - CONTRACT test { - ACTION acta(){} - TABLE taba { - uint64_t a; - float b; - uint64_t primary_key() { return a; } - }; +- Added `[[eosio::contract]]` attribute. This new attribute is used to mark a contract class as "contract" with the name being either the C++ name of the class or a user specified name (i.e. `[[eosio::contract("somecontract")]]`). This attribute can also be used in conjunction with the `eosio::action` and `eosio::table` attributes for tables that you would like to define outside of the `eosio::contract` class. This is used in conjunction with either the raw `eosio-cpp` option `--contract `, `-o .wasm` or with CMake `add_contract`. It acts as a filter enabling contract developers to include a header file with attributes from another contract (e.g. eosio.token) while generating an ABI devoid of those actions and tables. + ```c++ + #include + using namespace eosio; + CONTRACT test : public eosio::contract { + public: + using contract::contract; + ACTION acta(){} + TABLE taba { + uint64_t a; + float b; + uint64_t primary_key() const { return a; } + }; }; struct [[eosio::table, eosio::contract("test")]] tabb { - uint64_t a; - int b + uint64_t a; + int b; }; typedef eosio::multi_index<"testtaba"_n, test::taba> table_a; typedef eosio::multi_index<"testtabb"_n, tabb> table_b; + EOSIO_DISPATCH( test, (acta) ) ``` The above code will produce the tables `testtaba` and `testtabb` in your ABI. Example: `eosio-cpp -abigen test.cpp -o test.wasm` will mark this compilation and ABI generation for the `eosio::contract` `test`. The same thing can be done with `eosio-cpp -abigen test.cpp -o test_contract.wasm --contract test` or with the CMake command `add_contract( test, test_contract, test.cpp )`. Either of the previous two approaches will produce a test_contract.wasm and test_contract.abi generated under the context of the contract name of `test`. @@ -240,23 +245,23 @@ Example (four ways to declare an action for ABI generation): // this is the C++11 and greater style attribute [[eosio::action]] void testa( name n ) { - // do something + // do something } // this is the GNU style attribute, this can be used in C code and prior to C++ 11 __attribute__((eosio_action)) void testa( name n ){ - // do something + // do something } struct [[eosio::action]] testa { - name n; - EOSLIB_SERIALIZE( testa, (n) ) + name n; + EOSLIB_SERIALIZE( testa, (n) ) }; struct __attribute__((eosio_action)) testa { - name n; - EOSLIB_SERIALIZE( testa, (n) ) + name n; + EOSLIB_SERIALIZE( testa, (n) ) }; ``` If your action name is not a valid [EOSIO name](https://developers.eos.io/eosio-cpp/docs/naming-conventions) you can explicitly specify the name in the attribute ```c++ [[eosio::action("")]]``` @@ -264,16 +269,16 @@ If your action name is not a valid [EOSIO name](https://developers.eos.io/eosio- Example (two ways to declare a table for ABI generation): ```c++ struct [[eosio::table]] testtable { - uint64_t owner; - /* all other fields */ + uint64_t owner; + /* all other fields */ }; struct __attribute__((eosio_table)) testtable { - uint64_t owner; - /* all other fields */ + uint64_t owner; + /* all other fields */ }; -typedef eosio::multi_index testtable_t; +typedef eosio::multi_index<"tablename"_n, testtable> testtable_t; ``` If you don't want to use the multi-index you can explicitly specify the name in the attribute ```c++ [[eosio::table("")]]```. @@ -327,7 +332,7 @@ CONTRACT test : public eosio::contract { public: using contract::contract; - ACTION testact( account_name test ) { + ACTION testact( name test ) { } }; diff --git a/eosio_llvm b/eosio_llvm index 37dd4a0a587..e0f9c15ad41 160000 --- a/eosio_llvm +++ b/eosio_llvm @@ -1 +1 @@ -Subproject commit 37dd4a0a587aea453541808a6a47cfcb704fd110 +Subproject commit e0f9c15ad4199a628dda25df589cad1634d01c5b diff --git a/libraries/eosiolib/symbol.hpp b/libraries/eosiolib/symbol.hpp index 762e1dc8796..da5cb747acd 100644 --- a/libraries/eosiolib/symbol.hpp +++ b/libraries/eosiolib/symbol.hpp @@ -262,9 +262,9 @@ namespace eosio { constexpr extended_symbol( symbol sym, name con ) : symbol(sym), contract(con) {} - constexpr symbol get_symbol() { return symbol; } + constexpr symbol get_symbol() const { return symbol; } - constexpr name get_contract() { return contract; } + constexpr name get_contract() const { return contract; } /** * %Print the extended symbol