wa-lang.org/wazero@v1.0.2/imports/proxywasm/internal/abi_callback_configuration.go (about)

     1  // Copyright 2020-2021 Tetrate
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  // http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package internal
    16  
    17  import (
    18  	"time"
    19  
    20  	"wa-lang.org/wazero/imports/proxywasm/types"
    21  )
    22  
    23  //export proxy_on_vm_start
    24  func proxyOnVMStart(_ uint32, vmConfigurationSize int) types.OnVMStartStatus {
    25  	if recordTiming {
    26  		defer logTiming("proxyOnVMStart", time.Now())
    27  	}
    28  	return currentState.vmContext.OnVMStart(vmConfigurationSize)
    29  }
    30  
    31  //export proxy_on_configure
    32  func proxyOnConfigure(pluginContextID uint32, pluginConfigurationSize int) types.OnPluginStartStatus {
    33  	if recordTiming {
    34  		defer logTiming("proxyOnConfigure", time.Now())
    35  	}
    36  	ctx, ok := currentState.pluginContexts[pluginContextID]
    37  	if !ok {
    38  		panic("invalid context on proxy_on_configure")
    39  	}
    40  	currentState.setActiveContextID(pluginContextID)
    41  	return ctx.context.OnPluginStart(pluginConfigurationSize)
    42  }