Expand description
§fre-sys
Rust bindings for the AIR Native Extension (ANE) C API (FlashRuntimeExtensions.h).
§Examples
use fre_sys::*;
#[allow(unsafe_op_in_unsafe_fn, non_snake_case, unused_variables)]
#[unsafe(no_mangle)]
pub unsafe extern "C" fn Initializer (
ext_data_to_set: *mut FREData,
ctx_initializer_to_set: *mut FREContextInitializer,
ctx_finalizer_to_set: *mut Option<FREContextFinalizer>,
) {
*ctx_initializer_to_set = ctx_initializer;
}
#[allow(unsafe_op_in_unsafe_fn, unused_variables)]
unsafe extern "C" fn ctx_initializer (
ext_data: FREData,
ctx_type: FREStr,
ctx: FREContext,
num_funcs_to_set: *mut u32,
funcs_to_set: *mut *const FRENamedFunction,
) {
*num_funcs_to_set = 1;
*funcs_to_set = std::mem::transmute(&FUNC);
}
#[repr(transparent)]
struct Function (FRENamedFunction);
unsafe impl Sync for Function {}
static FUNC: Function = Function(FRENamedFunction {
name: c"hello_extension".as_ptr() as FREStr,
functionData: std::ptr::null_mut(),
function: hello,
});
unsafe extern "C" fn hello(_: FREContext, _: FREData, _: u32, _: *const FREObject) -> FREObject {
let bytes = "Hello! Flash Runtime.".as_bytes();
let mut str_obj = std::ptr::null_mut();
_ = unsafe {FRENewObjectFromUTF8(bytes.len() as u32, bytes.as_ptr(), &mut str_obj)};
str_obj
}Structs§
- FREBitmap
Data - A non-owning descriptor for bitmap data.
- FREBitmap
Data2 - A non-owning descriptor for bitmap data.
- FREByte
Array - A non-owning descriptor for bytes.
- FRENamed
Function - A non-owning descriptor for a registered native function.
- FREObject
Type - These values must not be changed.
- FRERender
Mode - Declared as [
uint8_t] instead of the C enum storage type, because the runtime writes only one byte in practice. - FREResult
- These values must not be changed.
Functions§
- FREAcquire
Bitmap ⚠Data - Referenced data is valid only for duration of the call to a registered function.
- FREAcquire
Bitmap ⚠Data2 - Referenced data is valid only for duration of the call to a registered function.
- FREAcquire
Byte ⚠Array - Referenced data is valid only for duration of the call to a registered function.
- FREAcquire
Native ⚠Window Handle - Referenced handle is valid only for duration of the call to a registered function.
- FRECall
Object ⚠Method - Parameters
- FREDispatch
Status ⚠Event Async - Causes a
StatusEventto be dispatched from the associatedExtensionContextobject. - FREGet
Array ⚠Element At - If an
Arrayis sparse and an element that isn’t defined is requested, the return value will beFREResult::FRE_OKbut the handle value will be invalid. - FREGet
Array ⚠Length - Returns
- FREGet
Context ⚠Action Script Data - Returns
- FREGet
Context ⚠Native Data - Returns
- FREGetFRE
Context ⚠From Extension Context - Get the
FREContextobject associated with anyExtensionContextobject. Note that theFREContextobject may become invalid based on what happens with the otherExtensionContext, so this value should not be cached between function calls. - FREGet
Native ⚠Context3D Handle - Access the native context type for a
Context3Dobject. The type depends on the render mode: currently this is only valid for OpenGL ES rendering and will return anEGLContextobject. This object should be valid until theContext3Dobject is disposed, or the device/application loses the graphics context. - FREGet
Object ⚠AsBool - Returns
- FREGet
Object ⚠AsDouble - Returns
- FREGet
Object ⚠AsInt32 - Returns
- FREGet
Object ⚠AsUT F8 - Retrieves a string representation of the object referred to by the given object. The referenced string is immutable and valid only for duration of the call to a registered function. If the caller wishes to keep the string, they must keep a copy of it.
- FREGet
Object ⚠AsUint32 - Returns
- FREGet
Object ⚠Property - Parameters
- FREGet
Object ⚠Type - Returns
- FREGet
Render ⚠Mode - Returns the current render mode and mechanism for AIR
- FREInvalidate
Bitmap ⚠Data Rect BitmapDatamust be acquired to call this. Clients must invalidate any region they modify in order to notify AIR of the changes. Only invalidated regions are redrawn.- FREMedia
Buffer ⚠Lock - Locks a
MediaBufferbitmap and returns information about the data storage. - FREMedia
Buffer ⚠Unlock - Unlocks a
MediaBufferbitmap. - FRENew
Byte ⚠Array - Creates a new byte array using optional input information (
lengthand optionalbyte) - FRENew
Object ⚠ - Parameters
- FRENew
Object ⚠From Bool - Returns
- FRENew
Object ⚠From Double - Returns
- FRENew
Object ⚠From Int32 - Returns
- FRENew
Object ⚠FromUT F8 - Creates a new
Stringobject that contains a copy of the specified string. - FRENew
Object ⚠From Uint32 - Returns
- FRERelease
Bitmap ⚠Data - Release data that has been acquired with an earlier call to
FREAcquireBitmapDataorFREAcquireBitmapData2 - FRERelease
Byte ⚠Array - Returns
- FRERelease
Native ⚠Window Handle - Returns
- FRESet
Array ⚠Element At - Returns
- FRESet
Array ⚠Length - Returns
- FRESet
Context ⚠Action Script Data - Returns
- FRESet
Context ⚠Native Data - Returns
- FRESet
Object ⚠Property - Parameters
- FRESet
Render ⚠Source - Sets a
MediaBufferobject as the rendering source for aDisplayObject. - FRETrace⚠
- Outputs a trace to the AS3 debugger.
Type Aliases§
- FREBoolean
- 32-bit integer representation of an ActionScript
Boolean. - FREBytes
- Pointer to a byte buffer.
- FREContext
- Handle to an extension context managed by the runtime.
- FREContext
Finalizer - Defines the signature for the finalizer that is called each time
an
ExtensionContextinstance is disposed. - FREContext
Initializer - Defines the signature for the initializer that is called each time a new AS3
ExtensionContextobject is created. - FREData
- Handle to user-defined data owned and managed by extensions.
- FREFinalizer
- Called iff the extension is unloaded from the process. Extensions are not guaranteed to be unloaded; the runtime process may exit without doing so.
- FREFunction
- Defines the signature for native calls that can be invoked via an instance
of the AS3
ExtensionContextclass. - FREHandle
- Opaque pointer to an unspecified data type.
- FREInitializer
- The initialization function provided by each extension must conform to the following signature.
- FRENative
Window - Handle to a native window; the underlying type is platform-specific.
- FREObject
- Handle to an AS3 object.
- FREStr
- Borrowed pointer to UTF-8 string.