Skip to content
This repository has been archived by the owner on Aug 14, 2023. It is now read-only.

proc-macros rewrite #190

Merged
merged 65 commits into from
Dec 17, 2020
Merged

proc-macros rewrite #190

merged 65 commits into from
Dec 17, 2020

Conversation

YaronWittenstein
Copy link
Contributor

@YaronWittenstein YaronWittenstein commented Dec 6, 2020

Motivation

This PR pretty much reimplements the svm-sdk-macros crate.
Firstly, it introduces a new proc-marco named, #[app] that serves as the root macro.
It decorates a module that implements SVM app, and they're also sub-proc-macros underneath.

Part of these sub-macros already exists (such as #[storage] and [endpoint]) and new ones are added.

This big rewrite should make the amount of work required for adding new proc-macros in the future much easier and faster.

@YaronWittenstein YaronWittenstein self-assigned this Dec 6, 2020
@YaronWittenstein YaronWittenstein marked this pull request as ready for review December 16, 2020 16:39
@@ -19,6 +19,7 @@ pub enum TypeError {

enum TypeKind {
None,
Unit,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this type for?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A function in Rust that returns nothing actually returns ()

@@ -0,0 +1,7 @@
error: #[endpoint]` and `#[fundable_hook]` can't co-exist.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this file used for some validation, or should it get removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's auto-generated by the trybuild.
The first time you run a test it's generated with a warning
and it asks you to move the error to the same directory as the test.

/// }
///
/// fn set_data(index: usize, value: u32) {
// svm_sdk::storage::ops::array_set_addr::<StorageImpl>(2, index, 3, value)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"//" => "///" (the misalignment breaks the entire clause inspection)

/// }
///
/// fn set_data(index: usize, value: u32) {
// svm_sdk::storage::ops::array_set_addr::<StorageImpl>(2, index, 3, value)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"//" => "///" (the misalignment breaks the entire clause inspection)

/// ```rust
/// use svm_sdk::app;
///
/// #[app]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not clear what this macro is actually doing (since it's hard to follow the macro implementation code). Perhaps provide an example of the compile-time results of using it (like for #[storage]).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This macro is doesn't do something.
it's the gateway for the other macros.

you can't use #[endpoint], #[storage] and others without wrapping them
within an #[app]


#[fundable(update_coins)]
#[endpoint]
fn do_nothing() {}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This endpoint returns ()
@moshababo

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, 10x

@YaronWittenstein YaronWittenstein merged commit 4397edc into master Dec 17, 2020
SVM Integration automation moved this from In progress to Done Dec 17, 2020
@YaronWittenstein YaronWittenstein deleted the app-proc-macro branch December 17, 2020 13:14
@YaronWittenstein YaronWittenstein changed the title #[app] proc-macro proc-macros rewrite Dec 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
big Big-sized task
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

2 participants