Add convenience macro for native program entrypoint

This commit is contained in:
Michael Vines
2018-11-13 18:38:51 -08:00
parent e33f3a2562
commit 0bf2ff6138
5 changed files with 24 additions and 8 deletions

View File

@ -6,3 +6,15 @@ pub const ENTRYPOINT: &str = "process";
// Native program ENTRYPOINT prototype
pub type Entrypoint =
unsafe extern "C" fn(keyed_accounts: &mut [KeyedAccount], data: &[u8]) -> bool;
// Convenience macro to define the native program entrypoint. Supply a fn to this macro that
// conforms to the `Entrypoint` type signature.
#[macro_export]
macro_rules! solana_entrypoint(
($entrypoint:ident) => (
#[no_mangle]
pub extern "C" fn process(keyed_accounts: &mut [KeyedAccount], data: &[u8]) -> bool {
return $entrypoint(keyed_accounts, data);
}
)
);