feat(c-api) Rename Operator to wasmer_parser_operator_t.

This commit is contained in:
Ivan Enderlin
2021-03-04 17:15:28 +01:00
parent 7780423c81
commit e2c4f1ee69
3 changed files with 513 additions and 8 deletions

View File

@@ -125,7 +125,7 @@
//! ```
use super::super::super::instance::wasm_instance_t;
use super::super::parser::operator::Operator as COperator;
use super::super::parser::operator::wasmer_parser_operator_t;
use super::wasmer_middleware_t;
use std::sync::Arc;
use wasmer::wasmparser::Operator;
@@ -202,7 +202,7 @@ pub struct wasmer_metering_t {
}
#[allow(non_camel_case_types)]
pub type wasmer_metering_cost_function_t = extern "C" fn(operator: COperator) -> u64;
pub type wasmer_metering_cost_function_t = extern "C" fn(operator: wasmer_parser_operator_t) -> u64;
/// Creates a new metering middleware with an initial limit, i.e. a
/// total number of operators to execute (regarding their respective

View File

@@ -1,7 +1,8 @@
use wasmer::wasmparser::Operator as OriginalOperator;
use wasmer::wasmparser::Operator;
#[repr(C)]
pub enum Operator {
#[allow(non_camel_case_types)]
pub enum wasmer_parser_operator_t {
Unreachable,
Nop,
Block,
@@ -505,9 +506,9 @@ pub enum Operator {
I32x4TruncSatF64x2UZero,
}
impl<'a> From<&OriginalOperator<'a>> for Operator {
fn from(operator: &OriginalOperator<'a>) -> Self {
use OriginalOperator::*;
impl<'a> From<&Operator<'a>> for wasmer_parser_operator_t {
fn from(operator: &Operator<'a>) -> Self {
use Operator::*;
match operator {
Unreachable => Self::Unreachable,