Compare commits

...

204 Commits

Author SHA1 Message Date
Dmytro Sydorchenko 3ca6b98f63 use correct leap commit for bls test 2023-07-26 17:02:11 -04:00
Dmytro Sydorchenko 45135cdd17 switch branch to commit 2023-07-25 21:01:07 -04:00
Dmytro Sydorchenko 3f9fa48c51 fixing integration tests for bls 2023-07-25 20:54:49 -04:00
Areg Hayrapetian b540790b05 Merge pull request #154 from mschoenebeck/main
BLS12-381 Crypto Primitives
2023-07-18 11:18:19 -07:00
mschoenebeck 3f701e2ea9 better fp2 type 2023-06-30 14:29:38 -05:00
mschoenebeck 8a18e7a976 Merge branch 'main' of https://github.com/AntelopeIO/cdt 2023-06-30 10:38:20 -05:00
mschoenebeck 9d1424dfcf added bls types to enforce correct operand sizes 2023-06-30 10:18:46 -05:00
mschoenebeck 7a6dfcb4a5 added bls integration tests 2023-06-30 08:42:30 -05:00
dimas1185 b5d71e23d6 Merge pull request #195 from dapp-protocols/update-catch2
[Meta-Refl] Update catch2 to v2.13.10
2023-06-29 13:29:27 -04:00
mschoenebeck 21a82212b3 don't throw but propagate error back to smart contract to be handled there 2023-06-27 19:32:22 -05:00
mikelik 2838fe7641 Merge pull request #194 from AntelopeIO/mikelik/clang-fix
compile with clang-16
2023-06-22 04:07:53 +02:00
Nathaniel baa6147ee3 [Meta-Refl] Update catch2 to v2.13.10
The version of catch2 in use is old enough to fail compiles on updated
Linux operating systems. Update to latest version in v2.0 series to
fix builds.

[Ref: https://github.com/catchorg/Catch2/issues/2421]
2023-06-17 13:21:36 -05:00
Michal Lesiak 7b058b424a Add llvm on ubuntu22 2023-06-16 16:10:37 +02:00
Michal Lesiak 6ed17a2b10 Replace is_callable_v with is_invocable 2023-06-16 13:56:59 +02:00
mschoenebeck 2975faaca2 update according to leap update 2023-06-07 18:15:35 -05:00
mschoenebeck 9142b6929f Merge branch 'main' of https://github.com/AntelopeIO/cdt 2023-06-07 16:02:15 -05:00
mschoenebeck 5a97108c6e removed bls types leftovers 2023-06-06 12:53:35 -05:00
Matt Witherspoon 78ced4c9ef Merge pull request #183 from AntelopeIO/stable-main
Stable main
2023-05-31 17:39:10 -04:00
Matt Witherspoon df628a1409 Merge pull request #187 from AntelopeIO/integration_tests_ci_main
[4.0 -> main] merge up #172 (CI integration tests), #182 (4.0 stable bump?)
2023-05-31 17:30:01 -04:00
Matt Witherspoon 44379dc422 Merge remote-tracking branch 'origin/release/4.0' into integration_tests_ci_main 2023-05-24 14:47:20 -04:00
Matt Witherspoon 09611db7ad Merge pull request #172 from AntelopeIO/integration_tests_ci
[4.0] run integration tests in CI with libtester from leap-dev.deb
2023-05-24 14:37:08 -04:00
mschoenebeck 80ef3056dc fixed submodule 2023-05-24 06:28:13 -05:00
mschoenebeck e2bec04986 synced with Antelope/main 2023-05-24 06:19:51 -05:00
mschoenebeck f778277931 sync with branch 'main' of https://github.com/AntelopeIO/cdt 2023-05-24 06:15:26 -05:00
mschoenebeck 861a86e500 removed bls types 2023-05-24 06:01:23 -05:00
Bucky Kittinger ca030252d9 Merge pull request #182 from AntelopeIO/4.0-stable
4.0-rc1 to stable
2023-05-23 11:41:05 -04:00
Alexander Molchevsky aa6efda41d Merge pull request #181 from AntelopeIO/crypto_api_update_proposal
Proposal: Update description of the crypto API to make it more user friendly
2023-05-23 17:17:27 +03:00
Bucky Kittinger 17cfeb8787 merge 2023-05-22 19:14:44 -04:00
Bucky Kittinger 64ee044632 revert antler-proj 2023-05-22 19:14:17 -04:00
Alexander Molchevsky 5b06bd3451 Apply suggestions from code review
a few grammatical changes were made

Co-authored-by: Scott B <Scott@TheBaileyFamily.org>
2023-05-23 00:06:53 +03:00
Bucky Kittinger c2eb13a427 Update build.yaml 2023-05-22 14:57:10 -04:00
Bucky Kittinger 8671ca2677 Merge branch '4.0-stable' into stable-main 2023-05-22 14:10:47 -04:00
Bucky Kittinger 360ce588a2 bump version 2023-05-22 14:10:12 -04:00
Dmytro Sydorchenko 86c38b5d28 #174 concerns addressed 2023-05-22 14:08:41 -04:00
Dmytro Sydorchenko 78e2b702a4 fix endian.h ending 2023-05-22 14:08:35 -04:00
Dmytro Sydorchenko 2e22f4742c fix warning in endian.h 2023-05-22 14:08:27 -04:00
Dmytro Sydorchenko a399d87d35 update 2023-05-22 14:04:55 -04:00
Bucky Kittinger 338cf85c17 update 2023-05-22 14:00:49 -04:00
Dmytro Sydorchenko 79797d4449 fix antler-proj ubuntu 18 build 2023-05-22 13:58:07 -04:00
Dmytro Sydorchenko 9d5531fb95 fix integration tests 2023-05-22 13:57:46 -04:00
Dmytro Sydorchenko d858a415f3 fixing abi for singleton with non-table type 2023-05-22 13:57:39 -04:00
Alexander Molchevsky a7fa7519b6 Updated after review 2023-05-19 21:48:41 +03:00
Alexander Molchevsky 4bae47bf94 Description of the Crypto API was updated 2023-05-19 08:06:44 +03:00
dimas1185 e3ef75c352 Merge pull request #178 from AntelopeIO/fix-abi-singleton
fixing abi for singleton with non-table type
2023-05-18 17:47:25 -04:00
mikelik 8a6bfbde42 Merge pull request #179 from AntelopeIO/mikelik/crud
Add insert, remove and update methods to multi_index (and index)
2023-05-18 16:23:59 +02:00
Michal Lesiak 65f928fcde Code review improvements 2023-05-18 15:04:57 +02:00
Michal Lesiak a1aae5f8d2 Update tests to cover both const and non-const version of remove() 2023-05-18 15:04:57 +02:00
Michal Lesiak 2b0fd5c55b Get rid of const obj for new modify() method. 2023-05-18 15:04:57 +02:00
Michal Lesiak 94ca0508dd Add insert, remove and update methods to multi_index (and index) 2023-05-18 15:04:57 +02:00
Dmytro Sydorchenko 46c13e9e9d fix integration tests 2023-05-17 17:34:17 -04:00
Alexander Molchevsky 5683746983 Merge pull request #180 from AntelopeIO/revert_new_cdt-abidiff
Revert "Added an implementation of a new cdt-abidiff"
2023-05-17 17:44:58 +03:00
Alexander Molchevsky 5931b591c5 Revert "Added an implementation of a new cdt-abidiff"
This reverts commit 20890cd510.
2023-05-17 15:08:49 +03:00
Dmytro Sydorchenko 23510b2d3c fixing abi for singleton with non-table type 2023-05-15 21:57:27 -04:00
dimas1185 aa0904a420 Merge pull request #177 from AntelopeIO/endian-warning-fix
Endian.h warning fix
2023-05-11 10:02:24 -04:00
Dmytro Sydorchenko 9a7e23f8f4 fix antler-proj ubuntu 18 build 2023-05-10 19:55:37 -04:00
mikelik 99e80b1b9a Merge pull request #158 from AntelopeIO/ehp/GH-157-doc-fix-clang-tidy
Doc Fix: Update Readme to install dep clang-tidy
2023-05-09 10:44:10 +02:00
dimas1185 34ccbaf915 Merge pull request #173 from AntelopeIO/endian-warning-fix
fix warning in endian.h
2023-05-08 21:11:42 -04:00
Dmytro Sydorchenko e38eef334d #174 concerns addressed 2023-05-08 20:57:45 -04:00
Dmytro Sydorchenko 1010b703af fix endian.h ending 2023-05-05 14:11:17 -04:00
Bucky Kittinger dba60dfb3c Merge branch 'release/4.0' into integration_tests_ci 2023-05-04 14:15:02 -04:00
Bucky Kittinger 2632fb1b0b Merge branch 'release/4.0' into endian-warning-fix 2023-05-04 14:14:36 -04:00
Alexander Molchevsky 23a78365b1 Merge pull request #171 from AntelopeIO/crypto_ext_doc_upd
The crypto extensions documentation updated
2023-05-04 15:56:08 +03:00
Bucky Kittinger bfb1edb40b Merge pull request #174 from AntelopeIO/larryk85/version_bump
version bump
2023-05-04 08:45:47 -04:00
Bucky Kittinger 567106266a update antler-proj submodulde 2023-05-04 08:22:52 -04:00
Bucky Kittinger f9a08ebfd4 Update README.md 2023-05-03 23:33:16 -04:00
Bucky Kittinger 84754fed3c version bump 2023-05-03 22:55:48 -04:00
Bucky Kittinger dc230529fd Merge branch 'main' into integration_tests_ci 2023-05-03 22:53:51 -04:00
Bucky Kittinger 5fe3166773 Merge branch 'main' into crypto_ext_doc_upd 2023-05-03 22:53:01 -04:00
Dmytro Sydorchenko d26cefa1f6 fix warning in endian.h 2023-05-03 22:25:44 -04:00
dimas1185 822ab27793 Merge pull request #170 from AntelopeIO/bump-leap-ver
leap 4.0 compatibility
2023-05-03 20:11:00 -04:00
Matt Witherspoon 146541f724 run integration tests in CI with libtester from leap-dev.deb 2023-05-03 19:24:54 -04:00
Alexander Molchevsky 19d33cca18 The crypto extensions documentation was reviewed and updated 2023-05-03 13:47:40 +03:00
Dmytro Sydorchenko fd8857c599 leap 4.0 compatibility 2023-05-02 20:07:57 -04:00
Matt Witherspoon 3619fc42cd Merge pull request #160 from AntelopeIO/remove_Runtime.h
remove unused `Runtime.h` include now removed in libtester's main
2023-05-01 14:59:48 -04:00
Matt Witherspoon 841315f9fd remove unused Runtime.h include now removed in libtester's main 2023-05-01 14:26:33 -04:00
Eric Passmore be7b70ccae note to install dep clang-tidy 2023-05-01 07:08:35 -07:00
mikelik a6d743aca8 Merge pull request #129 from AntelopeIO/patch/readme-deb-typo-fix
Fix readme typos for deb installation
2023-04-24 16:20:01 +02:00
Alexander Molchevsky 54c2a8b0ee Merge pull request #151 from AntelopeIO/abidiff_objdump_manpages
Abidiff objdump manpages
2023-04-24 17:11:05 +03:00
mschoenebeck c82a076e38 added bls12-381 crypto primitives 2023-04-22 08:39:49 -05:00
mikelik 06f0b13a86 Merge pull request #149 from AntelopeIO/mikelik/docs_troubleshooting_map
Add new troubleshooting section for generating abi for maps
2023-04-21 10:19:37 +02:00
mikelik e328ca8b15 Update docs/08_troubleshooting/index.md
code review rephrase

Co-authored-by: Scott B <Scott@TheBaileyFamily.org>
2023-04-21 09:53:00 +02:00
dimas1185 d5db46785c Merge pull request #146 from AntelopeIO/multi-index-fix
multi_index bugfix after migration from boost + tests
2023-04-20 17:49:53 -04:00
Alexander Molchevsky f48c430486 Updated after review 2023-04-19 00:13:07 +03:00
Scott B 090313bf50 Merge pull request #152 from AntelopeIO/sbailey/gitignore_more_builds
Added additional build and editor files.
2023-04-18 14:48:58 -05:00
Scott Bailey 8ae841d10b Added additional build and editor files. 2023-04-18 10:32:43 -05:00
Alexander Molchevsky bb076ec700 Wrong file was deleted 2023-04-18 15:20:58 +03:00
Alexander Molchevsky abecf721bf A name tag updated 2023-04-18 15:17:57 +03:00
Alexander Molchevsky 52263dbb78 Added new man pages for cdt-abidiff and cdt-objdump 2023-04-18 15:10:22 +03:00
Alexander Molchevsky 64746cfab7 Merge pull request #144 from AntelopeIO/cdt-ld_man_page
cdt-ld man page created
2023-04-18 15:06:33 +03:00
Alexander Molchevsky 77dfd8fda3 Merge pull request #145 from AntelopeIO/cdt-cc_man_page
cdt-cc man page created
2023-04-18 15:06:11 +03:00
Michal Lesiak c625b1bdd7 Add new troubleshooting section for backward incompatible change in accessing std::map from CDT 3.0.1 2023-04-17 15:26:34 +02:00
Alexander Molchevsky 20890cd510 Added an implementation of a new cdt-abidiff 2023-04-17 14:18:55 +03:00
Alexander Molchevsky 968f4a7822 The headers changed 2023-04-17 13:51:27 +03:00
Alexander Molchevsky 452ebb1dd4 The headers changed 2023-04-17 13:36:48 +03:00
Dmytro Sydorchenko e77c18e74a multi_index bugfix after migration from boost + tests 2023-04-14 20:04:59 -04:00
Alexander Molchevsky 3780ad2e6c cdt-cc man page created 2023-04-14 17:39:47 +03:00
Alexander Molchevsky 5a0e481e9b cdt-ld man page created 2023-04-14 17:26:34 +03:00
Alexander Molchevsky ab285eb34f Merge pull request #139 from AntelopeIO/man_pages
cdt-cpp man page added
2023-04-13 21:22:59 +03:00
Alexander Molchevsky ef0139b059 cdt-cpp man page updated after review 2023-04-13 16:57:12 +03:00
Alexander Molchevsky 1bd27a8494 cdt-cpp man page updated after review 2023-04-13 14:48:34 +03:00
Alexander Molchevsky 655f4565d0 cdt-cpp man page updated after review 2023-04-13 14:48:06 +03:00
Alexander Molchevsky ed378d905d cdt-cpp man page added 2023-04-12 17:54:51 +03:00
dimas1185 ac772cf0d8 Merge pull request #136 from AntelopeIO/cdt-init-fix 2023-04-11 21:50:18 -04:00
Dmytro Sydorchenko b5a319d5a5 fix cdt-init. see #60 2023-04-11 19:42:41 -04:00
dimas1185 d55ed814a6 Merge pull request #114 from AntelopeIO/add-antler-proj 2023-04-10 15:04:51 -04:00
Dmytro Sydorchenko 745cbdd53c add comment for commented out antler-run 2023-04-07 12:42:00 -04:00
Nathan James 4b60b49fd1 Fix readme typos for deb installation 2023-04-07 02:40:55 +03:00
Dmytro Sydorchenko 5e43caad78 cturtle update 2023-04-06 16:54:22 -04:00
Dmytro Sydorchenko e06b9f3335 ubuntu 18 build fix 2023-04-06 16:24:05 -04:00
Dmytro Sydorchenko 772926c08b revert back cturtle changes 2023-04-06 16:15:37 -04:00
Dmytro Sydorchenko 6510dd2719 adding custom cmake to ubuntu 18 build 2023-04-06 16:01:31 -04:00
Luis Paris 42a53d2597 Merge pull request #128 from AntelopeIO/fix-devrel#204
[3.1 -> main] Fix broken links in cdt repo
2023-04-06 12:34:08 -04:00
Luis 262b0f4875 fix url to license file 3.1 to main :doc 2023-04-06 12:11:03 -04:00
Luis e1f20450b7 Merge remote-tracking branch 'origin/release/3.1' into fix-devrel#204 2023-04-06 12:06:39 -04:00
Luis Paris a0902e5db7 Merge pull request #127 from AntelopeIO/fix-devrel#204-3.1
[3.0 -> 3.1] Fix broken links in cdt repo
2023-04-06 12:01:37 -04:00
Luis cf40868748 fix url to license file 3.0 to 3.1 :doc 2023-04-06 11:05:58 -04:00
Luis 8ae94b7190 Merge remote-tracking branch 'origin/release/3.0' into fix-devrel#204-3.1 2023-04-06 10:11:48 -04:00
Luis Paris bd3735e487 Merge pull request #126 from AntelopeIO/fix-devrel#204-3.0
[3.0] Fix broken links in cdt repo
2023-04-06 09:56:44 -04:00
mikelik 84a514fbda Merge pull request #125 from AntelopeIO/mikelik/singleton_fix
Fix getting wrong name of the table for singleton
2023-04-06 09:54:05 +02:00
Dmytro Sydorchenko 043dfa49ab ubuntu 18 build fix 2023-04-05 17:39:01 -04:00
Dmytro Sydorchenko 1a8b4d7c04 ubuntu 18 build fix 2023-04-05 15:01:07 -04:00
Michal Lesiak f32275b6b0 Fix getting wrong name of the table for singleton 2023-04-05 14:10:05 +02:00
Dmytro Sydorchenko b1fd200aa8 fixing ubuntu 22 build 2023-04-04 22:40:54 -04:00
Dmytro Sydorchenko b6220fbcea antler-proj updated 2023-04-04 22:32:37 -04:00
Matt Witherspoon 369119d15c Merge pull request #115 from AntelopeIO/filename_fixes
Fix some issues when building EOSIO contracts
2023-04-04 19:27:27 -07:00
Matt Witherspoon 9b1eb59964 use antelope not eosio for temp file prefix 2023-04-04 18:56:18 -04:00
Luis 94f51c8fd4 make lib references relative in how-tos 2023-03-31 00:31:34 -04:00
Luis 1e41e1ebf0 fix broken links to lib references in how-tos 2023-03-30 12:57:42 -04:00
Luis 6ed5f2d736 fix license broken link :doc 2023-03-27 15:36:35 -04:00
Bucky Kittinger 92116ada5e remove libcurl4-openssl 2023-03-27 07:35:49 -04:00
Bucky Kittinger 88d1569a93 update cicd 2023-03-27 05:45:53 -04:00
Bucky Kittinger be71fb0557 updates to allow for building and proper generation of packages 2023-03-27 05:06:43 -04:00
Bucky Kittinger 4027ddf7f2 Merge branch 'main' into add-antler-proj 2023-03-24 16:24:49 -04:00
Bucky Kittinger 5f8f201baa Merge pull request #117 from AntelopeIO/sbailey/additional_extended_asset_operators
Add extended_asset operators and unit tests.
2023-03-24 16:23:31 -04:00
Bucky Kittinger 1de734ccf5 Merge pull request #118 from AntelopeIO/mikelik/basic_string
Handle basic_string in datastream serializing/deserializing
2023-03-24 16:21:16 -04:00
Michal Lesiak da5547d016 Add back ds.read/write with bug fix. 2023-03-24 15:46:34 +01:00
Michal Lesiak 11abb4c503 Revert changes with datastream.write/read which do not handle correctly wide characters.
Add unit tests for 2 byte wchar_t.
2023-03-24 15:46:34 +01:00
Michal Lesiak 9abf293289 Code review fix - change from for loop to datastrem::write/read 2023-03-24 15:46:34 +01:00
Michal Lesiak b3803df627 Handle basic_string in datastream serializing/deserializing 2023-03-24 15:46:34 +01:00
Luis Paris f7c6ef3434 Merge pull request #120 from AntelopeIO/fix-devrel#204-main
[3.1 -> main] altering version rc1 -> no suffix; Fix wrong 3.0 version, use latest instead
2023-03-23 18:53:56 -04:00
Scott Bailey 84d75fe0d0 Use consts for asset values in extended_asset test. 2023-03-23 16:20:19 -05:00
Luis 58a2ec51a8 Merge remote-tracking branch 'origin/release/3.1' into fix-devrel#204-main 2023-03-23 17:03:55 -04:00
Luis Paris 23219b8d82 Merge pull request #119 from AntelopeIO/fix-devrel#204
[3.1] Fix wrong 3.0 version reference, use latest instead
2023-03-23 16:57:43 -04:00
Luis ea8bae3d7b fix small sentence construction :doc 2023-03-23 16:50:44 -04:00
Luis 8df5181245 fix wrong 3.0 version dep with latest instead :doc 2023-03-23 15:49:22 -04:00
Scott Bailey 3f606115d6 Add extended_asset operators and tests. 2023-03-21 17:25:52 -05:00
Scott B d89ea1d66a Merge pull request #100 from dapp-protocols/fix-abigen-templates
Resolve #99: Fix abigen with int expression template arguments
2023-03-20 09:27:13 -05:00
Scott B 3d14a671f7 Merge pull request #98 from dapp-protocols/fix-name-pk
Resolve #97: Allow `name` typed primary keys
2023-03-20 09:25:54 -05:00
Nathaniel 8dfff37a7b Ref #99: Add test
This test fails without the fix to issue #99, and passes with it.
The failure is a bit odd -- it doesn't fail because cdt-cpp crashes;
rather, it fails because the crashed cdt-cpp did not output an abi
file and therefore it cannot match the golden record... But hey, it
does test the issue, just rather indirectly. =)
2023-03-20 01:10:34 -05:00
Nathaniel Hourt 0b0c1c6fa9 Update tools/include/eosio/gen.hpp
Add braces

Co-authored-by: Scott B <Scott@TheBaileyFamily.org>
2023-03-20 01:10:34 -05:00
Nathaniel 92fae514ba Fix abigen with int expression template arguments
In my contracts, I use several template arguments which are expressions
which resolve to integral values (such as an eosio::name) but are
not literal integer values. This works great in my contracts, but
causes abigen to fail.

Fix abigen in cases where a template argument is an expression that
resolves to an integer, but isn't an integer literal.
2023-03-20 01:10:34 -05:00
Nathaniel faa9747a09 Ref #97/#98: Add unit test
Create a unit test for a table with a name primary key. The new test
fails to build before the commits in PReq #98, but passes when those
commits are included.
2023-03-19 19:07:48 -05:00
Nathaniel 9e8385bae4 Ref #98: Shorten primary_key_cast to to_raw_pk 2023-03-19 18:35:54 -05:00
Nathaniel cbb579d5b8 Fix build: add missing scope resolution 2023-03-19 18:29:02 -05:00
Nathaniel 3485d33798 Work around build issue
I'm not sure why this build failure occurs... It seems to me that the
requisite `auto` should be resolvable by the time the table is used,
but since it seems it is not, we give the compiler a hint to nudge it
to the right answer.

Using fancier syntax to make my problems go away =)
2023-03-18 22:53:08 -05:00
Nathaniel e6977a1cca [Name PK] Update accessors to allow name PK 2023-03-18 22:53:08 -05:00
Nathaniel b61ef08930 Allow multi_index pk to be a name 2023-03-18 22:53:08 -05:00
Matt Witherspoon 7909340966 Merge pull request #109 from dapp-protocols/issue-88
Resolve #88
2023-03-18 20:08:43 -07:00
Bucky Kittinger e7e19bb928 update ref 2023-03-16 21:49:17 -04:00
Steven Watanabe aeb707b16b Fix default output file. 2023-03-14 23:17:47 -04:00
Steven Watanabe 61bace3d3e Use proper temporary file names to avoid races. 2023-03-14 23:17:30 -04:00
Steven Watanabe b0dae1a2dd Fix dependency output. 2023-03-14 23:17:15 -04:00
Dmytro Sydorchenko cb02ee55fd fix build & test step: adding boost 2023-03-14 21:27:09 -04:00
Dmytro Sydorchenko 5f505262c0 fixing build & test step 2023-03-14 21:13:41 -04:00
Dmytro Sydorchenko a78788f1e6 fix build & test step 2023-03-14 20:58:08 -04:00
Dmytro Sydorchenko 32614bf8a9 install step fix 2023-03-14 20:50:34 -04:00
Dmytro Sydorchenko 87184a2103 fix build after adding antler-proj 2023-03-14 20:32:28 -04:00
Dmytro Sydorchenko 9736614860 add antler-proj to cdt 2023-03-14 20:23:31 -04:00
Nathaniel 887b129bde Ref #88 Review updates: check retval of intrinsic
Ensure the buffer was adequately large for the response and if not,
allocate sufficient space and call intrinsic again.
2023-03-13 21:26:55 -05:00
Matt Witherspoon 7c2c7e8c1d Merge pull request #113 from guilledk/fix_crypto_ext_inline
Resolve #110: Add missing inline declaration on blake2_f intrinsics helper
2023-03-07 19:00:59 -08:00
Matt Witherspoon 77308b625f Merge pull request #104 from YaroShkvorets/patch-1
Fix error message in division operator
2023-03-07 19:00:37 -08:00
Yaro Shkvorets bc52b103d8 Merge branch 'main' into patch-1 2023-03-07 21:44:20 -05:00
Guillermo Rodriguez 728f72c629 Add inline to blake2_f intrinsics 2023-03-07 14:21:22 -03:00
dimas1185 c4384f4bc5 Merge pull request #108 from AntelopeIO/remove-boost
Remove boost from eosiolib and native libraries
2023-03-03 19:08:48 -05:00
Nathaniel f7b206fe62 Resolve #88: Testing for get_code_hash 2023-02-26 13:40:16 -06:00
Nathaniel f78cbaa22d Ref #88: Implement wrapper for get_code_hash 2023-02-26 13:40:16 -06:00
Dmytro Sydorchenko cf2f1e9b3b build fix 2023-02-25 10:12:37 -05:00
Dmytro Sydorchenko caab530867 boost removed from eosiolib and native library 2023-02-24 22:04:57 -05:00
Lin Huang fb549b6cc3 Merge pull request #91 from AntelopeIO/crypto_ext_doc
add a new document explaining crypto extensions
2023-02-16 09:43:11 -05:00
dimas1185 950e7415a6 Merge pull request #94 from AntelopeIO/antler-run-base
Empty antler-run with eos-vm and eosiolib linked
2023-02-13 14:42:35 -05:00
YaroShkvorets 12c33d23fe fix test 2023-02-12 00:28:38 -05:00
Yaro Shkvorets b69b408df6 Fix division operator error 2023-02-11 15:58:17 -05:00
Dmytro Sydorchenko d1d41aa5f7 support of longjmp frpm shared object 2023-02-10 20:01:12 -05:00
Dmytro Sydorchenko ea20dd01ce reverting exceptions to jumps 2023-02-10 19:25:54 -05:00
Dmytro Sydorchenko 0a53b4a263 native library support of shared object 2023-02-09 16:52:01 -05:00
Dmytro Sydorchenko 23659dce80 native library shared object support 2023-02-09 16:22:37 -05:00
Dmytro Sydorchenko 226f497563 #94 concerns addressed 2023-02-03 13:45:49 -05:00
Dmytro Sydorchenko c47cb0f884 Revert "gcc 7 build fix"
This reverts commit f926d59c47.
2023-01-26 13:09:01 -05:00
Dmytro Sydorchenko 4c7d1bea9a eos-vm submodule ssh -> https for build server 2023-01-26 12:53:28 -05:00
Dmytro Sydorchenko 0c2e01dd6a update gcc for ubuntu 18 2023-01-25 17:45:38 -05:00
Dmytro Sydorchenko f926d59c47 gcc 7 build fix 2023-01-24 20:36:46 -05:00
Dmytro Sydorchenko 204b16eb7b fix ubuntu 18 build 2023-01-24 19:47:49 -05:00
Dmytro Sydorchenko 90506ff790 fix ubuntu 18 & 20 build 2023-01-24 18:56:51 -05:00
Dmytro Sydorchenko b7a0f32424 fixing ubuntu 18 & 20 builds 2023-01-24 18:47:49 -05:00
Dmytro Sydorchenko 37f7e3659d fix ubuntu 18 & 20 build 2023-01-24 17:28:50 -05:00
Dmytro Sydorchenko e7bc222c14 empty antler-run with eos-vm and eosiolib linked 2023-01-24 15:32:05 -05:00
dimas1185 a59ad639ba Merge pull request #87 from AntelopeIO/add-shared-object
add shared object option to CDTMacros
2023-01-23 18:04:45 -05:00
Dmytro Sydorchenko 18d575b43f removed duplication of rope_tests and policy to suppress this error 2023-01-23 16:43:46 -05:00
Lin Huang 5e6101d76d minor format corrections 2022-12-28 16:27:30 -05:00
Lin Huang fbded53d2c add a new document explaining new crypto extensions 2022-12-28 15:20:18 -05:00
Dmytro Sydorchenko 4d0173410a cdt-ld shared-object support added 2022-12-15 18:21:53 -05:00
Dmytro Sydorchenko 7efd2580d1 added shared object option to CDTMacros 2022-12-14 20:12:11 -05:00
dimas1185 a58860a250 Merge pull request #86 from AntelopeIO/bump_version
altering version rc1 -> no suffix
2022-12-14 18:12:52 -05:00
Dmytro Sydorchenko 3df8aff6bc altering version rc1 -> no suffix 2022-12-14 17:55:04 -05:00
120 changed files with 8075 additions and 397 deletions
+3
View File
@@ -7,5 +7,8 @@
},
"ubuntu22": {
"dockerfile": ".cicd/platforms/ubuntu22.Dockerfile"
},
"ubuntu22-llvm": {
"dockerfile": ".cicd/platforms/ubuntu22-llvm.Dockerfile"
}
}
+16 -3
View File
@@ -2,11 +2,21 @@ FROM ubuntu:bionic
RUN apt-get update && apt-get upgrade -y && \
DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential \
cmake \
g++-8 \
curl \
ninja-build \
software-properties-common \
zlib1g-dev
zlib1g-dev \
pkg-config \
libboost-all-dev \
libcurl4-gnutls-dev
RUN curl -L https://cmake.org/files/v3.13/cmake-3.13.5.tar.gz | tar zx && \
cd cmake-3.13.5 && \
./configure && \
make -j$(nproc) install && \
cd .. && \
rm -rf cmake-3.13.5
RUN add-apt-repository ppa:git-core/ppa && apt update && apt install -y git
@@ -15,4 +25,7 @@ RUN curl -L https://www.python.org/ftp/python/3.10.6/Python-3.10.6.tgz | tar zx
./configure --enable-optimizations --prefix=/usr && \
make -j$(nproc) install && \
cd .. && \
rm -rf Python*
rm -rf Python*
ENV CC=gcc-8
ENV CXX=g++-8
+4 -1
View File
@@ -5,4 +5,7 @@ RUN apt-get update && apt-get upgrade -y && \
cmake \
git \
ninja-build \
python3
python3 \
pkg-config \
libboost-all-dev \
libcurl4-gnutls-dev
+23
View File
@@ -0,0 +1,23 @@
FROM ubuntu:jammy
RUN apt-get update && apt-get upgrade -y && \
DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential \
cmake \
wget \
git \
ninja-build \
python3 \
pkg-config \
libboost-all-dev \
libcurl4-gnutls-dev \
lsb-release \
software-properties-common \
gnupg \
clang-tidy
RUN wget https://apt.llvm.org/llvm.sh
RUN chmod +x llvm.sh
RUN ./llvm.sh 16
ENV CC=clang-16
ENV CXX=clang++-16
+5 -1
View File
@@ -5,4 +5,8 @@ RUN apt-get update && apt-get upgrade -y && \
cmake \
git \
ninja-build \
python3
python3 \
pkg-config \
libboost-all-dev \
libcurl4-gnutls-dev \
clang-tidy
+20 -3
View File
@@ -60,19 +60,36 @@ jobs:
strategy:
fail-fast: false
matrix:
platform: [ubuntu18, ubuntu20, ubuntu22]
platform: [ubuntu18, ubuntu20, ubuntu22, ubuntu22-llvm]
runs-on: ["self-hosted", "enf-x86-beefy"]
container: ${{fromJSON(needs.d.outputs.p)[matrix.platform].image}}
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Download leap-dev.deb (Ubuntu 20 only)
if: matrix.platform == 'ubuntu20'
uses: AntelopeIO/asset-artifact-download-action@v2
with:
owner: AntelopeIO
repo: leap
file: 'leap-dev.*(x86_64|amd64).deb'
target: 8e63f2c047507184b4b37d6f942b2ecfdb70f950
artifact-name: leap-dev-ubuntu20-amd64
container-package: experimental-binaries
token: ${{github.token}}
- name: Install leap-dev.deb (Ubuntu 20 only)
if: matrix.platform == 'ubuntu20'
run: |
apt-get update && apt-get upgrade -y
apt install -y ./leap-dev*.deb
rm ./leap-dev*.deb
- name: Build & Test
run: |
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -GNinja ..
ninja
cmake -DCMAKE_BUILD_TYPE=Release ..
make -j $(nproc)
cd tests
ctest -j $(nproc) --output-on-failure
- name: Package (Ubuntu 18 only)
+2 -1
View File
@@ -35,7 +35,7 @@
.DS_Store
# Build
build/*
[Bb]uild*/
cmake-build-debug/
examples/multi_index_example/build
examples/hello/build
@@ -49,3 +49,4 @@ __pycache__/
*.vim
.idea/
.ccls-cache/
CMakeLists.txt.user
+6
View File
@@ -10,3 +10,9 @@
[submodule "libraries/native/softfloat"]
path = libraries/native/softfloat
url = https://github.com/AntelopeIO/berkeley-softfloat-3
[submodule "tools/external/eos-vm"]
path = tools/external/eos-vm
url = https://github.com/AntelopeIO/eos-vm
[submodule "tools/external/antler-proj"]
path = tools/external/antler-proj
url = https://github.com/AntelopeIO/antler-proj
+14 -3
View File
@@ -13,10 +13,10 @@ endif()
project(cdt)
set(VERSION_MAJOR 3)
set(VERSION_MINOR 2)
set(VERSION_MAJOR 4)
set(VERSION_MINOR 0)
set(VERSION_PATCH 0)
set(VERSION_SUFFIX dev)
set(VERSION_SUFFIX "")
if (VERSION_SUFFIX)
set(VERSION_FULL "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}-${VERSION_SUFFIX}")
@@ -93,6 +93,17 @@ configure_file(${CMAKE_SOURCE_DIR}/cdt-llvm/LICENSE.TXT ${CMAKE_BINARY_DIR}/lice
configure_file(${CMAKE_SOURCE_DIR}/libraries/boost/boost.license ${CMAKE_BINARY_DIR}/licenses/boost.license COPYONLY)
configure_file(${CMAKE_SOURCE_DIR}/libraries/meta_refl/LICENSE ${CMAKE_BINARY_DIR}/licenses/meta_refl.license COPYONLY)
configure_file(${CMAKE_SOURCE_DIR}/tools/external/wabt/LICENSE ${CMAKE_BINARY_DIR}/licenses/wabt.license COPYONLY)
configure_file(${CMAKE_SOURCE_DIR}/tools/external/antler-proj/LICENSE ${CMAKE_BINARY_DIR}/licenses/antler-proj.license COPYONLY)
file(GLOB license_files ${CMAKE_SOURCE_DIR}/tools/external/antler-proj/licenses/*)
# add licenses for antler-proj submodules
foreach(full_path IN ITEMS ${license_files})
# change format to match other license filenames
get_filename_component(file_name ${full_path} NAME)
string(REPLACE "LICENSE." "" file_name ${file_name})
string(TOLOWER ${file_name} file_name)
set(file_name "${file_name}.license")
configure_file("${full_path}" "${CMAKE_BINARY_DIR}/licenses/${file_name}" COPYONLY)
endforeach()
configure_file(${CMAKE_SOURCE_DIR}/tools/jsoncons/LICENSE ${CMAKE_BINARY_DIR}/licenses/jsoncons.license COPYONLY)
configure_file(${CMAKE_SOURCE_DIR}/LICENSE ${CMAKE_BINARY_DIR}/licenses/cdt.license COPYONLY)
+4 -3
View File
@@ -12,11 +12,11 @@ The `main` branch is the development branch: do not use this for production. Ref
CDT currently supports Linux x86_64 Debian packages. Visit the [release page](https://github.com/AntelopeIO/cdt/releases) to download the package for the appropriate version of CDT. This is the fastest way to get started with the software.
### Debian package install
The latest version of CDT is 3.0. Download the appropriate version of the Debian package and then install as follows:
Download the appropriate version of the Debian package and then install it. To download and install the latest version, run the following:
```sh
wget https://github.com/AntelopeIO/cdt/releases/download/v3.1.0-rc1/cdt_3.1.0-rc1_amd64.deb
sudo apt install ./cdt_3.1.0-rc1_amd64.deb
wget https://github.com/AntelopeIO/cdt/releases/download/v4.0.0/cdt_4.0.0_amd64.deb
sudo apt install ./cdt_4.0.0_amd64.deb
```
### Debian package uninstall
@@ -38,6 +38,7 @@ The instructions below assume that you are building on Ubuntu 20.04.
apt-get update && apt-get install \
build-essential \
clang \
clang-tidy \
cmake \
git \
libxml2-dev \
+194
View File
@@ -0,0 +1,194 @@
---
content_title: Crypto Extensions API
---
Antelope blockchain implements cryptographic functions for operations on points on elliptic curves, computing hashes
of big integers, big integer modular exponentiation, and other operations useful for implementing
cryptographic algorithms in your contracts.
In order to use the Crypto Extensions API you need to activate a protocol feature `CRYPTO_PRIMITIVES`
in `nodeos`. To do this you should call the following command in your command line:
`"cleos push action eosio activate ["6bcb40a24e49c26d0a60513b6aeb8551d264e4717f306b81a37a5afb3b47cedc"] -p eosio@active"`
And you need to include in the source code of your contract the following header: [crypto_ext.hpp](https://github.com/AntelopeIO/cdt/blob/main/libraries/eosiolib/core/eosio/crypto_ext.hpp)
The header declares following basic plain C functions which implement the core functionality:
## Plain C API
- `int32_t alt_bn128_add( const char* op1, uint32_t op1_len, const char* op2, uint32_t op2_len, char* result, uint32_t result_len )`
Perform addition operation on the elliptic curve `alt_bn128`, store the result in `result`, and return `0` if success otherwise `-1`
- `int32_t alt_bn128_mul( const char* g1, uint32_t g1_len, const char* scalar, uint32_t scalar_len, char* result, uint32_t result_len )`
Perform scalar multiplication operation on the elliptic curve `alt_bn128`
- `int32_t alt_bn128_pair( const char* pairs, uint32_t pairs_len )`
Perform Optimal-Ate pairing check elliptic curve `alt_bn128`, and return `0` if `true` and successful, `1` if `false`, otherwise `-1`
- `int32_t mod_exp( const char* base, uint32_t base_len, const char* exp, uint32_t exp_len, const char* mod, uint32_t mod_len, char* result, uint32_t result_len )`
Calculate `( BASE^EXP ) % MOD`, store in `result`, and return `0` if successful, otherwise `-1`
- `int32_t blake2_f( uint32_t rounds, const char* state, uint32_t state_len, const char* msg, uint32_t msg_len, const char* t0_offset, uint32_t t0_len, const char* t1_offset, uint32_t t1_len, int32_t final, char* result, uint32_t result_len)`
Implement BLAKE2 compression function `F`. Return `0` if success otherwise `-1`
- `eosio::checksum256 sha3(const char* data, uint32_t length)`
Return hash of `data` using `SHA3 NIST`
- `void assert_sha3(const char* data, uint32_t length, const eosio::checksum256& hash)`
Test if the SHA3 hash generated from data matches the provided digest
- `eosio::checksum256 keccak(const char* data, uint32_t length)`
Return hash of `data` using `SHA3 Keccak`
- `void assert_keccak(const char* data, uint32_t length, const eosio::checksum256& hash)
Test if the SHA3 keccak hash generated from data matches the provided digest
- `int32_t k1_recover( const char* sig, uint32_t sig_len, const char* dig, uint32_t dig_len, char* pub, uint32_t pub_len )`
Calculates the uncompressed public key used for a given signature on a given digest. Return `0` if success otherwise `-1`
Also, the header contains a set of handy C++ wrappers to simplify the contracts code.
## C++ API
`ec_point` type was added to represent `G1` and `G2` points on the elliptic curve.
`ec_point_view` type was added to provide a read-only interface for access to `G1` and `G2` points data.
### Data Types
```c++
// Abstracts mutable G1 and G2 points
template <std::size_t Size = 32>
struct ec_point {
std::vector<char> x; // x coordinate
std::vector<char> y; // y coordinate
// Construct from two coordinates represented by big integers
ec_point(std::vector<char>& x_, std::vector<char>& y_);
// Construct from a serialized point
ec_point(std::vector<char>& p);
// Return a serialized point containing only x and y
std::vector<char> serialized() const;
};
// Abstracts read-only G1 and G2 points
template <std::size_t Size = 32>
struct ec_point_view {
const char* x;
const char* y;
// Number of bytes in each of x and y
uint32_t size;
// Construct from two coordinates. Their sizes must be equal
ec_point_view(const char* x_, uint32_t x_size, const char* y_, uint32_t y_size);
// Construct from a serialized point
ec_point_view(const std::vector<char>& p);
// Construct a point view from a point
ec_point_view(const ec_point<Size>& p);
// Return serialized point containing only x and y
std::vector<char> serialized() const;
};
// Big integer.
using bigint = std::vector<char>;
```
### Methods
- Addition operation on the elliptic curve `alt_bn128`
```c++
template <typename T>
g1_point alt_bn128_add( const T& op1, const T& op2 )
```
- Scalar multiplication operation on the elliptic curve `alt_bn128`
```c++
template <typename T>
g1_point alt_bn128_mul( const T& g1, const bigint& scalar)
```
- Optimal-Ate pairing check elliptic curve `alt_bn128`
```c++
template <typename G1_T, typename G2_T>
int32_t alt_bn128_pair( const std::vector<std::pair<G1_T, G2_T>>& pairs )
```
- Big integer modular exponentiation returns `( BASE^EXP ) % MOD`
```c++
int32_t mod_exp( const bigint& base, const bigint& exp, const bigint& mod, bigint& result )
```
Please take a look into a [crypto_ext.hpp](https://github.com/AntelopeIO/cdt/blob/main/libraries/eosiolib/core/eosio/crypto_ext.hpp)
header file, it contains more wrappers and helper functions which may be useful in your code.
### Examples
- `alt_bn128_add`
```c++
std::vector<char> x1, y1, x2, y2; // Declare coordinates for points on an elliptic curve
// Create the points on the curve
eosio::g1_point point1 {x1, y1};
eosio::g1_point point2 {x2, y2};
// Add two points and get a third point on the curve as result
auto result = eosio::alt_bn128_add(point1, point2);
// Do the same addition but with g1_point_view data types
eosio::g1_point_view point_view1 {x1.data(), x1.size(), y1.data(), y1.size()};
eosio::g1_point_view point_view2 {x2.data(), x2.size(), y2.data(), y2.size()};
result = eosio::alt_bn128_add(point_view1, point_view2);
```
- `alt_bn128_mul`
```c++
// Declare coordinates for a point on an elliptic curve and a big integer
std::vector<char> x, y, scalar;
eosio::bigint s {scalar};
// Create the point object with given coordinates
eosio::g1_point g1_point {x, y};
// Multiply the point with a big integer and get a point on the curve as result
auto result = eosio::alt_bn128_mul(g1_point, s);
// Do the same multiplication but with g1_point_view data type
eosio::g1_point_view g1_view {x.data(), x.size(), y.data(), y.size()};
result = eosio::alt_bn128_mul(g1_view, s);
```
- `alt_bn128_pair`
```c++
// Declare coordinates for the pairs of points on an elliptic curve
std::vector<char> g1_a_x, g1_a_y, g2_a_x, g2_a_y, g1_b_x, g1_b_y, g2_b_x, g2_b_y;
// Create the point object by given coordinates
// First pair
eosio::g1_point g1_a {g1_a_x, g1_a_y};
eosio::g2_point g2_a {g2_a_x, g2_a_y};
// Second pair
eosio::g1_point g1_b {g1_b_x, g1_b_y};
eosio::g2_point g2_b {g2_b_x, g2_b_y};
// Create the pairs object
std::vector<std::pair<eosio::g1_point, eosio::g2_point>> pairs { {g1_a, g2_a}, {g1_b, g2_b} };
// Perform the pairing check
// Return:
// -1 if there is an error
// 1 if the points not in a target group
// 0 if the points in a target group
auto result = eosio::alt_bn128_pair(pairs);
// Do the same pairing check but with g1_point_view and g2_point_view data types
eosio::g1_point_view g1_view_a {g1_a_x.data(), g1_a_x.size(), g1_a_y.data(), g1_a_y.size()};
eosio::g2_point_view g2_view_a {g2_a_x.data(), g2_a_x.size(), g2_a_y.data(), g2_a_y.size()};
eosio::g1_point_view g1_view_b {g1_b_x.data(), g1_b_x.size(), g1_b_y.data(), g1_b_y.size()};
eosio::g2_point_view g2_view_b {g2_b_x.data(), g2_b_x.size(), g2_b_y.data(), g2_b_y.size()};
std::vector<std::pair<eosio::g1_point_view, eosio::g2_point_view>> view_pairs { {g1_a, g2_a}, {g1_b, g2_b} };
result = eosio::alt_bn128_pair(view_pairs);
```
- `mod_exp`
```c++
// Declare big integer variables for the base, the exponent and the modulo
std::vector<char> base, exp, modulo;
eosio::bigint base_val {base};
eosio::bigint exp_val {exp};
eosio::bigint modulo_val {modulo};
// Declare and init a big integer variable for the result of exponentiation
eosio::bigint result( modulo.size(), '\0' );
// Perform the exponentiation
// return -1 if there is an error otherwise 0
auto rc = eosio::mod_exp(base_val, exp_val, modulo_val, result);
```
@@ -16,10 +16,10 @@ This guide provides instructions how to perform authorization checks in a smart
See the following code reference guides for functions which can be used to implement authorization checks in a smart contract:
* function [has_auth(name n)](http://docs.eosnetwork.com/cdt/latest/reference/Namespaces/namespaceeosio#function-has_auth)
* function [require_auth(name n)](http://docs.eosnetwork.com/cdt/latest/reference/Namespaces/namespaceeosio#function-require_auth)
* function [require_auth2(capi_name name, capi_name permission)](http://docs.eosnetwork.com/cdt/latest/reference/Files/action_8h)
* function [check(bool pred, ...)](http://docs.eosnetwork.com/cdt/latest/reference/Namespaces/namespaceeosio#function-check)
* function [has_auth(name n)](../../reference/Namespaces/namespaceeosio#function-has_auth)
* function [require_auth(name n)](../../reference/Namespaces/namespaceeosio#function-require_auth)
* function [require_auth2(capi_name name, capi_name permission)](../../reference/Files/action_8h)
* function [check(bool pred, ...)](../../reference/Namespaces/namespaceeosio#function-check)
## Procedure
@@ -45,7 +45,7 @@ void hi( name user ) {
}
```
Another example can be found in the [Tic Tac Toe Tutorial](https://docs.eosnetwork.com/docs/latest/tutorials/tic-tac-toe-game-contract#action-handler---move).
Another example can be found in the [Tic Tac Toe Tutorial](https://docs.eosnetwork.com/docs/latest/smart-contracts/tutorials/tic-tac-toe-game-contract#create-tictactoecpp-file).
### 2. Use require_auth
@@ -10,13 +10,13 @@ This guide provides instructions to define a primary index for a multi-index tab
See the following code reference:
* The [`multi-index`](../../classeosio_1_1multi__index) class.
* The [`multi-index`](../../reference/Classes/classeosio_1_1multi__index) class.
## Before you begin
Make sure you have the following prerequisites in place:
* An Antelope development environment, for details consult the [Get Started Guide](https://docs.eosnetwork.com/docs/latest/getting-started/),
* An Antelope development environment, for details consult the [Documentation Portal](https://docs.eosnetwork.com/docs/latest/).
## Procedure
@@ -10,13 +10,13 @@ This guide provides instructions to define a secondary index for a multi-index t
See the following code reference:
* The [`multi-index`](../../classeosio_1_1multi__index) class.
* The [`multi-index`](../../reference/Classes/classeosio_1_1multi__index) class.
## Before you begin
Make sure you have the following prerequisites in place:
* An Antelope development environment, for details consult the [Get Started Guide](https://docs.eosnetwork.com/docs/latest/getting-started/),
* An Antelope development environment, for details consult the [Documentation Portal](https://docs.eosnetwork.com/docs/latest/).
* A multi-index table `testtab` along with its `test_table` data structure, its mandatory primary index, and the type alias definition `test_table_t`. Please see [How To Define A Primary Index](./how-to-define-a-primary-index) to set up these prerequisites.
## Procedure
@@ -10,13 +10,13 @@ This guide provides instructions to define a singleton.
See the following code reference:
* The [`singleton`](../../classeosio_1_1singleton) class.
* The [`singleton`](../../reference/Classes/classeosio_1_1singleton) class.
## Before you begin
Make sure you have the following prerequisites in place:
* An Antelope development environment, for details consult the [Get Started Guide](https://docs.eosnetwork.com/docs/latest/getting-started/),
* An Antelope development environment, for details consult the [Documentation Portal](https://docs.eosnetwork.com/docs/latest/).
## Procedure
@@ -10,15 +10,15 @@ This guide provides instructions to to delete data from a multi-index table.
See the following code reference:
* The [`multi-index`](../../classeosio_1_1multi__index) class.
* The [`multi-index::find(...)`](../../group__multiindex#function-find) method.
* The [`multi-index::erase(...)`](../../group__multiindex/#function-erase) method.
* The [`multi-index`](../../reference/Classes/classeosio_1_1multi__index) class.
* The [`multi-index::find(...)`](../../reference/Modules/group__multiindex#function-find) method.
* The [`multi-index::erase(...)`](../../reference/Modules/group__multiindex#function-erase) method.
## Before you begin
Make sure you have the following prerequisites in place:
* An Antelope development environment, for details consult the [Get Started Guide](https://docs.eosnetwork.com/docs/latest/getting-started/),
* An Antelope development environment, for details consult the [Documentation Portal](https://docs.eosnetwork.com/docs/latest/).
* A multi-index `testab` table instance which stores `user` objects indexed by the primary key which is of type `eosio::name`. Consult the section [How to instantiate a multi-index table](./how-to-instantiate-a-multi-index-table.md) to learn how to set it up.
## Procedure
@@ -27,7 +27,7 @@ Complete the following steps to implement a `del` action which deletes an user o
### 1. Find The User You Want To Delete
Use the multi-index [`find(...)`](../../group__multiindex#function-find) method to locate the user object you want to delete. The targeted user is searched based on its account name.
Use the multi-index [`find(...)`](../../reference/Modules/group__multiindex#function-find) method to locate the user object you want to delete. The targeted user is searched based on its account name.
```cpp
[[eosio::action]] void multi_index_example::del( name user ) {
@@ -38,7 +38,7 @@ Use the multi-index [`find(...)`](../../group__multiindex#function-find) method
### 2. Delete The User If Found
Check to see if the user exists and use [`erase`(...)](../../group__multiindex/#function-erase) method to delete the row from table. Otherwise print an informational message and return.
Check to see if the user exists and use [`erase`(...)](../../reference/Modules/group__multiindex#function-erase) method to delete the row from table. Otherwise print an informational message and return.
```diff
[[eosio::action]] void multi_index_example::del( name user ) {
@@ -62,7 +62,7 @@ In conclusion, the above instructions show how to delete data from a multi-index
## Next Steps
* You can verify if the user object was deleted from the multi-index table. .
* You can verify if the user object was deleted from the multi-index table.
```cpp
// check if the user was deleted
@@ -10,15 +10,15 @@ This guide provides instructions to insert data into a multi-index table.
See the following code reference:
* The [`multi-index`](../../classeosio_1_1multi__index) class.
* The [`multi-index::find(...)`](../../group__multiindex#function-find) method.
* The [`multi-index::emplace(...)`](../../group__multiindex/#function-emplace) method.
* The [`multi-index`](../../reference/Classes/classeosio_1_1multi__index) class.
* The [`multi-index::find(...)`](../../reference/Modules/group__multiindex#function-find) method.
* The [`multi-index::emplace(...)`](../../reference/Modules/group__multiindex#function-emplace) method.
## Before you begin
Make sure you have the following prerequisites in place:
* An Antelope development environment, for details consult the [Get Started Guide](https://docs.eosnetwork.com/docs/latest/getting-started/),
* An Antelope development environment, for details consult the [Documentation Portal](https://docs.eosnetwork.com/docs/latest/).
* A multi-index `testab` table instance which stores `user` objects indexed by the primary key which is of type `eosio::name`. Consult the section [How to instantiate a multi-index table](./how-to-instantiate-a-multi-index-table.md) to learn how to set it up.
## Procedure
@@ -38,7 +38,7 @@ Use of the multi-index table iterator to find out if the user object already exi
### 2. Insert The User If Not Found In Table
Use the [`emplace`](../../group__multiindex/#function-emplace) method to make the insertion if the user object is not already in the multi-index table. Otherwise print an informational message.
Use the [`emplace`](../../reference/Modules/group__multiindex#function-emplace) method to make the insertion if the user object is not already in the multi-index table. Otherwise print an informational message.
```diff
[[eosio::action]] void multi_index_example::set( name user ) {
@@ -10,13 +10,13 @@ This guide provides instructions to instantiate a multi-index table.
See the following code reference:
* The [`multi-index`](../../classeosio_1_1multi__index) class.
* The [`multi-index`](../../reference/Classes/classeosio_1_1multi__index) class.
## Before you begin
Make sure you have the following prerequisites in place:
* An Antelope development environment, for details consult the [Get Started Guide](https://docs.eosnetwork.com/docs/latest/getting-started/),
* An Antelope development environment, for details consult the [Documentation Portal](https://docs.eosnetwork.com/docs/latest/).
## Procedure
@@ -10,14 +10,14 @@ This guide provides instructions on how iterate and retrieve data from a multi-i
See the following code reference:
* The [`multi-index`](../../classeosio_1_1multi__index) class.
* The [`multi-index::find(...)`](../../group__multiindex#function-find) method.
* The [`multi-index`](../../reference/Classes/classeosio_1_1multi__index) class.
* The [`multi-index::find(...)`](../../reference/Modules/group__multiindex#function-find) method.
## Before you begin
Make sure you have the following prerequisites in place:
* An Antelope development environment, for details consult the [Get Started Guide](https://docs.eosnetwork.com/docs/latest/getting-started/),
* An Antelope development environment, for details consult the [Documentation Portal](https://docs.eosnetwork.com/docs/latest/).
* A multi-index `testab` table instance which stores `user` objects indexed by the primary key which is of type `eosio::name` and a secondary index for data member `secondary` of type `eosio::name` accessible through `by_secondary()` method. Consult the section [How to define a secondary index](./how-to-define-a-secondary-index) to learn how to set it up.
## Procedure
@@ -10,14 +10,14 @@ This guide provides instructions to iterate and retrieve data from a multi-index
See the following code reference:
* The [`multi-index`](../../classeosio_1_1multi__index) class.
* The [`multi-index::find(...)`](../../group__multiindex#function-find) method.
* The [`multi-index`](../../reference/Classes/classeosio_1_1multi__index) class.
* The [`multi-index::find(...)`](../../reference/Modules/group__multiindex#function-find) method.
## Before you begin
Make sure you have the following prerequisites in place:
* An Antelope development environment, for details consult the [Get Started Guide](https://docs.eosnetwork.com/docs/latest/getting-started/),
* An Antelope development environment, for details consult the [Documentation Portal](https://docs.eosnetwork.com/docs/latest/).
* A multi-index `testab` table instance which stores `user` objects indexed by the primary key which is of type `eosio::name`. Consult the section [How to instantiate a multi-index table](./how-to-instantiate-a-multi-index-table) to learn how to set it up.
## Procedure
@@ -10,14 +10,14 @@ This guide provides instructions to modify data in a multi-index table.
See the following code reference:
* The [`multi-index`](../../classeosio_1_1multi__index) class.
* The [`multi-index::modify(...)`](../../group__multiindex/#function-modify) method.
* The [`multi-index`](../../reference/Classes/classeosio_1_1multi__index) class.
* The [`multi-index::modify(...)`](../../reference/Modules/group__multiindex#function-modify) method.
## Before you begin
Make sure you have the following prerequisites in place:
* An Antelope development environment, for details consult the [Get Started Guide](https://docs.eosnetwork.com/docs/latest/getting-started/),
* An Antelope development environment, for details consult the [Documentation Portal](https://docs.eosnetwork.com/docs/latest/).
* A multi-index `testab` table instance which stores `user` objects indexed by the primary key which is of type `eosio::name`. Consult the section [How to instantiate a multi-index table](./how-to-instantiate-a-multi-index-table) to learn how to set it up.
## Procedure
@@ -42,7 +42,7 @@ Optionally, for ease of use add the action wrapper definition as well.
### 2. Find The User You Want To Modify
Use the multi-index [`find(...)`](../../group__multiindex#function-find) method to locate the user object you want to modify. The targeted user is searched based on its account name.
Use the multi-index [`find(...)`](../../reference/Modules/group__multiindex#function-find) method to locate the user object you want to modify. The targeted user is searched based on its account name.
```cpp
[[eosio::action]] void multi_index_example::mod( name user, uint32_t value ) {
@@ -52,7 +52,7 @@ Use the multi-index [`find(...)`](../../group__multiindex#function-find) method
### 3. Yield Error If User Not Found
If the `user` object you want to update is not found then raise an error message by using the [`eosio::check`](../../namespaceeosio/#function-check-17) method.
If the `user` object you want to update is not found then raise an error message by using the [`eosio::check`](../../reference/Namespaces/namespaceeosio#function-check) method.
```diff
[[eosio::action]] void multi_index_example::mod( name user, uint32_t value ) {
@@ -63,7 +63,7 @@ If the `user` object you want to update is not found then raise an error message
### 4. Update The User If Found
If the `user` object you want to update is found, the [`eosio::check`](../../namespaceeosio/#function-check-17) method will do nothing and the iterator `itr` will be pointing at the object which you want to update. Use the [`multi-index::modify(...)`](../../group__multiindex/#function-modify) method to update the user object `datum` data member with the `value` parameter.
If the `user` object you want to update is found, the [`eosio::check`](../../reference/Namespaces/namespaceeosio#function-check) method will do nothing and the iterator `itr` will be pointing at the object which you want to update. Use the [`multi-index::modify(...)`](../../reference/Modules/group__multiindex#function-modify) method to update the user object `datum` data member with the `value` parameter.
```diff
[[eosio::action]] void multi_index_example::mod( name user, uint32_t value ) {
@@ -11,13 +11,13 @@ This guide provides instructions to create and use an action wrapper in a smart
See the following code reference guide for action wrapper:
* [eosio::action_wrapper](../structeosio_1_1action__wrapper).
* [eosio::action_wrapper](../reference/Classes/structeosio_1_1action__wrapper).
## Before you begin
Make sure you have the following prerequisites in place:
* An Antelope development environment, for details consult the [Get Started Guide](https://docs.eosnetwork.com/docs/latest/getting-started/).
* An Antelope development environment, for details consult the [Documentation Portal](https://docs.eosnetwork.com/docs/latest/).
* A smart contract named `multi_index_example`, defined in file `multi_index_example.hpp`.
* An action `mod` which modifies the integer value `n` stored for row with key `user`.
@@ -12,7 +12,7 @@ In order to accomplish this, use the `return` statement and pass the desired ret
Make sure you have the following prerequisites in place:
* An Antelope development environment, for details consult the [Get Started Guide](https://docs.eosnetwork.com/docs/latest/getting-started/).
* An Antelope development environment, for details consult the [Documentation Portal](https://docs.eosnetwork.com/docs/latest/).
* A smart contract, lets call it `smrtcontract`, which builds without error.
* An action, lets call it `checkwithrv`, from which you want to return a value of a user defined type `action_response`.
+36
View File
@@ -165,3 +165,39 @@ assertion failure with message: system contract must first be initialized
The failure is stating that `eosio.system` `init` action was not called yet. The `init` action is implemented by the `void init(uint64_t, symbol)` function. The first parameter is the version, this should always be `0` for now, until a new version of `init` will be created that handles more information.
The second parameter is the system's symbol (i.e. for main net this is `EOS`). If you followed the [BIOS Boot Sequence](https://docs.eosnetwork.com/docs/latest/tutorials/bios-boot-sequence) tutorial and created a system with the default symbol `SYS` then `SYS` shall be used as the system's symbol in the `init` action. It is whatever symbol you as the chain creator want to use in your `Antelope` based blockchain.
## Backward incompatible change in generating abi for maps
In CDT version 3.0.1, there has been breaking ABI change in std::map. The change is as follows:
Old Version (CDT 3.0.0 or earlier):
```
"fields": [
{
"name": "key",
"type": "<map first type>"
},
{
"name": "value",
"type": "<map second type>"
}
]
```
New Version (CDT 3.0.1 and above):
```
"fields": [
{
"name": "first",
"type": "<map first type>"
},
{
"name": "second",
"type": "<map second type>"
}
]
```
As a result, if you are using code based on CDT 3.0.0 or earlier, you may encounter errors when upgrading to CDT 3.0.1 and above.
An example error message could be: `Error: missing pair_uint64_bytes.first (type=uint64)`.
To resolve this issue, you need to update your code to use `first` and `second` to access the elements of `std::map`, instead of the old `key` and `value` identifiers.
+1 -1
View File
@@ -10,4 +10,4 @@ If you are upgrading to CDT version 3.0 or later from version 1.8.1 (or earlier)
## License
[MIT](../LICENSE)
[MIT](https://github.com/AntelopeIO/cdt/blob/main/LICENSE)
+22
View File
@@ -0,0 +1,22 @@
.\" Automatically generated by Pandoc 2.5
.\"
.TH "CDT\-ABIDIFF" "1" "April 18 2023" "AntelopeIO" "Contract Development Toolkit (CDT)"
.hy
.SH NAME
.PP
cdt\-abidiff \- A tool for comparison of two CDT ABI files.
.SH SYNOPSIS
.PP
\f[C]cdt\-abidiff <file1.abi> <file2.abi>\f[R]
.SH DESCRIPTION
.PP
\f[B]cdt\-abidiff\f[R] To report differences with cdt\-abidiff, you only
need to pass the two ABI file names as command line arguments.
.SH BUGS
.PP
Please submit bug reports online at
https://github.com/AntelopeIO/cdt/issues
.SH SEE ALSO
.PP
For more details consult the full documentation and sources
https://github.com/AntelopeIO/cdt
+26
View File
@@ -0,0 +1,26 @@
---
title: CDT-ABIDIFF
section: 1
header: Contract Development Toolkit (CDT)
footer: AntelopeIO
date: April 18 2023
---
# NAME
cdt-abidiff - A tool for comparison of two CDT ABI files.
# SYNOPSIS
`cdt-abidiff <file1.abi> <file2.abi>`
# DESCRIPTION
**cdt-abidiff** To report differences with cdt-abidiff, you only need to pass the two ABI file names as command line arguments.
# BUGS
Please submit bug reports online at https://github.com/AntelopeIO/cdt/issues
# SEE ALSO
For more details consult the full documentation and sources https://github.com/AntelopeIO/cdt
+676
View File
@@ -0,0 +1,676 @@
.\" Automatically generated by Pandoc 2.5
.\"
.TH "CDT\-CC" "1" "April 14, 2023" "AntelopeIO" "Contract Development Toolkit (CDT)"
.hy
.SH NAME
.PP
cdt\-cc \- Antelope smart contract C to WebAssembly compiler
.SH SYNOPSIS
.PP
\f[C]cdt\-cc [options] <input file>\f[R]
.SH DESCRIPTION
.PP
\f[B]cdt\-cc\f[R] Is a C compiler which converts C smart contract code
to WebAssemply for execution in Antelope block chain virtual machines.
.SH OPTIONS
.PP
\f[B]\f[CB]\-C\f[B]\f[R]
.IP
.nf
\f[C]
Include comments in preprocessed output
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-CC\f[B]\f[R]
.IP
.nf
\f[C]
Include comments from within macros in preprocessed output
\f[R]
.fi
.PP
\f[B]\f[CB]\-D=<name definition>\f[B]\f[R]
.IP
.nf
\f[C]
Define <macro> to <value> (or 1 if <value> omitted)
\f[R]
.fi
.PP
\f[B]\f[CB]\-U=<name>\f[B]\f[R]
.IP
.nf
\f[C]
Undefine any previous definition of name, either built in or defined with a \-D option
\f[R]
.fi
.PP
\f[B]\f[CB]\-E\f[B]\f[R]
.IP
.nf
\f[C]
Only run the preprocessor
\f[R]
.fi
.PP
\f[B]\f[CB]\-I=<dir>\f[B]\f[R]
.IP
.nf
\f[C]
Add directory to include search path
\f[R]
.fi
.PP
\f[B]\f[CB]\-L=<dir>\f[B]\f[R]
.IP
.nf
\f[C]
Add directory to library search path
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-MF=<file>\f[B]\f[R]
.IP
.nf
\f[C]
Write depfile output
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-MD\f[B]\f[R]
.IP
.nf
\f[C]
Write depfile containing user and system headers
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-MMD\f[B]\f[R]
.IP
.nf
\f[C]
Like \-MD except mention only user header files, not system header files.
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-MT=<target>\f[B]\f[R]
.IP
.nf
\f[C]
Specify name of main file output in depfile
\f[R]
.fi
.PP
\f[B]\f[CB]\-O=<optimization_level>\f[B]\f[R]
.IP
.nf
\f[C]
Optimization level s, 0\-3
\f[R]
.fi
.PP
\f[B]\f[CB]\-R=<dir>\f[B]\f[R]
.IP
.nf
\f[C]
Add the directory dir to the list of directories to be searched for resource files
\f[R]
.fi
.PP
\f[B]\f[CB]\-S\f[B]\f[R]
.IP
.nf
\f[C]
Only run preprocess and compilation steps
\f[R]
.fi
.PP
\f[B]\f[CB]\-W=<warning_name>\f[B]\f[R]
.IP
.nf
\f[C]
Enable the specified warning.
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-abi\-version=<string>\f[B]\f[R]
.IP
.nf
\f[C]
Which ABI version to generate
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-abigen\f[B]\f[R]
.IP
.nf
\f[C]
Generate ABI
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-abigen_output=<string>\f[B]\f[R]
.IP
.nf
\f[C]
ABIGEN output
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-allow\-names\f[B]\f[R]
.IP
.nf
\f[C]
Allow creation of name section
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-allow\-sse\f[B]\f[R]
.IP
.nf
\f[C]
Should not be used, except for build libc
\f[R]
.fi
.PP
\f[B]\f[CB]\-c\f[B]\f[R]
.IP
.nf
\f[C]
Only run preprocess, compile, and assemble steps
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-contract=<string>\f[B]\f[R]
.IP
.nf
\f[C]
Contract name
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-dD\f[B]\f[R]
.IP
.nf
\f[C]
Print macro definitions in \-E mode in addition to normal output
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-dI\f[B]\f[R]
.IP
.nf
\f[C]
Print include directives in \-E mode in addition to normal output
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-dM\f[B]\f[R]
.IP
.nf
\f[C]
Print macro definitions in \-E mode instead to normal output
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-disable\-symbolication\f[B]\f[R]
.IP
.nf
\f[C]
Disable symbolizing crash backtraces.
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-emit\-ast\f[B]\f[R]
.IP
.nf
\f[C]
Emit Clang AST files for source inputs
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-emit\-ir\f[B]\f[R]
.IP
.nf
\f[C]
Emit llvm ir
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-emit\-llvm\f[B]\f[R]
.IP
.nf
\f[C]
Use the LLVM representation for assembler and object files
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-eosio\-pp\-dir=<string>\f[B]\f[R]
.IP
.nf
\f[C]
Set the directory for eosio\-pp
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-fPIC\f[B]\f[R]
.IP
.nf
\f[C]
Generate position independent code. This option is used for shared libraries
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-fasm\f[B]\f[R]
.IP
.nf
\f[C]
Assemble file for x86\-64
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-fcolor\-diagnostics\f[B]\f[R]
.IP
.nf
\f[C]
Use colors in diagnostics
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-finline\-functions\f[B]\f[R]
.IP
.nf
\f[C]
Inline suitable functions
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-finline\-hint\-functions\f[B]\f[R]
.IP
.nf
\f[C]
Inline functions which are (explicitly or implicitly) marked inline
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-fmerge\-all\-constants\f[B]\f[R]
.IP
.nf
\f[C]
Allow merging of constants
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-fnative\f[B]\f[R]
.IP
.nf
\f[C]
Compile and link for x86\-64
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-fno\-cfl\-aa\f[B]\f[R]
.IP
.nf
\f[C]
Disable CFL Alias Analysis
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-fno\-elide\-constructors\f[B]\f[R]
.IP
.nf
\f[C]
Disable C++ copy constructor elision
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-fno\-lto\f[B]\f[R]
.IP
.nf
\f[C]
Disable LTO
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-fno\-post\-pass\f[B]\f[R]
.IP
.nf
\f[C]
Don\[aq]t run post processing pass
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-fno\-stack\-first\f[B]\f[R]
.IP
.nf
\f[C]
Don\[aq]t set the stack first in memory
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-fquery\f[B]\f[R]
.IP
.nf
\f[C]
Produce binaries for wasmql
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-fquery\-client\f[B]\f[R]
.IP
.nf
\f[C]
Produce binaries for wasmql
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-fquery\-server\f[B]\f[R]
.IP
.nf
\f[C]
Produce binaries for wasmql
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-fstack\-protector\f[B]\f[R]
.IP
.nf
\f[C]
Enable stack protectors for functions potentially vulnerable to stack smashing
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-fstack\-protector\-all\f[B]\f[R]
.IP
.nf
\f[C]
Force the usage of stack protectors for all functions
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-fstack\-protector\-strong\f[B]\f[R]
.IP
.nf
\f[C]
Use a strong heuristic to apply stack protectors to functions
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-fstrict\-enums\f[B]\f[R]
.IP
.nf
\f[C]
Enable optimizations based on the strict definition of an enum\[aq]s value range
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-fstrict\-return\f[B]\f[R]
.IP
.nf
\f[C]
Always treat control flow paths that fall off the end of a non\-void function as unreachable
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-fstrict\-vtable\-pointers\f[B]\f[R]
.IP
.nf
\f[C]
Enable optimizations based on the strict rules for overwriting polymorphic C++ objects
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-fuse\-main\f[B]\f[R]
.IP
.nf
\f[C]
Use main as entry
\f[R]
.fi
.PP
\f[B]\f[CB]\-h\f[B]\f[R]
.IP
.nf
\f[C]
Alias for \-\-help
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-help\f[B]\f[R]
.IP
.nf
\f[C]
Display available options (\-\-help\-hidden for more)
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-help\-hidden\f[B]\f[R]
.IP
.nf
\f[C]
Display all available options
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-help\-list\f[B]\f[R]
.IP
.nf
\f[C]
Display list of available options (\-\-help\-list\-hidden for more)
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-help\-list\-hidden\f[B]\f[R]
.IP
.nf
\f[C]
Display list of all available options
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-imports=<string>\f[B]\f[R]
.IP
.nf
\f[C]
Set the file for cdt.imports
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-include=<string>\f[B]\f[R]
.IP
.nf
\f[C]
Include file before parsing
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-isysroot=<string>\f[B]\f[R]
.IP
.nf
\f[C]
Set the system root directory (usually /)
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-isystem=<string>\f[B]\f[R]
.IP
.nf
\f[C]
Add directory to SYSTEM include search path
\f[R]
.fi
.PP
\f[B]\f[CB]\-l=<string>\f[B]\f[R]
.IP
.nf
\f[C]
Root name of library to link
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-lto\-opt=<string>\f[B]\f[R]
.IP
.nf
\f[C]
LTO Optimization level (O0\-O3)
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-mllvm=<string>\f[B]\f[R]
.IP
.nf
\f[C]
Pass arguments to llvm
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-no\-abigen\f[B]\f[R]
.IP
.nf
\f[C]
Disable ABI file generation
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-no\-missing\-ricardian\-clause\f[B]\f[R]
.IP
.nf
\f[C]
Disable warnings for missing Ricardian clauses
\f[R]
.fi
.PP
\f[B]\f[CB]\-o=<file>\f[B]\f[R]
.IP
.nf
\f[C]
Write output to <file>
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-only\-export=<string>\f[B]\f[R]
.IP
.nf
\f[C]
Export only this symbol
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-print\-all\-options\f[B]\f[R]
.IP
.nf
\f[C]
Print all option values after command line parsing
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-print\-options\f[B]\f[R]
.IP
.nf
\f[C]
Print non\-default options after command line parsing
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-shared\f[B]\f[R]
.IP
.nf
\f[C]
Make shared object native library
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-stack\-canary\f[B]\f[R]
.IP
.nf
\f[C]
Stack canary for non stack first layouts
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-stack\-size=<int>\f[B]\f[R]
.IP
.nf
\f[C]
Specifies the maximum stack size for the contract. Defaults to 8192 bytes
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-sysroot=<string>\f[B]\f[R]
.IP
.nf
\f[C]
Set the system root directory
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-use\-freeing\-malloc\f[B]\f[R]
.IP
.nf
\f[C]
Set the malloc implementation to the old freeing malloc
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-use\-rt\f[B]\f[R]
.IP
.nf
\f[C]
Use software compiler\-rt
\f[R]
.fi
.PP
\f[B]\f[CB]\-v\f[B]\f[R]
.IP
.nf
\f[C]
Show commands to run and use verbose output
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-version\f[B]\f[R]
.IP
.nf
\f[C]
Display the version of this program
\f[R]
.fi
.PP
\f[B]\f[CB]\-w\f[B]\f[R]
.IP
.nf
\f[C]
Suppress all warnings
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-warn\-action\-read\-only\f[B]\f[R]
.IP
.nf
\f[C]
Issue a warning if a read\-only action uses a write API and continue compilation
\f[R]
.fi
.SH BUGS
.PP
Please submit bug reports online at
https://github.com/AntelopeIO/cdt/issues
.SH SEE ALSO
.PP
For more details consult the full documentation and sources
https://github.com/AntelopeIO/cdt
+351
View File
@@ -0,0 +1,351 @@
---
title: CDT-CC
section: 1
header: Contract Development Toolkit (CDT)
footer: AntelopeIO
date: April 14, 2023
---
# NAME
cdt-cc - Antelope smart contract C to WebAssembly compiler
# SYNOPSIS
`cdt-cc [options] <input file>`
# DESCRIPTION
**cdt-cc** Is a C compiler which converts C smart contract code to WebAssemply for
execution in Antelope block chain virtual machines.
# OPTIONS
**`-C`**
Include comments in preprocessed output
**`--CC`**
Include comments from within macros in preprocessed output
**`-D=<name definition>`**
Define <macro> to <value> (or 1 if <value> omitted)
**`-U=<name>`**
Undefine any previous definition of name, either built in or defined with a -D option
**`-E`**
Only run the preprocessor
**`-I=<dir>`**
Add directory to include search path
**`-L=<dir>`**
Add directory to library search path
**`--MF=<file>`**
Write depfile output
**`--MD`**
Write depfile containing user and system headers
**`--MMD`**
Like -MD except mention only user header files, not system header files.
**`--MT=<target>`**
Specify name of main file output in depfile
**`-O=<optimization_level>`**
Optimization level s, 0-3
**`-R=<dir>`**
Add the directory dir to the list of directories to be searched for resource files
**`-S`**
Only run preprocess and compilation steps
**`-W=<warning_name>`**
Enable the specified warning.
**`--abi-version=<string>`**
Which ABI version to generate
**`--abigen`**
Generate ABI
**`--abigen_output=<string>`**
ABIGEN output
**`--allow-names`**
Allow creation of name section
**`--allow-sse`**
Should not be used, except for build libc
**`-c`**
Only run preprocess, compile, and assemble steps
**`--contract=<string>`**
Contract name
**`--dD`**
Print macro definitions in -E mode in addition to normal output
**`--dI`**
Print include directives in -E mode in addition to normal output
**`--dM`**
Print macro definitions in -E mode instead to normal output
**`--disable-symbolication`**
Disable symbolizing crash backtraces.
**`--emit-ast`**
Emit Clang AST files for source inputs
**`--emit-ir`**
Emit llvm ir
**`--emit-llvm`**
Use the LLVM representation for assembler and object files
**`--eosio-pp-dir=<string>`**
Set the directory for eosio-pp
**`--fPIC`**
Generate position independent code. This option is used for shared libraries
**`--fasm`**
Assemble file for x86-64
**`--fcolor-diagnostics`**
Use colors in diagnostics
**`--finline-functions`**
Inline suitable functions
**`--finline-hint-functions`**
Inline functions which are (explicitly or implicitly) marked inline
**`--fmerge-all-constants`**
Allow merging of constants
**`--fnative`**
Compile and link for x86-64
**`--fno-cfl-aa`**
Disable CFL Alias Analysis
**`--fno-elide-constructors`**
Disable C++ copy constructor elision
**`--fno-lto`**
Disable LTO
**`--fno-post-pass`**
Don't run post processing pass
**`--fno-stack-first`**
Don't set the stack first in memory
**`--fquery`**
Produce binaries for wasmql
**`--fquery-client`**
Produce binaries for wasmql
**`--fquery-server`**
Produce binaries for wasmql
**`--fstack-protector`**
Enable stack protectors for functions potentially vulnerable to stack smashing
**`--fstack-protector-all`**
Force the usage of stack protectors for all functions
**`--fstack-protector-strong`**
Use a strong heuristic to apply stack protectors to functions
**`--fstrict-enums`**
Enable optimizations based on the strict definition of an enum's value range
**`--fstrict-return`**
Always treat control flow paths that fall off the end of a non-void function as unreachable
**`--fstrict-vtable-pointers`**
Enable optimizations based on the strict rules for overwriting polymorphic C++ objects
**`--fuse-main`**
Use main as entry
**`-h`**
Alias for --help
**`--help`**
Display available options (--help-hidden for more)
**`--help-hidden`**
Display all available options
**`--help-list`**
Display list of available options (--help-list-hidden for more)
**`--help-list-hidden`**
Display list of all available options
**`--imports=<string>`**
Set the file for cdt.imports
**`--include=<string>`**
Include file before parsing
**`--isysroot=<string>`**
Set the system root directory (usually /)
**`--isystem=<string>`**
Add directory to SYSTEM include search path
**`-l=<string>`**
Root name of library to link
**`--lto-opt=<string>`**
LTO Optimization level (O0-O3)
**`--mllvm=<string>`**
Pass arguments to llvm
**`--no-abigen`**
Disable ABI file generation
**`--no-missing-ricardian-clause`**
Disable warnings for missing Ricardian clauses
**`-o=<file>`**
Write output to <file>
**`--only-export=<string>`**
Export only this symbol
**`--print-all-options`**
Print all option values after command line parsing
**`--print-options`**
Print non-default options after command line parsing
**`--shared`**
Make shared object native library
**`--stack-canary`**
Stack canary for non stack first layouts
**`--stack-size=<int>`**
Specifies the maximum stack size for the contract. Defaults to 8192 bytes
**`--sysroot=<string>`**
Set the system root directory
**`--use-freeing-malloc`**
Set the malloc implementation to the old freeing malloc
**`--use-rt`**
Use software compiler-rt
**`-v`**
Show commands to run and use verbose output
**`--version`**
Display the version of this program
**`-w`**
Suppress all warnings
**`--warn-action-read-only`**
Issue a warning if a read-only action uses a write API and continue compilation
# BUGS
Please submit bug reports online at https://github.com/AntelopeIO/cdt/issues
# SEE ALSO
For more details consult the full documentation and sources https://github.com/AntelopeIO/cdt
+850
View File
@@ -0,0 +1,850 @@
.\" Automatically generated by Pandoc 2.5
.\"
.TH "CDT\-CPP" "1" "April 08, 2023" "AntelopeIO" "Contract Development Toolkit (CDT)"
.hy
.SH NAME
.PP
cdt\-cpp \- Antelope smart contract C++ to WebAssembly compiler
.SH SYNOPSIS
.PP
\f[C]cdt\-cpp [options] <input file>\f[R]
.SH DESCRIPTION
.PP
\f[B]cdt\-cpp\f[R] Is a C++ compiler which converts C++ smart contract
code to WebAssemply for execution in Antelope block chain virtual
machines.
.SH OPTIONS
.PP
\f[B]\f[CB]\-C\f[B]\f[R]
.IP
.nf
\f[C]
Include comments in preprocessed output
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-CC\f[B]\f[R]
.IP
.nf
\f[C]
Include comments from within macros in preprocessed output
\f[R]
.fi
.PP
\f[B]\f[CB]\-D=<name definition>\f[B]\f[R]
.IP
.nf
\f[C]
Define <macro> to <value> (or 1 if <value> omitted)
\f[R]
.fi
.PP
\f[B]\f[CB]\-U=<name>\f[B]\f[R]
.IP
.nf
\f[C]
Undefine any previous definition of name, either built in or defined with a \-D option
\f[R]
.fi
.PP
\f[B]\f[CB]\-E\f[B]\f[R]
.IP
.nf
\f[C]
Only run the preprocessor
\f[R]
.fi
.PP
\f[B]\f[CB]\-I=<dir>\f[B]\f[R]
.IP
.nf
\f[C]
Add directory to include search path
\f[R]
.fi
.PP
\f[B]\f[CB]\-L=<dir>\f[B]\f[R]
.IP
.nf
\f[C]
Add directory to library search path
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-MF=<file>\f[B]\f[R]
.IP
.nf
\f[C]
Write depfile output
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-MD\f[B]\f[R]
.IP
.nf
\f[C]
Write depfile containing user and system headers
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-MMD\f[B]\f[R]
.IP
.nf
\f[C]
Like \-MD except mention only user header files, not system header files.
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-MT=<target>\f[B]\f[R]
.IP
.nf
\f[C]
Specify name of main file output in depfile
\f[R]
.fi
.PP
\f[B]\f[CB]\-O=<optimization_level>\f[B]\f[R]
.IP
.nf
\f[C]
Optimization level s, 0\-3
\f[R]
.fi
.PP
\f[B]\f[CB]\-R=<dir>\f[B]\f[R]
.IP
.nf
\f[C]
Add the directory dir to the list of directories to be searched for resource files
\f[R]
.fi
.PP
\f[B]\f[CB]\-S\f[B]\f[R]
.IP
.nf
\f[C]
Only run preprocess and compilation steps
\f[R]
.fi
.PP
\f[B]\f[CB]\-W=<warning_name>\f[B]\f[R]
.IP
.nf
\f[C]
Enable the specified warning.
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-abi\-version=<string>\f[B]\f[R]
.IP
.nf
\f[C]
Which ABI version to generate
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-abigen\f[B]\f[R]
.IP
.nf
\f[C]
Generate ABI
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-abigen_output=<string>\f[B]\f[R]
.IP
.nf
\f[C]
ABIGEN output
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-allow\-names\f[B]\f[R]
.IP
.nf
\f[C]
Allow creation of name section
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-allow\-sse\f[B]\f[R]
.IP
.nf
\f[C]
Should not be used, except for building libc
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-as\-secure\-log\-file\-name=<value>\f[B]\f[R]
.IP
.nf
\f[C]
As secure log file name (initialized from AS_SECURE_LOG_FILE env variable)
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-asm\-macro\-max\-nesting\-depth=<uint>\f[B]\f[R]
.IP
.nf
\f[C]
The maximum nesting depth allowed for assembly macros
\f[R]
.fi
.PP
\f[B]\f[CB]\-c\f[B]\f[R]
.IP
.nf
\f[C]
Only run preprocess, compile, and assemble steps
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-color\f[B]\f[R]
.IP
.nf
\f[C]
Use colors in output (default=autodetect)
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-contract=<string>\f[B]\f[R]
.IP
.nf
\f[C]
Contract name
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-dD\f[B]\f[R]
.IP
.nf
\f[C]
Print macro definitions in \-E mode in addition to normal output
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-dI\f[B]\f[R]
.IP
.nf
\f[C]
Print include directives in \-E mode in addition to normal output
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-dM\f[B]\f[R]
.IP
.nf
\f[C]
Print macro definitions in \-E mode instead to normal output
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-disable\-symbolication\f[B]\f[R]
.IP
.nf
\f[C]
Disable symbolizing crash backtraces.
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-emit\-ast\f[B]\f[R]
.IP
.nf
\f[C]
Emit Clang AST files for source inputs
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-emit\-ir\f[B]\f[R]
.IP
.nf
\f[C]
Emit llvm ir
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-emit\-llvm\f[B]\f[R]
.IP
.nf
\f[C]
Use the LLVM representation for assembler and object files
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-eosio\-pp\-dir=<string>\f[B]\f[R]
.IP
.nf
\f[C]
Set the directory for eosio\-pp
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-fPIC\f[B]\f[R]
.IP
.nf
\f[C]
Generate position independent code. This option is used for shared libraries
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-faligned\-allocation\f[B]\f[R]
.IP
.nf
\f[C]
Enable C++17 aligned allocation functions
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-fasm\f[B]\f[R]
.IP
.nf
\f[C]
Assemble file for x86\-64
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-fcolor\-diagnostics\f[B]\f[R]
.IP
.nf
\f[C]
Use colors in diagnostics
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-fcoroutine\-ts\f[B]\f[R]
.IP
.nf
\f[C]
Enable support for the C++ Coroutines TS
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-finline\-functions\f[B]\f[R]
.IP
.nf
\f[C]
Inline suitable functions
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-finline\-hint\-functions\f[B]\f[R]
.IP
.nf
\f[C]
Inline functions which are (explicitly or implicitly) marked inline
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-fmerge\-all\-constants\f[B]\f[R]
.IP
.nf
\f[C]
Allow merging of constants
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-fnative\f[B]\f[R]
.IP
.nf
\f[C]
Compile and link for x86\-64
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-fno\-cfl\-aa\f[B]\f[R]
.IP
.nf
\f[C]
Disable CFL Alias Analysis
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-fno\-elide\-constructors\f[B]\f[R]
.IP
.nf
\f[C]
Disable C++ copy constructor elision
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-fno\-lto\f[B]\f[R]
.IP
.nf
\f[C]
Disable LTO
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-fno\-post\-pass\f[B]\f[R]
.IP
.nf
\f[C]
Don\[aq]t run post processing pass
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-fno\-stack\-first\f[B]\f[R]
.IP
.nf
\f[C]
Don\[aq]t set the stack first in memory
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-fquery\f[B]\f[R]
.IP
.nf
\f[C]
Produce binaries for wasmql
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-fquery\-client\f[B]\f[R]
.IP
.nf
\f[C]
Produce binaries for wasmql
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-fquery\-server\f[B]\f[R]
.IP
.nf
\f[C]
Produce binaries for wasmql
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-fstack\-protector\f[B]\f[R]
.IP
.nf
\f[C]
Enable stack protectors for functions potentially vulnerable to stack smashing
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-fstack\-protector\-all\f[B]\f[R]
.IP
.nf
\f[C]
Force the usage of stack protectors for all functions
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-fstack\-protector\-strong\f[B]\f[R]
.IP
.nf
\f[C]
Use a strong heuristic to apply stack protectors to functions
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-fstrict\-enums\f[B]\f[R]
.IP
.nf
\f[C]
Enable optimizations based on the strict definition of an enum\[aq]s value range
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-fstrict\-return\f[B]\f[R]
.IP
.nf
\f[C]
Always treat control flow paths that fall off the end of a non\-void function as unreachable
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-fstrict\-vtable\-pointers\f[B]\f[R]
.IP
.nf
\f[C]
Enable optimizations based on the strict rules for overwriting polymorphic C++ objects
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-fuse\-main\f[B]\f[R]
.IP
.nf
\f[C]
Use main as entry
\f[R]
.fi
.PP
\f[B]\f[CB]\-h\f[B]\f[R]
.IP
.nf
\f[C]
Alias for \-\-help
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-help\f[B]\f[R]
.IP
.nf
\f[C]
Display available options (\-\-help\-hidden for more)
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-help\-hidden\f[B]\f[R]
.IP
.nf
\f[C]
Display all available options
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-help\-list\f[B]\f[R]
.IP
.nf
\f[C]
Display list of available options (\-\-help\-list\-hidden for more)
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-help\-list\-hidden\f[B]\f[R]
.IP
.nf
\f[C]
Display list of all available options
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-imports=<string>\f[B]\f[R]
.IP
.nf
\f[C]
Set the file for cdt.imports
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-include=<string>\f[B]\f[R]
.IP
.nf
\f[C]
Include file before parsing
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-info\-output\-file=<filename>\f[B]\f[R]
.IP
.nf
\f[C]
File to append \-stats and \-timer output to
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-isysroot=<string>\f[B]\f[R]
.IP
.nf
\f[C]
Set the system root directory (usually /)
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-isystem=<string>\f[B]\f[R]
.IP
.nf
\f[C]
Add directory to SYSTEM include search path
\f[R]
.fi
.PP
\f[B]\f[CB]\-l=<string>\f[B]\f[R]
.IP
.nf
\f[C]
Root name of library to link
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-lto\-opt=<string>\f[B]\f[R]
.IP
.nf
\f[C]
LTO Optimization level (O0\-O3)
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-mllvm=<string>\f[B]\f[R]
.IP
.nf
\f[C]
Pass arguments to llvm
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-no\-abigen\f[B]\f[R]
.IP
.nf
\f[C]
Disable ABI file generation
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-no\-missing\-ricardian\-clause\f[B]\f[R]
.IP
.nf
\f[C]
Disable warnings for missing Ricardian clauses
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-non\-global\-value\-max\-name\-size=<uint>\f[B]\f[R]
.IP
.nf
\f[C]
Maximum size for the name of non\-global values
\f[R]
.fi
.PP
\f[B]\f[CB]\-o=<file>\f[B]\f[R]
.IP
.nf
\f[C]
Write output to <file>
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-only\-export=<string>\f[B]\f[R]
.IP
.nf
\f[C]
Export only this symbol
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-opt\-bisect\-limit=<int>\f[B]\f[R]
.IP
.nf
\f[C]
Maximum optimization to perform
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-pass\-remarks=<pattern>\f[B]\f[R]
.IP
.nf
\f[C]
Enable optimization remarks from passes whose name match the given regular expression
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-pass\-remarks\-analysis=<pattern>\f[B]\f[R]
.IP
.nf
\f[C]
Enable optimization analysis remarks from passes whose name match the given regular expression
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-pass\-remarks\-missed=<pattern>\f[B]\f[R]
.IP
.nf
\f[C]
Enable missed optimization remarks from passes whose name match the given regular expression
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-print\-all\-options\f[B]\f[R]
.IP
.nf
\f[C]
Print all option values after command line parsing
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-print\-options\f[B]\f[R]
.IP
.nf
\f[C]
Print non\-default options after command line parsing
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-remarks\-yaml\-string\-table\f[B]\f[R]
.IP
.nf
\f[C]
Enable the usage of a string table with YAML remarks
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-rng\-seed=<seed>\f[B]\f[R]
.IP
.nf
\f[C]
Seed for the random number generator
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-shared\f[B]\f[R]
.IP
.nf
\f[C]
Make shared object native library
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-stack\-canary\f[B]\f[R]
.IP
.nf
\f[C]
Stack canary for non stack first layouts
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-stack\-size=<int>\f[B]\f[R]
.IP
.nf
\f[C]
Specifies the maximum stack size for the contract. Defaults to 8192 bytes
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-static\-func\-full\-module\-prefix\f[B]\f[R]
.IP
.nf
\f[C]
Use full module build paths in the profile counter names for static functions
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-static\-func\-strip\-dirname\-prefix=<uint>\f[B]\f[R]
.IP
.nf
\f[C]
Strip specified level of directory name from source path in the profile counter name for static functions
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-stats\f[B]\f[R]
.IP
.nf
\f[C]
Enable statistics output from program (available with Asserts)
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-stats\-json\f[B]\f[R]
.IP
.nf
\f[C]
Display statistics as json data
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-std=<string>\f[B]\f[R]
.IP
.nf
\f[C]
Language standard to compile for
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-switch\-inst\-prof\-update\-wrapper\-strict\f[B]\f[R]
.IP
.nf
\f[C]
Assert that prof branch_weights metadata is valid when creating an instance of SwitchInstProfUpdateWrapper
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-sysroot=<string>\f[B]\f[R]
.IP
.nf
\f[C]
Set the system root directory
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-time\-trace\-granularity=<uint>\f[B]\f[R]
.IP
.nf
\f[C]
Minimum time granularity (in microseconds) traced by time profiler
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-track\-memory\f[B]\f[R]
.IP
.nf
\f[C]
Enable \-time\-passes memory tracking (this may be slow)
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-use\-dbg\-addr\f[B]\f[R]
.IP
.nf
\f[C]
Use llvm.dbg.addr for all local variables
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-use\-freeing\-malloc\f[B]\f[R]
.IP
.nf
\f[C]
Set the malloc implementation to the old freeing malloc
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-use\-rt\f[B]\f[R]
.IP
.nf
\f[C]
Use software compiler\-rt
\f[R]
.fi
.PP
\f[B]\f[CB]\-v\f[B]\f[R]
.IP
.nf
\f[C]
Show commands to run and use verbose output
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-version\f[B]\f[R]
.IP
.nf
\f[C]
Display the version of this program
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-view\-background\f[B]\f[R]
.IP
.nf
\f[C]
Execute graph viewer in the background. Creates tmp file litter
\f[R]
.fi
.PP
\f[B]\f[CB]\-w\f[B]\f[R]
.IP
.nf
\f[C]
Suppress all warnings
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-warn\-action\-read\-only\f[B]\f[R]
.IP
.nf
\f[C]
Issue a warning if a read\-only action uses a write API and continue compilation
\f[R]
.fi
.SH BUGS
.PP
Please submit bug reports online at
https://github.com/AntelopeIO/cdt/issues
.SH SEE ALSO
.PP
For more details consult the full documentation and sources
https://github.com/AntelopeIO/cdt
+443
View File
@@ -0,0 +1,443 @@
---
title: CDT-CPP
section: 1
header: Contract Development Toolkit (CDT)
footer: AntelopeIO
date: April 08, 2023
---
# NAME
cdt-cpp - Antelope smart contract C++ to WebAssembly compiler
# SYNOPSIS
`cdt-cpp [options] <input file>`
# DESCRIPTION
**cdt-cpp** Is a C++ compiler which converts C++ smart contract code to WebAssemply for
execution in Antelope block chain virtual machines.
# OPTIONS
**`-C`**
Include comments in preprocessed output
**`--CC`**
Include comments from within macros in preprocessed output
**`-D=<name definition>`**
Define <macro> to <value> (or 1 if <value> omitted)
**`-U=<name>`**
Undefine any previous definition of name, either built in or defined with a -D option
**`-E`**
Only run the preprocessor
**`-I=<dir>`**
Add directory to include search path
**`-L=<dir>`**
Add directory to library search path
**`--MF=<file>`**
Write depfile output
**`--MD`**
Write depfile containing user and system headers
**`--MMD`**
Like -MD except mention only user header files, not system header files.
**`--MT=<target>`**
Specify name of main file output in depfile
**`-O=<optimization_level>`**
Optimization level s, 0-3
**`-R=<dir>`**
Add the directory dir to the list of directories to be searched for resource files
**`-S`**
Only run preprocess and compilation steps
**`-W=<warning_name>`**
Enable the specified warning.
**`--abi-version=<string>`**
Which ABI version to generate
**`--abigen`**
Generate ABI
**`--abigen_output=<string>`**
ABIGEN output
**`--allow-names`**
Allow creation of name section
**`--allow-sse`**
Should not be used, except for building libc
**`--as-secure-log-file-name=<value>`**
As secure log file name (initialized from AS_SECURE_LOG_FILE env variable)
**`--asm-macro-max-nesting-depth=<uint>`**
The maximum nesting depth allowed for assembly macros
**`-c`**
Only run preprocess, compile, and assemble steps
**`--color`**
Use colors in output (default=autodetect)
**`--contract=<string>`**
Contract name
**`--dD`**
Print macro definitions in -E mode in addition to normal output
**`--dI`**
Print include directives in -E mode in addition to normal output
**`--dM`**
Print macro definitions in -E mode instead to normal output
**`--disable-symbolication`**
Disable symbolizing crash backtraces.
**`--emit-ast`**
Emit Clang AST files for source inputs
**`--emit-ir`**
Emit llvm ir
**`--emit-llvm`**
Use the LLVM representation for assembler and object files
**`--eosio-pp-dir=<string>`**
Set the directory for eosio-pp
**`--fPIC`**
Generate position independent code. This option is used for shared libraries
**`--faligned-allocation`**
Enable C++17 aligned allocation functions
**`--fasm`**
Assemble file for x86-64
**`--fcolor-diagnostics`**
Use colors in diagnostics
**`--fcoroutine-ts`**
Enable support for the C++ Coroutines TS
**`--finline-functions`**
Inline suitable functions
**`--finline-hint-functions`**
Inline functions which are (explicitly or implicitly) marked inline
**`--fmerge-all-constants`**
Allow merging of constants
**`--fnative`**
Compile and link for x86-64
**`--fno-cfl-aa`**
Disable CFL Alias Analysis
**`--fno-elide-constructors`**
Disable C++ copy constructor elision
**`--fno-lto`**
Disable LTO
**`--fno-post-pass`**
Don't run post processing pass
**`--fno-stack-first`**
Don't set the stack first in memory
**`--fquery`**
Produce binaries for wasmql
**`--fquery-client`**
Produce binaries for wasmql
**`--fquery-server`**
Produce binaries for wasmql
**`--fstack-protector`**
Enable stack protectors for functions potentially vulnerable to stack smashing
**`--fstack-protector-all`**
Force the usage of stack protectors for all functions
**`--fstack-protector-strong`**
Use a strong heuristic to apply stack protectors to functions
**`--fstrict-enums`**
Enable optimizations based on the strict definition of an enum's value range
**`--fstrict-return`**
Always treat control flow paths that fall off the end of a non-void function as unreachable
**`--fstrict-vtable-pointers`**
Enable optimizations based on the strict rules for overwriting polymorphic C++ objects
**`--fuse-main`**
Use main as entry
**`-h`**
Alias for --help
**`--help`**
Display available options (--help-hidden for more)
**`--help-hidden`**
Display all available options
**`--help-list`**
Display list of available options (--help-list-hidden for more)
**`--help-list-hidden`**
Display list of all available options
**`--imports=<string>`**
Set the file for cdt.imports
**`--include=<string>`**
Include file before parsing
**`--info-output-file=<filename>`**
File to append -stats and -timer output to
**`--isysroot=<string>`**
Set the system root directory (usually /)
**`--isystem=<string>`**
Add directory to SYSTEM include search path
**`-l=<string>`**
Root name of library to link
**`--lto-opt=<string>`**
LTO Optimization level (O0-O3)
**`--mllvm=<string>`**
Pass arguments to llvm
**`--no-abigen`**
Disable ABI file generation
**`--no-missing-ricardian-clause`**
Disable warnings for missing Ricardian clauses
**`--non-global-value-max-name-size=<uint>`**
Maximum size for the name of non-global values
**`-o=<file>`**
Write output to <file>
**`--only-export=<string>`**
Export only this symbol
**`--opt-bisect-limit=<int>`**
Maximum optimization to perform
**`--pass-remarks=<pattern>`**
Enable optimization remarks from passes whose name match the given regular expression
**`--pass-remarks-analysis=<pattern>`**
Enable optimization analysis remarks from passes whose name match the given regular expression
**`--pass-remarks-missed=<pattern>`**
Enable missed optimization remarks from passes whose name match the given regular expression
**`--print-all-options`**
Print all option values after command line parsing
**`--print-options`**
Print non-default options after command line parsing
**`--remarks-yaml-string-table`**
Enable the usage of a string table with YAML remarks
**`--rng-seed=<seed>`**
Seed for the random number generator
**`--shared`**
Make shared object native library
**`--stack-canary`**
Stack canary for non stack first layouts
**`--stack-size=<int>`**
Specifies the maximum stack size for the contract. Defaults to 8192 bytes
**`--static-func-full-module-prefix`**
Use full module build paths in the profile counter names for static functions
**`--static-func-strip-dirname-prefix=<uint>`**
Strip specified level of directory name from source path in the profile counter name for static functions
**`--stats`**
Enable statistics output from program (available with Asserts)
**`--stats-json`**
Display statistics as json data
**`--std=<string>`**
Language standard to compile for
**`--switch-inst-prof-update-wrapper-strict`**
Assert that prof branch_weights metadata is valid when creating an instance of SwitchInstProfUpdateWrapper
**`--sysroot=<string>`**
Set the system root directory
**`--time-trace-granularity=<uint>`**
Minimum time granularity (in microseconds) traced by time profiler
**`--track-memory`**
Enable -time-passes memory tracking (this may be slow)
**`--use-dbg-addr`**
Use llvm.dbg.addr for all local variables
**`--use-freeing-malloc`**
Set the malloc implementation to the old freeing malloc
**`--use-rt`**
Use software compiler-rt
**`-v`**
Show commands to run and use verbose output
**`--version`**
Display the version of this program
**`--view-background`**
Execute graph viewer in the background. Creates tmp file litter
**`-w`**
Suppress all warnings
**`--warn-action-read-only`**
Issue a warning if a read-only action uses a write API and continue compilation
# BUGS
Please submit bug reports online at https://github.com/AntelopeIO/cdt/issues
# SEE ALSO
For more details consult the full documentation and sources https://github.com/AntelopeIO/cdt
+215
View File
@@ -0,0 +1,215 @@
.\" Automatically generated by Pandoc 2.5
.\"
.TH "CDT\-LD" "1" "April 14, 2023" "AntelopeIO" "Contract Development Toolkit (CDT)"
.hy
.SH NAME
.PP
cdt\-ld \- Antelope smart contract WebAssembly linker
.SH SYNOPSIS
.PP
\f[C]cdt\-ld [options] <input file>\f[R]
.SH DESCRIPTION
.PP
\f[B]cdt\-ld\f[R] Is a compiled smart contract linker which creates
WebAssemply code for execution in Antelope block chain virtual machines.
.SH OPTIONS
.PP
\f[B]\f[CB]\-L=<string>\f[B]\f[R]
.IP
.nf
\f[C]
Add directory to library search path
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-abi\-version=<string>\f[B]\f[R]
.IP
.nf
\f[C]
Which ABI version to generate
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-allow\-names\f[B]\f[R]
.IP
.nf
\f[C]
Allows name section to be created
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-fasm\f[B]\f[R]
.IP
.nf
\f[C]
Assemble file for x86\-64
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-fnative\f[B]\f[R]
.IP
.nf
\f[C]
Compile and link for x86\-64
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-fno\-cfl\-aa\f[B]\f[R]
.IP
.nf
\f[C]
Disable CFL Alias Analysis
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-fno\-lto\f[B]\f[R]
.IP
.nf
\f[C]
Disable LTO
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-fno\-post\-pass\f[B]\f[R]
.IP
.nf
\f[C]
Don\[aq]t run post processing pass
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-fno\-stack\-first\f[B]\f[R]
.IP
.nf
\f[C]
Don\[aq]t set the stack first in memory
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-fquery\f[B]\f[R]
.IP
.nf
\f[C]
Produce binaries for wasmql
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-fquery\-client\f[B]\f[R]
.IP
.nf
\f[C]
Produce binaries for wasmql
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-fquery\-server\f[B]\f[R]
.IP
.nf
\f[C]
Produce binaries for wasmql
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-fuse\-main\f[B]\f[R]
.IP
.nf
\f[C]
Use main as entry
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-help\f[B]\f[R]
.IP
.nf
\f[C]
Display available options (\-\-help\-hidden for more)
\f[R]
.fi
.PP
\f[B]\f[CB]\-l=<string>\f[B]\f[R]
.IP
.nf
\f[C]
Root name of library to link
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-lto\-opt=<string>\f[B]\f[R]
.IP
.nf
\f[C]
LTO Optimization level (O0\-O3)
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-mllvm=<string>\f[B]\f[R]
.IP
.nf
\f[C]
Pass arguments to llvm
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-no\-abigen\f[B]\f[R]
.IP
.nf
\f[C]
Disable ABI file generation
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-no\-missing\-ricardian\-clause\f[B]\f[R]
.IP
.nf
\f[C]
Disable warnings for missing Ricardian clauses
\f[R]
.fi
.PP
\f[B]\f[CB]\-o=<string>\f[B]\f[R]
.IP
.nf
\f[C]
Write output to <file>
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-shared\f[B]\f[R]
.IP
.nf
\f[C]
Make shared object native library
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-stack\-canary\f[B]\f[R]
.IP
.nf
\f[C]
Stack canary for non stack first layouts
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-stack\-size=<int>\f[B]\f[R]
.IP
.nf
\f[C]
Specifies the maximum stack size for the contract. Defaults to 8192 bytes
\f[R]
.fi
.PP
\f[B]\f[CB]\-\-version\f[B]\f[R]
.IP
.nf
\f[C]
Display the version of this program
\f[R]
.fi
.SH BUGS
.PP
Please submit bug reports online at
https://github.com/AntelopeIO/cdt/issues
.SH SEE ALSO
.PP
For more details consult the full documentation and sources
https://github.com/AntelopeIO/cdt
+127
View File
@@ -0,0 +1,127 @@
---
title: CDT-LD
section: 1
header: Contract Development Toolkit (CDT)
footer: AntelopeIO
date: April 14, 2023
---
# NAME
cdt-ld - Antelope smart contract WebAssembly linker
# SYNOPSIS
`cdt-ld [options] <input file>`
# DESCRIPTION
**cdt-ld** Is a compiled smart contract linker which creates WebAssemply code for
execution in Antelope block chain virtual machines.
# OPTIONS
**`-L=<string>`**
Add directory to library search path
**`--abi-version=<string>`**
Which ABI version to generate
**`--allow-names`**
Allows name section to be created
**`--fasm`**
Assemble file for x86-64
**`--fnative`**
Compile and link for x86-64
**`--fno-cfl-aa`**
Disable CFL Alias Analysis
**`--fno-lto`**
Disable LTO
**`--fno-post-pass`**
Don't run post processing pass
**`--fno-stack-first`**
Don't set the stack first in memory
**`--fquery`**
Produce binaries for wasmql
**`--fquery-client`**
Produce binaries for wasmql
**`--fquery-server`**
Produce binaries for wasmql
**`--fuse-main`**
Use main as entry
**`--help`**
Display available options (--help-hidden for more)
**`-l=<string>`**
Root name of library to link
**`--lto-opt=<string>`**
LTO Optimization level (O0-O3)
**`--mllvm=<string>`**
Pass arguments to llvm
**`--no-abigen`**
Disable ABI file generation
**`--no-missing-ricardian-clause`**
Disable warnings for missing Ricardian clauses
**`-o=<string>`**
Write output to <file>
**`--shared`**
Make shared object native library
**`--stack-canary`**
Stack canary for non stack first layouts
**`--stack-size=<int>`**
Specifies the maximum stack size for the contract. Defaults to 8192 bytes
**`--version`**
Display the version of this program
# BUGS
Please submit bug reports online at https://github.com/AntelopeIO/cdt/issues
# SEE ALSO
For more details consult the full documentation and sources https://github.com/AntelopeIO/cdt
+263
View File
@@ -0,0 +1,263 @@
.\" Automatically generated by Pandoc 2.5
.\"
.TH "CDT\-OBJDUMP" "1" "April 18, 2023" "AntelopeIO" "Contract Development Toolkit (CDT)"
.hy
.SH NAME
.PP
cdt\-objdump \- manual page for cdt\-objdump
.SH DESCRIPTION
.PP
cdt\-objdump is a CDT object file dumper
.SH SYNOPSIS
.PP
cdt\-objdump [options] <input object files>
.SH OPTIONS
.PP
Generic Options:
.PP
\f[B]\-\-help\f[R] \- Display available options
(\f[B]\-\-help\-hidden\f[R] for more)
.PP
\f[B]\-\-help\-list\f[R] \- Display list of available options
(\f[B]\-\-help\-list\-hidden\f[R] for more)
.PP
\f[B]\-\-version\f[R] \- Display the version of this program
.PP
cdt\-objdump MachO Specific Options:
.PP
\f[B]\-\-arch=\f[R]<string> \- architecture(s) from a Mach\-O file to
dump
.PP
\f[B]\-\-archive\-member\-offsets\f[R] \- Print the offset to each
archive member for Mach\-O archives (requires \f[B]\-\-macho\f[R] and
\f[B]\-archive\-headers\f[R])
.PP
\f[B]\-\-bind\f[R] \- Display mach\-o binding info
.PP
\f[B]\-\-data\-in\-code\f[R] \- Print the data in code table for Mach\-O
objects (requires \f[B]\-\-macho\f[R])
.PP
\f[B]\-\-dis\-symname=\f[R]<string> \- disassemble just this
symbol\[aq]s instructions (requires \f[B]\-\-macho\f[R])
.PP
\f[B]\-\-dsym=\f[R]<string> \- Use .dSYM file for debug info
.PP
\f[B]\-\-dylib\-id\f[R] \- Print the shared library\[aq]s id for the
dylib Mach\-O file (requires \f[B]\-\-macho\f[R])
.PP
\f[B]\-\-dylibs\-used\f[R] \- Print the shared libraries used for linked
Mach\-O files (requires \f[B]\-\-macho\f[R])
.PP
\f[B]\-\-exports\-trie\f[R] \- Display mach\-o exported symbols
.PP
\f[B]\-\-full\-leading\-addr\f[R] \- Print full leading address
.PP
\f[B]\-g\f[R] \- Print line information from debug info if available
.PP
\f[B]\-\-indirect\-symbols\f[R] \- Print indirect symbol table for
Mach\-O objects (requires \f[B]\-\-macho\f[R])
.PP
\f[B]\-\-info\-plist\f[R] \- Print the info plist section as strings for
Mach\-O objects (requires \f[B]\-\-macho\f[R])
.PP
\f[B]\-\-lazy\-bind\f[R] \- Display mach\-o lazy binding info
.PP
\f[B]\-\-link\-opt\-hints\f[R] \- Print the linker optimization hints
for Mach\-O objects (requires \f[B]\-\-macho\f[R])
.PP
\f[B]\-\-no\-leading\-headers\f[R] \- Print no leading headers
.PP
\f[B]\-\-no\-symbolic\-operands\f[R] \- do not symbolic operands when
disassembling (requires \f[B]\-\-macho\f[R])
.PP
\f[B]\-\-non\-verbose\f[R] \- Print the info for Mach\-O objects in
non\-verbose or numeric form (requires \f[B]\-\-macho\f[R])
.PP
\f[B]\-\-objc\-meta\-data\f[R] \- Print the Objective\-C runtime meta
data for Mach\-O files (requires \f[B]\-\-macho\f[R])
.PP
\f[B]\-\-private\-header\f[R] \- Display only the first format specific
file header
.PP
\f[B]\-\-rebase\f[R] \- Display mach\-o rebasing info
.PP
\f[B]\-\-universal\-headers\f[R] \- Print Mach\-O universal headers
(requires \f[B]\-\-macho\f[R])
.PP
\f[B]\-\-weak\-bind\f[R] \- Display mach\-o weak binding info
.PP
cdt\-objdump Options:
.PP
\f[B]\-C\f[R] \- Alias for \f[B]\-\-demangle\f[R]
.PP
\f[B]\-D\f[R] \- Alias for \f[B]\-\-disassemble\-all\f[R]
.PP
\f[B]\-M\f[R] \- Alias for \f[B]\-\-disassembler\-options\f[R]
.PP
\f[B]\-R\f[R] \- Alias for \f[B]\-\-dynamic\-reloc\f[R]
.PP
\f[B]\-S\f[R] \- Alias for \f[B]\-\-source\f[R]
.PP
\f[B]\-T\f[R] \- Alias for \f[B]\-\-dynamic\-syms\f[R]
.PP
\f[B]\-a\f[R] \- Alias for \f[B]\-\-archive\-headers\f[R]
.PP
\f[B]\-\-adjust\-vma=\f[R]<offset> \- Increase the displayed address by
the specified offset
.PP
\f[B]\-\-all\-headers\f[R] \- Display all available header information
.PP
\f[B]\-\-arch\-name=\f[R]<string> \- Target arch to disassemble for, see
\f[B]\-version\f[R] for available targets
.PP
\f[B]\-\-archive\-headers\f[R] \- Display archive header information
.PP
\f[B]\-d\f[R] \- Alias for \f[B]\-\-disassemble\f[R]
.PP
\f[B]\-\-debug\-vars\f[R] \- Print the locations (in registers or
memory) of source\-level variables alongside disassembly
.PP
\f[B]\-\-debug\-vars=\f[R]<value> \- Print the locations (in registers
or memory) of source\-level variables alongside disassembly
.TP
.B =<empty>
\- unicode
.TP
.B =unicode
\- unicode
.TP
.B =ascii
\- unicode
.PP
\f[B]\-\-debug\-vars\-indent=\f[R]<int> \- Distance to indent the
source\-level variable display, relative to the start of the disassembly
.PP
\f[B]\-\-demangle\f[R] \- Demangle symbols names
.PP
\f[B]\-\-disassemble\f[R] \- Display assembler mnemonics for the machine
instructions
.PP
\f[B]\-\-disassemble\-all\f[R] \- Display assembler mnemonics for the
machine instructions
.PP
\f[B]\-\-disassemble\-symbols=\f[R]<string> \- List of symbols to
disassemble.
Accept demangled names when \f[B]\-\-demangle\f[R] is specified,
otherwise accept mangled names
.PP
\f[B]\-\-disassemble\-zeroes\f[R] \- Do not skip blocks of zeroes when
disassembling
.PP
\f[B]\-\-disassembler\-options=\f[R]<options> \- Pass target specific
disassembler options
.PP
\f[B]\-\-dwarf=\f[R]<value> \- Dump of dwarf debug sections:
.TP
.B =frames
\- .debug_frame
.PP
\f[B]\-\-dynamic\-reloc\f[R] \- Display the dynamic relocation entries
in the file
.PP
\f[B]\-\-dynamic\-syms\f[R] \- Display the contents of the dynamic
symbol table
.PP
\f[B]\-f\f[R] \- Alias for \f[B]\-\-file\-headers\f[R]
.PP
\f[B]\-\-fault\-map\-section\f[R] \- Display contents of faultmap
section
.PP
\f[B]\-\-file\-headers\f[R] \- Display the contents of the overall file
header
.PP
\f[B]\-\-full\-contents\f[R] \- Display the content of each section
.PP
\f[B]\-h\f[R] \- Alias for \f[B]\-\-section\-headers\f[R]
.PP
\f[B]\-\-headers\f[R] \- Alias for \f[B]\-\-section\-headers\f[R]
.PP
\f[B]\-j\f[R] \- Alias for \f[B]\-\-section\f[R]
.PP
\f[B]\-l\f[R] \- Alias for \f[B]\-\-line\-numbers\f[R]
.PP
\f[B]\-\-line\-numbers\f[R] \- Display source line numbers with
disassembly.
Implies disassemble object
.PP
\f[B]\-m\f[R] \- Alias for \f[B]\-\-macho\f[R]
.PP
\f[B]\-\-macho\f[R] \- Use MachO specific object file parser
.PP
\f[B]\-\-mattr=\f[R]<a1,+a2,\-a3,...> \- Target specific attributes
.PP
\f[B]\-\-mcpu=\f[R]<cpu\-name> \- Target a specific cpu type
(\f[B]\-mcpu\f[R]=\f[I]help\f[R] for details)
.PP
\f[B]\-\-no\-leading\-addr\f[R] \- Print no leading address
.PP
\f[B]\-\-no\-show\-raw\-insn\f[R] \- When disassembling instructions, do
not print the instruction bytes.
.PP
\f[B]\-p\f[R] \- Alias for \f[B]\-\-private\-headers\f[R]
.PP
\f[B]\-\-print\-imm\-hex\f[R] \- Use hex format for immediate values
.PP
\f[B]\-\-private\-headers\f[R] \- Display format specific file headers
.PP
\f[B]\-r\f[R] \- Alias for \f[B]\-\-reloc\f[R]
.PP
\f[B]\-\-raw\-clang\-ast\f[R] \- Dump the raw binary contents of the
clang AST section
.PP
\f[B]\-\-reloc\f[R] \- Display the relocation entries in the file
.PP
\f[B]\-s\f[R] \- Alias for \f[B]\-\-full\-contents\f[R]
.PP
\f[B]\-\-section=\f[R]<string> \- Operate on the specified sections
only.
With \f[B]\-\-macho\f[R] dump segment,section
.PP
\f[B]\-\-section\-headers\f[R] \- Display summaries of the headers for
each section.
.PP
\f[B]\-\-show\-lma\f[R] \- Display LMA column when dumping ELF section
headers
.PP
\f[B]\-\-source\f[R] \- Display source inlined with disassembly.
Implies disassemble object
.PP
\f[B]\-\-start\-address=\f[R]<address> \- Disassemble beginning at
address
.PP
\f[B]\-\-stop\-address=\f[R]<address> \- Stop disassembly at address
.PP
\f[B]\-\-symbol\-description\f[R] \- Add symbol description for
disassembly.
This option is for XCOFF files only
.PP
\f[B]\-\-syms\f[R] \- Display the symbol table
.PP
\f[B]\-t\f[R] \- Alias for \f[B]\-\-syms\f[R]
.PP
\f[B]\-\-triple=\f[R]<string> \- Target triple to disassemble for, see
\f[B]\-version\f[R] for available targets
.PP
\f[B]\-u\f[R] \- Alias for \f[B]\-\-unwind\-info\f[R]
.PP
\f[B]\-\-unwind\-info\f[R] \- Display unwind information
.PP
\f[B]\-\-wide\f[R] \- Ignored for compatibility with GNU objdump
.PP
\f[B]\-x\f[R] \- Alias for \f[B]\-\-all\-headers\f[R]
.PP
\f[B]\-z\f[R] \- Alias for \f[B]\-\-disassemble\-zeroes\f[R]
.PP
Pass \[at]FILE as argument to read options from FILE.
.SH BUGS
.PP
Please submit bug reports online at
https://github.com/AntelopeIO/cdt/issues
.SH SEE ALSO
.PP
For more details consult the full documentation and sources
https://github.com/AntelopeIO/cdt
+262
View File
@@ -0,0 +1,262 @@
---
date: April 18, 2023
section: 1
title: 'CDT-OBJDUMP'
footer: AntelopeIO
header: Contract Development Toolkit (CDT)
---
# NAME
cdt-objdump - manual page for cdt-objdump
# DESCRIPTION
cdt-objdump is a CDT object file dumper
# SYNOPSIS
cdt-objdump \[options\] \<input object files\>
# OPTIONS
Generic Options:
**\--help** - Display available options (**\--help-hidden** for more)
**\--help-list** - Display list of available options
(**\--help-list-hidden** for more)
**\--version** - Display the version of this program
cdt-objdump MachO Specific Options:
**\--arch=**\<string\> - architecture(s) from a Mach-O file to dump
**\--archive-member-offsets** - Print the offset to each archive member
for Mach-O archives (requires **\--macho** and **-archive-headers**)
**\--bind** - Display mach-o binding info
**\--data-in-code** - Print the data in code table for Mach-O objects
(requires **\--macho**)
**\--dis-symname=**\<string\> - disassemble just this symbol\'s
instructions (requires **\--macho**)
**\--dsym=**\<string\> - Use .dSYM file for debug info
**\--dylib-id** - Print the shared library\'s id for the dylib Mach-O
file (requires **\--macho**)
**\--dylibs-used** - Print the shared libraries used for linked Mach-O
files (requires **\--macho**)
**\--exports-trie** - Display mach-o exported symbols
**\--full-leading-addr** - Print full leading address
**-g** - Print line information from debug info if available
**\--indirect-symbols** - Print indirect symbol table for Mach-O objects
(requires **\--macho**)
**\--info-plist** - Print the info plist section as strings for Mach-O
objects (requires **\--macho**)
**\--lazy-bind** - Display mach-o lazy binding info
**\--link-opt-hints** - Print the linker optimization hints for Mach-O
objects (requires **\--macho**)
**\--no-leading-headers** - Print no leading headers
**\--no-symbolic-operands** - do not symbolic operands when
disassembling (requires **\--macho**)
**\--non-verbose** - Print the info for Mach-O objects in non-verbose or
numeric form (requires **\--macho**)
**\--objc-meta-data** - Print the Objective-C runtime meta data for
Mach-O files (requires **\--macho**)
**\--private-header** - Display only the first format specific file
header
**\--rebase** - Display mach-o rebasing info
**\--universal-headers** - Print Mach-O universal headers (requires
**\--macho**)
**\--weak-bind** - Display mach-o weak binding info
cdt-objdump Options:
**-C** - Alias for **\--demangle**
**-D** - Alias for **\--disassemble-all**
**-M** - Alias for **\--disassembler-options**
**-R** - Alias for **\--dynamic-reloc**
**-S** - Alias for **\--source**
**-T** - Alias for **\--dynamic-syms**
**-a** - Alias for **\--archive-headers**
**\--adjust-vma=**\<offset\> - Increase the displayed address by the
specified offset
**\--all-headers** - Display all available header information
**\--arch-name=**\<string\> - Target arch to disassemble for, see
**-version** for available targets
**\--archive-headers** - Display archive header information
**-d** - Alias for **\--disassemble**
**\--debug-vars** - Print the locations (in registers or memory) of
source-level variables alongside disassembly
**\--debug-vars=**\<value\> - Print the locations (in registers or
memory) of source-level variables alongside disassembly
=\<empty\>
: \- unicode
=unicode
: \- unicode
=ascii
: \- unicode
**\--debug-vars-indent=**\<int\> - Distance to indent the source-level
variable display, relative to the start of the disassembly
**\--demangle** - Demangle symbols names
**\--disassemble** - Display assembler mnemonics for the machine
instructions
**\--disassemble-all** - Display assembler mnemonics for the machine
instructions
**\--disassemble-symbols=**\<string\> - List of symbols to disassemble.
Accept demangled names when **\--demangle** is specified, otherwise
accept mangled names
**\--disassemble-zeroes** - Do not skip blocks of zeroes when
disassembling
**\--disassembler-options=**\<options\> - Pass target specific
disassembler options
**\--dwarf=**\<value\> - Dump of dwarf debug sections:
=frames
: \- .debug\_frame
**\--dynamic-reloc** - Display the dynamic relocation entries in the
file
**\--dynamic-syms** - Display the contents of the dynamic symbol table
**-f** - Alias for **\--file-headers**
**\--fault-map-section** - Display contents of faultmap section
**\--file-headers** - Display the contents of the overall file header
**\--full-contents** - Display the content of each section
**-h** - Alias for **\--section-headers**
**\--headers** - Alias for **\--section-headers**
**-j** - Alias for **\--section**
**-l** - Alias for **\--line-numbers**
**\--line-numbers** - Display source line numbers with disassembly.
Implies disassemble object
**-m** - Alias for **\--macho**
**\--macho** - Use MachO specific object file parser
**\--mattr=**\<a1,+a2,-a3,\...\> - Target specific attributes
**\--mcpu=**\<cpu-name\> - Target a specific cpu type (**-mcpu**=*help*
for details)
**\--no-leading-addr** - Print no leading address
**\--no-show-raw-insn** - When disassembling instructions, do not print
the instruction bytes.
**-p** - Alias for **\--private-headers**
**\--print-imm-hex** - Use hex format for immediate values
**\--private-headers** - Display format specific file headers
**-r** - Alias for **\--reloc**
**\--raw-clang-ast** - Dump the raw binary contents of the clang AST
section
**\--reloc** - Display the relocation entries in the file
**-s** - Alias for **\--full-contents**
**\--section=**\<string\> - Operate on the specified sections only. With
**\--macho** dump segment,section
**\--section-headers** - Display summaries of the headers for each
section.
**\--show-lma** - Display LMA column when dumping ELF section headers
**\--source** - Display source inlined with disassembly. Implies
disassemble object
**\--start-address=**\<address\> - Disassemble beginning at address
**\--stop-address=**\<address\> - Stop disassembly at address
**\--symbol-description** - Add symbol description for disassembly. This
option is for XCOFF files only
**\--syms** - Display the symbol table
**-t** - Alias for **\--syms**
**\--triple=**\<string\> - Target triple to disassemble for, see
**-version** for available targets
**-u** - Alias for **\--unwind-info**
**\--unwind-info** - Display unwind information
**\--wide** - Ignored for compatibility with GNU objdump
**-x** - Alias for **\--all-headers**
**-z** - Alias for **\--disassemble-zeroes**
Pass \@FILE as argument to read options from FILE.
# BUGS
Please submit bug reports online at https://github.com/AntelopeIO/cdt/issues
# SEE ALSO
For more details consult the full documentation and sources https://github.com/AntelopeIO/cdt
+4
View File
@@ -0,0 +1,4 @@
#!/bin/bash
for file in cdt-*.1.md; do
pandoc "$file" -s -t man -o "${file%.md}"
done
-1
View File
@@ -21,7 +21,6 @@ set(CMAKE_CXX_EXTENSIONS ON)
add_subdirectory(libc)
add_subdirectory(libc++)
add_subdirectory(eosiolib)
add_subdirectory(boost)
add_subdirectory(rt)
if (ENABLE_NATIVE_COMPILER)
+59 -37
View File
@@ -1,50 +1,72 @@
set(PARENT_PROJECT_NAME ${PROJECT_NAME})
file(GLOB HEADERS "*.hpp"
"*.h")
add_library(eosio
eosiolib.cpp
crypto.cpp
${HEADERS})
if (${PARENT_PROJECT_NAME} STREQUAL "cdt_tools")
project(native_eosio)
add_library( ${PROJECT_NAME}
eosiolib.cpp
crypto.cpp
malloc.cpp
${HEADERS} )
target_compile_definitions(${PROJECT_NAME} PUBLIC EOSIO_NATIVE EOSIOLIB_DISABLE_MALLOC)
target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_SOURCE_DIR}/../libraries/eosiolib/core
${CMAKE_SOURCE_DIR}/../libraries/meta_refl/include)
target_compile_options(${PROJECT_NAME} PUBLIC -fPIC -fexceptions -fno-rtti)
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "12.0")
target_compile_options(${PROJECT_NAME} PUBLIC -Wno-attributes)
else()
target_compile_options(${PROJECT_NAME} PUBLIC -Wno-attributes=gnu::eosio_wasm_import)
target_compile_options(${PROJECT_NAME} PUBLIC -Wno-attributes=eosio::ignore)
endif()
endif()
else()
add_library(eosio
eosiolib.cpp
crypto.cpp
${HEADERS})
add_library(eosio_malloc
malloc.cpp
${HEADERS})
add_library(eosio_malloc
malloc.cpp
${HEADERS})
add_library(eosio_dsm
simple_malloc.cpp
${HEADERS})
add_library(eosio_dsm
simple_malloc.cpp
${HEADERS})
add_library(eosio_cmem
memory.cpp
${HEADERS})
add_library(eosio_cmem
memory.cpp
${HEADERS})
set_target_properties(eosio_malloc PROPERTIES LINKER_LANGUAGE C)
set_target_properties(eosio_malloc PROPERTIES LINKER_LANGUAGE C)
target_include_directories(eosio PUBLIC
${CMAKE_SOURCE_DIR}/libc/cdt-musl/include
${CMAKE_SOURCE_DIR}/libc/cdt-musl/src/internal
${CMAKE_SOURCE_DIR}/libc/cdt-musl/src/crypt
${CMAKE_SOURCE_DIR}/libc/cdt-musl/arch/eos
${CMAKE_SOURCE_DIR}/libc++/cdt-libcxx/include
${CMAKE_SOURCE_DIR}
${CMAKE_SOURCE_DIR}/boost/include)
target_include_directories(eosio PUBLIC
${CMAKE_SOURCE_DIR}/libc/cdt-musl/include
${CMAKE_SOURCE_DIR}/libc/cdt-musl/src/internal
${CMAKE_SOURCE_DIR}/libc/cdt-musl/src/crypt
${CMAKE_SOURCE_DIR}/libc/cdt-musl/arch/eos
${CMAKE_SOURCE_DIR}/libc++/cdt-libcxx/include
${CMAKE_SOURCE_DIR})
target_link_libraries( eosio c c++ )
add_custom_command( TARGET eosio POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:eosio> ${BASE_BINARY_DIR}/lib )
add_custom_command( TARGET eosio_malloc POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:eosio_malloc> ${BASE_BINARY_DIR}/lib )
add_custom_command( TARGET eosio_dsm POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:eosio_dsm> ${BASE_BINARY_DIR}/lib )
add_custom_command( TARGET eosio_cmem POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:eosio_cmem> ${BASE_BINARY_DIR}/lib )
target_link_libraries( eosio c c++ )
add_custom_command( TARGET eosio POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:eosio> ${BASE_BINARY_DIR}/lib )
add_custom_command( TARGET eosio_malloc POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:eosio_malloc> ${BASE_BINARY_DIR}/lib )
add_custom_command( TARGET eosio_dsm POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:eosio_dsm> ${BASE_BINARY_DIR}/lib )
add_custom_command( TARGET eosio_cmem POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:eosio_cmem> ${BASE_BINARY_DIR}/lib )
if (ENABLE_NATIVE_COMPILER)
add_native_library(native_eosio
eosiolib.cpp
crypto.cpp
malloc.cpp
${HEADERS})
if (ENABLE_NATIVE_COMPILER)
add_native_library(native_eosio
eosiolib.cpp
crypto.cpp
malloc.cpp
${HEADERS})
add_dependencies( native_eosio eosio )
add_custom_command( TARGET native_eosio POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:native_eosio> ${BASE_BINARY_DIR}/lib )
endif()
add_dependencies( native_eosio eosio )
add_custom_command( TARGET native_eosio POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:native_eosio> ${BASE_BINARY_DIR}/lib )
endif()
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/../eosiolib DESTINATION ${BASE_BINARY_DIR}/include FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp")
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/../eosiolib DESTINATION ${BASE_BINARY_DIR}/include FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp")
endif()
+10
View File
@@ -168,6 +168,16 @@ uint64_t publication_time( void );
__attribute__((eosio_wasm_import))
capi_name current_receiver( void );
/**
* Get the hash of the code currently published on the given account
* @param account Name of the account to hash the code of
* @param struct_version Version specifying the desired format of the returned struct
* @param result_buffer Buffer wherein the result should be written
* @param buffer_size Size in bytes of result_buffer
*/
__attribute__((eosio_wasm_import))
uint32_t get_code_hash( uint64_t account, uint32_t struct_version, char* result_buffer, size_t buffer_size );
/**
* Set the action return value which will be included in the action_receipt
* @brief Set the action return value
@@ -0,0 +1,40 @@
#pragma once
#include "types.h"
#ifdef __cplusplus
extern "C" {
#endif
__attribute__((eosio_wasm_import))
int32_t bls_g1_add(const char* op1, uint32_t op1_len, const char* op2, uint32_t op2_len, char* res, uint32_t res_len);
__attribute__((eosio_wasm_import))
int32_t bls_g2_add(const char* op1, uint32_t op1_len, const char* op2, uint32_t op2_len, char* res, uint32_t res_len);
__attribute__((eosio_wasm_import))
int32_t bls_g1_mul(const char* point, uint32_t point_len, const char* scalar, uint32_t scalar_len, char* res, uint32_t res_len);
__attribute__((eosio_wasm_import))
int32_t bls_g2_mul(const char* point, uint32_t point_len, const char* scalar, uint32_t scalar_len, char* res, uint32_t res_len);
__attribute__((eosio_wasm_import))
int32_t bls_g1_exp(const char* points, uint32_t points_len, const char* scalars, uint32_t scalars_len, uint32_t n, char* res, uint32_t res_len);
__attribute__((eosio_wasm_import))
int32_t bls_g2_exp(const char* points, uint32_t points_len, const char* scalars, uint32_t scalars_len, uint32_t n, char* res, uint32_t res_len);
__attribute__((eosio_wasm_import))
int32_t bls_pairing(const char* g1_points, uint32_t g1_points_len, const char* g2_points, uint32_t g2_points_len, uint32_t n, char* res, uint32_t res_len);
__attribute__((eosio_wasm_import))
int32_t bls_g1_map(const char* e, uint32_t e_len, char* res, uint32_t res_len);
__attribute__((eosio_wasm_import))
int32_t bls_g2_map(const char* e, uint32_t e_len, char* res, uint32_t res_len);
__attribute__((eosio_wasm_import))
int32_t bls_fp_mod(const char* s, uint32_t s_len, char* res, uint32_t res_len);
#ifdef __cplusplus
}
#endif
+2
View File
@@ -6,6 +6,8 @@
#pragma once
#include "types.h"
#include "eosio/types.hpp"
#ifdef __cplusplus
extern "C" {
#endif
+12 -2
View File
@@ -32,7 +32,12 @@ typedef uint64_t capi_name;
/**
* EOSIO Public Key. K1 and R1 keys are 34 bytes. Newer keys can be variable-sized
*/
struct __attribute__((deprecated("newer public key types cannot be represented as a fixed size structure", "char[]")))
struct
#ifdef __GNUC__
__attribute__((deprecated("newer public key types cannot be represented as a fixed size structure, use char[] instead")))
#else
__attribute__((deprecated("newer public key types cannot be represented as a fixed size structure", "char[]")))
#endif
capi_public_key {
char data[34];
};
@@ -40,7 +45,12 @@ capi_public_key {
/**
* EOSIO Signature. K1 and R1 signatures are 66 bytes. Newer signatures can be variable-sized
*/
struct __attribute__((deprecated("newer signature types cannot be represented as a fixed size structure", "char[]")))
struct
#ifdef __GNUC__
__attribute__((deprecated("newer public key types cannot be represented as a fixed size structure, use char[] instead")))
#else
__attribute__((deprecated("newer public key types cannot be represented as a fixed size structure", "char[]")))
#endif
capi_signature {
uint8_t data[66];
};
+64 -10
View File
@@ -4,18 +4,15 @@
*/
#pragma once
#include <cstdlib>
#include <type_traits>
#include "../../core/eosio/serialize.hpp"
#include "../../core/eosio/datastream.hpp"
#include "../../core/eosio/name.hpp"
#include "../../core/eosio/fixed_bytes.hpp"
#include "../../core/eosio/ignore.hpp"
#include "../../core/eosio/time.hpp"
#include <boost/preprocessor/variadic/size.hpp>
#include <boost/preprocessor/variadic/to_tuple.hpp>
#include <boost/preprocessor/tuple/enum.hpp>
#include <boost/preprocessor/facilities/overload.hpp>
namespace eosio {
namespace internal_use_do_not_use {
@@ -52,9 +49,23 @@ namespace eosio {
__attribute__((eosio_wasm_import))
uint64_t current_receiver();
__attribute__((eosio_wasm_import))
uint32_t get_code_hash( uint64_t account, uint32_t struct_version, char* result_buffer, size_t buffer_size );
}
};
struct code_hash_result {
unsigned_int struct_version;
uint64_t code_sequence;
checksum256 code_hash;
uint8_t vm_type;
uint8_t vm_version;
CDT_REFLECT(struct_version, code_sequence, code_hash, vm_type, vm_version);
EOSLIB_SERIALIZE(code_hash_result, (struct_version)(code_sequence)(code_hash)(vm_type)(vm_version));
};
/**
* @defgroup action Action
* @ingroup contracts
@@ -150,6 +161,50 @@ namespace eosio {
return name{internal_use_do_not_use::current_receiver()};
}
/**
* Get the hash of the code currently published on the given account
* @param account Name of the account to hash the code of
* @param full_result Optional: If a full result struct is desired, a pointer to the struct to populate
* @return The SHA256 hash of the specified account's code
*/
inline checksum256 get_code_hash( name account, code_hash_result* full_result = nullptr ) {
if (full_result == nullptr)
full_result = (code_hash_result*)alloca(sizeof(code_hash_result));
constexpr size_t max_stack_buffer_size = 50;
// Packed size of this struct will virtually always be less than the struct size; always less after padding
auto struct_buffer_size = sizeof(code_hash_result);
char* struct_buffer = (char*)alloca(struct_buffer_size);
using VersionType = decltype(code_hash_result::struct_version);
const VersionType STRUCT_VERSION = 0;
auto response_size =
internal_use_do_not_use::get_code_hash(account.value, STRUCT_VERSION, struct_buffer, struct_buffer_size);
// Safety check: in this case, response size should never exceed our buffer, but just in case...
bool buffer_on_heap = false;
if (response_size > struct_buffer_size) {
// Slow path: allocate an adequate buffer and try again
// No need to deallocate struct_buffer since it was alloca'd
if (response_size > max_stack_buffer_size) {
struct_buffer = (char*)malloc(response_size);
buffer_on_heap = true;
} else {
struct_buffer = (char*)alloca(response_size);
}
internal_use_do_not_use::get_code_hash(account.value, STRUCT_VERSION, struct_buffer, struct_buffer_size);
}
check(unpack<VersionType>(struct_buffer, struct_buffer_size) == STRUCT_VERSION,
"Hypervisor returned unexpected code hash struct version");
unpack(*full_result, struct_buffer, struct_buffer_size);
// If struct_buffer is heap allocated, we must free it
if (buffer_on_heap)
free(struct_buffer);
return full_result->code_hash;
}
/**
* Copy up to length bytes of current action data to the specified location
*
@@ -268,12 +323,12 @@ namespace eosio {
/**
* Name of the account the action is intended for
*/
name account;
eosio::name account;
/**
* Name of the action
*/
name name;
eosio::name name;
/**
* List of permissions that authorize this action
@@ -570,7 +625,7 @@ namespace eosio {
#define INLINE_ACTION_SENDER2( CONTRACT_CLASS, NAME )\
INLINE_ACTION_SENDER3( CONTRACT_CLASS, NAME, ::eosio::name(#NAME) )
#define INLINE_ACTION_SENDER(...) BOOST_PP_OVERLOAD(INLINE_ACTION_SENDER,__VA_ARGS__)(__VA_ARGS__)
#define INLINE_ACTION_SENDER(...) BLUEGRASS_META_OVERLOAD(INLINE_ACTION_SENDER,__VA_ARGS__)(__VA_ARGS__)
/**
* Send an inline-action from inside a contract.
@@ -599,5 +654,4 @@ INLINE_ACTION_SENDER3( CONTRACT_CLASS, NAME, ::eosio::name(#NAME) )
*/
#define SEND_INLINE_ACTION( CONTRACT, NAME, ... )\
INLINE_ACTION_SENDER(std::decay_t<decltype(CONTRACT)>, NAME)( (CONTRACT).get_self(),\
BOOST_PP_TUPLE_ENUM(BOOST_PP_VARIADIC_SIZE(__VA_ARGS__), BOOST_PP_VARIADIC_TO_TUPLE(__VA_ARGS__)) );
INLINE_ACTION_SENDER(std::decay_t<decltype(CONTRACT)>, NAME)( (CONTRACT).get_self(),__VA_ARGS__)
@@ -1,10 +1,8 @@
#pragma once
#include "action.hpp"
#include <boost/fusion/adapted/std_tuple.hpp>
#include <boost/fusion/include/std_tuple.hpp>
#include <boost/mp11/tuple.hpp>
#include <bluegrass/meta/preprocessor.hpp>
#include <tuple>
namespace eosio {
@@ -85,7 +83,7 @@ namespace eosio {
((&inst)->*func)( a... );
};
boost::mp11::tuple_apply( f2, args );
std::apply( f2, args );
if ( max_stack_buffer_size < size ) {
free(buffer);
}
@@ -95,14 +93,14 @@ namespace eosio {
/// @cond INTERNAL
// Helper macro for EOSIO_DISPATCH_INTERNAL
#define EOSIO_DISPATCH_INTERNAL( r, OP, elem ) \
case eosio::name( BOOST_PP_STRINGIZE(elem) ).value: \
#define EOSIO_DISPATCH_INTERNAL( OP, elem ) \
case eosio::name( BLUEGRASS_META_STRINGIZE(elem) ).value: \
eosio::execute_action( eosio::name(receiver), eosio::name(code), &OP::elem ); \
break;
// Helper macro for EOSIO_DISPATCH
#define EOSIO_DISPATCH_HELPER( TYPE, MEMBERS ) \
BOOST_PP_SEQ_FOR_EACH( EOSIO_DISPATCH_INTERNAL, TYPE, MEMBERS )
BLUEGRASS_META_FOREACH_SEQ( EOSIO_DISPATCH_INTERNAL, TYPE, MEMBERS )
/// @endcond
+351 -106
View File
@@ -9,9 +9,10 @@
#include "../../core/eosio/serialize.hpp"
#include "../../core/eosio/fixed_bytes.hpp"
#include <bluegrass/meta/for_each.hpp>
#include <vector>
#include <tuple>
#include <boost/hana.hpp>
#include <functional>
#include <utility>
#include <type_traits>
@@ -303,8 +304,6 @@ struct secondary_key_traits<TYPE> {\
namespace _multi_index_detail {
namespace hana = boost::hana;
template<typename T>
struct secondary_index_db_functions;
@@ -335,6 +334,10 @@ namespace _multi_index_detail {
static constexpr eosio::fixed_bytes<32> true_lowest() { return eosio::fixed_bytes<32>(); }
};
template<typename PK>
inline uint64_t to_raw_key(PK pk) { return pk; }
inline uint64_t to_raw_key(eosio::name pk) { return pk.value; }
}
/**
@@ -342,7 +345,7 @@ namespace _multi_index_detail {
*
* @ingroup multiindex
* @tparam IndexName - is the name of the index. The name must be provided as an EOSIO base32 encoded 64-bit integer and must conform to the EOSIO naming requirements of a maximum of 13 characters, the first twelve from the lowercase characters a-z, digits 1-5, and ".", and if there is a 13th character, it is restricted to lowercase characters a-p and ".".
* @tparam Extractor - is a function call operator that takes a const reference to the table object type and returns either a secondary key type or a reference to a secondary key type. It is recommended to use the `eosio::const_mem_fun` template, which is a type alias to the `boost::multi_index::const_mem_fun`. See the documentation for the Boost `const_mem_fun` key extractor for more details.
* @tparam Extractor - is a function call operator that takes a const reference to the table object type and returns either a secondary key type or a reference to a secondary key type. It is recommended to use the `eosio::const_mem_fun` template.
*
* Example:
*
@@ -436,6 +439,8 @@ class multi_index
{
private:
static_assert( std::is_same_v<decltype(_multi_index_detail::to_raw_key(std::declval<T>().primary_key())), uint64_t>,
"Primary key must be uint64_t or name" );
static_assert( sizeof...(Indices) <= 16, "multi_index only supports a maximum of 16 secondary indices" );
constexpr static bool validate_table_name( name n ) {
@@ -727,11 +732,21 @@ class multi_index
_multidx->modify( *itr, payer, std::forward<Lambda&&>(updater) );
}
template<typename Lambda>
void update( const_iterator itr, eosio::name payer, Lambda&& updater ) {
modify( itr, payer, std::forward<Lambda>(updater) );
}
template<typename Lambda>
void modify( const T& obj, eosio::name payer, Lambda&& updater ) {
_multidx->modify( obj, payer, std::forward<Lambda&&>(updater) );
}
template<typename Lambda>
void update( T& obj, eosio::name payer, Lambda&& updater ) {
_multidx->update( obj, payer, std::forward<Lambda&&>(updater) );
}
const_iterator erase( const_iterator itr ) {
eosio::check( itr != cend(), "cannot pass end iterator to erase" );
@@ -743,11 +758,17 @@ class multi_index
return itr;
}
const_iterator remove( const_iterator itr ) {
return erase(itr);
}
eosio::name get_code()const { return _multidx->get_code(); }
uint64_t get_scope()const { return _multidx->get_scope(); }
static auto extract_secondary_key(const T& obj) { return secondary_extractor_type()(obj); }
// used only for type deduction
constexpr index() : _multidx(nullptr) { }
private:
friend class multi_index;
@@ -759,32 +780,37 @@ class multi_index
template<uint64_t I>
struct intc { enum e{ value = I }; operator uint64_t()const{ return I; } };
enum index_cv { const_index = 0, mutable_index = 1 };
static constexpr auto transform_indices( ) {
using namespace _multi_index_detail;
template<std::size_t Num, typename... Values>
class make_index_tuple {
typedef decltype( hana::zip_shortest(
hana::make_tuple( intc<0>(), intc<1>(), intc<2>(), intc<3>(), intc<4>(), intc<5>(),
intc<6>(), intc<7>(), intc<8>(), intc<9>(), intc<10>(), intc<11>(),
intc<12>(), intc<13>(), intc<14>(), intc<15>() ),
hana::tuple<Indices...>() ) ) indices_input_type;
template <std::size_t... Seq>
static constexpr auto get_type(std::index_sequence<Seq...>) {
return std::make_tuple(std::make_tuple(index<eosio::name::raw(static_cast<uint64_t>(Values::index_name)),
typename Values::secondary_extractor_type,
intc<Seq>::e::value, const_index>{},
index<eosio::name::raw(static_cast<uint64_t>(Values::index_name)),
typename Values::secondary_extractor_type,
intc<Seq>::e::value, mutable_index>{})...);
}
public:
using type = decltype( get_type(std::make_index_sequence<Num>{}) );
};
return hana::transform( indices_input_type(), [&]( auto&& idx ){
typedef typename std::decay<decltype(hana::at_c<0>(idx))>::type num_type;
typedef typename std::decay<decltype(hana::at_c<1>(idx))>::type idx_type;
return hana::make_tuple( hana::type_c<index<eosio::name::raw(static_cast<uint64_t>(idx_type::index_name)),
typename idx_type::secondary_extractor_type,
num_type::e::value, false> >,
hana::type_c<index<eosio::name::raw(static_cast<uint64_t>(idx_type::index_name)),
typename idx_type::secondary_extractor_type,
num_type::e::value, true> > );
});
}
typedef decltype( multi_index::transform_indices() ) indices_type;
indices_type _indices;
using indices_type = typename make_index_tuple<sizeof... (Indices), Indices...>::type;
class make_extractor_tuple {
template <typename Obj, typename IndicesType, std::size_t... Seq>
static constexpr auto extractor_tuple(IndicesType, const Obj& obj, std::index_sequence<Seq...>) {
return std::make_tuple(std::tuple_element_t<const_index, std::tuple_element_t<Seq, IndicesType>>::extract_secondary_key(obj)...);
}
public:
template <typename Obj, typename IndicesType>
static constexpr auto get_extractor_tuple(IndicesType, const Obj& obj) {
return extractor_tuple(IndicesType{}, obj, std::make_index_sequence<std::tuple_size_v<IndicesType>>{});
}
};
const item& load_object_by_primary_iterator( int32_t itr )const {
using namespace _multi_index_detail;
@@ -810,15 +836,14 @@ class multi_index
ds >> val;
i.__primary_itr = itr;
hana::for_each( _indices, [&]( auto& idx ) {
typedef typename decltype(+hana::at_c<1>(idx))::type index_type;
bluegrass::meta::for_each(indices_type{}, [&](auto idx){
typedef std::tuple_element_t<const_index, decltype(idx)> index_type;
i.__iters[ index_type::number() ] = -1;
});
});
const item* ptr = itm.get();
auto pk = itm->primary_key();
auto pk = _multi_index_detail::to_raw_key(itm->primary_key());
auto pitr = itm->__primary_itr;
_items_vector.emplace_back( std::move(itm), pk, pitr );
@@ -830,6 +855,56 @@ class multi_index
return *ptr;
} /// load_object_by_primary_iterator
template<typename Lambda>
void modify_object(T& obj, name payer, Lambda&& updater) {
using namespace _multi_index_detail;
auto& objitem = static_cast<item&>(obj);
eosio::check( objitem.__idx == this, "object passed to modify is not in multi_index" );
eosio::check( _code == current_receiver(), "cannot modify objects in table of another contract" ); // Quick fix for mutating db using multi_index that shouldn't allow mutation. Real fix can come in RC2.
auto secondary_keys = make_extractor_tuple::get_extractor_tuple(indices_type{}, obj);
uint64_t pk = to_raw_key(obj.primary_key());
updater( obj );
eosio::check( pk == to_raw_key(obj.primary_key()), "updater cannot change primary key when modifying an object" );
size_t size = pack_size( obj );
//using malloc/free here potentially is not exception-safe, although WASM doesn't support exceptions
void* buffer = max_stack_buffer_size < size ? malloc(size) : alloca(size);
datastream<char*> ds( (char*)buffer, size );
ds << obj;
internal_use_do_not_use::db_update_i64( objitem.__primary_itr, payer.value, buffer, size );
if ( max_stack_buffer_size < size ) {
free( buffer );
}
if( pk >= _next_primary_key )
_next_primary_key = (pk >= no_available_primary_key) ? no_available_primary_key : (pk + 1);
bluegrass::meta::for_each(indices_type{}, [&](auto idx){
typedef std::tuple_element_t<const_index, decltype(idx)> index_type;
auto secondary = index_type::extract_secondary_key( obj );
if( memcmp( &std::get<index_type::index_number>(secondary_keys), &secondary, sizeof(secondary) ) != 0 ) {
auto indexitr = objitem.__iters[index_type::number()];
if( indexitr < 0 ) {
typename index_type::secondary_key_type temp_secondary_key;
indexitr = objitem.__iters[index_type::number()]
= secondary_index_db_functions<typename index_type::secondary_key_type>::db_idx_find_primary( _code.value, _scope, index_type::name(), pk, temp_secondary_key );
}
secondary_index_db_functions<typename index_type::secondary_key_type>::db_idx_update( indexitr, payer.value, secondary );
}
} );
}
public:
/**
* Constructs an instance of a Multi-Index table.
@@ -850,7 +925,7 @@ class multi_index
* - `Indices` is a list of up to 16 secondary indices.
* - Each must be a default constructable class or struct
* - Each must have a function call operator that takes a const reference to the table object type and returns either a secondary key type or a reference to a secondary key type
* - It is recommended to use the eosio::const_mem_fun template, which is a type alias to the boost::multi_index::const_mem_fun. See the documentation for the Boost const_mem_fun key extractor for more details.
* - It is recommended to use the eosio::const_mem_fun template
*
* Example:
*
@@ -1266,8 +1341,10 @@ class multi_index
* EOSIO_DISPATCH( addressbook, (myaction) )
* @endcode
*/
const_iterator lower_bound( uint64_t primary )const {
auto itr = internal_use_do_not_use::db_lowerbound_i64( _code.value, _scope, static_cast<uint64_t>(TableName), primary );
template<typename PK>
const_iterator lower_bound( PK primary )const {
uint64_t primary_int = _multi_index_detail::to_raw_key(primary);
auto itr = internal_use_do_not_use::db_lowerbound_i64( _code.value, _scope, static_cast<uint64_t>(TableName), primary_int );
if( itr < 0 ) return end();
const auto& obj = load_object_by_primary_iterator( itr );
return {this, &obj};
@@ -1310,8 +1387,10 @@ class multi_index
* EOSIO_DISPATCH( addressbook, (myaction) )
* @endcode
*/
const_iterator upper_bound( uint64_t primary )const {
auto itr = internal_use_do_not_use::db_upperbound_i64( _code.value, _scope, static_cast<uint64_t>(TableName), primary );
template<typename PK>
const_iterator upper_bound( PK primary )const {
uint64_t primary_int = _multi_index_detail::to_raw_key(primary);
auto itr = internal_use_do_not_use::db_upperbound_i64( _code.value, _scope, static_cast<uint64_t>(TableName), primary_int );
if( itr < 0 ) return end();
const auto& obj = load_object_by_primary_iterator( itr );
return {this, &obj};
@@ -1412,13 +1491,13 @@ class multi_index
auto get_index() {
using namespace _multi_index_detail;
auto res = hana::find_if( _indices, []( auto&& in ) {
return std::integral_constant<bool, static_cast<uint64_t>(std::decay<typename decltype(+hana::at_c<0>(in))::type>::type::index_name) == static_cast<uint64_t>(IndexName)>();
constexpr uint64_t index_num = bluegrass::meta::for_each(indices_type{}, [](auto idx){
return std::tuple_element_t<const_index, decltype(idx)>::index_name == static_cast<uint64_t>(IndexName);
});
static_assert( res != hana::nothing, "name provided is not the name of any secondary index within multi_index" );
static_assert( index_num < sizeof...(Indices), "name provided is not the name of any secondary index within multi_index" );
return typename decltype(+hana::at_c<0>(res.value()))::type(this);
return std::tuple_element_t<const_index, std::tuple_element_t<index_num, indices_type>>(this);
}
/**
@@ -1463,13 +1542,13 @@ class multi_index
auto get_index()const {
using namespace _multi_index_detail;
auto res = hana::find_if( _indices, []( auto&& in ) {
return std::integral_constant<bool, static_cast<uint64_t>(std::decay<typename decltype(+hana::at_c<1>(in))::type>::type::index_name) == static_cast<uint64_t>(IndexName)>();
constexpr uint64_t index_num = bluegrass::meta::for_each(indices_type{}, [](auto idx){
return std::tuple_element_t<mutable_index, decltype(idx)>::index_name == static_cast<uint64_t>(IndexName);
});
static_assert( res != hana::nothing, "name provided is not the name of any secondary index within multi_index" );
static_assert( index_num < sizeof...(Indices), "name provided is not the name of any secondary index within multi_index" );
return typename decltype(+hana::at_c<1>(res.value()))::type(this);
return std::tuple_element_t<mutable_index, std::tuple_element_t<index_num, indices_type>>(this);
}
/**
@@ -1516,6 +1595,7 @@ class multi_index
eosio::check( objitem.__idx == this, "object passed to iterator_to is not in multi_index" );
return {this, &objitem};
}
/**
* Adds a new object (i.e., row) to the table.
* @ingroup multiindex
@@ -1571,7 +1651,7 @@ class multi_index
datastream<char*> ds( (char*)buffer, size );
ds << obj;
auto pk = obj.primary_key();
uint64_t pk = _multi_index_detail::to_raw_key(obj.primary_key());
i.__primary_itr = internal_use_do_not_use::db_store_i64( _scope, static_cast<uint64_t>(TableName), payer.value, pk, buffer, size );
@@ -1582,15 +1662,15 @@ class multi_index
if( pk >= _next_primary_key )
_next_primary_key = (pk >= no_available_primary_key) ? no_available_primary_key : (pk + 1);
hana::for_each( _indices, [&]( auto& idx ) {
typedef typename decltype(+hana::at_c<0>(idx))::type index_type;
bluegrass::meta::for_each(indices_type{}, [&](auto idx){
typedef std::tuple_element_t<const_index, decltype(idx)> index_type;
i.__iters[index_type::number()] = secondary_index_db_functions<typename index_type::secondary_key_type>::db_idx_store( _scope, index_type::name(), payer.value, obj.primary_key(), index_type::extract_secondary_key(obj) );
i.__iters[index_type::number()] = secondary_index_db_functions<typename index_type::secondary_key_type>::db_idx_store( _scope, index_type::name(), payer.value, obj.primary_key(), index_type::extract_secondary_key(obj) );
});
});
const item* ptr = itm.get();
auto pk = itm->primary_key();
auto pk = _multi_index_detail::to_raw_key(itm->primary_key());
auto pitr = itm->__primary_itr;
_items_vector.emplace_back( std::move(itm), pk, pitr );
@@ -1598,6 +1678,48 @@ class multi_index
return {this, ptr};
}
/**
* Adds a new object (i.e., row) to the table, alias for emplace()
* @ingroup multiindex
*
* @param payer - Account name of the payer for the Storage usage of the new object
* @param constructor - Lambda function that does an in-place initialization of the object to be created in the table
*
* @pre A multi index table has been instantiated
* @post A new object is created in the Multi-Index table, with a unique primary key (as specified in the object). The object is serialized and written to the table. If the table does not exist, it is created.
* @post Secondary indices are updated to refer to the newly added object. If the secondary index tables do not exist, they are created.
* @post The payer is charged for the storage usage of the new object and, if the table (and secondary index tables) must be created, for the overhead of the table creation.
*
* @return A primary key iterator to the newly created object
*
* Exception - The account is not authorized to write to the table.
*
* Example:
*
* @code
* // This assumes the code from the constructor example. Replace myaction() {...}
*
* void myaction() {
* address_index addresses(_self, _self.value); // code, scope
* // add to table, first argument is account to bill for storage
* addresses.insert(_self, [&](auto& address) {
* address.account_name = "dan"_n;
* address.first_name = "Daniel";
* address.last_name = "Larimer";
* address.street = "1 EOS Way";
* address.city = "Blacksburg";
* address.state = "VA";
* });
* }
* }
* EOSIO_DISPATCH( addressbook, (myaction) )
* @endcode
*/
template<typename Lambda>
const_iterator insert( name payer, Lambda&& constructor ) {
return emplace(payer, std::forward<Lambda>(constructor));
}
/**
* Modifies an existing object in a table.
* @ingroup multiindex
@@ -1645,6 +1767,51 @@ class multi_index
modify( *itr, payer, std::forward<Lambda&&>(updater) );
}
/**
* Updates an existing object in a table, alias for modify()
* @ingroup multiindex
*
* @param itr - an iterator pointing to the object to be updated
* @param payer - account name of the payer for the storage usage of the updated row
* @param updater - lambda function that updates the target object
*
* @pre itr points to an existing element
* @pre payer is a valid account that is authorized to execute the action and be billed for storage usage.
*
* @post The updated object is serialized, then replaces the existing object in the table.
* @post Secondary indices are updated; the primary key of the updated object is not changed.
* @post The payer is charged for the storage usage of the updated object.
* @post If payer is the same as the existing payer, payer only pays for the usage difference between existing and updated object (and is refunded if this difference is negative).
* @post If payer is different from the existing payer, the existing payer is refunded for the storage usage of the existing object.
*
* Exceptions:
* If called with an invalid precondition, execution is aborted.
*
* Example:
*
* @code
* // This assumes the code from the constructor example. Replace myaction() {...}
*
* void myaction() {
* // create reference to address_index - see emplace example
* // add dan account to table - see emplace example
*
* auto itr = addresses.find("dan"_n);
* eosio::check(itr != addresses.end(), "Address for account not found");
* addresses.update( itr, account payer, [&]( auto& address ) {
* address.city = "San Luis Obispo";
* address.state = "CA";
* });
* }
* }
* EOSIO_DISPATCH( addressbook, (myaction) )
* @endcode
*/
template<typename Lambda>
void update( const_iterator itr, name payer, Lambda&& updater ) {
modify( itr, payer, std::forward<Lambda>(updater) );
}
/**
* Modifies an existing object in a table.
* @ingroup multiindex
@@ -1688,58 +1855,55 @@ class multi_index
*/
template<typename Lambda>
void modify( const T& obj, name payer, Lambda&& updater ) {
using namespace _multi_index_detail;
T& mutable_obj = const_cast<T&>(obj);
const auto& objitem = static_cast<const item&>(obj);
eosio::check( objitem.__idx == this, "object passed to modify is not in multi_index" );
auto& mutableitem = const_cast<item&>(objitem);
eosio::check( _code == current_receiver(), "cannot modify objects in table of another contract" ); // Quick fix for mutating db using multi_index that shouldn't allow mutation. Real fix can come in RC2.
modify_object(mutable_obj, payer, std::forward<Lambda>(updater));
}
auto secondary_keys = hana::transform( _indices, [&]( auto&& idx ) {
typedef typename decltype(+hana::at_c<0>(idx))::type index_type;
return index_type::extract_secondary_key( obj );
});
auto pk = obj.primary_key();
auto& mutableobj = const_cast<T&>(obj); // Do not forget the auto& otherwise it would make a copy and thus not update at all.
updater( mutableobj );
eosio::check( pk == obj.primary_key(), "updater cannot change primary key when modifying an object" );
size_t size = pack_size( obj );
//using malloc/free here potentially is not exception-safe, although WASM doesn't support exceptions
void* buffer = max_stack_buffer_size < size ? malloc(size) : alloca(size);
datastream<char*> ds( (char*)buffer, size );
ds << obj;
internal_use_do_not_use::db_update_i64( objitem.__primary_itr, payer.value, buffer, size );
if ( max_stack_buffer_size < size ) {
free( buffer );
}
if( pk >= _next_primary_key )
_next_primary_key = (pk >= no_available_primary_key) ? no_available_primary_key : (pk + 1);
hana::for_each( _indices, [&]( auto& idx ) {
typedef typename decltype(+hana::at_c<0>(idx))::type index_type;
auto secondary = index_type::extract_secondary_key( obj );
if( memcmp( &hana::at_c<index_type::index_number>(secondary_keys), &secondary, sizeof(secondary) ) != 0 ) {
auto indexitr = mutableitem.__iters[index_type::number()];
if( indexitr < 0 ) {
typename index_type::secondary_key_type temp_secondary_key;
indexitr = mutableitem.__iters[index_type::number()]
= secondary_index_db_functions<typename index_type::secondary_key_type>::db_idx_find_primary( _code.value, _scope, index_type::name(), pk, temp_secondary_key );
}
secondary_index_db_functions<typename index_type::secondary_key_type>::db_idx_update( indexitr, payer.value, secondary );
}
});
/**
* Updates an existing object in a table, alias for modify()
* @ingroup multiindex
*
* @param obj - a reference to the object to be updated
* @param payer - account name of the payer for the storage usage of the updated row
* @param updater - lambda function that updates the target object
*
* @pre obj is an existing object in the table
* @pre payer is a valid account that is authorized to execute the action and be billed for storage usage.
*
* @post The modified object is serialized, then replaces the existing object in the table.
* @post Secondary indices are updated; the primary key of the updated object is not changed.
* @post The payer is charged for the storage usage of the updated object.
* @post If payer is the same as the existing payer, payer only pays for the usage difference between existing and updated object (and is refunded if this difference is negative).
* @post If payer is different from the existing payer, the existing payer is refunded for the storage usage of the existing object.
*
* Exceptions:
* If called with an invalid precondition, execution is aborted.
*
* Example:
*
* @code
* // This assumes the code from the constructor example. Replace myaction() {...}
*
* void myaction() {
* // create reference to address_index - see emplace example
* // add dan account to table - see emplace example
*
* auto itr = addresses.find("dan"_n);
* eosio::check(itr != addresses.end(), "Address for account not found");
* addresses.update( *itr, payer, [&]( auto& address ) {
* address.city = "San Luis Obispo";
* address.state = "CA";
* });
* eosio::check(itr->city == "San Luis Obispo", "Lock arf, Address not modified");
* }
* }
* EOSIO_DISPATCH( addressbook, (myaction) )
* @endcode
*/
template<typename Lambda>
void update( T& obj, name payer, Lambda&& updater ) {
modify_object(obj, payer, std::forward<Lambda>(updater));
}
/**
@@ -1774,7 +1938,8 @@ class multi_index
* The most common mistake is when the local variable is defined as auto
* typename, instead it should be of type auto& or decltype(auto).
*/
const T& get( uint64_t primary, const char* error_msg = "unable to find key" )const {
template<typename PK>
const T& get( PK primary, const char* error_msg = "unable to find key" )const {
auto result = find( primary );
eosio::check( result != cend(), error_msg );
return *result;
@@ -1803,14 +1968,16 @@ class multi_index
* EOSIO_DISPATCH( addressbook, (myaction) )
* @endcode
*/
const_iterator find( uint64_t primary )const {
template<typename PK>
const_iterator find( PK primary )const {
auto itr2 = std::find_if(_items_vector.rbegin(), _items_vector.rend(), [&](const item_ptr& ptr) {
return ptr._item->primary_key() == primary;
});
if( itr2 != _items_vector.rend() )
return iterator_to(*(itr2->_item));
auto itr = internal_use_do_not_use::db_find_i64( _code.value, _scope, static_cast<uint64_t>(TableName), primary );
uint64_t primary_int = _multi_index_detail::to_raw_key(primary);
auto itr = internal_use_do_not_use::db_find_i64( _code.value, _scope, static_cast<uint64_t>(TableName), primary_int );
if( itr < 0 ) return end();
const item& i = load_object_by_primary_iterator( itr );
@@ -1826,14 +1993,16 @@ class multi_index
* @return An iterator to the found object which has a primary key equal to `primary` OR throws an exception if an object with primary key `primary` is not found.
*/
const_iterator require_find( uint64_t primary, const char* error_msg = "unable to find key" )const {
template<typename PK>
const_iterator require_find( PK primary, const char* error_msg = "unable to find key" )const {
auto itr2 = std::find_if(_items_vector.rbegin(), _items_vector.rend(), [&](const item_ptr& ptr) {
return ptr._item->primary_key() == primary;
});
if( itr2 != _items_vector.rend() )
return iterator_to(*(itr2->_item));
auto itr = internal_use_do_not_use::db_find_i64( _code.value, _scope, static_cast<uint64_t>(TableName), primary );
uint64_t primary_int = _multi_index_detail::to_raw_key(primary);
auto itr = internal_use_do_not_use::db_find_i64( _code.value, _scope, static_cast<uint64_t>(TableName), primary_int );
eosio::check( itr >= 0, error_msg );
const item& i = load_object_by_primary_iterator( itr );
@@ -1887,6 +2056,46 @@ class multi_index
return itr;
}
/**
* Deletes an existing object from a table using its primary key, alias for erase()
* @ingroup multiindex
*
* @param itr - An iterator pointing to the object to be removed
*
* @pre itr points to an existing element
* @post The object is removed from the table and all associated storage is reclaimed.
* @post Secondary indices associated with the table are updated.
* @post The existing payer for storage usage of the object is refunded for the table and secondary indices usage of the removed object, and if the table and indices are removed, for the associated overhead.
*
* @return For the signature with `const_iterator`, returns a pointer to the object following the removed object.
*
* Exceptions:
* The object to be removed is not in the table.
* The action is not authorized to modify the table.
* The given iterator is invalid.
*
* Example:
*
* @code
* // This assumes the code from the constructor example. Replace myaction() {...}
*
* void myaction() {
* // create reference to address_index - see emplace example
* // add dan account to table - see emplace example
*
* auto itr = addresses.find("dan"_n);
* eosio::check(itr != addresses.end(), "Address for account not found");
* addresses.delete( itr );
* eosio::check(itr != addresses.end(), "Everting lock arf, Address not erased properly");
* }
* }
* EOSIO_ABI( addressbook, (myaction) )
* @endcode
*/
const_iterator remove( const_iterator itr ) {
return erase(itr);
}
/**
* Remove an existing object from a table using its primary key.
* @ingroup multiindex
@@ -1935,8 +2144,8 @@ class multi_index
internal_use_do_not_use::db_remove_i64( objitem.__primary_itr );
hana::for_each( _indices, [&]( auto& idx ) {
typedef typename decltype(+hana::at_c<0>(idx))::type index_type;
bluegrass::meta::for_each(indices_type{}, [&](auto idx){
typedef std::tuple_element_t<const_index, decltype(idx)> index_type;
auto i = objitem.__iters[index_type::number()];
if( i < 0 ) {
@@ -1950,5 +2159,41 @@ class multi_index
_items_vector.erase(--(itr2.base()));
}
/**
* Remove an existing object from a table using its primary key, alias for erase()
* @ingroup multiindex
*
* @param obj - Object to be removed
*
* @pre obj is an existing object in the table
* @post The object is removed from the table and all associated storage is reclaimed.
* @post Secondary indices associated with the table are updated.
* @post The existing payer for storage usage of the object is refunded for the table and secondary indices usage of the removed object, and if the table and indices are removed, for the associated overhead.
*
* Exceptions:
* The object to be removed is not in the table.
* The action is not authorized to modify the table.
* The given iterator is invalid.
*
* Example:
*
* @code
* // This assumes the code from the constructor example. Replace myaction() {...}
*
* void myaction() {
* auto itr = addresses.find("dan"_n);
* eosio::check(itr != addresses.end(), "Record is not found");
* addresses.remove(*itr);
* itr = addresses.find("dan"_n);
* eosio::check(itr == addresses.end(), "Record is not deleted");
* }
* }
* EOSIO_DISPATCH( addressbook, (myaction) )
* @endcode
*/
void remove( const T& obj ) {
erase(obj);
}
};
} /// eosio
+44 -5
View File
@@ -231,7 +231,7 @@ namespace eosio {
*/
friend int64_t operator/( const asset& a, const asset& b ) {
eosio::check( b.amount != 0, "divide by zero" );
eosio::check( a.symbol == b.symbol, "comparison of assets with different symbols is not allowed" );
eosio::check( a.symbol == b.symbol, "attempt to divide assets with different symbol" );
return a.amount / b.amount;
}
@@ -462,30 +462,69 @@ namespace eosio {
return a;
}
/// Multiplication operator.
extended_asset& operator*=( int64_t b ) {
quantity *= b;
return *this;
}
/// Multiplication operator.
friend extended_asset operator*( const extended_asset& a, int64_t b ) {
return {a.quantity * b, a.contract};
}
/// Multiplication operator.
friend extended_asset operator*( int64_t a, const extended_asset& b ) {
return {a * b.quantity, b.contract};
}
/// Division operator. Follows format of 'int64_t operator/( const asset& a, const asset& b )'.
friend int64_t operator/( const extended_asset& a, const extended_asset& b ) {
eosio::check( a.contract == b.contract, "type mismatch" );
return a.quantity / b.quantity;
}
/// Division operator.
extended_asset& operator/=( int64_t b ) {
quantity /= b;
return *this;
}
/// Division operator.
friend extended_asset operator/( const extended_asset& a, int64_t b ) {
return {a.quantity / b, a.contract};
}
/// Less than operator
friend bool operator<( const extended_asset& a, const extended_asset& b ) {
eosio::check( a.contract == b.contract, "type mismatch" );
return a.quantity < b.quantity;
}
/// Greater than operator
friend bool operator>( const extended_asset& a, const extended_asset& b ) {
eosio::check( a.contract == b.contract, "type mismatch" );
return a.quantity > b.quantity;
}
/// Comparison operator
/// Equality operator
friend bool operator==( const extended_asset& a, const extended_asset& b ) {
return std::tie(a.quantity, a.contract) == std::tie(b.quantity, b.contract);
}
/// Comparison operator
/// Inequality operator
friend bool operator!=( const extended_asset& a, const extended_asset& b ) {
return std::tie(a.quantity, a.contract) != std::tie(b.quantity, b.contract);
}
/// Comparison operator
/// Less than or equal operator
friend bool operator<=( const extended_asset& a, const extended_asset& b ) {
eosio::check( a.contract == b.contract, "type mismatch" );
return a.quantity <= b.quantity;
}
/// Comparison operator
/// Greater than or equal operator
friend bool operator>=( const extended_asset& a, const extended_asset& b ) {
eosio::check( a.contract == b.contract, "type mismatch" );
return a.quantity >= b.quantity;
@@ -0,0 +1,170 @@
#pragma once
#include "fixed_bytes.hpp"
#include "varint.hpp"
#include "serialize.hpp"
#include <array>
#include <vector>
namespace eosio {
namespace internal_use_do_not_use {
extern "C" {
__attribute__((eosio_wasm_import))
int32_t bls_g1_add(const char* op1, uint32_t op1_len, const char* op2, uint32_t op2_len, char* res, uint32_t res_len);
__attribute__((eosio_wasm_import))
int32_t bls_g2_add(const char* op1, uint32_t op1_len, const char* op2, uint32_t op2_len, char* res, uint32_t res_len);
__attribute__((eosio_wasm_import))
int32_t bls_g1_mul(const char* point, uint32_t point_len, const char* scalar, uint32_t scalar_len, char* res, uint32_t res_len);
__attribute__((eosio_wasm_import))
int32_t bls_g2_mul(const char* point, uint32_t point_len, const char* scalar, uint32_t scalar_len, char* res, uint32_t res_len);
__attribute__((eosio_wasm_import))
int32_t bls_g1_exp(const char* points, uint32_t points_len, const char* scalars, uint32_t scalars_len, uint32_t n, char* res, uint32_t res_len);
__attribute__((eosio_wasm_import))
int32_t bls_g2_exp(const char* points, uint32_t points_len, const char* scalars, uint32_t scalars_len, uint32_t n, char* res, uint32_t res_len);
__attribute__((eosio_wasm_import))
int32_t bls_pairing(const char* g1_points, uint32_t g1_points_len, const char* g2_points, uint32_t g2_points_len, uint32_t n, char* res, uint32_t res_len);
__attribute__((eosio_wasm_import))
int32_t bls_g1_map(const char* e, uint32_t e_len, char* res, uint32_t res_len);
__attribute__((eosio_wasm_import))
int32_t bls_g2_map(const char* e, uint32_t e_len, char* res, uint32_t res_len);
__attribute__((eosio_wasm_import))
int32_t bls_fp_mod(const char* s, uint32_t s_len, char* res, uint32_t res_len);
}
}
using bls_scalar = uint8_t[32];
using bls_fp = uint8_t[48];
using bls_fp2 = bls_fp[2];
using bls_g1 = uint8_t[144];
using bls_g2 = uint8_t[288];
using bls_gt = uint8_t[576];
int32_t bls_g1_add(const bls_g1& op1, const bls_g1& op2, bls_g1& res)
{
return internal_use_do_not_use::bls_g1_add(
reinterpret_cast<const char*>(op1),
sizeof(bls_g1),
reinterpret_cast<const char*>(op2),
sizeof(bls_g1),
reinterpret_cast<char*>(res),
sizeof(bls_g1)
);
}
int32_t bls_g2_add(const bls_g2& op1, const bls_g2& op2, bls_g2& res)
{
return internal_use_do_not_use::bls_g2_add(
reinterpret_cast<const char*>(op1),
sizeof(bls_g2),
reinterpret_cast<const char*>(op2),
sizeof(bls_g2),
reinterpret_cast<char*>(res),
sizeof(bls_g2)
);
}
int32_t bls_g1_mul(const bls_g1& point, const bls_scalar& scalar, bls_g1& res)
{
return internal_use_do_not_use::bls_g1_mul(
reinterpret_cast<const char*>(point),
sizeof(bls_g1),
reinterpret_cast<const char*>(scalar),
sizeof(bls_scalar),
reinterpret_cast<char*>(res),
sizeof(bls_g1)
);
}
int32_t bls_g2_mul(const bls_g2& point, const bls_scalar& scalar, bls_g2& res)
{
return internal_use_do_not_use::bls_g2_mul(
reinterpret_cast<const char*>(point),
sizeof(bls_g2),
reinterpret_cast<const char*>(scalar),
sizeof(bls_scalar),
reinterpret_cast<char*>(res),
sizeof(bls_g2)
);
}
int32_t bls_g1_exp(const bls_g1* points, const bls_scalar* scalars, const uint32_t num, bls_g1& res)
{
return internal_use_do_not_use::bls_g1_exp(
reinterpret_cast<const char*>(points),
num * sizeof(bls_g1),
reinterpret_cast<const char*>(scalars),
num * sizeof(bls_scalar),
num,
reinterpret_cast<char*>(res),
sizeof(bls_g1)
);
}
int32_t bls_g2_exp(const bls_g2* points, const bls_scalar* scalars, const uint32_t num, bls_g2& res)
{
return internal_use_do_not_use::bls_g2_exp(
reinterpret_cast<const char*>(points),
num * sizeof(bls_g2),
reinterpret_cast<const char*>(scalars),
num * sizeof(bls_scalar),
num,
reinterpret_cast<char*>(res),
sizeof(bls_g2)
);
}
int32_t bls_pairing(const bls_g1* g1_points, const bls_g2* g2_points, const uint32_t num, bls_gt& res)
{
return internal_use_do_not_use::bls_pairing(
reinterpret_cast<const char*>(g1_points),
num * sizeof(bls_g1),
reinterpret_cast<const char*>(g2_points),
num * sizeof(bls_g2),
num,
reinterpret_cast<char*>(res),
sizeof(bls_gt)
);
}
int32_t bls_g1_map(const bls_fp& e, bls_g1& res)
{
return internal_use_do_not_use::bls_g1_map(
reinterpret_cast<const char*>(e),
sizeof(bls_fp),
reinterpret_cast<char*>(res),
sizeof(bls_g1)
);
}
int32_t bls_g2_map(const bls_fp2& e, bls_g2& res)
{
return internal_use_do_not_use::bls_g2_map(
reinterpret_cast<const char*>(e),
sizeof(bls_fp2),
reinterpret_cast<char*>(res),
sizeof(bls_g2)
);
}
int32_t bls_fp_mod(const uint8_t* s, bls_fp& res)
{
return internal_use_do_not_use::bls_fp_mod(
reinterpret_cast<const char*>(s),
64,
reinterpret_cast<char*>(res),
sizeof(bls_fp)
);
}
}
+5 -5
View File
@@ -224,7 +224,7 @@ namespace eosio {
inline int32_t alt_bn128_add( const char* op1, uint32_t op1_len, const char* op2, uint32_t op2_len, char* result, uint32_t result_len ) {
return internal_use_do_not_use::alt_bn128_add( op1, op1_len, op2, op2_len, result, result_len);
}
/**
* Scalar multiplication operation on the elliptic curve `alt_bn128`
*
@@ -257,7 +257,7 @@ namespace eosio {
inline int32_t alt_bn128_mul( const char* g1, uint32_t g1_len, const char* scalar, uint32_t scalar_len, char* result, uint32_t result_len ) {
return internal_use_do_not_use::alt_bn128_mul( g1, g1_len, scalar, scalar_len, result, result_len );
}
/**
* Optimal-Ate pairing check elliptic curve `alt_bn128`
*
@@ -343,7 +343,7 @@ namespace eosio {
* @param result - the result of the compression
* @return -1 if there is an error otherwise 0
*/
int32_t blake2_f( uint32_t rounds, const std::vector<char>& state, const std::vector<char>& msg, const std::vector<char>& t0_offset, const std::vector<char>& t1_offset, bool final, std::vector<char>& result) {
inline int32_t blake2_f( uint32_t rounds, const std::vector<char>& state, const std::vector<char>& msg, const std::vector<char>& t0_offset, const std::vector<char>& t1_offset, bool final, std::vector<char>& result) {
eosio::check( result.size() >= blake2f_result_size, "blake2_f result parameter's size must be >= 64" );
return internal_use_do_not_use::blake2_f( rounds, state.data(), state.size(), msg.data(), msg.size(), t0_offset.data(), t0_offset.size(), t1_offset.data(), t1_offset.size(), final, result.data(), result.size());
}
@@ -367,11 +367,11 @@ namespace eosio {
* @param result_len - size of result
* @return -1 if there is an error otherwise 0
*/
int32_t blake2_f( uint32_t rounds, const char* state, uint32_t state_len, const char* msg, uint32_t msg_len,
inline int32_t blake2_f( uint32_t rounds, const char* state, uint32_t state_len, const char* msg, uint32_t msg_len,
const char* t0_offset, uint32_t t0_len, const char* t1_offset, uint32_t t1_len, int32_t final, char* result, uint32_t result_len) {
return internal_use_do_not_use::blake2_f( rounds, state, state_len, msg, msg_len, t0_offset, t0_len, t1_offset, t1_len, final, result, result_len);
}
/**
* Hashes `data` using `sha3`
*
+42 -12
View File
@@ -5,6 +5,7 @@
#pragma once
#include "check.hpp"
#include "varint.hpp"
#include <bluegrass/meta/for_each.hpp>
#include <list>
#include <queue>
@@ -16,13 +17,7 @@
#include <optional>
#include <variant>
#include <boost/fusion/algorithm/iteration/for_each.hpp>
#include <boost/fusion/include/for_each.hpp>
#include <boost/fusion/adapted/std_tuple.hpp>
#include <boost/fusion/include/std_tuple.hpp>
#include <boost/mp11/tuple.hpp>
#include <boost/pfr.hpp>
#include <cstring>
namespace eosio {
@@ -64,7 +59,7 @@ class datastream {
* @param s - the number of bytes to read
* @return true
*/
inline bool read( char* d, size_t s ) {
inline bool read( void* d, size_t s ) {
eosio::check( size_t(_end - _pos) >= (size_t)s, "datastream attempted to read past the end" );
memcpy( d, _pos, s );
_pos += s;
@@ -770,6 +765,41 @@ datastream<Stream>& operator >> ( datastream<Stream>& ds, std::vector<T>& v ) {
return ds;
}
/**
* Serialize a basic_string
*
* @param ds - The stream to write
* @param s - The value to serialize
* @tparam Stream - Type of datastream buffer
* @tparam T - Type of the object contained in the basic_string
* @return datastream<Stream>& - Reference to the datastream
*/
template<typename Stream, typename T>
datastream<Stream>& operator << ( datastream<Stream>& ds, const std::basic_string<T>& s ) {
ds << unsigned_int(s.size());
if (s.size())
ds.write(s.data(), s.size()*sizeof(T));
return ds;
}
/**
* Deserialize a basic_string
*
* @param ds - The stream to read
* @param s - The destination for deserialized value
* @tparam Stream - Type of datastream buffer
* @tparam T - Type of the object contained in the basic_string
* @return datastream<Stream>& - Reference to the datastream
*/
template<typename Stream, typename T>
datastream<Stream>& operator >> ( datastream<Stream>& ds, std::basic_string<T>& s ) {
unsigned_int v;
ds >> v;
s.resize(v.value);
ds.read(s.data(), s.size()*sizeof(T));
return ds;
}
/**
* Serialize a set
*
@@ -864,7 +894,7 @@ datastream<Stream>& operator >> ( datastream<Stream>& ds, std::map<K,V>& m ) {
*/
template<typename Stream, typename... Args>
datastream<Stream>& operator<<( datastream<Stream>& ds, const std::tuple<Args...>& t ) {
boost::fusion::for_each( t, [&]( const auto& i ) {
bluegrass::meta::for_each( t, [&]( const auto& i ) {
ds << i;
});
return ds;
@@ -881,7 +911,7 @@ datastream<Stream>& operator<<( datastream<Stream>& ds, const std::tuple<Args...
*/
template<typename Stream, typename... Args>
datastream<Stream>& operator>>( datastream<Stream>& ds, std::tuple<Args...>& t ) {
boost::fusion::for_each( t, [&]( auto& i ) {
bluegrass::meta::for_each( t, [&]( auto& i ) {
ds >> i;
});
return ds;
@@ -898,7 +928,7 @@ datastream<Stream>& operator>>( datastream<Stream>& ds, std::tuple<Args...>& t )
*/
template<typename DataStream, typename T, std::enable_if_t<std::is_class<T>::value && _datastream_detail::is_datastream<DataStream>::value>* = nullptr>
DataStream& operator<<( DataStream& ds, const T& v ) {
boost::pfr::for_each_field(v, [&](const auto& field) {
bluegrass::meta::for_each_field(v, [&](const auto& field) {
ds << field;
});
return ds;
@@ -915,7 +945,7 @@ DataStream& operator<<( DataStream& ds, const T& v ) {
*/
template<typename DataStream, typename T, std::enable_if_t<std::is_class<T>::value && _datastream_detail::is_datastream<DataStream>::value>* = nullptr>
DataStream& operator>>( DataStream& ds, T& v ) {
boost::pfr::for_each_field(v, [&](auto& field) {
bluegrass::meta::for_each_field(v, [&](auto& field) {
ds >> field;
});
return ds;
@@ -4,6 +4,7 @@
*/
#pragma once
#include "datastream.hpp"
#include "types.hpp"
#include <array>
#include <algorithm>
+1 -1
View File
@@ -5,7 +5,7 @@
#pragma once
#include <utility>
#include <string>
#include "types.hpp"
namespace eosio {
+1 -1
View File
@@ -3,4 +3,4 @@
#include <bluegrass/meta/refl.hpp>
#define CDT_REFLECT(...) \
BLUEGRASS_META_REFL(__VA_ARGS__); \
BLUEGRASS_META_REFL(__VA_ARGS__);
+6 -10
View File
@@ -1,10 +1,6 @@
#include <boost/preprocessor/seq/for_each.hpp>
#include <boost/preprocessor/seq/enum.hpp>
#include <boost/preprocessor/seq/size.hpp>
#include <boost/preprocessor/seq/seq.hpp>
#include <boost/preprocessor/stringize.hpp>
#include <bluegrass/meta/preprocessor.hpp>
#define EOSLIB_REFLECT_MEMBER_OP( r, OP, elem ) \
#define EOSLIB_REFLECT_MEMBER_OP( OP, elem ) \
OP t.elem
/**
@@ -23,11 +19,11 @@
#define EOSLIB_SERIALIZE( TYPE, MEMBERS ) \
template<typename DataStream> \
friend DataStream& operator << ( DataStream& ds, const TYPE& t ){ \
return ds BOOST_PP_SEQ_FOR_EACH( EOSLIB_REFLECT_MEMBER_OP, <<, MEMBERS );\
return ds BLUEGRASS_META_FOREACH_SEQ( EOSLIB_REFLECT_MEMBER_OP, <<, MEMBERS );\
}\
template<typename DataStream> \
friend DataStream& operator >> ( DataStream& ds, TYPE& t ){ \
return ds BOOST_PP_SEQ_FOR_EACH( EOSLIB_REFLECT_MEMBER_OP, >>, MEMBERS );\
return ds BLUEGRASS_META_FOREACH_SEQ( EOSLIB_REFLECT_MEMBER_OP, >>, MEMBERS );\
}
/**
@@ -43,10 +39,10 @@
template<typename DataStream> \
friend DataStream& operator << ( DataStream& ds, const TYPE& t ){ \
ds << static_cast<const BASE&>(t); \
return ds BOOST_PP_SEQ_FOR_EACH( EOSLIB_REFLECT_MEMBER_OP, <<, MEMBERS );\
return ds BLUEGRASS_META_FOREACH_SEQ( EOSLIB_REFLECT_MEMBER_OP, <<, MEMBERS );\
}\
template<typename DataStream> \
friend DataStream& operator >> ( DataStream& ds, TYPE& t ){ \
ds >> static_cast<BASE&>(t); \
return ds BOOST_PP_SEQ_FOR_EACH( EOSLIB_REFLECT_MEMBER_OP, >>, MEMBERS );\
return ds BLUEGRASS_META_FOREACH_SEQ( EOSLIB_REFLECT_MEMBER_OP, >>, MEMBERS );\
}
+10
View File
@@ -0,0 +1,10 @@
/**
* @file
* @copyright defined in eos/LICENSE
*/
#pragma once
#ifdef __GNUC__
typedef __int128 int128_t;
typedef unsigned __int128 uint128_t;
#endif
+4
View File
@@ -1,5 +1,6 @@
#include <cstdlib>
#include <alloca.h>
#include <string.h>
#include "core/eosio/check.hpp"
#include "core/eosio/print.hpp"
@@ -525,6 +526,8 @@ namespace eosio {
} /// namespace eosio
extern "C" {
#ifndef EOSIOLIB_DISABLE_MALLOC
void* malloc(size_t size) {
return eosio::memory_heap.malloc(size);
}
@@ -542,5 +545,6 @@ void* realloc(void* ptr, size_t size) {
void free(void* ptr) {
return eosio::memory_heap.free(ptr);
}
#endif
}
@@ -0,0 +1,912 @@
#pragma once
#include <tuple>
#include <type_traits>
#include "function_traits.hpp"
namespace bluegrass { namespace meta {
namespace detail {
template <std::size_t Index>
using size_t_ = std::integral_constant<std::size_t, Index >;
///////////////////// Structure that can be converted to reference to anything
struct ubiq_constructor {
std::size_t ignore;
template <class Type> constexpr operator Type&() const noexcept; // Undefined, allows initialization of reference fields (T& and const T&)
};
///////////////////// Structure that can be converted to reference to anything except reference to T
template <class T>
struct ubiq_constructor_except {
template <class Type> constexpr operator std::enable_if_t<!std::is_same<T, Type>::value, Type&> () const noexcept; // Undefined
};
///////////////////// Hand-made is_aggregate_initializable_n<T> trait
// `std::is_constructible<T, ubiq_constructor_except<T>>` consumes a lot of time, so we made a separate lazy trait for it.
template <std::size_t N, class T> struct is_single_field_and_aggregate_initializable: std::false_type {};
template <class T> struct is_single_field_and_aggregate_initializable<1, T>: std::integral_constant<
bool, !std::is_constructible<T, ubiq_constructor_except<T>>::value
> {};
// Hand-made is_aggregate<T> trait:
// Aggregates could be constructed from `decltype(ubiq_constructor{I})...` but report that there's no constructor from `decltype(ubiq_constructor{I})...`
// Special case for N == 1: `std::is_constructible<T, ubiq_constructor>` returns true if N == 1 and T is copy/move constructible.
template <class T, std::size_t N>
struct is_aggregate_initializable_n {
template <std::size_t ...I>
static constexpr bool is_not_constructible_n(std::index_sequence<I...>) noexcept {
return !std::is_constructible<T, decltype(ubiq_constructor{I})...>::value
|| is_single_field_and_aggregate_initializable<N, T>::value
;
}
static constexpr bool value =
std::is_empty<T>::value
|| std::is_fundamental<T>::value
|| is_not_constructible_n(std::make_index_sequence<N>{})
;
};
///////////////////// Helper for SFINAE on fields count
template <class T, std::size_t... I>
constexpr auto enable_if_constructible_helper(std::index_sequence<I...>) noexcept
-> typename std::add_pointer<decltype(T{ ubiq_constructor{I}... })>::type;
template <class T, std::size_t N, class /*Enable*/ = decltype( enable_if_constructible_helper<T>(std::make_index_sequence<N>()) ) >
using enable_if_constructible_helper_t = std::size_t;
///////////////////// Non greedy fields count search. Templates instantiation depth is log(sizeof(T)), templates instantiation count is log(sizeof(T)).
template <class T, std::size_t N>
constexpr std::size_t detect_fields_count(size_t_<N>, size_t_<N>, long) noexcept {
return N;
}
template <class T, std::size_t Begin, std::size_t Middle>
constexpr std::size_t detect_fields_count(size_t_<Begin>, size_t_<Middle>, int) noexcept;
template <class T, std::size_t Begin, std::size_t Middle>
constexpr auto detect_fields_count(size_t_<Begin>, size_t_<Middle>, long) noexcept
-> enable_if_constructible_helper_t<T, Middle>
{
using next_t = size_t_<Middle + (Middle - Begin + 1) / 2>;
return detect_fields_count<T>(size_t_<Middle>{}, next_t{}, 1L);
}
template <class T, std::size_t Begin, std::size_t Middle>
constexpr std::size_t detect_fields_count(size_t_<Begin>, size_t_<Middle>, int) noexcept {
using next_t = size_t_<(Begin + Middle) / 2>;
return detect_fields_count<T>(size_t_<Begin>{}, next_t{}, 1L);
}
///////////////////// Greedy search. Templates instantiation depth is log(sizeof(T)), templates instantiation count is log(sizeof(T))*T in worst case.
template <class T, std::size_t N>
constexpr auto detect_fields_count_greedy_remember(size_t_<N>, long) noexcept
-> enable_if_constructible_helper_t<T, N>
{
return N;
}
template <class T, std::size_t N>
constexpr std::size_t detect_fields_count_greedy_remember(size_t_<N>, int) noexcept {
return 0;
}
template <class T, std::size_t N>
constexpr std::size_t detect_fields_count_greedy(size_t_<N>, size_t_<N>) noexcept {
return detect_fields_count_greedy_remember<T>(size_t_<N>{}, 1L);
}
template <class T, std::size_t Begin, std::size_t Last>
constexpr std::size_t detect_fields_count_greedy(size_t_<Begin>, size_t_<Last>) noexcept {
constexpr std::size_t middle = Begin + (Last - Begin) / 2;
constexpr std::size_t fields_count_big = detect_fields_count_greedy<T>(size_t_<middle + 1>{}, size_t_<Last>{});
constexpr std::size_t fields_count_small = detect_fields_count_greedy<T>(size_t_<Begin>{}, size_t_<fields_count_big ? Begin : middle>{});
return fields_count_big ? fields_count_big : fields_count_small;
}
///////////////////// Choosing between greedy and non greedy search.
template <class T, std::size_t N>
constexpr auto detect_fields_count_dispatch(size_t_<N>, long) noexcept
-> decltype(sizeof(T{}))
{
return detect_fields_count<T>(size_t_<0>{}, size_t_<N / 2 + 1>{}, 1L);
}
template <class T, std::size_t N>
constexpr std::size_t detect_fields_count_dispatch(size_t_<N>, int) noexcept {
// T is not default aggregate initialzable. It means that at least one of the members is not default constructible,
// so we have to check all the aggregate initializations for T up to N parameters and return the bigest succeeded
// (we can not use binary search for detecting fields count).
return detect_fields_count_greedy<T>(size_t_<0>{}, size_t_<N>{});
}
///////////////////// Returns non-flattened fields count
template <class T>
constexpr std::size_t fields_count() noexcept {
using type = std::remove_cv_t<T>;
static_assert(
!std::is_reference<type>::value,
"Attempt to get fields count on a reference. This is not allowed because that could hide an issue and different library users expect different behavior in that case."
);
static_assert(
std::is_copy_constructible<std::remove_all_extents_t<type>>::value,
"Type and each field in the type must be copy constructible."
);
static_assert(
!std::is_polymorphic<type>::value,
"Type must have no virtual function, because otherwise it is not aggregate initializable."
);
#ifdef __cpp_lib_is_aggregate
static_assert(
std::is_aggregate<type>::value // Does not return `true` for build in types.
|| std::is_standard_layout<type>::value, // Does not return `true` for structs that have non standard layout members.
"Type must be aggregate initializable."
);
#endif
constexpr std::size_t max_fields_count = (sizeof(type) * 8); // We multiply by 8 because we may have bitfields in T
constexpr std::size_t result = detect_fields_count_dispatch<type>(size_t_<max_fields_count>{}, 1L);
static_assert(
is_aggregate_initializable_n<type, result>::value,
"Types with user specified constructors (non-aggregate initializable types) are not supported."
);
static_assert(
result != 0 || std::is_empty<type>::value || std::is_fundamental<type>::value || std::is_reference<type>::value,
"Something went wrong. Please report this issue to the github along with the structure you're reflecting."
);
return result;
}
namespace sequence_tuple {
template <std::size_t N, class T>
struct base_from_member {
T value;
};
template <class I, class ...Tail>
struct tuple_base;
template <std::size_t... I, class ...Tail>
struct tuple_base< std::index_sequence<I...>, Tail... >
: base_from_member<I , Tail>...
{
static constexpr std::size_t size_v = sizeof...(I);
// We do not use `noexcept` in the following functions, because if user forget to put one then clang will issue an error:
// "error: exception specification of explicitly defaulted default constructor does not match the calculated one".
constexpr tuple_base() = default;
constexpr tuple_base(tuple_base&&) = default;
constexpr tuple_base(const tuple_base&) = default;
constexpr tuple_base(Tail... v) noexcept
: base_from_member<I, Tail>{ v }...
{}
};
template <>
struct tuple_base<std::index_sequence<> > {
static constexpr std::size_t size_v = 0;
};
template <std::size_t N, class T>
constexpr T& get_impl(base_from_member<N, T>& t) noexcept {
return t.value;
}
template <std::size_t N, class T>
constexpr const T& get_impl(const base_from_member<N, T>& t) noexcept {
return t.value;
}
template <std::size_t N, class T>
constexpr volatile T& get_impl(volatile base_from_member<N, T>& t) noexcept {
return t.value;
}
template <std::size_t N, class T>
constexpr const volatile T& get_impl(const volatile base_from_member<N, T>& t) noexcept {
return t.value;
}
template <std::size_t N, class T>
constexpr T&& get_impl(base_from_member<N, T>&& t) noexcept {
return std::forward<T>(t.value);
}
template <class ...Values>
struct tuple: tuple_base<
std::make_index_sequence<sizeof...(Values)>,
Values...>
{
using tuple_base<
std::make_index_sequence<sizeof...(Values)>,
Values...
>::tuple_base;
};
template <std::size_t N, class ...T>
constexpr decltype(auto) get(tuple<T...>& t) noexcept {
static_assert(N < tuple<T...>::size_v, "Tuple index out of bounds");
return get_impl<N>(t);
}
template <std::size_t N, class ...T>
constexpr decltype(auto) get(const tuple<T...>& t) noexcept {
static_assert(N < tuple<T...>::size_v, "Tuple index out of bounds");
return get_impl<N>(t);
}
template <std::size_t N, class ...T>
constexpr decltype(auto) get(const volatile tuple<T...>& t) noexcept {
static_assert(N < tuple<T...>::size_v, "Tuple index out of bounds");
return get_impl<N>(t);
}
template <std::size_t N, class ...T>
constexpr decltype(auto) get(volatile tuple<T...>& t) noexcept {
static_assert(N < tuple<T...>::size_v, "Tuple index out of bounds");
return get_impl<N>(t);
}
template <std::size_t N, class ...T>
constexpr decltype(auto) get(tuple<T...>&& t) noexcept {
static_assert(N < tuple<T...>::size_v, "Tuple index out of bounds");
return get_impl<N>(std::move(t));
}
template <std::size_t I, class T>
using tuple_element = std::remove_reference< decltype(
detail::sequence_tuple::get<I>( std::declval<T>() )
) >;
} //sequence_tuple
template <class... Args>
constexpr auto make_tuple_of_references(Args&&... args) noexcept {
return sequence_tuple::tuple<Args&...>{ args... };
}
template <class T>
constexpr auto tie_as_tuple(T&, size_t_<0>) noexcept {
return sequence_tuple::tuple<>{};
}
template <class T>
constexpr auto tie_as_tuple(T& val, size_t_<1>, std::enable_if_t<std::is_class< std::remove_cv_t<T> >::value>* = 0) noexcept {
auto& [a] = val;
return make_tuple_of_references(a);
}
template <class T>
constexpr auto tie_as_tuple(T& val, size_t_<1>, std::enable_if_t<!std::is_class< std::remove_cv_t<T> >::value>* = 0) noexcept {
return make_tuple_of_references( val );
}
template <class T>
constexpr auto tie_as_tuple(T& val, size_t_<2>) noexcept {
auto& [a,b] = val;
return make_tuple_of_references(a,b);
}
template <class T>
constexpr auto tie_as_tuple(T& val, size_t_<3>) noexcept {
auto& [a,b,c] = val;
return make_tuple_of_references(a,b,c);
}
template <class T>
constexpr auto tie_as_tuple(T& val, size_t_<4>) noexcept {
auto& [a,b,c,d] = val;
return make_tuple_of_references(a,b,c,d);
}
template <class T>
constexpr auto tie_as_tuple(T& val, size_t_<5>) noexcept {
auto& [a,b,c,d,e] = val;
return make_tuple_of_references(a,b,c,d,e);
}
template <class T>
constexpr auto tie_as_tuple(T& val, size_t_<6>) noexcept {
auto& [a,b,c,d,e,f] = val;
return make_tuple_of_references(a,b,c,d,e,f);
}
template <class T>
constexpr auto tie_as_tuple(T& val, size_t_<7>) noexcept {
auto& [a,b,c,d,e,f,g] = val;
return make_tuple_of_references(a,b,c,d,e,f,g);
}
template <class T>
constexpr auto tie_as_tuple(T& val, size_t_<8>) noexcept {
auto& [a,b,c,d,e,f,g,h] = val;
return make_tuple_of_references(a,b,c,d,e,f,g,h);
}
template <class T>
constexpr auto tie_as_tuple(T& val, size_t_<9>) noexcept {
auto& [a,b,c,d,e,f,g,h,j] = val;
return make_tuple_of_references(a,b,c,d,e,f,g,h,j);
}
template <class T>
constexpr auto tie_as_tuple(T& val, size_t_<10>) noexcept {
auto& [a,b,c,d,e,f,g,h,j,k] = val;
return make_tuple_of_references(a,b,c,d,e,f,g,h,j,k);
}
template <class T>
constexpr auto tie_as_tuple(T& val, size_t_<11>) noexcept {
auto& [a,b,c,d,e,f,g,h,j,k,l] = val;
return make_tuple_of_references(a,b,c,d,e,f,g,h,j,k,l);
}
template <class T>
constexpr auto tie_as_tuple(T& val, size_t_<12>) noexcept {
auto& [a,b,c,d,e,f,g,h,j,k,l,m] = val;
return make_tuple_of_references(a,b,c,d,e,f,g,h,j,k,l,m);
}
template <class T>
constexpr auto tie_as_tuple(T& val, size_t_<13>) noexcept {
auto& [a,b,c,d,e,f,g,h,j,k,l,m,n] = val;
return make_tuple_of_references(a,b,c,d,e,f,g,h,j,k,l,m,n);
}
template <class T>
constexpr auto tie_as_tuple(T& val, size_t_<14>) noexcept {
auto& [a,b,c,d,e,f,g,h,j,k,l,m,n,p] = val;
return make_tuple_of_references(a,b,c,d,e,f,g,h,j,k,l,m,n,p);
}
template <class T>
constexpr auto tie_as_tuple(T& val, size_t_<15>) noexcept {
auto& [a,b,c,d,e,f,g,h,j,k,l,m,n,p,q] = val;
return make_tuple_of_references(a,b,c,d,e,f,g,h,j,k,l,m,n,p,q);
}
template <class T>
constexpr auto tie_as_tuple(T& val, size_t_<16>) noexcept {
auto& [a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r] = val;
return make_tuple_of_references(a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r);
}
template <class T>
constexpr auto tie_as_tuple(T& val, size_t_<17>) noexcept {
auto& [a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s] = val;
return make_tuple_of_references(a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s);
}
template <class T>
constexpr auto tie_as_tuple(T& val, size_t_<18>) noexcept {
auto& [a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t] = val;
return make_tuple_of_references(a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t);
}
template <class T>
constexpr auto tie_as_tuple(T& val, size_t_<19>) noexcept {
auto& [a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u] = val;
return make_tuple_of_references(a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u);
}
template <class T>
constexpr auto tie_as_tuple(T& val, size_t_<20>) noexcept {
auto& [a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v] = val;
return make_tuple_of_references(a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v);
}
template <class T>
constexpr auto tie_as_tuple(T& val, size_t_<21>) noexcept {
auto& [a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w] = val;
return make_tuple_of_references(a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w);
}
template <class T>
constexpr auto tie_as_tuple(T& val, size_t_<22>) noexcept {
auto& [a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x] = val;
return make_tuple_of_references(a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x);
}
template <class T>
constexpr auto tie_as_tuple(T& val, size_t_<23>) noexcept {
auto& [a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y] = val;
return make_tuple_of_references(a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y);
}
template <class T>
constexpr auto tie_as_tuple(T& val, size_t_<24>) noexcept {
auto& [a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z] = val;
return make_tuple_of_references(a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z);
}
template <class T>
constexpr auto tie_as_tuple(T& val, size_t_<25>) noexcept {
auto& [a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A] = val;
return make_tuple_of_references(a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A);
}
template <class T>
constexpr auto tie_as_tuple(T& val, size_t_<26>) noexcept {
auto& [a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B] = val;
return make_tuple_of_references(a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B);
}
template <class T>
constexpr auto tie_as_tuple(T& val, size_t_<27>) noexcept {
auto& [a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C] = val;
return make_tuple_of_references(a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C);
}
template <class T>
constexpr auto tie_as_tuple(T& val, size_t_<28>) noexcept {
auto& [a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D] = val;
return make_tuple_of_references(a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D);
}
template <class T>
constexpr auto tie_as_tuple(T& val, size_t_<29>) noexcept {
auto& [a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E] = val;
return make_tuple_of_references(a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E);
}
template <class T>
constexpr auto tie_as_tuple(T& val, size_t_<30>) noexcept {
auto& [a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F] = val;
return make_tuple_of_references(a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F);
}
template <class T>
constexpr auto tie_as_tuple(T& val, size_t_<31>) noexcept {
auto& [a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G] = val;
return make_tuple_of_references(a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G);
}
template <class T>
constexpr auto tie_as_tuple(T& val, size_t_<32>) noexcept {
auto& [a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H] = val;
return make_tuple_of_references(a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H);
}
template <class T>
constexpr auto tie_as_tuple(T& val, size_t_<33>) noexcept {
auto& [a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,J] = val;
return make_tuple_of_references(a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,J);
}
template <class T>
constexpr auto tie_as_tuple(T& val, size_t_<34>) noexcept {
auto& [a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,J,K] = val;
return make_tuple_of_references(a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,J,K);
}
template <class T>
constexpr auto tie_as_tuple(T& val, size_t_<35>) noexcept {
auto& [a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,J,K,L] = val;
return make_tuple_of_references(a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,J,K,L);
}
template <class T>
constexpr auto tie_as_tuple(T& val, size_t_<36>) noexcept {
auto& [a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,J,K,L,M] = val;
return make_tuple_of_references(a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,J,K,L,M);
}
template <class T>
constexpr auto tie_as_tuple(T& val, size_t_<37>) noexcept {
auto& [a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,J,K,L,M,N] = val;
return make_tuple_of_references(a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,J,K,L,M,N);
}
template <class T>
constexpr auto tie_as_tuple(T& val, size_t_<38>) noexcept {
auto& [a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,J,K,L,M,N,P] = val;
return make_tuple_of_references(a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,J,K,L,M,N,P);
}
template <class T>
constexpr auto tie_as_tuple(T& val, size_t_<39>) noexcept {
auto& [a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,J,K,L,M,N,P,Q] = val;
return make_tuple_of_references(a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,J,K,L,M,N,P,Q);
}
template <class T>
constexpr auto tie_as_tuple(T& val, size_t_<40>) noexcept {
auto& [a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,J,K,L,M,N,P,Q,R] = val;
return make_tuple_of_references(a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,J,K,L,M,N,P,Q,R);
}
template <class T>
constexpr auto tie_as_tuple(T& val, size_t_<41>) noexcept {
auto& [a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,J,K,L,M,N,P,Q,R,S] = val;
return make_tuple_of_references(a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,J,K,L,M,N,P,Q,R,S);
}
template <class T>
constexpr auto tie_as_tuple(T& val, size_t_<42>) noexcept {
auto& [a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,J,K,L,M,N,P,Q,R,S,U] = val;
return make_tuple_of_references(a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,J,K,L,M,N,P,Q,R,S,U);
}
template <class T>
constexpr auto tie_as_tuple(T& val, size_t_<43>) noexcept {
auto& [a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,J,K,L,M,N,P,Q,R,S,U,V] = val;
return make_tuple_of_references(a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,J,K,L,M,N,P,Q,R,S,U,V);
}
template <class T>
constexpr auto tie_as_tuple(T& val, size_t_<44>) noexcept {
auto& [a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,J,K,L,M,N,P,Q,R,S,U,V,W] = val;
return make_tuple_of_references(a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,J,K,L,M,N,P,Q,R,S,U,V,W);
}
template <class T>
constexpr auto tie_as_tuple(T& val, size_t_<45>) noexcept {
auto& [a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,J,K,L,M,N,P,Q,R,S,U,V,W,X] = val;
return make_tuple_of_references(a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,J,K,L,M,N,P,Q,R,S,U,V,W,X);
}
template <class T>
constexpr auto tie_as_tuple(T& val, size_t_<46>) noexcept {
auto& [a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,J,K,L,M,N,P,Q,R,S,U,V,W,X,Y] = val;
return make_tuple_of_references(a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,J,K,L,M,N,P,Q,R,S,U,V,W,X,Y);
}
template <class T>
constexpr auto tie_as_tuple(T& val, size_t_<47>) noexcept {
auto& [a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,J,K,L,M,N,P,Q,R,S,U,V,W,X,Y,Z] = val;
return make_tuple_of_references(a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,J,K,L,M,N,P,Q,R,S,U,V,W,X,Y,Z);
}
template <class T>
constexpr auto tie_as_tuple(T& val, size_t_<48>) noexcept {
auto& [
a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,J,K,L,M,N,P,Q,R,S,U,V,W,X,Y,Z,
aa
] = val;
return make_tuple_of_references(
a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,J,K,L,M,N,P,Q,R,S,U,V,W,X,Y,Z,
aa
);
}
template <class T>
constexpr auto tie_as_tuple(T& val, size_t_<49>) noexcept {
auto& [
a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,J,K,L,M,N,P,Q,R,S,U,V,W,X,Y,Z,
aa,ab
] = val;
return make_tuple_of_references(
a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,J,K,L,M,N,P,Q,R,S,U,V,W,X,Y,Z,
aa,ab
);
}
template <class T>
constexpr auto tie_as_tuple(T& val, size_t_<50>) noexcept {
auto& [
a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,J,K,L,M,N,P,Q,R,S,U,V,W,X,Y,Z,
aa,ab,ac
] = val;
return make_tuple_of_references(
a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,J,K,L,M,N,P,Q,R,S,U,V,W,X,Y,Z,
aa,ab,ac
);
}
template <class T>
constexpr auto tie_as_tuple(T& val, size_t_<51>) noexcept {
auto& [
a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,J,K,L,M,N,P,Q,R,S,U,V,W,X,Y,Z,
aa,ab,ac,ad
] = val;
return make_tuple_of_references(
a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,J,K,L,M,N,P,Q,R,S,U,V,W,X,Y,Z,
aa,ab,ac,ad
);
}
template <class T>
constexpr auto tie_as_tuple(T& val, size_t_<52>) noexcept {
auto& [
a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,J,K,L,M,N,P,Q,R,S,U,V,W,X,Y,Z,
aa,ab,ac,ad,ae
] = val;
return make_tuple_of_references(
a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,J,K,L,M,N,P,Q,R,S,U,V,W,X,Y,Z,
aa,ab,ac,ad,ae
);
}
template <class T>
constexpr auto tie_as_tuple(T& val, size_t_<53>) noexcept {
auto& [
a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,J,K,L,M,N,P,Q,R,S,U,V,W,X,Y,Z,
aa,ab,ac,ad,ae,af
] = val;
return make_tuple_of_references(
a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,J,K,L,M,N,P,Q,R,S,U,V,W,X,Y,Z,
aa,ab,ac,ad,ae,af
);
}
template <class T>
constexpr auto tie_as_tuple(T& val, size_t_<54>) noexcept {
auto& [
a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,J,K,L,M,N,P,Q,R,S,U,V,W,X,Y,Z,
aa,ab,ac,ad,ae,af,ag
] = val;
return make_tuple_of_references(
a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,J,K,L,M,N,P,Q,R,S,U,V,W,X,Y,Z,
aa,ab,ac,ad,ae,af,ag
);
}
template <class T>
constexpr auto tie_as_tuple(T& val, size_t_<55>) noexcept {
auto& [
a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,J,K,L,M,N,P,Q,R,S,U,V,W,X,Y,Z,
aa,ab,ac,ad,ae,af,ag,ah
] = val;
return make_tuple_of_references(
a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,J,K,L,M,N,P,Q,R,S,U,V,W,X,Y,Z,
aa,ab,ac,ad,ae,af,ag,ah
);
}
template <class T>
constexpr auto tie_as_tuple(T& val, size_t_<56>) noexcept {
auto& [
a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,J,K,L,M,N,P,Q,R,S,U,V,W,X,Y,Z,
aa,ab,ac,ad,ae,af,ag,ah,aj
] = val;
return make_tuple_of_references(
a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,J,K,L,M,N,P,Q,R,S,U,V,W,X,Y,Z,
aa,ab,ac,ad,ae,af,ag,ah,aj
);
}
template <class T>
constexpr auto tie_as_tuple(T& val, size_t_<57>) noexcept {
auto& [
a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,J,K,L,M,N,P,Q,R,S,U,V,W,X,Y,Z,
aa,ab,ac,ad,ae,af,ag,ah,aj,ak
] = val;
return make_tuple_of_references(
a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,J,K,L,M,N,P,Q,R,S,U,V,W,X,Y,Z,
aa,ab,ac,ad,ae,af,ag,ah,aj,ak
);
}
template <class T>
constexpr auto tie_as_tuple(T& val, size_t_<58>) noexcept {
auto& [
a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,J,K,L,M,N,P,Q,R,S,U,V,W,X,Y,Z,
aa,ab,ac,ad,ae,af,ag,ah,aj,ak,al
] = val;
return make_tuple_of_references(
a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,J,K,L,M,N,P,Q,R,S,U,V,W,X,Y,Z,
aa,ab,ac,ad,ae,af,ag,ah,aj,ak,al
);
}
template <class T>
constexpr auto tie_as_tuple(T& val, size_t_<59>) noexcept {
auto& [
a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,J,K,L,M,N,P,Q,R,S,U,V,W,X,Y,Z,
aa,ab,ac,ad,ae,af,ag,ah,aj,ak,al,am
] = val;
return make_tuple_of_references(
a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,J,K,L,M,N,P,Q,R,S,U,V,W,X,Y,Z,
aa,ab,ac,ad,ae,af,ag,ah,aj,ak,al,am
);
}
template <class T>
constexpr auto tie_as_tuple(T& val, size_t_<60>) noexcept {
auto& [
a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,J,K,L,M,N,P,Q,R,S,U,V,W,X,Y,Z,
aa,ab,ac,ad,ae,af,ag,ah,aj,ak,al,am,an
] = val;
return make_tuple_of_references(
a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,J,K,L,M,N,P,Q,R,S,U,V,W,X,Y,Z,
aa,ab,ac,ad,ae,af,ag,ah,aj,ak,al,am,an
);
}
template <class T>
constexpr auto tie_as_tuple(T& val, size_t_<61>) noexcept {
auto& [
a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,J,K,L,M,N,P,Q,R,S,U,V,W,X,Y,Z,
aa,ab,ac,ad,ae,af,ag,ah,aj,ak,al,am,an,ap
] = val;
return make_tuple_of_references(
a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,J,K,L,M,N,P,Q,R,S,U,V,W,X,Y,Z,
aa,ab,ac,ad,ae,af,ag,ah,aj,ak,al,am,an,ap
);
}
template <class T>
constexpr auto tie_as_tuple(T& val, size_t_<62>) noexcept {
auto& [
a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,J,K,L,M,N,P,Q,R,S,U,V,W,X,Y,Z,
aa,ab,ac,ad,ae,af,ag,ah,aj,ak,al,am,an,ap,aq
] = val;
return make_tuple_of_references(
a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,J,K,L,M,N,P,Q,R,S,U,V,W,X,Y,Z,
aa,ab,ac,ad,ae,af,ag,ah,aj,ak,al,am,an,ap,aq
);
}
template <class T>
constexpr auto tie_as_tuple(T& val, size_t_<63>) noexcept {
auto& [
a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,J,K,L,M,N,P,Q,R,S,U,V,W,X,Y,Z,
aa,ab,ac,ad,ae,af,ag,ah,aj,ak,al,am,an,ap,aq,ar
] = val;
return make_tuple_of_references(
a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,J,K,L,M,N,P,Q,R,S,U,V,W,X,Y,Z,
aa,ab,ac,ad,ae,af,ag,ah,aj,ak,al,am,an,ap,aq,ar
);
}
template <class T>
constexpr auto tie_as_tuple(T& val, size_t_<64>) noexcept {
auto& [
a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,J,K,L,M,N,P,Q,R,S,U,V,W,X,Y,Z,
aa,ab,ac,ad,ae,af,ag,ah,aj,ak,al,am,an,ap,aq,ar,as
] = val;
return make_tuple_of_references(
a,b,c,d,e,f,g,h,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,J,K,L,M,N,P,Q,R,S,U,V,W,X,Y,Z,
aa,ab,ac,ad,ae,af,ag,ah,aj,ak,al,am,an,ap,aq,ar,as
);
}
template <class T>
constexpr auto tie_as_tuple(T& val) noexcept {
typedef size_t_<fields_count<T>()> fields_count_tag;
return detail::tie_as_tuple(val, fields_count_tag{});
}
template <class T, class F, std::size_t... I>
void for_each_field_dispatcher(T& t, F&& f, std::index_sequence<I...>) {
std::forward<F>(f)(
detail::tie_as_tuple(t)
);
}
template <class T, class F, class I, class = decltype(std::declval<F>()(std::declval<T>(), I{}))>
void for_each_field_impl_apply(T&& v, F&& f, I i, long) {
std::forward<F>(f)(std::forward<T>(v), i);
}
template <class T, class F, class I>
void for_each_field_impl_apply(T&& v, F&& f, I /*i*/, int) {
std::forward<F>(f)(std::forward<T>(v));
}
template <class T, class F, std::size_t... I>
void for_each_field_impl(T& t, F&& f, std::index_sequence<I...>, std::false_type /*move_values*/) {
const int v[] = {(
for_each_field_impl_apply(sequence_tuple::get<I>(t), std::forward<F>(f), size_t_<I>{}, 1L),
0
)...};
(void)v;
}
template <class T, class F, std::size_t... I>
void for_each_field_impl(T& t, F&& f, std::index_sequence<I...>, std::true_type /*move_values*/) {
const int v[] = {(
for_each_field_impl_apply(sequence_tuple::get<I>(std::move(t)), std::forward<F>(f), size_t_<I>{}, 1L),
0
)...};
(void)v;
}
} //detail
/// Calls `func` for each field of a `value`. Copied from boost library
///
/// \b Requires: C++17 or \constexprinit{C++14 constexpr aggregate intializable type}.
///
/// \param func must have one of the following signatures:
/// * any_return_type func(U&& field) // field of value is perfect forwarded to function
/// * any_return_type func(U&& field, std::size_t i)
/// * any_return_type func(U&& value, I i) // Here I is an `std::integral_constant<size_t, field_index>`
///
/// \param value To each field of this variable will be the `func` applied.
///
/// \rcast14
///
/// \b Example:
/// \code
/// struct my_struct { int i, short s; };
/// int sum = 0;
/// for_each_field(my_struct{20, 22}, [&sum](const auto& field) { sum += field; });
/// assert(sum == 42);
/// \endcode
template <class T, class F>
void for_each_field(T&& value, F&& func) {
constexpr std::size_t fields_count_val = detail::fields_count<std::remove_reference_t<T>>();
detail::for_each_field_dispatcher(
value,
[f = std::forward<F>(func), fields_count_val](auto&& t) mutable {
detail::for_each_field_impl(
t,
std::forward<F>(f),
std::make_index_sequence<fields_count_val>{},
std::is_rvalue_reference<T&&>{}
);
},
std::make_index_sequence<fields_count_val>{}
);
}
template <size_t I = 0, template<typename...> typename Tuple, typename Fn, typename... Ts>
constexpr size_t for_each_impl(Tuple<Ts...>& tup, Fn fn) {
if constexpr(I < sizeof...(Ts)) {
using result_t = decltype(fn(std::get<I>(tup)));
if constexpr (std::is_same_v<void, result_t>) {
fn(std::get<I>(tup));
}
else {
if (fn(std::get<I>(tup)))
return I;
}
return for_each_impl<I + 1>(tup, fn);
}
return I;
}
/// @brief iterates over tuple elements
/// @tparam Fn functor called on each element. If it returns value convertible to true
/// then for_each stops processing more elements and returns index of element
/// if function returns void or false it continues iterating until it reaches the end
/// @tparam Tuple<...> tuple type
/// @param t tuple
/// @param f functor
/// @return index of last processed element or size of tuple (if all elements were iterated)
template <typename Fn, typename Tuple>
constexpr inline auto for_each( Tuple& t, Fn f ) {
return for_each_impl(t, f);
}
template<typename Fn, typename Tuple>
constexpr inline auto for_each( const Tuple& t, Fn f ) {
return for_each_impl(const_cast<Tuple&>(t), f);
}
}} // bluegrass::meta
@@ -34,7 +34,7 @@
#define BLUEGRASS_HAS_TEMPLATE_MEMBER(ARG, NAME) \
bluegrass::meta::overloaded { \
[&](auto&& f, std::enable_if_t<std::is_class_v<std::decay_t<decltype(f)>> && \
[](auto&& f, std::enable_if_t<std::is_class_v<std::decay_t<decltype(f)>> && \
bluegrass::meta::detail::pass_type< \
decltype(&std::decay_t<decltype(f)>::type::template NAME)>(), int> = 0) constexpr { \
return true; \
@@ -65,11 +65,6 @@ namespace bluegrass { namespace meta {
template <typename T>
constexpr bool pass_type() { return true; }
template <typename>
constexpr bool is_callable_impl(...) {
return false;
}
template <typename T>
struct wrapper_t {
using type = T;
@@ -81,12 +76,6 @@ namespace bluegrass { namespace meta {
inline constexpr U&& make_dependent(U&& u) { return static_cast<U&&>(u); }
}
template <auto FN>
inline constexpr static bool is_callable_v = BLUEGRASS_HAS_MEMBER(AUTO_PARAM_WORKAROUND(FN), operator());
template <typename F>
constexpr bool is_callable(F&& fn) { return BLUEGRASS_HAS_MEMBER(fn, operator()); }
namespace detail {
template <bool Decay, typename R, typename... Args>
constexpr auto get_types(R(Args...)) -> std::tuple<R, freestanding,
@@ -111,7 +100,7 @@ namespace bluegrass { namespace meta {
std::tuple<std::conditional_t<Decay, std::decay_t<Args>, Args>...>>;
template <bool Decay, typename F>
constexpr auto get_types(F&& fn) {
if constexpr (is_callable_v<decltype(fn)>)
if constexpr (std::is_invocable<F>::value)
return get_types<Decay>(&F::operator());
else
return get_types<Decay>(fn);
@@ -153,7 +142,7 @@ namespace bluegrass { namespace meta {
constexpr auto parameters_from_impl(R(Cls::*)(Args...)const &&) -> pack_from_t<N, Args...>;
template <std::size_t N, typename F>
constexpr auto parameters_from_impl(F&& fn) {
if constexpr (is_callable_v<decltype(fn)>)
if constexpr (std::is_invocable<F>::value)
return parameters_from_impl<N>(&F::operator());
else
return parameters_from_impl<N>(fn);
@@ -1,9 +1,123 @@
#pragma once
#define BLUEGRASS_META_EXPAND(X) X
#define BLUEGRASS_META_STRINGIZE(text) BLUEGRASS_META_STRINGIZE_I(text)
#define BLUEGRASS_META_STRINGIZE_I(text) #text
#define BLUEGRASS_META_CAT(a, b) BLUEGRASS_META_CAT_I(a, b)
#define BLUEGRASS_META_CAT_I(a, b) a ## b
#define BLUEGRASS_META_EXPAND(x) BLUEGRASS_META_EXPAND_I(x)
#define BLUEGRASS_META_EXPAND_I(x) x
#define BLUEGRASS_META_GET_NTH_ARG(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, NAME, ...) NAME
#define BLUEGRASS_META_SEQ_SIZE(seq) BLUEGRASS_META_SEQ_SIZE_I(seq)
#define BLUEGRASS_META_SEQ_SIZE_I(seq) BLUEGRASS_META_CAT(BLUEGRASS_META_SEQ_SIZE_, BLUEGRASS_META_SEQ_SIZE_0 seq)
# define BLUEGRASS_META_SEQ_SIZE_0(_) BLUEGRASS_META_SEQ_SIZE_1
# define BLUEGRASS_META_SEQ_SIZE_1(_) BLUEGRASS_META_SEQ_SIZE_2
# define BLUEGRASS_META_SEQ_SIZE_2(_) BLUEGRASS_META_SEQ_SIZE_3
# define BLUEGRASS_META_SEQ_SIZE_3(_) BLUEGRASS_META_SEQ_SIZE_4
# define BLUEGRASS_META_SEQ_SIZE_4(_) BLUEGRASS_META_SEQ_SIZE_5
# define BLUEGRASS_META_SEQ_SIZE_5(_) BLUEGRASS_META_SEQ_SIZE_6
# define BLUEGRASS_META_SEQ_SIZE_6(_) BLUEGRASS_META_SEQ_SIZE_7
# define BLUEGRASS_META_SEQ_SIZE_7(_) BLUEGRASS_META_SEQ_SIZE_8
# define BLUEGRASS_META_SEQ_SIZE_8(_) BLUEGRASS_META_SEQ_SIZE_9
# define BLUEGRASS_META_SEQ_SIZE_9(_) BLUEGRASS_META_SEQ_SIZE_10
# define BLUEGRASS_META_SEQ_SIZE_10(_) BLUEGRASS_META_SEQ_SIZE_11
# define BLUEGRASS_META_SEQ_SIZE_11(_) BLUEGRASS_META_SEQ_SIZE_12
# define BLUEGRASS_META_SEQ_SIZE_12(_) BLUEGRASS_META_SEQ_SIZE_13
# define BLUEGRASS_META_SEQ_SIZE_13(_) BLUEGRASS_META_SEQ_SIZE_14
# define BLUEGRASS_META_SEQ_SIZE_14(_) BLUEGRASS_META_SEQ_SIZE_15
# define BLUEGRASS_META_SEQ_SIZE_15(_) BLUEGRASS_META_SEQ_SIZE_16
# define BLUEGRASS_META_SEQ_SIZE_16(_) BLUEGRASS_META_SEQ_SIZE_17
# define BLUEGRASS_META_SEQ_SIZE_17(_) BLUEGRASS_META_SEQ_SIZE_18
# define BLUEGRASS_META_SEQ_SIZE_18(_) BLUEGRASS_META_SEQ_SIZE_19
# define BLUEGRASS_META_SEQ_SIZE_19(_) BLUEGRASS_META_SEQ_SIZE_20
# define BLUEGRASS_META_SEQ_SIZE_20(_) BLUEGRASS_META_SEQ_SIZE_21
# define BLUEGRASS_META_SEQ_SIZE_21(_) BLUEGRASS_META_SEQ_SIZE_22
# define BLUEGRASS_META_SEQ_SIZE_22(_) BLUEGRASS_META_SEQ_SIZE_23
# define BLUEGRASS_META_SEQ_SIZE_23(_) BLUEGRASS_META_SEQ_SIZE_24
# define BLUEGRASS_META_SEQ_SIZE_24(_) BLUEGRASS_META_SEQ_SIZE_25
# define BLUEGRASS_META_SEQ_SIZE_25(_) BLUEGRASS_META_SEQ_SIZE_26
# define BLUEGRASS_META_SEQ_SIZE_26(_) BLUEGRASS_META_SEQ_SIZE_27
# define BLUEGRASS_META_SEQ_SIZE_27(_) BLUEGRASS_META_SEQ_SIZE_28
# define BLUEGRASS_META_SEQ_SIZE_28(_) BLUEGRASS_META_SEQ_SIZE_29
# define BLUEGRASS_META_SEQ_SIZE_29(_) BLUEGRASS_META_SEQ_SIZE_30
# define BLUEGRASS_META_SEQ_SIZE_30(_) BLUEGRASS_META_SEQ_SIZE_31
# define BLUEGRASS_META_SEQ_SIZE_31(_) BLUEGRASS_META_SEQ_SIZE_32
# define BLUEGRASS_META_SEQ_SIZE_32(_) BLUEGRASS_META_SEQ_SIZE_33
# define BLUEGRASS_META_SEQ_SIZE_BLUEGRASS_META_SEQ_SIZE_0 0
# define BLUEGRASS_META_SEQ_SIZE_BLUEGRASS_META_SEQ_SIZE_1 1
# define BLUEGRASS_META_SEQ_SIZE_BLUEGRASS_META_SEQ_SIZE_2 2
# define BLUEGRASS_META_SEQ_SIZE_BLUEGRASS_META_SEQ_SIZE_3 3
# define BLUEGRASS_META_SEQ_SIZE_BLUEGRASS_META_SEQ_SIZE_4 4
# define BLUEGRASS_META_SEQ_SIZE_BLUEGRASS_META_SEQ_SIZE_5 5
# define BLUEGRASS_META_SEQ_SIZE_BLUEGRASS_META_SEQ_SIZE_6 6
# define BLUEGRASS_META_SEQ_SIZE_BLUEGRASS_META_SEQ_SIZE_7 7
# define BLUEGRASS_META_SEQ_SIZE_BLUEGRASS_META_SEQ_SIZE_8 8
# define BLUEGRASS_META_SEQ_SIZE_BLUEGRASS_META_SEQ_SIZE_9 9
# define BLUEGRASS_META_SEQ_SIZE_BLUEGRASS_META_SEQ_SIZE_10 10
# define BLUEGRASS_META_SEQ_SIZE_BLUEGRASS_META_SEQ_SIZE_11 11
# define BLUEGRASS_META_SEQ_SIZE_BLUEGRASS_META_SEQ_SIZE_12 12
# define BLUEGRASS_META_SEQ_SIZE_BLUEGRASS_META_SEQ_SIZE_13 13
# define BLUEGRASS_META_SEQ_SIZE_BLUEGRASS_META_SEQ_SIZE_14 14
# define BLUEGRASS_META_SEQ_SIZE_BLUEGRASS_META_SEQ_SIZE_15 15
# define BLUEGRASS_META_SEQ_SIZE_BLUEGRASS_META_SEQ_SIZE_16 16
# define BLUEGRASS_META_SEQ_SIZE_BLUEGRASS_META_SEQ_SIZE_17 17
# define BLUEGRASS_META_SEQ_SIZE_BLUEGRASS_META_SEQ_SIZE_18 18
# define BLUEGRASS_META_SEQ_SIZE_BLUEGRASS_META_SEQ_SIZE_19 19
# define BLUEGRASS_META_SEQ_SIZE_BLUEGRASS_META_SEQ_SIZE_20 20
# define BLUEGRASS_META_SEQ_SIZE_BLUEGRASS_META_SEQ_SIZE_21 21
# define BLUEGRASS_META_SEQ_SIZE_BLUEGRASS_META_SEQ_SIZE_22 22
# define BLUEGRASS_META_SEQ_SIZE_BLUEGRASS_META_SEQ_SIZE_23 23
# define BLUEGRASS_META_SEQ_SIZE_BLUEGRASS_META_SEQ_SIZE_24 24
# define BLUEGRASS_META_SEQ_SIZE_BLUEGRASS_META_SEQ_SIZE_25 25
# define BLUEGRASS_META_SEQ_SIZE_BLUEGRASS_META_SEQ_SIZE_26 26
# define BLUEGRASS_META_SEQ_SIZE_BLUEGRASS_META_SEQ_SIZE_27 27
# define BLUEGRASS_META_SEQ_SIZE_BLUEGRASS_META_SEQ_SIZE_28 28
# define BLUEGRASS_META_SEQ_SIZE_BLUEGRASS_META_SEQ_SIZE_29 29
# define BLUEGRASS_META_SEQ_SIZE_BLUEGRASS_META_SEQ_SIZE_30 30
# define BLUEGRASS_META_SEQ_SIZE_BLUEGRASS_META_SEQ_SIZE_31 31
# define BLUEGRASS_META_SEQ_SIZE_BLUEGRASS_META_SEQ_SIZE_32 32
#define BLUEGRASS_META_SEQ_ENUM(seq) BLUEGRASS_META_SEQ_ENUM_I(seq)
#define BLUEGRASS_META_SEQ_ENUM_I(seq) BLUEGRASS_META_CAT(BLUEGRASS_META_SEQ_ENUM_, BLUEGRASS_META_SEQ_SIZE(seq)) seq
# define BLUEGRASS_META_SEQ_ENUM_1(x) x
# define BLUEGRASS_META_SEQ_ENUM_2(x) x, BLUEGRASS_META_SEQ_ENUM_1
# define BLUEGRASS_META_SEQ_ENUM_3(x) x, BLUEGRASS_META_SEQ_ENUM_2
# define BLUEGRASS_META_SEQ_ENUM_4(x) x, BLUEGRASS_META_SEQ_ENUM_3
# define BLUEGRASS_META_SEQ_ENUM_5(x) x, BLUEGRASS_META_SEQ_ENUM_4
# define BLUEGRASS_META_SEQ_ENUM_6(x) x, BLUEGRASS_META_SEQ_ENUM_5
# define BLUEGRASS_META_SEQ_ENUM_7(x) x, BLUEGRASS_META_SEQ_ENUM_6
# define BLUEGRASS_META_SEQ_ENUM_8(x) x, BLUEGRASS_META_SEQ_ENUM_7
# define BLUEGRASS_META_SEQ_ENUM_9(x) x, BLUEGRASS_META_SEQ_ENUM_8
# define BLUEGRASS_META_SEQ_ENUM_10(x) x, BLUEGRASS_META_SEQ_ENUM_9
# define BLUEGRASS_META_SEQ_ENUM_11(x) x, BLUEGRASS_META_SEQ_ENUM_10
# define BLUEGRASS_META_SEQ_ENUM_12(x) x, BLUEGRASS_META_SEQ_ENUM_11
# define BLUEGRASS_META_SEQ_ENUM_13(x) x, BLUEGRASS_META_SEQ_ENUM_12
# define BLUEGRASS_META_SEQ_ENUM_14(x) x, BLUEGRASS_META_SEQ_ENUM_13
# define BLUEGRASS_META_SEQ_ENUM_15(x) x, BLUEGRASS_META_SEQ_ENUM_14
# define BLUEGRASS_META_SEQ_ENUM_16(x) x, BLUEGRASS_META_SEQ_ENUM_15
# define BLUEGRASS_META_SEQ_ENUM_17(x) x, BLUEGRASS_META_SEQ_ENUM_16
# define BLUEGRASS_META_SEQ_ENUM_18(x) x, BLUEGRASS_META_SEQ_ENUM_17
# define BLUEGRASS_META_SEQ_ENUM_19(x) x, BLUEGRASS_META_SEQ_ENUM_18
# define BLUEGRASS_META_SEQ_ENUM_20(x) x, BLUEGRASS_META_SEQ_ENUM_19
# define BLUEGRASS_META_SEQ_ENUM_21(x) x, BLUEGRASS_META_SEQ_ENUM_20
# define BLUEGRASS_META_SEQ_ENUM_22(x) x, BLUEGRASS_META_SEQ_ENUM_21
# define BLUEGRASS_META_SEQ_ENUM_23(x) x, BLUEGRASS_META_SEQ_ENUM_22
# define BLUEGRASS_META_SEQ_ENUM_24(x) x, BLUEGRASS_META_SEQ_ENUM_23
# define BLUEGRASS_META_SEQ_ENUM_25(x) x, BLUEGRASS_META_SEQ_ENUM_24
# define BLUEGRASS_META_SEQ_ENUM_26(x) x, BLUEGRASS_META_SEQ_ENUM_25
# define BLUEGRASS_META_SEQ_ENUM_27(x) x, BLUEGRASS_META_SEQ_ENUM_26
# define BLUEGRASS_META_SEQ_ENUM_28(x) x, BLUEGRASS_META_SEQ_ENUM_27
# define BLUEGRASS_META_SEQ_ENUM_29(x) x, BLUEGRASS_META_SEQ_ENUM_28
# define BLUEGRASS_META_SEQ_ENUM_30(x) x, BLUEGRASS_META_SEQ_ENUM_29
# define BLUEGRASS_META_SEQ_ENUM_31(x) x, BLUEGRASS_META_SEQ_ENUM_30
# define BLUEGRASS_META_SEQ_ENUM_32(x) x, BLUEGRASS_META_SEQ_ENUM_31
#define BLUEGRASS_META_FE0(MAC, ...)
#define BLUEGRASS_META_FE1(MAC, A, B) MAC(A, B)
#define BLUEGRASS_META_FE2(MAC, A, B, ...) MAC(A, B) BLUEGRASS_META_FE1(MAC, A, ##__VA_ARGS__)
@@ -73,6 +187,20 @@
BLUEGRASS_META_GET_NTH_ARG("ignored", ##__VA_ARGS__, \
BLUEGRASS_META_FE32,BLUEGRASS_META_FE31,BLUEGRASS_META_FE30,BLUEGRASS_META_FE29,BLUEGRASS_META_FE28,BLUEGRASS_META_FE27,BLUEGRASS_META_FE26,BLUEGRASS_META_FE25,BLUEGRASS_META_FE24,BLUEGRASS_META_FE23,BLUEGRASS_META_FE22,BLUEGRASS_META_FE21,BLUEGRASS_META_FE20,BLUEGRASS_META_FE19,BLUEGRASS_META_FE18,BLUEGRASS_META_FE17,BLUEGRASS_META_FE16,BLUEGRASS_META_FE15,BLUEGRASS_META_FE14,BLUEGRASS_META_FE13,BLUEGRASS_META_FE12,BLUEGRASS_META_FE11,BLUEGRASS_META_FE10,BLUEGRASS_META_FE9,BLUEGRASS_META_FE8,BLUEGRASS_META_FE7,BLUEGRASS_META_FE6,BLUEGRASS_META_FE5,BLUEGRASS_META_FE4,BLUEGRASS_META_FE3,BLUEGRASS_META_FE2,BLUEGRASS_META_FE1,BLUEGRASS_META_FE0)(MAC, D, ##__VA_ARGS__)
#define BLUEGRASS_META_FOREACH_SEQ_ARGS(MAC, D, SEQ) \
(MAC, D, BLUEGRASS_META_SEQ_ENUM(SEQ))
#define BLUEGRASS_META_GET_NTH_ARG_SEQ_ARGS(...) \
("ignored", BLUEGRASS_META_SEQ_ENUM(__VA_ARGS__), BLUEGRASS_META_FE32,BLUEGRASS_META_FE31,BLUEGRASS_META_FE30,BLUEGRASS_META_FE29,BLUEGRASS_META_FE28,BLUEGRASS_META_FE27,BLUEGRASS_META_FE26,BLUEGRASS_META_FE25,BLUEGRASS_META_FE24,BLUEGRASS_META_FE23,BLUEGRASS_META_FE22,BLUEGRASS_META_FE21,BLUEGRASS_META_FE20,BLUEGRASS_META_FE19,BLUEGRASS_META_FE18,BLUEGRASS_META_FE17,BLUEGRASS_META_FE16,BLUEGRASS_META_FE15,BLUEGRASS_META_FE14,BLUEGRASS_META_FE13,BLUEGRASS_META_FE12,BLUEGRASS_META_FE11,BLUEGRASS_META_FE10,BLUEGRASS_META_FE9,BLUEGRASS_META_FE8,BLUEGRASS_META_FE7,BLUEGRASS_META_FE6,BLUEGRASS_META_FE5,BLUEGRASS_META_FE4,BLUEGRASS_META_FE3,BLUEGRASS_META_FE2,BLUEGRASS_META_FE1,BLUEGRASS_META_FE0)
#define BLUEGRASS_META_FOREACH_SEQ(MAC, D, ...) \
BLUEGRASS_META_EXPAND(BLUEGRASS_META_EXPAND(BLUEGRASS_META_GET_NTH_ARG BLUEGRASS_META_GET_NTH_ARG_SEQ_ARGS(__VA_ARGS__)) BLUEGRASS_META_FOREACH_SEQ_ARGS(MAC, D, ##__VA_ARGS__))
#define BLUEGRASS_META_FOREACH(MAC, D, ...) \
BLUEGRASS_META_GET_NTH_ARG("ignored", ##__VA_ARGS__, \
BLUEGRASS_META_FE_COMMA32,BLUEGRASS_META_FE_COMMA31,BLUEGRASS_META_FE_COMMA30,BLUEGRASS_META_FE_COMMA29,BLUEGRASS_META_FE_COMMA28,BLUEGRASS_META_FE_COMMA27,BLUEGRASS_META_FE_COMMA26,BLUEGRASS_META_FE_COMMA25,BLUEGRASS_META_FE_COMMA24,BLUEGRASS_META_FE_COMMA23,BLUEGRASS_META_FE_COMMA22,BLUEGRASS_META_FE_COMMA21,BLUEGRASS_META_FE_COMMA20,BLUEGRASS_META_FE_COMMA19,BLUEGRASS_META_FE_COMMA18,BLUEGRASS_META_FE_COMMA17,BLUEGRASS_META_FE_COMMA16,BLUEGRASS_META_FE_COMMA15,BLUEGRASS_META_FE_COMMA14,BLUEGRASS_META_FE_COMMA13,BLUEGRASS_META_FE_COMMA12,BLUEGRASS_META_FE_COMMA11,BLUEGRASS_META_FE_COMMA10,BLUEGRASS_META_FE_COMMA9,BLUEGRASS_META_FE_COMMA8,BLUEGRASS_META_FE_COMMA7,BLUEGRASS_META_FE_COMMA6,BLUEGRASS_META_FE_COMMA5,BLUEGRASS_META_FE_COMMA4,BLUEGRASS_META_FE_COMMA3,BLUEGRASS_META_FE_COMMA2,BLUEGRASS_META_FE1,BLUEGRASS_META_FE0)(MAC, D, ##__VA_ARGS__)
#define BLUEGRASS_META_ARGS_NUM(...) \
BLUEGRASS_META_GET_NTH_ARG(__VA_ARGS__, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1,)
#define BLUEGRASS_META_OVERLOAD(MAC, ...) \
BLUEGRASS_META_CAT(MAC,BLUEGRASS_META_ARGS_NUM(__VA_ARGS__))
@@ -16,7 +16,7 @@ if (NOT ${found_project})
ExternalProject_Add(
catch2_external_proj
GIT_REPOSITORY "https://github.com/catchorg/Catch2"
GIT_TAG "v2.12.2"
GIT_TAG "v2.13.10"
SOURCE_DIR @CATCH2_DIRECTORY@/catch2
BINARY_DIR @CATCH2_DIRECTORY@/catch2
BUILD_ALWAYS 0
+25 -7
View File
@@ -1,3 +1,5 @@
set(PARENT_PROJECT_NAME ${PROJECT_NAME})
project(native LANGUAGES CXX ASM)
if (NOT __APPLE)
@@ -6,8 +8,10 @@ else()
set(CRT_ASM macho_crt.s)
endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-everything -allow-sse")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-everything -allow-sse")
if (NOT ${PARENT_PROJECT_NAME} MATCHES "cdt_tools")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-everything -allow-sse")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-everything -allow-sse")
endif()
file(GLOB HEADERS "*.hpp"
"*.h")
@@ -332,15 +336,29 @@ list( APPEND softfloat_sources ${softfloat_headers} )
add_library ( sf STATIC ${softfloat_sources} )
target_include_directories( sf PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/softfloat/source/include" "${CMAKE_CURRENT_SOURCE_DIR}/softfloat/source/8086-SSE" "${CMAKE_CURRENT_SOURCE_DIR}/softfloat/build/Linux-x86_64-GCC" ${CMAKE_SOURCE_DIR})
add_native_library ( native STATIC ${softfloat_sources} intrinsics.cpp crt.cpp ${CRT_ASM} )
if (${PARENT_PROJECT_NAME} STREQUAL "cdt_tools")
add_library(${PROJECT_NAME} STATIC ${softfloat_sources} intrinsics.cpp crt_lib.cpp)
target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_SOURCE_DIR}/../libraries/eosiolib/core
${CMAKE_SOURCE_DIR}/../libraries/eosiolib/contracts
${CMAKE_SOURCE_DIR}/../libraries/eosiolib/capi
${CMAKE_SOURCE_DIR}/../libraries/meta_refl/include)
# suppress executable stack warning. this is due to absence of .note.GNU-stack
target_link_libraries(${PROJECT_NAME} PUBLIC "-Wl,-z,noexecstack")
else()
add_native_library ( native STATIC ${softfloat_sources} intrinsics.cpp crt.cpp ${CRT_ASM})
endif()
target_include_directories( native PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/softfloat/source/include" "${CMAKE_CURRENT_SOURCE_DIR}/softfloat/source/8086-SSE" "${CMAKE_CURRENT_SOURCE_DIR}/softfloat/build/Linux-x86_64-GCC" ${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/eosiolib/capi ${CMAKE_SOURCE_DIR}/eosiolib/contracts ${CMAKE_SOURCE_DIR}/eosiolib/core)
add_dependencies(native native_eosio)
add_custom_command( TARGET native POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:native> ${BASE_BINARY_DIR}/lib )
if (NOT ${PARENT_PROJECT_NAME} MATCHES "cdt_tools")
add_custom_command( TARGET native POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:native> ${BASE_BINARY_DIR}/lib )
add_custom_command( TARGET sf POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:sf> ${BASE_BINARY_DIR}/lib )
add_custom_command( TARGET sf POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:sf> ${BASE_BINARY_DIR}/lib )
file(COPY ${CMAKE_CURRENT_SOURCE_DIR} DESTINATION ${BASE_BINARY_DIR}/include/eosio FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp" PATTERN "softfloat" EXCLUDE)
file(COPY ${CMAKE_CURRENT_SOURCE_DIR} DESTINATION ${BASE_BINARY_DIR}/include/eosio FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp" PATTERN "softfloat" EXCLUDE)
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/native DESTINATION ${BASE_BINARY_DIR}/include/eosiolib FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp" PATTERN "softfloat" EXCLUDE)
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/native DESTINATION ${BASE_BINARY_DIR}/include/eosiolib FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp" PATTERN "softfloat" EXCLUDE)
endif()
+3
View File
@@ -64,6 +64,9 @@ extern "C" {
}
}
jmp_buf* __get_jmp_buf() {
return ___env_ptr;
}
void __set_env_test() {
___env_ptr = &test_env;
}
+45
View File
@@ -0,0 +1,45 @@
#include "native/eosio/crt.hpp"
#include <cstdio>
eosio::cdt::output_stream std_out;
eosio::cdt::output_stream std_err;
bool ___disable_output = false;
bool ___has_failed = false;
bool ___earlier_unit_test_has_failed = false;
static jmp_buf env;
static jmp_buf test_env;
jmp_buf* ___env_ptr = &env;
jmp_buf* __get_jmp_buf() {
return ___env_ptr;
}
void __set_env_test() {
___env_ptr = &test_env;
}
void __reset_env() {
___env_ptr = &env;
}
void _prints_l(const char* cstr, uint32_t len, uint8_t which) {
for (int i=0; i < len; i++) {
if (which == eosio::cdt::output_stream_kind::std_out)
std_out.push(cstr[i]);
else if (which == eosio::cdt::output_stream_kind::std_err)
std_err.push(cstr[i]);
if (!___disable_output) {
std::putc(cstr[i], which == eosio::cdt::output_stream_kind::std_out ? stdout : stderr);
}
}
}
void _prints(const char* cstr, uint8_t which) {
for (int i=0; cstr[i] != '\0'; i++) {
if (which == eosio::cdt::output_stream_kind::std_out)
std_out.push(cstr[i]);
else if (which == eosio::cdt::output_stream_kind::std_err)
std_err.push(cstr[i]);
if (!___disable_output)
std::putc(cstr[i], which == eosio::cdt::output_stream_kind::std_out ? stdout : stderr);
}
}
+51 -1
View File
@@ -935,4 +935,54 @@ int32_t mod_exp( const char* base, uint32_t base_len, const char* exp, uint32_t
void sha3( const char* data, uint32_t data_len, char* hash, uint32_t hash_len, int32_t keccak ) {
intrinsics::get().call<intrinsics::sha3>(data, data_len, hash, hash_len, keccak);
}
}
int32_t bls_g1_add(const char* op1, uint32_t op1_len, const char* op2, uint32_t op2_len, char* res, uint32_t res_len)
{
return intrinsics::get().call<intrinsics::bls_g1_add>(op1, op1_len, op2, op2_len, res, res_len);
}
int32_t bls_g2_add(const char* op1, uint32_t op1_len, const char* op2, uint32_t op2_len, char* res, uint32_t res_len)
{
return intrinsics::get().call<intrinsics::bls_g2_add>(op1, op1_len, op2, op2_len, res, res_len);
}
int32_t bls_g1_mul(const char* point, uint32_t point_len, const char* scalar, uint32_t scalar_len, char* res, uint32_t res_len)
{
return intrinsics::get().call<intrinsics::bls_g1_mul>(point, point_len, scalar, scalar_len, res, res_len);
}
int32_t bls_g2_mul(const char* point, uint32_t point_len, const char* scalar, uint32_t scalar_len, char* res, uint32_t res_len)
{
return intrinsics::get().call<intrinsics::bls_g2_mul>(point, point_len, scalar, scalar_len, res, res_len);
}
int32_t bls_g1_exp(const char* points, uint32_t points_len, const char* scalars, uint32_t scalars_len, uint32_t n, char* res, uint32_t res_len)
{
return intrinsics::get().call<intrinsics::bls_g1_exp>(points, points_len, scalars, scalars_len, n, res, res_len);
}
int32_t bls_g2_exp(const char* points, uint32_t points_len, const char* scalars, uint32_t scalars_len, uint32_t n, char* res, uint32_t res_len)
{
return intrinsics::get().call<intrinsics::bls_g2_exp>(points, points_len, scalars, scalars_len, n, res, res_len);
}
int32_t bls_pairing(const char* g1_points, uint32_t g1_points_len, const char* g2_points, uint32_t g2_points_len, uint32_t n, char* res, uint32_t res_len)
{
return intrinsics::get().call<intrinsics::bls_pairing>(g1_points, g1_points_len, g1_points, g1_points_len, n, res, res_len);
}
int32_t bls_g1_map(const char* e, uint32_t e_len, char* res, uint32_t res_len)
{
return intrinsics::get().call<intrinsics::bls_g1_map>(e, e_len, res, res_len);
}
int32_t bls_g2_map(const char* e, uint32_t e_len, char* res, uint32_t res_len)
{
return intrinsics::get().call<intrinsics::bls_g2_map>(e, e_len, res, res_len);
}
int32_t bls_fp_mod(const char* s, uint32_t s_len, char* res, uint32_t res_len)
{
return intrinsics::get().call<intrinsics::bls_fp_mod>(s, s_len, res, res_len);
}
+8 -2
View File
@@ -4,6 +4,7 @@
#include <string>
namespace eosio { namespace cdt {
enum output_stream_kind {
std_out,
std_err,
@@ -25,10 +26,15 @@ namespace eosio { namespace cdt {
extern eosio::cdt::output_stream std_out;
extern eosio::cdt::output_stream std_err;
extern "C" jmp_buf* ___env_ptr;
extern "C" char* ___heap_ptr;
extern "C" {
extern jmp_buf* ___env_ptr;
extern char* ___heap_ptr;
extern bool ___disable_output;
extern bool ___has_failed;
extern bool ___earlier_unit_test_has_failed;
jmp_buf* __get_jmp_buf();
void __set_env_test();
void __reset_env();
void _prints_l(const char* cstr, uint32_t len, uint8_t which);
@@ -4,6 +4,7 @@
#include <eosio/chain.h>
#include <eosio/crypto.h>
#include <eosio/crypto_ext.h>
#include <eosio/crypto_bls_ext.h>
#include <eosio/db.h>
#include <eosio/permission.h>
#include <eosio/print.h>
@@ -14,6 +15,7 @@
#include <eosio/security_group.h>
#include <type_traits>
#include <functional>
namespace eosio { namespace native {
template <typename... Args, size_t... Is>
@@ -171,7 +173,17 @@ intrinsic_macro(k1_recover) \
intrinsic_macro(alt_bn128_add) \
intrinsic_macro(alt_bn128_mul) \
intrinsic_macro(alt_bn128_pair) \
intrinsic_macro(mod_exp)
intrinsic_macro(mod_exp) \
intrinsic_macro(bls_g1_add) \
intrinsic_macro(bls_g2_add) \
intrinsic_macro(bls_g1_mul) \
intrinsic_macro(bls_g2_mul) \
intrinsic_macro(bls_g1_exp) \
intrinsic_macro(bls_g2_exp) \
intrinsic_macro(bls_pairing) \
intrinsic_macro(bls_g1_map) \
intrinsic_macro(bls_g2_map) \
intrinsic_macro(bls_fp_mod)
+16 -3
View File
@@ -14,17 +14,16 @@ macro (target_ricardian_directory TARGET DIR)
file(GLOB contracts ${DIR}/*.contracts.md ${DIR}/*.clauses.md)
get_target_property(contract_sources ${TARGET} SOURCES)
if(contracts)
set_source_files_properties(${contract_sources} PROPERTIES OBJECT_DEPENDS ${contracts})
set_source_files_properties(${contract_sources} PROPERTIES OBJECT_DEPENDS "${contracts}")
endif()
endmacro()
macro (add_native_library TARGET)
add_library( ${TARGET} ${ARGN} )
target_compile_options( ${TARGET} PUBLIC -fnative )
target_compile_options( ${TARGET} PUBLIC -fnative -fPIC )
endmacro()
macro (add_native_executable TARGET)
cmake_policy(SET CMP0002 OLD)
add_executable( ${TARGET} ${ARGN} )
target_compile_options( ${TARGET} PUBLIC -fnative )
set_target_properties( ${TARGET} PROPERTIES LINK_FLAGS "-fnative" SUFFIX "" )
@@ -38,3 +37,17 @@ macro (add_native_executable TARGET)
endif()
endmacro()
macro (add_native_shared_lib TARGET)
set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS TRUE)
add_library( ${TARGET} SHARED ${ARGN} )
target_compile_options( ${TARGET} PUBLIC -fnative )
get_target_property(BINOUTPUT ${TARGET} BINARY_DIR)
if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug" AND APPLE)
target_compile_options( ${TARGET} PUBLIC -g )
find_program ( name NAMES "dsymutil" )
if ( name )
add_custom_command( TARGET ${TARGET} POST_BUILD COMMAND dsymutil ${BINOUTPUT}/${TARGET} )
endif()
endif()
endmacro()
+1
View File
@@ -21,6 +21,7 @@ set(WASM_LINKER "@CDT_ROOT_DIR@/bin/cdt-ld")
set(CMAKE_C_LINK_EXECUTABLE "${WASM_LINKER} <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
set(CMAKE_CXX_LINK_EXECUTABLE "${WASM_LINKER} <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
set(CMAKE_CXX_CREATE_SHARED_LIBRARY "${WASM_LINKER} -shared <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
set(CMAKE_EXECUTABLE_SUFFIX_C ".wasm")
set(CMAKE_EXECUTABLE_SUFFIX_CXX ".wasm")
+1
View File
@@ -74,6 +74,7 @@ cdt_tool_install_and_symlink(cdt-cpp cdt-cpp)
cdt_tool_install_and_symlink(cdt-ld cdt-ld)
cdt_tool_install_and_symlink(cdt-abidiff cdt-abidiff)
cdt_tool_install_and_symlink(cdt-init cdt-init)
cdt_tool_install_and_symlink(antler-proj antler-proj)
cdt_clang_install(../lib/LLVMEosioApply${CMAKE_SHARED_LIBRARY_SUFFIX})
cdt_clang_install(../lib/LLVMEosioSoftfloat${CMAKE_SHARED_LIBRARY_SUFFIX})
+1
View File
@@ -19,6 +19,7 @@ NAME="${PROJECT}_${VERSION_NO_SUFFIX}-${RELEASE}_${ARCH}"
mkdir -p ${PROJECT}/DEBIAN
echo "Package: ${PROJECT}
Version: ${VERSION_NO_SUFFIX}-${RELEASE}
Depends: libcurl4-gnutls-dev
Section: devel
Priority: optional
Architecture: ${ARCH}
+4
View File
@@ -64,6 +64,8 @@ create_symlink eosio-pp eosio-pp
create_symlink cdt-init cdt-init
create_symlink eosio-wasm2wast eosio-wasm2wast
create_symlink eosio-wast2wasm eosio-wast2wasm
create_symlink eosio-wasm2wast cdt-wasm2wast
create_symlink eosio-wast2wasm cdt-wast2wasm
create_symlink cdt-ar cdt-ar
create_symlink cdt-abidiff cdt-abidiff
create_symlink cdt-nm cdt-nm
@@ -72,6 +74,8 @@ create_symlink cdt-objdump cdt-objdump
create_symlink cdt-ranlib cdt-ranlib
create_symlink cdt-readelf cdt-readelf
create_symlink cdt-strip cdt-strip
create_symlink antler-proj antler-proj
create_symlink antler-proj cdt-proj
echo "Generating Tarball $NAME.tar.gz..."
tar -cvzf $NAME.tar.gz ./${PREFIX}/* || exit 1
+1 -1
View File
@@ -1,7 +1,7 @@
cmake_minimum_required( VERSION 3.5 )
set(EOSIO_VERSION_MIN "3.1")
set(EOSIO_VERSION_SOFT_MAX "3.1")
set(EOSIO_VERSION_SOFT_MAX "4.0")
#set(EOSIO_VERSION_HARD_MAX "")
find_package(leap)
@@ -2,8 +2,6 @@
#include <eosio/testing/tester.hpp>
#include <eosio/chain/abi_serializer.hpp>
#include <Runtime/Runtime.h>
#include <fc/variant_object.hpp>
#include <contracts.hpp>
+108
View File
@@ -0,0 +1,108 @@
#include <boost/test/unit_test.hpp>
#include <eosio/testing/tester.hpp>
#include <eosio/chain/abi_serializer.hpp>
#include <fc/variant_object.hpp>
#include <contracts.hpp>
using namespace eosio;
using namespace eosio::testing;
using namespace eosio::chain;
using namespace eosio::testing;
using namespace fc;
using mvo = fc::mutable_variant_object;
struct bls_primitives_tester : tester {
bls_primitives_tester() {
create_accounts( { "test"_n } );
produce_block();
set_code( "eosio"_n, contracts::bls_primitives_test_wasm() );
set_abi( "eosio"_n, contracts::bls_primitives_test_abi().data() );
produce_blocks();
}
};
BOOST_AUTO_TEST_SUITE(bls_primitives_tests)
BOOST_FIXTURE_TEST_CASE( g1_add_test, bls_primitives_tester ) try {
push_action("eosio"_n, "testg1add"_n, "test"_n, mvo()
("op1", "160c53fd9087b35cf5ff769967fc1778c1a13b14c7954f1547e7d0f3cd6aaef040f4db21cc6eceed75fb0b9e417701127122e70cd593acba8efd18791a63228cce250757135f59dd945140502958ac51c05900ad3f8c1c0e6aa20850fc3ebc0bfdff02000000097602000cc40b00f4ebba58c7535798485f455752705358ce776dec56a2971a075c93e480fac35ef615")
("op2", "160c53fd9087b35cf5ff769967fc1778c1a13b14c7954f1547e7d0f3cd6aaef040f4db21cc6eceed75fb0b9e417701127122e70cd593acba8efd18791a63228cce250757135f59dd945140502958ac51c05900ad3f8c1c0e6aa20850fc3ebc0bfdff02000000097602000cc40b00f4ebba58c7535798485f455752705358ce776dec56a2971a075c93e480fac35ef615")
("res", "2b90dabdf4613e10d269d70050e61bdc53c6d01ac517ad33cd8e82799d5515dfba05bc172fd280e2a73ff01aca77e30cbf82182b9005141106ef83a6d33dcda8bece738c9f9d6313f7e05945fd92c23a208efbe7a2048c6250f7f14df9f5c215e244ce19aa2759751dfb31f234c644189d4b0eae26beb2ba29a380a052b058a380b3005a7f18391cd44411a0f87d7817"));
} FC_LOG_AND_RETHROW()
BOOST_FIXTURE_TEST_CASE( g2_add_test, bls_primitives_tester ) try {
push_action("eosio"_n, "testg2add"_n, "test"_n, mvo()
("op1", "100a9402a28ff2f51a96b48726fbf5b380e52a3eb593a8a1e9ae3c1a9d9994986b36631863b7676fd7bc50439291810506f6239e75c0a9a5c360cdbc9dc5a0aa067886e2187eb13b67b34185ccb61a1b478515f20eedb6c2f3ed6073092a92114a4c4960f80a734c5a9c365e1ffa7c595a630aaa6c85e6e75f490d6ee9b5efbba225eff075a9d307e5da807e8efd83005db064df92fcc0addc61142b0a27aa18a0ebe43b6aacad863aa33dc94e5c4979edca3ca4505817e7f21bde63a1c22b0bfdff02000000097602000cc40b00f4ebba58c7535798485f455752705358ce776dec56a2971a075c93e480fac35ef615000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")
("op2", "100a9402a28ff2f51a96b48726fbf5b380e52a3eb593a8a1e9ae3c1a9d9994986b36631863b7676fd7bc50439291810506f6239e75c0a9a5c360cdbc9dc5a0aa067886e2187eb13b67b34185ccb61a1b478515f20eedb6c2f3ed6073092a92114a4c4960f80a734c5a9c365e1ffa7c595a630aaa6c85e6e75f490d6ee9b5efbba225eff075a9d307e5da807e8efd83005db064df92fcc0addc61142b0a27aa18a0ebe43b6aacad863aa33dc94e5c4979edca3ca4505817e7f21bde63a1c22b0bfdff02000000097602000cc40b00f4ebba58c7535798485f455752705358ce776dec56a2971a075c93e480fac35ef615000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")
("res", "1987cff592d8ae5c83ba9e9a1a016afd3a4e80d646e10a1274ba259b60a405c189945d07b3608d4d339a96429d60f80d8290d66f4e963c0e8c00e35db541ab46e93148fd7e41449f0be0a1883e36e4b56cf87121991d6d4778d499fdf1501c09a9220f11cdfe60560b15d7e6ec33825a8d9ce209fe8e20391d32210ba83dbd77ce4cd6019ca50465f8f5fed4a8a631048739c8d9b8fdc26a962b24f0306f8293a00d72d37fb2fb1b0643d9a8453cbf6a520463a54e25e8c42134d6798d7cce00949892c0f015e698b4386dbc3ef4f9b2b4c61454d90acdcfbf921adcd26bdf77454bdee1eb52a70fcab501fd1cfb0701ba60c9be25f9815bb9c32856144e543140d7c977d4585b0d75467b929db892f2da957948a1b02ecee537bcc742855716"));
} FC_LOG_AND_RETHROW()
BOOST_FIXTURE_TEST_CASE( g1_mul_test, bls_primitives_tester ) try {
push_action("eosio"_n, "testg1mul"_n, "test"_n, mvo()
("point", "160c53fd9087b35cf5ff769967fc1778c1a13b14c7954f1547e7d0f3cd6aaef040f4db21cc6eceed75fb0b9e417701127122e70cd593acba8efd18791a63228cce250757135f59dd945140502958ac51c05900ad3f8c1c0e6aa20850fc3ebc0bfdff02000000097602000cc40b00f4ebba58c7535798485f455752705358ce776dec56a2971a075c93e480fac35ef615")
("scalar", "2a000000000000002a000000000000002a000000000000002a00000000000000")
("res", "de3e7eeee055abe12a480e58411508d51a356ff6692b14b43426d22cc354cd5d7469c41e0f1f5e40503c91e11419a30285cb057a62c93e2caaaff6c9c1dbc8f88c0a122157f51a617ce0e2890442cd9ce004a8ba972442e61bce9dabf1c6780c191984ae3c11ef21884a536f0d3450974df37295e9579d16cdb8dfdf9252091ca3cd9d05f4c6e645535add05ac197b08"));
} FC_LOG_AND_RETHROW()
BOOST_FIXTURE_TEST_CASE( g2_mul_test, bls_primitives_tester ) try {
push_action("eosio"_n, "testg2mul"_n, "test"_n, mvo()
("point", "100a9402a28ff2f51a96b48726fbf5b380e52a3eb593a8a1e9ae3c1a9d9994986b36631863b7676fd7bc50439291810506f6239e75c0a9a5c360cdbc9dc5a0aa067886e2187eb13b67b34185ccb61a1b478515f20eedb6c2f3ed6073092a92114a4c4960f80a734c5a9c365e1ffa7c595a630aaa6c85e6e75f490d6ee9b5efbba225eff075a9d307e5da807e8efd83005db064df92fcc0addc61142b0a27aa18a0ebe43b6aacad863aa33dc94e5c4979edca3ca4505817e7f21bde63a1c22b0bfdff02000000097602000cc40b00f4ebba58c7535798485f455752705358ce776dec56a2971a075c93e480fac35ef615000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")
("scalar", "2a000000000000002a000000000000002a000000000000002a00000000000000")
("res", "aa25f3f539b6f3215318d81b22d14bf9108294790e8a50545a404ae2057278304d8c3b5844271202b757767d1555a106ede90a9967cdc27b527d4a5720efda79a68b17072ad9402ed373ce9a2d28f5496106fc4cd23234b083181e8325734417f8330d2ced14040b815a006f7f905361f654d483c45abb90b4a958b4ca20ee2bb97cc1c9b6ff45644539abb32149610f33858c88450dad3d2adb82df72f9ed9c42dc2ef78e17f5a2a1abd0468853d55f05f6458179fdf5671db784795a686c0ffae139afaed0212d18d615b0ff90a9deba090f723190521dc8c822621b0a7e70a03b9f3faaeb862846dccd418855d70406fc57e73783c2da92433c1a3873640217539ec7c01f3d354506d86db49fddad225e82421506d99c19b749170aa4f805"));
} FC_LOG_AND_RETHROW()
BOOST_FIXTURE_TEST_CASE( g1_exp_test, bls_primitives_tester ) try {
push_action("eosio"_n, "testg1exp"_n, "test"_n, mvo()
("points", "160c53fd9087b35cf5ff769967fc1778c1a13b14c7954f1547e7d0f3cd6aaef040f4db21cc6eceed75fb0b9e417701127122e70cd593acba8efd18791a63228cce250757135f59dd945140502958ac51c05900ad3f8c1c0e6aa20850fc3ebc0bfdff02000000097602000cc40b00f4ebba58c7535798485f455752705358ce776dec56a2971a075c93e480fac35ef615160c53fd9087b35cf5ff769967fc1778c1a13b14c7954f1547e7d0f3cd6aaef040f4db21cc6eceed75fb0b9e417701127122e70cd593acba8efd18791a63228cce250757135f59dd945140502958ac51c05900ad3f8c1c0e6aa20850fc3ebc0bfdff02000000097602000cc40b00f4ebba58c7535798485f455752705358ce776dec56a2971a075c93e480fac35ef615")
("scalars", "2a000000000000002a000000000000002a000000000000002a000000000000002a000000000000002a000000000000002a000000000000002a00000000000000")
("res", "9e80ed609e62978a3a7f0d6bf57e1df4070725c1bf4dab43a6b710adef7450fb41f0cf14a7895ec26fd8c830c327cc0e2c8fe7687d23ff84647b47bbad04cf77625dee1049e53ad5162fe772278e5fe3ceb0bdc472f31952343da7b75532f7016613af892092131ad77d13afc8c9192487ac19f8454ad932653145f06e25790d26b23ac6b83025326f3397efbd845511"));
} FC_LOG_AND_RETHROW()
BOOST_FIXTURE_TEST_CASE( g2_exp_test, bls_primitives_tester ) try {
push_action("eosio"_n, "testg2exp"_n, "test"_n, mvo()
("points", "100a9402a28ff2f51a96b48726fbf5b380e52a3eb593a8a1e9ae3c1a9d9994986b36631863b7676fd7bc50439291810506f6239e75c0a9a5c360cdbc9dc5a0aa067886e2187eb13b67b34185ccb61a1b478515f20eedb6c2f3ed6073092a92114a4c4960f80a734c5a9c365e1ffa7c595a630aaa6c85e6e75f490d6ee9b5efbba225eff075a9d307e5da807e8efd83005db064df92fcc0addc61142b0a27aa18a0ebe43b6aacad863aa33dc94e5c4979edca3ca4505817e7f21bde63a1c22b0bfdff02000000097602000cc40b00f4ebba58c7535798485f455752705358ce776dec56a2971a075c93e480fac35ef615000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100a9402a28ff2f51a96b48726fbf5b380e52a3eb593a8a1e9ae3c1a9d9994986b36631863b7676fd7bc50439291810506f6239e75c0a9a5c360cdbc9dc5a0aa067886e2187eb13b67b34185ccb61a1b478515f20eedb6c2f3ed6073092a92114a4c4960f80a734c5a9c365e1ffa7c595a630aaa6c85e6e75f490d6ee9b5efbba225eff075a9d307e5da807e8efd83005db064df92fcc0addc61142b0a27aa18a0ebe43b6aacad863aa33dc94e5c4979edca3ca4505817e7f21bde63a1c22b0bfdff02000000097602000cc40b00f4ebba58c7535798485f455752705358ce776dec56a2971a075c93e480fac35ef615000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")
("scalars", "2a000000000000002a000000000000002a000000000000002a000000000000002a000000000000002a000000000000002a000000000000002a00000000000000")
("res", "595a2cbaa4315ecc0dd9838a81712e0cfb88cb2c4468640ff382abb321b3a9bedebb0aad985a9057f664fc52eb52cd194b1c9611b25ef4281e439a52d1832813decd66c22440821f0288dcb7a82151386aa0240e943b6905e61619be2e11c208fa03df16e11a1b1368abac90598bb237f785701d5d1d5cb0af6934ed633d366de28703431b8d70899d92797689207c0cd35c345460f971dff5d648d9ddec8f5fabef99b15ea7c4440ac1564d6e0326076f32a4ec9cf0d10059593d64afd35c03d10f16794821628b565c9319f4af3c96b98c4fb11bc0c04172bb57372531f6e76798142d4b00488adbea850a2649a305b71fa389c3c226f2df4a58c8bce5d90698452f4126046be0c82d8817b64162a53787f1cb73af27d969adc626c1392716"));
} FC_LOG_AND_RETHROW()
BOOST_FIXTURE_TEST_CASE( pairing_test, bls_primitives_tester ) try {
push_action("eosio"_n, "testpairing"_n, "test"_n, mvo()
("g1_points", "160c53fd9087b35cf5ff769967fc1778c1a13b14c7954f1547e7d0f3cd6aaef040f4db21cc6eceed75fb0b9e417701127122e70cd593acba8efd18791a63228cce250757135f59dd945140502958ac51c05900ad3f8c1c0e6aa20850fc3ebc0bfdff02000000097602000cc40b00f4ebba58c7535798485f455752705358ce776dec56a2971a075c93e480fac35ef615160c53fd9087b35cf5ff769967fc1778c1a13b14c7954f1547e7d0f3cd6aaef040f4db21cc6eceed75fb0b9e417701127122e70cd593acba8efd18791a63228cce250757135f59dd945140502958ac51c05900ad3f8c1c0e6aa20850fc3ebc0bfdff02000000097602000cc40b00f4ebba58c7535798485f455752705358ce776dec56a2971a075c93e480fac35ef615160c53fd9087b35cf5ff769967fc1778c1a13b14c7954f1547e7d0f3cd6aaef040f4db21cc6eceed75fb0b9e417701127122e70cd593acba8efd18791a63228cce250757135f59dd945140502958ac51c05900ad3f8c1c0e6aa20850fc3ebc0bfdff02000000097602000cc40b00f4ebba58c7535798485f455752705358ce776dec56a2971a075c93e480fac35ef615")
("g2_points", "100a9402a28ff2f51a96b48726fbf5b380e52a3eb593a8a1e9ae3c1a9d9994986b36631863b7676fd7bc50439291810506f6239e75c0a9a5c360cdbc9dc5a0aa067886e2187eb13b67b34185ccb61a1b478515f20eedb6c2f3ed6073092a92114a4c4960f80a734c5a9c365e1ffa7c595a630aaa6c85e6e75f490d6ee9b5efbba225eff075a9d307e5da807e8efd83005db064df92fcc0addc61142b0a27aa18a0ebe43b6aacad863aa33dc94e5c4979edca3ca4505817e7f21bde63a1c22b0bfdff02000000097602000cc40b00f4ebba58c7535798485f455752705358ce776dec56a2971a075c93e480fac35ef615000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100a9402a28ff2f51a96b48726fbf5b380e52a3eb593a8a1e9ae3c1a9d9994986b36631863b7676fd7bc50439291810506f6239e75c0a9a5c360cdbc9dc5a0aa067886e2187eb13b67b34185ccb61a1b478515f20eedb6c2f3ed6073092a92114a4c4960f80a734c5a9c365e1ffa7c595a630aaa6c85e6e75f490d6ee9b5efbba225eff075a9d307e5da807e8efd83005db064df92fcc0addc61142b0a27aa18a0ebe43b6aacad863aa33dc94e5c4979edca3ca4505817e7f21bde63a1c22b0bfdff02000000097602000cc40b00f4ebba58c7535798485f455752705358ce776dec56a2971a075c93e480fac35ef615000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100a9402a28ff2f51a96b48726fbf5b380e52a3eb593a8a1e9ae3c1a9d9994986b36631863b7676fd7bc50439291810506f6239e75c0a9a5c360cdbc9dc5a0aa067886e2187eb13b67b34185ccb61a1b478515f20eedb6c2f3ed6073092a92114a4c4960f80a734c5a9c365e1ffa7c595a630aaa6c85e6e75f490d6ee9b5efbba225eff075a9d307e5da807e8efd83005db064df92fcc0addc61142b0a27aa18a0ebe43b6aacad863aa33dc94e5c4979edca3ca4505817e7f21bde63a1c22b0bfdff02000000097602000cc40b00f4ebba58c7535798485f455752705358ce776dec56a2971a075c93e480fac35ef615000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")
("res", "af587ca8f5f0760b888e4ec66748623d1b13986547b5de2042ce89233c2c837bbb080329a505285c948d8bb4c88a5914ae216a64db582ba084178db4364a7b3843ef7fb9056a90526d27dc9e252b38600fc54ce7a5ec15771c555816edc26d0166e75d3315789c846387c8c234b1c98b50baf233b7312aa317ae56a2bfa170b1bc43f0e046b4a1f45cb7aacea7d0ae0320496e3960d4dbc2039027ba8cfe1ca120ea98fa94cf25034ccb5e74033f447b837a78b03affd44b87f865f3d713000de78ab5629dbde8d0c8b7a28941717be3ebd23924cf16897144bb69730f68bff5a109fc2e6d563b15e2eb883cf4becd11edcbc2ec4402c93249389ed612fa0396ed6eadcbe4d703667d46b0150ee3a5158caef956791e4f527e1312c8402f8509acf7001dc0dc311549d76398c247e79b737b614d0a6663f7dbdb314e5b51eace14457ee7b1f3f54d5987c16c8f89d1022d91d4649f5f6a204047077e5791a654cd2277506cd0af77f9ea789278b364c115ec07ba14390a9c22d59aa9c97a9c09ce025b5e14443f3c4e4cd602ef34105fadd82837fc5ce60a461e6ea11b13ae67b82e3366a2b2d1bbe78b2579173b3c0c5aed88b2949403060c3e065782bcb742c55c559e75e373293d80dec54120773d80144b21b353ead58dc8427e5b9cbd0c1431f1a74caf5f57c4b55b89810029cdd24ef4a029797ced68ff882492a8f55f31fe52217356366983e35d2a5640e818cc8bddf9274de0100e624a6bf03e2b9ff22f8dda09a46b50b1b305cb6adfa2ae775febbce4a2b507cd2390db968ceb13"));
} FC_LOG_AND_RETHROW()
BOOST_FIXTURE_TEST_CASE( g1_map_test, bls_primitives_tester ) try {
push_action("eosio"_n, "testg1map"_n, "test"_n, mvo()
("e", "c93f817b159bdf8404dc378514f845192bbae4faac7f4a568924f2d9725125000489408fd796461c288900add00d4618")
("res", "d8e09005badb694b1e5dba8476ba3012cd2bf0c472ee1811ac9b34c869638b47e669bce16933e98ce9b129f83d93d71890d6fd13b77d4ad8df1a5f1c6b81df2b3f305721b7b7874cd81eba23ca05e8bc974b14f7e4c2c77cbdf321c340ba4903a2a46af290abe078e426f913e492b8d9b997232dbe6198aea719a31e73b40e110c4efa9e42d737a42883e0ca5f344d02"));
} FC_LOG_AND_RETHROW()
BOOST_FIXTURE_TEST_CASE( g2_map_test, bls_primitives_tester ) try {
push_action("eosio"_n, "testg2map"_n, "test"_n, mvo()
("e", "d4f2cfec99387809574fcc2dba105603d950d490e2bebe0c212c05e16b784745ef4fe8e70b554d0a52fe0bed5ea6690ade2348eb8972a96740a430df162d920e175f5923a76d18650ea24a8ec06d414c6d1d218d673dac3619a1a5c142785708")
("res", "9968ae9e9bf3d22ec6c9670efa64ea23d4966b41bb25f76ea2ef71b96fa35e031adb866b3df234065b9aa72d0b12ab14978678279eb944f05b5af53d91e700b57aa87076727def2e9f2fba3cf6784a25591ae1669c2cf15cdcf038b826d1e81178bd7b59b7e911e0c2d11d6805756222201e3364f8010fb651939eca63f7e77709042ee1030cd938f53905a714e815112a7dfeed207757d30382f69617014bc683a175d0dfbd74f2684de26c771f3f55a538e6d2f969eb282bddfec4fc08dd18f37df0889292f288dff631b02f07b88134410fd86526d234d75b9a329bc9a8b6e71c7ad516b87af9717d962cba5d2b19fd1b77746f1e484a54e6aec81ede148f01e2c8283c598a4976182d2ce287fe6888e23996ce03b03ce6709e4aa8e66416"));
} FC_LOG_AND_RETHROW()
BOOST_FIXTURE_TEST_CASE( sig_verify_test, bls_primitives_tester ) try {
push_action("eosio"_n, "verify"_n, "test"_n, mvo()
("pk", "90ace8f520a5e056eab099d4e6a6f761a8f51301e1e15910908453007d94e33f8e86b834808dcb5323313153be066d01d49660f594a805ad9a4249d0af4190407e3e221e1d6fdad866e022308357776ed5e396777c7f7dfd020e7d736511ac06fdff02000000097602000cc40b00f4ebba58c7535798485f455752705358ce776dec56a2971a075c93e480fac35ef615")
("sig", "3c38a59a6c016fb598d8da531e205e4d8e0953868675760f8333c7fee725d81ddf246db75792eb7cf0ab8aeba051800babf407ddd8ec721db83fe1b1098b9334bf45ad63f10cf5a6b56b60f74b391615d7373088d182711358a6032f8c31fe1694ff3f3254a7e02e3e2811ce0becdec6031b193b5541d577b49cdb6cf09f919917b09776b1f05c977ffa17c2de876205f402f7e4fb00896cb9b3df1a25f761239e5625ddaab4bfacce8e6c505c13eb73632b12cedd30b0804fe29f317015c307ec2dfe48cb5060d84fd2c2756f41ae79f4c0a3a37ba62b22877b23042bb30a063d4ad3255de844545e89f0886041b513410df52d380fac23c31277997381115651c02014a9aeeaaec85c34b81a93ee73cd712ce241f394dc860ea5e792b0f50e"));
} FC_LOG_AND_RETHROW()
BOOST_AUTO_TEST_SUITE_END()
-2
View File
@@ -2,8 +2,6 @@
#include <eosio/testing/tester.hpp>
#include <eosio/chain/abi_serializer.hpp>
#include <Runtime/Runtime.h>
#include <fc/variant_object.hpp>
#include <contracts.hpp>
-2
View File
@@ -2,8 +2,6 @@
#include <eosio/testing/tester.hpp>
#include <eosio/chain/abi_serializer.hpp>
#include <Runtime/Runtime.h>
#include <fc/variant_object.hpp>
#include <contracts.hpp>
+14
View File
@@ -22,5 +22,19 @@ namespace eosio::testing {
static std::vector<uint8_t> crypto_primitives_test_wasm() { return read_wasm("${CMAKE_BINARY_DIR}/../unit/test_contracts/crypto_primitives_tests.wasm"); }
static std::vector<char> crypto_primitives_test_abi() { return read_abi("${CMAKE_BINARY_DIR}/../unit/test_contracts/crypto_primitives_tests.abi"); }
static std::vector<uint8_t> bls_primitives_test_wasm() { return read_wasm("${CMAKE_BINARY_DIR}/../unit/test_contracts/bls_primitives_tests.wasm"); }
static std::vector<char> bls_primitives_test_abi() { return read_abi("${CMAKE_BINARY_DIR}/../unit/test_contracts/bls_primitives_tests.abi"); }
static std::vector<uint8_t> get_code_hash_write_test_wasm() { return read_wasm("${CMAKE_BINARY_DIR}/../unit/test_contracts/get_code_hash_write.wasm"); }
static std::vector<char> get_code_hash_write_test_abi() { return read_abi("${CMAKE_BINARY_DIR}/../unit/test_contracts/get_code_hash_write.abi"); }
static std::vector<uint8_t> get_code_hash_read_test_wasm() { return read_wasm("${CMAKE_BINARY_DIR}/../unit/test_contracts/get_code_hash_read.wasm"); }
static std::vector<char> get_code_hash_read_test_abi() { return read_abi("${CMAKE_BINARY_DIR}/../unit/test_contracts/get_code_hash_read.abi"); }
static std::vector<uint8_t> name_pk_tests_wasm() { return read_wasm("${CMAKE_BINARY_DIR}/../unit/test_contracts/name_pk_tests.wasm"); }
static std::vector<char> name_pk_tests_abi() { return read_abi("${CMAKE_BINARY_DIR}/../unit/test_contracts/name_pk_tests.abi"); }
static std::vector<uint8_t> test_multi_index_wasm() { return read_wasm("${CMAKE_BINARY_DIR}/../unit/test_contracts/test_multi_index.wasm"); }
static std::vector<char> test_multi_index_abi() { return read_abi("${CMAKE_BINARY_DIR}/../unit/test_contracts/test_multi_index.abi"); }
};
} //ns eosio::testing
-2
View File
@@ -2,8 +2,6 @@
#include <eosio/testing/tester.hpp>
#include <eosio/chain/abi_serializer.hpp>
#include <Runtime/Runtime.h>
#include <fc/variant_object.hpp>
#include <contracts.hpp>
+44
View File
@@ -0,0 +1,44 @@
#include <boost/test/unit_test.hpp>
#include <eosio/testing/tester.hpp>
#include <eosio/chain/abi_serializer.hpp>
#include <fc/variant_object.hpp>
#include <contracts.hpp>
using namespace eosio;
using namespace eosio::testing;
using namespace eosio::chain;
using namespace fc;
using mvo = fc::mutable_variant_object;
struct code_hash {
uint64_t id;
fc::sha256 hash;
uint64_t primary_key() const { return id; }
};
FC_REFLECT(code_hash, (id)(hash))
BOOST_AUTO_TEST_SUITE(get_code_hash_tests_suite)
BOOST_FIXTURE_TEST_CASE( get_code_hash_tests, tester ) try {
create_accounts( { "test"_n } );
produce_block();
set_code( "test"_n, contracts::get_code_hash_write_test_wasm() );
set_abi( "test"_n, contracts::get_code_hash_write_test_abi().data() );
produce_blocks();
push_action("test"_n, "theaction"_n, "test"_n, mvo());
code_hash entry;
get_table_entry(entry, "test"_n, "test"_n, "code.hash"_n, 0);
wdump((entry.hash));
set_code( "test"_n, contracts::get_code_hash_read_test_wasm() );
produce_blocks();
push_action("test"_n, "theaction"_n, "test"_n, mvo());
} FC_LOG_AND_RETHROW()
BOOST_AUTO_TEST_SUITE_END()
-1
View File
@@ -8,7 +8,6 @@
#include <boost/test/included/unit_test.hpp>
#include <fc/log/logger.hpp>
#include <eosio/chain/exceptions.hpp>
#include <Runtime/Runtime.h>
#define BOOST_TEST_STATIC_LINK
-2
View File
@@ -2,8 +2,6 @@
#include <eosio/testing/tester.hpp>
#include <eosio/chain/abi_serializer.hpp>
#include <Runtime/Runtime.h>
#include <fc/variant_object.hpp>
#include <contracts.hpp>
+75
View File
@@ -0,0 +1,75 @@
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wsign-compare"
#include <boost/test/unit_test.hpp>
#pragma GCC diagnostic pop
#include <eosio/testing/tester.hpp>
#include <contracts.hpp>
using namespace eosio;
using namespace eosio::testing;
#ifdef NON_VALIDATING_TEST
#define TESTER tester
#else
#define TESTER validating_tester
#endif
BOOST_AUTO_TEST_SUITE(multi_index_tests)
// this test is copy from leap test_api_multi_index
BOOST_FIXTURE_TEST_CASE(main_multi_index_tests, TESTER) { try {
produce_blocks(1);
create_account( "testapi"_n );
produce_blocks(1);
set_code( "testapi"_n, contracts::test_multi_index_wasm() );
set_abi( "testapi"_n, contracts::test_multi_index_abi().data() );
produce_blocks(1);
auto check_failure = [this]( action_name a, const char* expected_error_msg ) {
BOOST_CHECK_EXCEPTION( push_action( "testapi"_n, a, "testapi"_n, {} ),
eosio_assert_message_exception,
eosio_assert_message_is( expected_error_msg )
);
};
push_action( "testapi"_n, "s1g"_n, "testapi"_n, {} ); // idx64_general
push_action( "testapi"_n, "s1store"_n, "testapi"_n, {} ); // idx64_store_only
push_action( "testapi"_n, "s1check"_n, "testapi"_n, {} ); // idx64_check_without_storing
push_action( "testapi"_n, "s2g"_n, "testapi"_n, {} ); // idx128_general
push_action( "testapi"_n, "s2store"_n, "testapi"_n, {} ); // idx128_store_only
push_action( "testapi"_n, "s2check"_n, "testapi"_n, {} ); // idx128_check_without_storing
push_action( "testapi"_n, "s2autoinc"_n, "testapi"_n, {} ); // idx128_autoincrement_test
push_action( "testapi"_n, "s2autoinc1"_n, "testapi"_n, {} ); // idx128_autoincrement_test_part1
push_action( "testapi"_n, "s2autoinc2"_n, "testapi"_n, {} ); // idx128_autoincrement_test_part2
push_action( "testapi"_n, "s3g"_n, "testapi"_n, {} ); // idx256_general
push_action( "testapi"_n, "sdg"_n, "testapi"_n, {} ); // idx_double_general
push_action( "testapi"_n, "sldg"_n, "testapi"_n, {} ); // idx_long_double_general
check_failure( "s1pkend"_n, "cannot increment end iterator" ); // idx64_pk_iterator_exceed_end
check_failure( "s1skend"_n, "cannot increment end iterator" ); // idx64_sk_iterator_exceed_end
check_failure( "s1pkbegin"_n, "cannot decrement iterator at beginning of table" ); // idx64_pk_iterator_exceed_begin
check_failure( "s1skbegin"_n, "cannot decrement iterator at beginning of index" ); // idx64_sk_iterator_exceed_begin
check_failure( "s1pkref"_n, "object passed to iterator_to is not in multi_index" ); // idx64_pass_pk_ref_to_other_table
check_failure( "s1skref"_n, "object passed to iterator_to is not in multi_index" ); // idx64_pass_sk_ref_to_other_table
check_failure( "s1pkitrto"_n, "object passed to iterator_to is not in multi_index" ); // idx64_pass_pk_end_itr_to_iterator_to
check_failure( "s1pkmodify"_n, "cannot pass end iterator to modify" ); // idx64_pass_pk_end_itr_to_modify
check_failure( "s1pkerase"_n, "cannot pass end iterator to erase" ); // idx64_pass_pk_end_itr_to_erase
check_failure( "s1skitrto"_n, "object passed to iterator_to is not in multi_index" ); // idx64_pass_sk_end_itr_to_iterator_to
check_failure( "s1skmodify"_n, "cannot pass end iterator to modify" ); // idx64_pass_sk_end_itr_to_modify
check_failure( "s1skerase"_n, "cannot pass end iterator to erase" ); // idx64_pass_sk_end_itr_to_erase
check_failure( "s1modpk"_n, "updater cannot change primary key when modifying an object" ); // idx64_modify_primary_key
check_failure( "s1exhaustpk"_n, "next primary key in table is at autoincrement limit" ); // idx64_run_out_of_avl_pk
check_failure( "s1findfail1"_n, "unable to find key" ); // idx64_require_find_fail
check_failure( "s1findfail2"_n, "unable to find primary key in require_find" );// idx64_require_find_fail_with_msg
check_failure( "s1findfail3"_n, "unable to find secondary key" ); // idx64_require_find_sk_fail
check_failure( "s1findfail4"_n, "unable to find sec key" ); // idx64_require_find_sk_fail_with_msg
push_action( "testapi"_n, "s1skcache"_n, "testapi"_n, {} ); // idx64_sk_cache_pk_lookup
push_action( "testapi"_n, "s1pkcache"_n, "testapi"_n, {} ); // idx64_pk_cache_sk_lookup
BOOST_REQUIRE_EQUAL( validate(), true );
} FC_LOG_AND_RETHROW() }
BOOST_AUTO_TEST_SUITE_END()
+30
View File
@@ -0,0 +1,30 @@
#include <boost/test/unit_test.hpp>
#include <eosio/testing/tester.hpp>
#include <eosio/chain/abi_serializer.hpp>
#include <fc/variant_object.hpp>
#include <contracts.hpp>
using namespace eosio;
using namespace eosio::testing;
using namespace eosio::chain;
using namespace fc;
using mvo = fc::mutable_variant_object;
BOOST_AUTO_TEST_SUITE(name_pk_tests_suite)
BOOST_FIXTURE_TEST_CASE( name_pk_tests, tester ) try {
create_accounts( { "test"_n } );
produce_block();
set_code( "test"_n, contracts::name_pk_tests_wasm() );
set_abi( "test"_n, contracts::name_pk_tests_abi().data() );
produce_blocks();
push_action("test"_n, "write"_n, "test"_n, mvo());
push_action("test"_n, "read"_n, "test"_n, mvo());
} FC_LOG_AND_RETHROW()
BOOST_AUTO_TEST_SUITE_END()
@@ -0,0 +1,45 @@
{
"____comment": "This file was generated with eosio-abigen. DO NOT EDIT ",
"version": "eosio::abi/1.2",
"types": [],
"structs": [
{
"name": "tbl_config",
"base": "",
"fields": [
{
"name": "y",
"type": "uint64"
},
{
"name": "x",
"type": "uint64"
}
]
},
{
"name": "whatever",
"base": "",
"fields": []
}
],
"actions": [
{
"name": "whatever",
"type": "whatever",
"ricardian_contract": ""
}
],
"tables": [
{
"name": "config",
"type": "tbl_config",
"index_type": "i64",
"key_names": [],
"key_types": []
}
],
"ricardian_clauses": [],
"variants": [],
"action_results": []
}
@@ -0,0 +1,21 @@
#include <eosio/asset.hpp>
#include <eosio/eosio.hpp>
#include <eosio/name.hpp>
#include <eosio/singleton.hpp>
using namespace eosio;
class [[eosio::contract("singleton_contract")]] singleton_contract : public contract {
public:
using contract::contract;
[[eosio::action]]
void whatever() {};
struct [[eosio::table]] tbl_config {
uint64_t y;
uint64_t x;
};
typedef eosio::singleton<"config"_n, tbl_config> config;
};
@@ -0,0 +1,10 @@
{
"tests" : [
{
"expected" : {
"abi-file" : "singleton_contract.abi"
}
}
]
}
@@ -0,0 +1,31 @@
{
"____comment": "This file was generated with eosio-abigen. DO NOT EDIT ",
"version": "eosio::abi/1.2",
"types": [],
"structs": [
{
"name": "whatever",
"base": "",
"fields": []
}
],
"actions": [
{
"name": "whatever",
"type": "whatever",
"ricardian_contract": ""
}
],
"tables": [
{
"name": "smpl.config",
"type": "name",
"index_type": "i64",
"key_names": [],
"key_types": []
}
],
"ricardian_clauses": [],
"variants": [],
"action_results": []
}
@@ -0,0 +1,16 @@
#include <eosio/asset.hpp>
#include <eosio/eosio.hpp>
#include <eosio/name.hpp>
#include <eosio/singleton.hpp>
using namespace eosio;
class [[eosio::contract("singleton_contract_simple")]] singleton_contract_simple : public contract {
public:
using contract::contract;
[[eosio::action]]
void whatever() {};
typedef eosio::singleton<"smpl.config"_n, name> config;
};
@@ -0,0 +1,10 @@
{
"tests" : [
{
"expected" : {
"abi-file" : "singleton_contract_simple.abi"
}
}
]
}
@@ -0,0 +1,38 @@
{
"____comment": "This file was generated with eosio-abigen. DO NOT EDIT ",
"version": "eosio::abi/1.2",
"types": [],
"structs": [
{
"name": "TaggedNumber_3472950412842106880",
"base": "",
"fields": [
{
"name": "value",
"type": "uint64"
}
]
},
{
"name": "test",
"base": "",
"fields": [
{
"name": "",
"type": "TaggedNumber_3472950412842106880"
}
]
}
],
"actions": [
{
"name": "test",
"type": "test",
"ricardian_contract": ""
}
],
"tables": [],
"ricardian_clauses": [],
"variants": [],
"action_results": []
}
@@ -0,0 +1,17 @@
#include <eosio/eosio.hpp>
using namespace eosio;
template<uint64_t Tag>
struct TaggedNumber {
uint64_t value;
};
class [[eosio::contract]] tagged_number_test : public contract {
public:
using contract::contract;
[[eosio::action]]
void test(TaggedNumber<"a.tag"_n.value>) {
}
};
@@ -0,0 +1,9 @@
{
"tests" : [
{
"expected" : {
"abi-file" : "tagged_number_test.abi"
}
}
]
}
-1
View File
@@ -27,7 +27,6 @@ add_cdt_unit_test(string_tests1)
add_cdt_unit_test(string_tests2)
add_cdt_unit_test(symbol_tests)
add_cdt_unit_test(system_tests)
add_cdt_unit_test(rope_tests)
add_cdt_unit_test(print_tests)
add_cdt_unit_test(time_tests)
add_cdt_unit_test(varint_tests)
+132 -35
View File
@@ -312,7 +312,7 @@ EOSIO_TEST_BEGIN(asset_type_test)
})
)
CHECK_ASSERT( "comparison of assets with different symbols is not allowed", (
CHECK_ASSERT( "attempt to divide assets with different symbol", (
[&]() {
asset{1LL, s0} / asset{1LL, s1};
})
@@ -364,7 +364,16 @@ EOSIO_TEST_BEGIN(extended_asset_type_test)
static constexpr extended_symbol ext_sym_no_prec{sym_no_prec, name{"eosioaccountj"}};
static constexpr extended_symbol ext_sym_prec{sym_prec, name{"eosioaccountj"}};
static const asset asset_no_prec{0LL, sym_no_prec};
// Assets with sym_no_prec
static const auto a0 = asset{ 0LL, sym_no_prec}; // AKA asset_no_prec
static const auto a1 = asset{ 1LL, sym_no_prec};
static const auto a2 = asset{ 2LL, sym_no_prec};
static const auto a4 = asset{ 4LL, sym_no_prec};
static const auto aneg1 = asset{ -1LL, sym_no_prec};
static const auto aneg2 = asset{ -2LL, sym_no_prec};
static const auto aneg4 = asset{ -4LL, sym_no_prec};
// Assets with sym_prec
static const asset asset_prec{0LL, sym_prec};
//// extended_asset()
@@ -372,12 +381,12 @@ EOSIO_TEST_BEGIN(extended_asset_type_test)
CHECK_EQUAL( extended_asset{}.contract, name{} )
//// extended_asset(int64_t, extended_symbol)
CHECK_EQUAL( (extended_asset{{},ext_sym_no_prec}.quantity), (asset{0LL, sym_no_prec}) )
CHECK_EQUAL( (extended_asset{{},ext_sym_no_prec}.quantity), (a0) )
CHECK_EQUAL( (extended_asset{{},ext_sym_no_prec}.contract), (name{"eosioaccountj"}) )
//// extended_asset(asset, name)
CHECK_EQUAL( (extended_asset{asset_no_prec, name{"eosioaccountj"}}.quantity), (asset{ 0LL, sym_no_prec}) )
CHECK_EQUAL( (extended_asset{asset_no_prec, name{"eosioaccountj"}}.contract), (name{"eosioaccountj"}) )
CHECK_EQUAL( (extended_asset{a0, name{"eosioaccountj"}}.quantity), (a0) )
CHECK_EQUAL( (extended_asset{a0, name{"eosioaccountj"}}.contract), (name{"eosioaccountj"}) )
// ------------------------------------------
// extended_symbol get_extended_symbol()const
@@ -426,13 +435,13 @@ EOSIO_TEST_BEGIN(extended_asset_type_test)
// -------------------------------
// extended_asset operator-()const
CHECK_EQUAL( (-extended_asset{asset{ 0, sym_no_prec}, {}}.quantity), (extended_asset{asset_no_prec, {}}.quantity) )
CHECK_EQUAL( (-extended_asset{asset{-0, sym_no_prec}, {}}.quantity), (extended_asset{asset_no_prec, {}}.quantity) )
CHECK_EQUAL( (-extended_asset{asset{ 0, sym_no_prec}, {}}.quantity), (extended_asset{a0, {}}.quantity) )
CHECK_EQUAL( (-extended_asset{asset{-0, sym_no_prec}, {}}.quantity), (extended_asset{a0, {}}.quantity) )
CHECK_EQUAL( (-extended_asset{asset{ 0, sym_prec}, {}}.quantity), (extended_asset{asset_prec, {}}.quantity) )
CHECK_EQUAL( (-extended_asset{asset{-0, sym_prec}, {}}.quantity), (extended_asset{asset_prec, {}}.quantity) )
CHECK_EQUAL( (-extended_asset{asset{1LL, sym_no_prec}, {}}.quantity), (extended_asset{asset{-1LL, sym_no_prec}, {}}.quantity) )
CHECK_EQUAL( (-extended_asset{asset{1LL, sym_no_prec}, {}}.quantity), (extended_asset{asset{-1LL, sym_no_prec}, {}}.quantity) )
CHECK_EQUAL( (-extended_asset{a1, {}}.quantity), (extended_asset{aneg1, {}}.quantity) )
CHECK_EQUAL( (-extended_asset{a1, {}}.quantity), (extended_asset{aneg1, {}}.quantity) )
CHECK_EQUAL( (-extended_asset{asset{1LL, sym_prec}, {}}.quantity), (extended_asset{asset{-1LL, sym_prec}, {}}.quantity) )
CHECK_EQUAL( (-extended_asset{asset{1LL, sym_prec}, {}}.quantity), (extended_asset{asset{-1LL, sym_prec}, {}}.quantity) )
@@ -443,68 +452,146 @@ EOSIO_TEST_BEGIN(extended_asset_type_test)
// -----------------------------------------------------------------------------
// friend extended_asset operator+(const extended_asset&, const extended_asset&)
CHECK_EQUAL( (extended_asset{asset{0LL, sym_no_prec}, {}} + extended_asset{asset{ 0LL, sym_no_prec}, {}}), (extended_asset{asset_no_prec, {}}) )
CHECK_EQUAL( (extended_asset{asset{1LL, sym_no_prec}, {}} + extended_asset{asset{-1LL, sym_no_prec}, {}}), (extended_asset{asset_no_prec, {}}) )
CHECK_EQUAL( (extended_asset{a0, {}} + extended_asset{a0, {}}), (extended_asset{a0, {}}) )
CHECK_EQUAL( (extended_asset{a1, {}} + extended_asset{aneg1, {}}), (extended_asset{a0, {}}) )
CHECK_ASSERT( "type mismatch", (
[&]() {
extended_asset{asset_no_prec, name{"eosioaccountj"}} + extended_asset{asset_no_prec, name{"jtnuoccaoisoe"}};
extended_asset{a0, name{"eosioaccountj"}} + extended_asset{a0, name{"jtnuoccaoisoe"}};
})
)
// -------------------------------------------------------------------------
// friend extended_asset& operator+=(extended_asset&, const extended_asset&)
extended_asset temp{asset_no_prec, {}};
CHECK_EQUAL( (temp += temp), (extended_asset{asset_no_prec, {}}) )
temp = extended_asset{asset{1LL, sym_no_prec}, {}};
CHECK_EQUAL( (temp += extended_asset{asset{-1LL, sym_no_prec}, {}}), (extended_asset{asset_no_prec, {}}) )
extended_asset temp{a0, {}};
CHECK_EQUAL( (temp += temp), (extended_asset{a0, {}}) )
temp = extended_asset{a1, {}};
CHECK_EQUAL( (temp += extended_asset{aneg1, {}}), (extended_asset{a0, {}}) )
CHECK_ASSERT( "type mismatch", (
[&]() {
temp += extended_asset{asset_no_prec, name{"eosioaccountj"}};
temp += extended_asset{a0, name{"eosioaccountj"}};
})
)
// -----------------------------------------------------------------------------
// friend extended_asset operator-(const extended_asset&, const extended_asset&)
CHECK_EQUAL( (extended_asset{asset_no_prec, {}} - extended_asset{asset_no_prec, {}}),
(extended_asset{asset_no_prec, {}}) )
CHECK_EQUAL( (extended_asset{asset{1LL, sym_no_prec}, {}} - extended_asset{asset{1LL, sym_no_prec}, {}}),
(extended_asset{asset{asset_no_prec}, {}}) )
CHECK_EQUAL( (extended_asset{a0, {}} - extended_asset{a0, {}}),
(extended_asset{a0, {}}) )
CHECK_EQUAL( (extended_asset{a1, {}} - extended_asset{a1, {}}),
(extended_asset{asset{a0}, {}}) )
CHECK_ASSERT( "type mismatch", (
[&]() {
extended_asset{asset_no_prec, name{"eosioaccountj"}} - extended_asset{asset_no_prec, name{"jtnuoccaoisoe"}};
extended_asset{a0, name{"eosioaccountj"}} - extended_asset{a0, name{"jtnuoccaoisoe"}};
})
)
// --------------------------------------------------------------------------
// friend extended_asset& operator-=(extended_asset&, const extended_asset&)
temp = extended_asset{asset_no_prec, {}};
CHECK_EQUAL( (temp -= temp), (extended_asset{asset_no_prec, {}}) )
temp = extended_asset{asset{1LL, sym_no_prec}, {}};
CHECK_EQUAL( (temp -= temp), (extended_asset{asset_no_prec, {}}) )
temp = extended_asset{a0, {}};
CHECK_EQUAL( (temp -= temp), (extended_asset{a0, {}}) )
temp = extended_asset{a1, {}};
CHECK_EQUAL( (temp -= temp), (extended_asset{a0, {}}) )
CHECK_ASSERT( "type mismatch", (
[&]() {
temp -= extended_asset{asset_no_prec, name{"jtnuoccaoisoe"}};
temp -= extended_asset{a0, name{"jtnuoccaoisoe"}};
})
)
// --------------------------------------------------------------------------
// extended_asset& operator*=( int64_t b )
CHECK_EQUAL( (extended_asset{ a0, {}} *= 0LL ), (extended_asset{ a0, {}}) );
CHECK_EQUAL( (extended_asset{ a2, {}} *= 1LL ), (extended_asset{ a2, {}}) );
CHECK_EQUAL( (extended_asset{ a2, {}} *= -1LL ), (extended_asset{ aneg2, {}}) );
CHECK_ASSERT( "multiplication underflow", (
[&]() {
extended_asset{ asset{asset_min, sym_no_prec}, {}} *= 2LL;
})
)
CHECK_ASSERT( "multiplication overflow", (
[&]() {
extended_asset{ asset{ asset_max, sym_no_prec}, {}} *= 2LL;
})
)
// --------------------------------------------------------------------------
// friend extended_asset operator*( const extended_asset& a, int64_t b )
CHECK_EQUAL( (extended_asset{ a0, {}} * 0LL ), (extended_asset{ a0, {}}) );
CHECK_EQUAL( (extended_asset{ a2, {}} * 1LL ), (extended_asset{ a2, {}}) );
CHECK_EQUAL( (extended_asset{ a2, {}} * -1LL ), (extended_asset{ aneg2, {}}) );
CHECK_ASSERT( "multiplication underflow", (
[&]() {
extended_asset{ asset{asset_min, sym_no_prec}, {}} * 2LL;
})
)
CHECK_ASSERT( "multiplication overflow", (
[&]() {
extended_asset{ asset{ asset_max, sym_no_prec}, {}} * 2LL;
})
)
// --------------------------------------------------------------------------
// friend extended_asset operator*( int64_t a, const extended_asset& b )
CHECK_EQUAL( ( 0LL * extended_asset{ a0, {}} ), (extended_asset{ a0, {}}) );
CHECK_EQUAL( ( 1LL * extended_asset{ a2, {}} ), (extended_asset{ a2, {}}) );
CHECK_EQUAL( (-1LL * extended_asset{ a2, {}} ), (extended_asset{ aneg2, {}}) );
CHECK_ASSERT( "multiplication underflow", (
[&]() {
2LL * extended_asset{ asset{asset_min, sym_no_prec}, {}};
})
)
CHECK_ASSERT( "multiplication overflow", (
[&]() {
2LL * extended_asset{ asset{ asset_max, sym_no_prec}, {}};
})
)
// --------------------------------------------------------------------------
// friend int64_t operator/( const extended_asset& a, const extended_asset& b )
CHECK_EQUAL( (extended_asset{ a0, {}} / extended_asset{ a1, {}}), 0LL )
CHECK_EQUAL( (extended_asset{ a1, {}} / extended_asset{ a1, {}}), 1LL )
CHECK_EQUAL( (extended_asset{ a4, {}} / extended_asset{ a2, {}}), 2LL )
CHECK_EQUAL( (extended_asset{ aneg4, {}} / extended_asset{ a2, {}}), -2LL )
CHECK_EQUAL( (extended_asset{ aneg4, {}} / extended_asset{ aneg2, {}}), 2LL )
// --------------------------------------------------------------------------
// friend extended_asset& operator/=( extended_asset& a, int64_t b )
CHECK_EQUAL( (extended_asset{ a0, {}} /= 1LL ), (extended_asset{ a0, {}}) )
CHECK_EQUAL( (extended_asset{ a1, {}} /= 1LL ), (extended_asset{ a1, {}}) )
CHECK_EQUAL( (extended_asset{ a4, {}} /= 2LL ), (extended_asset{ a2, {}}) )
CHECK_EQUAL( (extended_asset{ aneg4, {}} /= 2LL ), (extended_asset{ aneg2, {}}) )
CHECK_EQUAL( (extended_asset{ aneg4, {}} /= -2LL ), (extended_asset{ a2, {}}) )
// --------------------------------------------------------------------------
// friend extended_asset operator/( const extended_asset& a, int64_t b )
CHECK_EQUAL( (extended_asset{ a0, {}} / 1LL ), (extended_asset{ a0, {}}) )
CHECK_EQUAL( (extended_asset{ a1, {}} / 1LL ), (extended_asset{ a1, {}}) )
CHECK_EQUAL( (extended_asset{ a4, {}} / 2LL ), (extended_asset{ a2, {}}) )
CHECK_EQUAL( (extended_asset{ aneg4, {}} / 2LL ), (extended_asset{ aneg2, {}}) )
CHECK_EQUAL( (extended_asset{ aneg4, {}} / -2LL ), (extended_asset{ a2, {}}) )
// --------------------------------------------------------------------
// friend bool operator==(const extended_asset&, const extended_asset&)
CHECK_EQUAL( (extended_asset{asset_no_prec, {}} == extended_asset{asset_no_prec, {}}), true )
CHECK_EQUAL( (extended_asset{asset{1LL, sym_no_prec}, {}} == extended_asset{asset{1LL, sym_no_prec}, {}}), true )
CHECK_EQUAL( (extended_asset{a0, {}} == extended_asset{a0, {}}), true )
CHECK_EQUAL( (extended_asset{a1, {}} == extended_asset{a1, {}}), true )
// --------------------------------------------------------------------
// friend bool operator!=(const extended_asset&, const extended_asset&)
CHECK_EQUAL( (extended_asset{asset_no_prec, name{"eosioaccountj"}} != extended_asset{asset_no_prec, name{"jtnuoccaoisoe"}}), true )
CHECK_EQUAL( (extended_asset{asset{1LL, sym_no_prec}, {}} != extended_asset{asset{-1LL, sym_no_prec}, {}}), true )
CHECK_EQUAL( (extended_asset{asset{1LL, sym_no_prec}, {}} != extended_asset{asset{ 0LL, sym_no_prec}, name{"eosioaccountj"}}), true )
CHECK_EQUAL( (extended_asset{a0, name{"eosioaccountj"}} != extended_asset{a0, name{"jtnuoccaoisoe"}}), true )
CHECK_EQUAL( (extended_asset{a1, {}} != extended_asset{aneg1, {}}), true )
CHECK_EQUAL( (extended_asset{a1, {}} != extended_asset{a0, name{"eosioaccountj"}}), true )
// -------------------------------------------------------------------
// friend bool operator<(const extended_asset&, const extended_asset&)
CHECK_EQUAL( (extended_asset{asset_no_prec, name{}} < extended_asset{asset{ 1LL, sym_no_prec}, {}}), true )
CHECK_EQUAL( (extended_asset{a0, name{}} < extended_asset{a1, {}}), true )
CHECK_ASSERT( "type mismatch", (
[&]() {
bool b{extended_asset{{}, name{}} < extended_asset{{}, name{"eosioaccountj"}}};
@@ -512,9 +599,19 @@ EOSIO_TEST_BEGIN(extended_asset_type_test)
})
)
// -------------------------------------------------------------------
// friend bool operator>(const extended_asset&, const extended_asset&)
CHECK_EQUAL( (extended_asset{a1, {}} > extended_asset{a0, name{}}), true )
CHECK_ASSERT( "type mismatch", (
[&]() {
bool b{extended_asset{{}, name{}} > extended_asset{{}, name{"eosioaccountj"}}};
return b;
})
)
// --------------------------------------------------------------------
// friend bool operator<=(const extended_asset&, const extended_asset&)
CHECK_EQUAL( (extended_asset{asset_no_prec, name{}} <= extended_asset{asset{ 1LL, sym_no_prec}, {}}), true );
CHECK_EQUAL( (extended_asset{a0, name{}} <= extended_asset{a1, {}}), true );
CHECK_ASSERT( "type mismatch", (
[&]() {
bool b{extended_asset{{}, name{}} <= extended_asset{{}, name{"eosioaccountj"}}};
@@ -524,7 +621,7 @@ EOSIO_TEST_BEGIN(extended_asset_type_test)
// --------------------------------------------------------------------
// friend bool operator>=(const extended_asset&, const extended_asset&)
CHECK_EQUAL( (extended_asset{asset{ 1LL, sym_no_prec}, {}} >= extended_asset{asset_no_prec, name{}}), true );
CHECK_EQUAL( (extended_asset{a1, {}} >= extended_asset{a0, name{}}), true );
CHECK_ASSERT( "type mismatch", (
[&]() {
bool b{extended_asset{{}, name{}} >= extended_asset{{}, name{"eosioaccountj"}}};
+32
View File
@@ -385,6 +385,38 @@ EOSIO_TEST_BEGIN(datastream_stream_test)
ds >> str;
CHECK_EQUAL( cstr, str )
// -----------
// std::basic_string<uint8_t>
ds.seekp(0);
fill(begin(datastream_buffer), end(datastream_buffer), 0);
static const std::basic_string<uint8_t> inputBasicString {0, 1, 2, 3, 4, 5};
std::basic_string<uint8_t> outputBasicString{};
ds << inputBasicString;
ds.seekp(0);
ds >> outputBasicString;
CHECK_EQUAL( inputBasicString, outputBasicString )
// -----------
// empty std::basic_string
ds.seekp(0);
fill(begin(datastream_buffer), end(datastream_buffer), 0);
static const std::basic_string<uint8_t> emptyBasicString;
ds << emptyBasicString;
ds.seekp(0);
ds >> outputBasicString;
CHECK_EQUAL( emptyBasicString, outputBasicString )
// -----------
// std::basic_string<wchar_t>
ds.seekp(0);
fill(begin(datastream_buffer), end(datastream_buffer), 0);
static const std::basic_string<wchar_t> inputWideBasicString {L'\x3b1', L'\x3b2'};
std::basic_string<wchar_t> outputWideBasicString{};
ds << inputWideBasicString;
ds.seekp(0);
ds >> outputWideBasicString;
CHECK_EQUAL( inputWideBasicString, outputWideBasicString )
// ----------
// std::tuple
ds.seekp(0);
+5
View File
@@ -7,6 +7,11 @@ add_contract(explicit_nested_tests explicit_nested_tests explicit_nested_tests.c
add_contract(transfer_contract transfer_contract transfer.cpp)
add_contract(minimal_tests minimal_tests minimal_tests.cpp)
add_contract(crypto_primitives_tests crypto_primitives_tests crypto_primitives_tests.cpp)
add_contract(bls_primitives_tests bls_primitives_tests bls_primitives_tests.cpp)
add_contract(get_code_hash_tests get_code_hash_write get_code_hash_write.cpp)
add_contract(get_code_hash_tests get_code_hash_read get_code_hash_read.cpp)
add_contract(name_pk_tests name_pk_tests name_pk_tests.cpp)
add_contract(test_multi_index test_multi_index multi_index_tests.cpp)
add_contract(capi_tests capi_tests capi/capi.c capi/action.c capi/chain.c capi/crypto.c capi/db.c capi/permission.c
capi/print.c capi/privileged.c capi/system.c capi/transaction.c)
@@ -0,0 +1,419 @@
#include <eosio/eosio.hpp>
#include <eosio/crypto.hpp>
#include <eosio/crypto_ext.hpp>
#include <eosio/crypto_bls_ext.hpp>
using namespace eosio;
namespace bls12_381
{
class sha256
{
public:
sha256(): m_blocklen(0), m_bitlen(0)
{
m_state[0] = 0x6a09e667;
m_state[1] = 0xbb67ae85;
m_state[2] = 0x3c6ef372;
m_state[3] = 0xa54ff53a;
m_state[4] = 0x510e527f;
m_state[5] = 0x9b05688c;
m_state[6] = 0x1f83d9ab;
m_state[7] = 0x5be0cd19;
}
void update(const uint8_t * data, size_t length)
{
for(size_t i = 0 ; i < length ; i++)
{
m_data[m_blocklen++] = data[i];
if (m_blocklen == 64)
{
transform();
// End of the block
m_bitlen += 512;
m_blocklen = 0;
}
}
}
void update(const std::string &data)
{
update(reinterpret_cast<const uint8_t*> (data.c_str()), data.size());
}
std::array<uint8_t, 32> digest()
{
std::array<uint8_t, 32> hash;
pad();
revert(hash);
return hash;
}
void digest(uint8_t* dst)
{
std::array<uint8_t, 32>* phash = reinterpret_cast<std::array<uint8_t, 32>*>(dst);
pad();
revert(*phash);
}
//static string toString(const array<uint8_t, 32>& digest);
private:
uint8_t m_data[64];
uint32_t m_blocklen;
uint64_t m_bitlen;
uint32_t m_state[8]; //A, B, C, D, E, F, G, H
static constexpr std::array<uint32_t, 64> K = {
0x428a2f98,0x71374491,0xb5c0fbcf,0xe9b5dba5,
0x3956c25b,0x59f111f1,0x923f82a4,0xab1c5ed5,
0xd807aa98,0x12835b01,0x243185be,0x550c7dc3,
0x72be5d74,0x80deb1fe,0x9bdc06a7,0xc19bf174,
0xe49b69c1,0xefbe4786,0x0fc19dc6,0x240ca1cc,
0x2de92c6f,0x4a7484aa,0x5cb0a9dc,0x76f988da,
0x983e5152,0xa831c66d,0xb00327c8,0xbf597fc7,
0xc6e00bf3,0xd5a79147,0x06ca6351,0x14292967,
0x27b70a85,0x2e1b2138,0x4d2c6dfc,0x53380d13,
0x650a7354,0x766a0abb,0x81c2c92e,0x92722c85,
0xa2bfe8a1,0xa81a664b,0xc24b8b70,0xc76c51a3,
0xd192e819,0xd6990624,0xf40e3585,0x106aa070,
0x19a4c116,0x1e376c08,0x2748774c,0x34b0bcb5,
0x391c0cb3,0x4ed8aa4a,0x5b9cca4f,0x682e6ff3,
0x748f82ee,0x78a5636f,0x84c87814,0x8cc70208,
0x90befffa,0xa4506ceb,0xbef9a3f7,0xc67178f2
};
static uint32_t rotr(uint32_t x, uint32_t n)
{
return (x >> n) | (x << (32 - n));
}
static uint32_t choose(uint32_t e, uint32_t f, uint32_t g)
{
return (e & f) ^ (~e & g);
}
static uint32_t majority(uint32_t a, uint32_t b, uint32_t c)
{
return (a & (b | c)) | (b & c);
}
static uint32_t sig0(uint32_t x)
{
return sha256::rotr(x, 7) ^ sha256::rotr(x, 18) ^ (x >> 3);
}
static uint32_t sig1(uint32_t x)
{
return sha256::rotr(x, 17) ^ sha256::rotr(x, 19) ^ (x >> 10);
}
void transform()
{
uint32_t maj, xorA, ch, xorE, sum, newA, newE, m[64];
uint32_t state[8];
for(uint8_t i = 0, j = 0; i < 16; i++, j += 4)
{
// Split data in 32 bit blocks for the 16 first words
m[i] = (m_data[j] << 24) | (m_data[j + 1] << 16) | (m_data[j + 2] << 8) | (m_data[j + 3]);
}
for(uint8_t k = 16 ; k < 64; k++)
{
// Remaining 48 blocks
m[k] = sha256::sig1(m[k - 2]) + m[k - 7] + sha256::sig0(m[k - 15]) + m[k - 16];
}
for(uint8_t i = 0 ; i < 8 ; i++)
{
state[i] = m_state[i];
}
for(uint8_t i = 0; i < 64; i++)
{
maj = sha256::majority(state[0], state[1], state[2]);
xorA = sha256::rotr(state[0], 2) ^ sha256::rotr(state[0], 13) ^ sha256::rotr(state[0], 22);
ch = choose(state[4], state[5], state[6]);
xorE = sha256::rotr(state[4], 6) ^ sha256::rotr(state[4], 11) ^ sha256::rotr(state[4], 25);
sum = m[i] + K[i] + state[7] + ch + xorE;
newA = xorA + maj + sum;
newE = state[3] + sum;
state[7] = state[6];
state[6] = state[5];
state[5] = state[4];
state[4] = newE;
state[3] = state[2];
state[2] = state[1];
state[1] = state[0];
state[0] = newA;
}
for(uint8_t i = 0 ; i < 8 ; i++)
{
m_state[i] += state[i];
}
}
void pad()
{
uint64_t i = m_blocklen;
uint8_t end = m_blocklen < 56 ? 56 : 64;
m_data[i++] = 0x80; // Append a bit 1
while(i < end)
{
m_data[i++] = 0x00; // Pad with zeros
}
if(m_blocklen >= 56)
{
transform();
memset(m_data, 0, 56);
}
// Append to the padding the total message's length in bits and transform.
m_bitlen += m_blocklen * 8;
m_data[63] = m_bitlen;
m_data[62] = m_bitlen >> 8;
m_data[61] = m_bitlen >> 16;
m_data[60] = m_bitlen >> 24;
m_data[59] = m_bitlen >> 32;
m_data[58] = m_bitlen >> 40;
m_data[57] = m_bitlen >> 48;
m_data[56] = m_bitlen >> 56;
transform();
}
void revert(std::array<uint8_t, 32>& hash)
{
// SHA uses big endian byte ordering
// Revert all bytes
for(uint8_t i = 0 ; i < 4 ; i++)
{
for(uint8_t j = 0 ; j < 8 ; j++)
{
hash[i + (j * 4)] = (m_state[j] >> (24 - i * 8)) & 0x000000ff;
}
}
}
};
} // namespace bls12_381
class [[eosio::contract]] bls_primitives_tests : public contract{
public:
using contract::contract;
[[eosio::action]]
void testg1add(const std::vector<uint8_t>& op1, const std::vector<uint8_t>& op2, const std::vector<uint8_t>& res)
{
bls_g1 lhs, rhs, r;
memcpy(lhs, op1.data(), sizeof(bls_g1));
memcpy(rhs, op1.data(), sizeof(bls_g1));
bls_g1_add(lhs, rhs, r);
check(0 == memcmp(r, res.data(), sizeof(bls_g1)), "bls_g1_add test failed");
}
[[eosio::action]]
void testg2add(const std::vector<uint8_t>& op1, const std::vector<uint8_t>& op2, const std::vector<uint8_t>& res)
{
bls_g2 lhs, rhs, r;
memcpy(lhs, op1.data(), sizeof(bls_g2));
memcpy(rhs, op1.data(), sizeof(bls_g2));
bls_g2_add(lhs, rhs, r);
check(0 == memcmp(r, res.data(), sizeof(bls_g2)), "bls_g2_add test failed");
}
[[eosio::action]]
void testg1mul(const std::vector<uint8_t>& point, const std::vector<uint8_t>& scalar, const std::vector<uint8_t>& res)
{
bls_g1 p, r;
bls_scalar s;
memcpy(p, point.data(), sizeof(bls_g1));
memcpy(s, scalar.data(), sizeof(bls_scalar));
bls_g1_mul(p, s, r);
check(0 == memcmp(r, res.data(), sizeof(bls_g1)), "bls_g1_mul test failed");
}
[[eosio::action]]
void testg2mul(const std::vector<uint8_t>& point, const std::vector<uint8_t>& scalar, const std::vector<uint8_t>& res)
{
bls_g2 p, r;
bls_scalar s;
memcpy(p, point.data(), sizeof(bls_g2));
memcpy(s, scalar.data(), sizeof(bls_scalar));
bls_g2_mul(p, s, r);
check(0 == memcmp(r, res.data(), sizeof(bls_g2)), "bls_g2_mul test failed");
}
[[eosio::action]]
void testg1exp(const std::vector<uint8_t>& points, const std::vector<uint8_t>& scalars, const std::vector<uint8_t>& res)
{
check(points.size()/sizeof(bls_g1) == scalars.size()/sizeof(bls_scalar), "number of elements in points and scalars must be equal");
uint32_t num = scalars.size()/sizeof(bls_scalar);
const bls_g1* pp = reinterpret_cast<const bls_g1*>(points.data());
const bls_scalar* ps = reinterpret_cast<const bls_scalar*>(scalars.data());
bls_g1 r;
bls_g1_exp(pp, ps, num, r);
check(0 == memcmp(r, res.data(), sizeof(bls_g1)), "bls_g1_exp test failed");
}
[[eosio::action]]
void testg2exp(const std::vector<uint8_t>& points, const std::vector<uint8_t>& scalars, const std::vector<uint8_t>& res)
{
check(points.size()/sizeof(bls_g2) == scalars.size()/sizeof(bls_scalar), "number of elements in points and scalars must be equal");
uint32_t num = scalars.size()/sizeof(bls_scalar);
const bls_g2* pp = reinterpret_cast<const bls_g2*>(points.data());
const bls_scalar* ps = reinterpret_cast<const bls_scalar*>(scalars.data());
bls_g2 r;
bls_g2_exp(pp, ps, num, r);
check(0 == memcmp(r, res.data(), sizeof(bls_g2)), "bls_g2_exp test failed");
}
[[eosio::action]]
void testpairing(const std::vector<uint8_t>& g1_points, const std::vector<uint8_t>& g2_points, const std::vector<uint8_t>& res)
{
check(g1_points.size()/sizeof(bls_g1) == g2_points.size()/sizeof(bls_g2), "number of elements in g1_points and g2_points must be equal");
uint32_t num = g1_points.size()/sizeof(bls_g1);
const bls_g1* pp1 = reinterpret_cast<const bls_g1*>(g1_points.data());
const bls_g2* pp2 = reinterpret_cast<const bls_g2*>(g2_points.data());
bls_gt r;
bls_pairing(pp1, pp2, num, r);
check(0 == memcmp(r, res.data(), sizeof(bls_gt)), "bls_pairing test failed");
}
[[eosio::action]]
void testg1map(const std::vector<uint8_t>& e, const std::vector<uint8_t>& res)
{
bls_fp element;
memcpy(element, e.data(), sizeof(bls_fp));
bls_g1 r;
bls_g1_map(element, r);
check(0 == memcmp(r, res.data(), sizeof(bls_g1)), "bls_g1_map test failed");
}
[[eosio::action]]
void testg2map(const std::vector<uint8_t>& e, const std::vector<uint8_t>& res)
{
bls_fp2 element;
memcpy(element, e.data(), sizeof(bls_fp2));
bls_g2 r;
bls_g2_map(element, r);
check(0 == memcmp(r, res.data(), sizeof(bls_g2)), "bls_g2_map test failed");
}
// Construct an extensible-output function based on SHA256
void xmd_sh256(
uint8_t *buf,
int buf_len,
const uint8_t *in,
int in_len,
const uint8_t *dst,
int dst_len
)
{
const unsigned int SHA256HashSize = 32;
const unsigned int SHA256_Message_Block_Size = 64;
const unsigned ell = (buf_len + SHA256HashSize - 1) / SHA256HashSize;
if (buf_len < 0 || ell > 255 || dst_len > 255)
{
return;
}
const uint8_t Z_pad[SHA256_Message_Block_Size] = { 0, };
const uint8_t l_i_b_0_str[] = {
static_cast<uint8_t>(buf_len >> 8),
static_cast<uint8_t>(buf_len & 0xff),
0,
static_cast<uint8_t>(dst_len)
};
const uint8_t *dstlen_str = l_i_b_0_str + 3;
uint8_t b_0[SHA256HashSize];
bls12_381::sha256 sha;
sha.update(Z_pad, SHA256_Message_Block_Size);
sha.update(in, in_len);
sha.update(l_i_b_0_str, 3);
sha.update(dst, dst_len);
sha.update(dstlen_str, 1);
sha.digest(b_0);
uint8_t b_i[SHA256HashSize + 1] = { 0, };
for (unsigned i = 1; i <= ell; ++i)
{
for (unsigned j = 0; j < SHA256HashSize; ++j)
{
b_i[j] = b_0[j] ^ b_i[j];
}
b_i[SHA256HashSize] = i;
bls12_381::sha256 s;
s.update(b_i, SHA256HashSize + 1);
s.update(dst, dst_len);
s.update(dstlen_str, 1);
s.digest(b_i);
const int rem_after = buf_len - i * SHA256HashSize;
const int copy_len = SHA256HashSize + (rem_after < 0 ? rem_after : 0);
memcpy(buf + (i - 1) * SHA256HashSize, b_i, copy_len);
}
}
std::array<uint64_t, 8> scalar_fromBytesBE(const std::array<uint8_t, 8*8>& in)
{
std::array<uint64_t, 8> out;
for(uint64_t i = 0; i < 8; i++)
{
int64_t a = 8*8 - i*8;
out[i] =
static_cast<uint64_t>(in[a-1]) | static_cast<uint64_t>(in[a-2]) << 8 |
static_cast<uint64_t>(in[a-3]) << 16 | static_cast<uint64_t>(in[a-4]) << 24 |
static_cast<uint64_t>(in[a-5]) << 32 | static_cast<uint64_t>(in[a-6]) << 40 |
static_cast<uint64_t>(in[a-7]) << 48 | static_cast<uint64_t>(in[a-8]) << 56;
}
return out;
}
void g2_fromMessage(const std::vector<uint8_t>& msg, const std::string& dst, bls_g2& res)
{
uint8_t buf[4 * 64];
xmd_sh256(buf, 4 * 64, msg.data(), msg.size(), reinterpret_cast<const uint8_t*>(dst.c_str()), dst.length());
std::array<uint64_t, 8> k;
bls_fp2 t;
bls_g2 p, q;
k = scalar_fromBytesBE(*reinterpret_cast<std::array<uint8_t, 64>*>(buf));
bls_fp_mod(reinterpret_cast<uint8_t*>(&k[0]), t[0]);
k = scalar_fromBytesBE(*reinterpret_cast<std::array<uint8_t, 64>*>(buf + 64));
bls_fp_mod(reinterpret_cast<uint8_t*>(&k[0]), t[1]);
bls_g2_map(t, p);
k = scalar_fromBytesBE(*reinterpret_cast<std::array<uint8_t, 64>*>(buf + 2*64));
bls_fp_mod(reinterpret_cast<uint8_t*>(&k[0]), t[0]);
k = scalar_fromBytesBE(*reinterpret_cast<std::array<uint8_t, 64>*>(buf + 3*64));
bls_fp_mod(reinterpret_cast<uint8_t*>(&k[0]), t[1]);
bls_g2_map(t, q);
bls_g2_add(p, q, res);
}
const std::string CIPHERSUITE_ID = "BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_";
const std::vector<uint8_t> G1_ONE_NEG = {0x16, 0x0c, 0x53, 0xfd, 0x90, 0x87, 0xb3, 0x5c, 0xf5, 0xff, 0x76, 0x99, 0x67, 0xfc, 0x17, 0x78, 0xc1, 0xa1, 0x3b, 0x14, 0xc7, 0x95, 0x4f, 0x15, 0x47, 0xe7, 0xd0, 0xf3, 0xcd, 0x6a, 0xae, 0xf0, 0x40, 0xf4, 0xdb, 0x21, 0xcc, 0x6e, 0xce, 0xed, 0x75, 0xfb, 0x0b, 0x9e, 0x41, 0x77, 0x01, 0x12, 0x3a, 0x88, 0x18, 0xf3, 0x2a, 0x6c, 0x52, 0xff, 0x70, 0x02, 0x3b, 0x38, 0xe4, 0x9c, 0x89, 0x92, 0x55, 0xd0, 0xa9, 0x9f, 0x8d, 0x73, 0xd7, 0x89, 0x2a, 0xc1, 0x44, 0xa3, 0x5b, 0xf3, 0xca, 0x12, 0x17, 0x53, 0x4b, 0x96, 0x76, 0x1b, 0xff, 0x3c, 0x30, 0x44, 0x77, 0xe9, 0xed, 0xd2, 0x44, 0x0e, 0xfd, 0xff, 0x02, 0x00, 0x00, 0x00, 0x09, 0x76, 0x02, 0x00, 0x0c, 0xc4, 0x0b, 0x00, 0xf4, 0xeb, 0xba, 0x58, 0xc7, 0x53, 0x57, 0x98, 0x48, 0x5f, 0x45, 0x57, 0x52, 0x70, 0x53, 0x58, 0xce, 0x77, 0x6d, 0xec, 0x56, 0xa2, 0x97, 0x1a, 0x07, 0x5c, 0x93, 0xe4, 0x80, 0xfa, 0xc3, 0x5e, 0xf6, 0x15};
const std::vector<uint8_t> GT_ONE = {0xfd, 0xff, 0x02, 0x00, 0x00, 0x00, 0x09, 0x76, 0x02, 0x00, 0x0c, 0xc4, 0x0b, 0x00, 0xf4, 0xeb, 0xba, 0x58, 0xc7, 0x53, 0x57, 0x98, 0x48, 0x5f, 0x45, 0x57, 0x52, 0x70, 0x53, 0x58, 0xce, 0x77, 0x6d, 0xec, 0x56, 0xa2, 0x97, 0x1a, 0x07, 0x5c, 0x93, 0xe4, 0x80, 0xfa, 0xc3, 0x5e, 0xf6, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
std::vector<uint8_t> msg = {51, 23, 56, 93, 212, 129, 128, 27, 251, 12, 42, 129, 210, 9, 34, 98};
[[eosio::action]]
void verify(const std::vector<uint8_t>& pk, const std::vector<uint8_t>& sig)
{
bls_g1 g1_points[2];
bls_g2 g2_points[2];
memcpy(&g1_points[0], G1_ONE_NEG.data(), sizeof(bls_g1));
memcpy(&g2_points[0], sig.data(), sizeof(bls_g2));
bls_g2 p_msg;
g2_fromMessage(msg, CIPHERSUITE_ID, p_msg);
memcpy(&g1_points[1], pk.data(), sizeof(bls_g1));
memcpy(&g2_points[1], p_msg, sizeof(bls_g2));
bls_gt r;
bls_pairing(g1_points, g2_points, 2, r);
check(0 == memcmp(r, GT_ONE.data(), sizeof(bls_gt)), "bls signature verify failed");
}
};
+1
View File
@@ -13,5 +13,6 @@ void test_action( void ) {
send_context_free_inline(NULL, 0);
publication_time();
current_receiver();
get_code_hash(0, 0, NULL, 0);
set_action_return_value(NULL, 0);
}
@@ -32,7 +32,7 @@ CONTRACT explicit_nested_tests : public contract {
std::tuple<uint64_t, std::optional<float>, std::vector<int>> tup1;
std::variant<uint64_t, std::optional<std::pair<int, float>>, std::vector<int>> var1;
std::vector<std::vector<_mystruct>> vvmys;
auto primary_key() const { return id; }
auto primary_key() const -> decltype(id) { return id; }
EOSLIB_SERIALIZE(testdata, (id)(data)(data_vec)(data_vec2)(data_vec3)(tup1)(var1)(vvmys));
};
@@ -0,0 +1,27 @@
#include <eosio/eosio.hpp>
#include <eosio/action.hpp>
#include <eosio/name.hpp>
#include "get_code_hash_table.hpp"
class [[eosio::contract]] get_code_hash_tests : public contract {
public:
using contract::contract;
using hash_table = multi_index<name("code.hash"), code_hash>;
// Read the old code's hash from database and verify new code's hash differs
[[eosio::action]]
void theaction() {
require_auth(get_self());
hash_table hashes(get_self(), get_self().value);
auto hash = get_code_hash(get_self());
check(hash != checksum256(), "Code hash should not be null");
auto record = hashes.get(0, "Unable to find recorded hash");
check(hash != record.hash, "Code hash has not changed");
eosio::print("Old hash: ", record.hash, "; new hash: ", hash);
}
};

Some files were not shown because too many files have changed in this diff Show More