aes_externalobj 0.1.2

ExtendScript external object library implementation in Rust
Documentation
#![allow(warnings)]
#![allow(non_snake_case)]
use std::ffi::{c_void, c_char, c_long};
pub use aes_types::{TaggedData,TaggedDataUnion};


pub type SoHServer = *mut c_long;
pub type SoHObject = *mut c_long;
pub type ESerror_t = c_long;



pub type SoObjectInitialize_f = unsafe extern "C" fn(hObject: SoHObject, argc: i32, argv: *mut TaggedData) -> ESerror_t;
pub type SoObjectGet_f = unsafe extern "C" fn(hObject: SoHObject, name: *mut SoCClientName, pValue: *mut TaggedData) -> ESerror_t;
pub type SoObjectPut_f = unsafe extern "C" fn(hObject: SoHObject, name: *mut SoCClientName, pValue: *mut TaggedData) -> ESerror_t;
pub type SoObjectCall_f = unsafe extern "C" fn(hObject: SoHObject, name: *mut SoCClientName, argc: i32, argv: *mut TaggedData, pResult: *mut TaggedData) -> ESerror_t;
pub type SoObjectValueOf_f = unsafe extern "C" fn(hObject: SoHObject, pResult: *mut TaggedData) -> ESerror_t;
pub type SoObjectToString_f = unsafe extern "C" fn(hObject: SoHObject, pResult: *mut TaggedData) -> ESerror_t;
pub type SoObjectFinalize_f = unsafe extern "C" fn(hObject: SoHObject) -> ESerror_t;

pub type SoMemoryMalloc_f = unsafe extern "C" fn(size: usize) -> *mut c_void;
pub type SoMemoryFree_f = unsafe extern "C" fn(ptr: *mut c_void);

 
 

// Structures from SoCClient.h
#[repr(C)]
#[repr(align(8))]
#[derive(Copy, Clone)]
pub struct SoCClientName {
    pub name_sig: *const c_char,
    pub id: i32,
    pub desc: *mut c_char,
}

#[repr(C)]
#[repr(align(8))]
#[derive(Copy, Clone)]
pub struct SoMemoryInterface {
    pub malloc: SoMemoryMalloc_f,
    pub free: SoMemoryFree_f,
}

#[repr(C)]
#[repr(align(8))]
#[derive(Copy, Clone)]
pub struct SoObjectInterface {
    pub initialize: SoObjectInitialize_f,
    pub put: SoObjectPut_f,
    pub get: SoObjectGet_f,
    pub call: SoObjectCall_f,
    pub valueOf: SoObjectValueOf_f,
    pub toString: SoObjectToString_f,
    pub finalize: SoObjectFinalize_f,
}

#[repr(C)]
#[repr(align(8))]
#[derive(Copy, Clone)]
pub struct SoServerInterface {
    pub dumpServer: SoServerDumpServer_f,
    pub dumpObject: SoServerDumpObject_f,
    pub addClass: SoServerAddClass_f,
    pub addMethod: SoServerAddMethod_f,
    pub addMethods: SoServerAddMethods_f,
    pub addProperty: SoServerAddProperty_f,
    pub addProperties: SoServerAddProperties_f,
    pub getClass: SoServerGetClass_f,
    pub getServer: SoServerGetServer_f,
    pub setClientData: SoServerSetClientData_f,
    pub getClientData: SoServerGetClientData_f,
    pub eval: SoServerEval_f,
    pub taggedDataInit: SoServerTaggedDataInit_f,
    pub taggedDataFree: SoServerTaggedDataFree_f,
    pub callLiveObject: SoServerCallLiveObject_f,
    pub getLiveObject: SoServerGetLiveObject_f,
    pub putLiveObject: SoServerPutLiveObject_f,
}

// Function type definitions
/**
You may call this interface to communicate with ExtendScript

@param	SoServerDumpServer_f		Dump the server to stdout (debugging function)
@param	SoServerDumpObject_f		Dump the object to stdout (debugging function)
@param	SoServerAddClass_f			Add a new Class of ExtendScript Objects
@param	SoServerAddMethod_f			Add a method to an object instance
@param	SoServerAddMethods_f		Add methods to an object instance
@param	SoServerAddProperty_f		Add a property to an object instance
@param	SoServerAddProperties_f		Add properties to an object instance
@param	SoServerGetClass_f			Object the class of a live object
@param	SoServerGetServer_f			Object the Server for a live object
@param	SoServerSetClientData_f		Set data in an object instance
@param	SoServerGetClientData_f		Get data from an object instance
@param	SoServerEval_f				Call the JavaScript interpreter
@param	SoServerTaggedDataInit_f	Initialize tagged data
@param  SoServerTaggedDataFree_f	Free tagged data

@param  SoServerCallLiveObject_f	Call a live object
@param  SoServerGetLiveObject_f		Get a live object property
@param  SoServerPutLiveObject_f		Set a live object property
*/
pub type SoServerDumpServer_f = unsafe extern "C" fn(hServer: SoHServer) -> ESerror_t;
pub type SoServerDumpObject_f = unsafe extern "C" fn(hObject: SoHObject) -> ESerror_t;
pub type SoServerAddClass_f = unsafe extern "C" fn(hServer: SoHServer, name: *mut c_char, objectInterface: *mut SoObjectInterface) -> ESerror_t;
pub type SoServerAddMethod_f = unsafe extern "C" fn(hObject: SoHObject, name: *const c_char, id: i32, desc: *mut c_char) -> ESerror_t;
pub type SoServerAddMethods_f = unsafe extern "C" fn(hObject: SoHObject, pNames: *mut SoCClientName) -> ESerror_t;
pub type SoServerAddProperty_f = unsafe extern "C" fn(hObject: SoHObject, name: *const c_char, id: i32, desc: *mut c_char) -> ESerror_t;
pub type SoServerAddProperties_f = unsafe extern "C" fn(hObject: SoHObject, pNames: *mut SoCClientName) -> ESerror_t;
pub type SoServerGetClass_f = unsafe extern "C" fn(hObject: SoHObject, name: *mut c_char, name_l: i32) -> ESerror_t;
pub type SoServerGetServer_f = unsafe extern "C" fn(hObject: SoHObject, phServer: *mut SoHServer, ppServerInterface: *mut *mut SoServerInterface) -> ESerror_t;
pub type SoServerSetClientData_f = unsafe extern "C" fn(hObject: SoHObject, pClientData: *mut c_void) -> ESerror_t;
pub type SoServerGetClientData_f = unsafe extern "C" fn(hObject: SoHObject, ppClientData: *mut *mut c_void) -> ESerror_t;
pub type SoServerEval_f = unsafe extern "C" fn(hServer: SoHServer, string: *mut c_char, pTaggedData: *mut TaggedData) -> ESerror_t;
pub type SoServerTaggedDataInit_f = unsafe extern "C" fn(hServer: SoHServer, pTaggedData: *mut TaggedData) -> ESerror_t;
pub type SoServerTaggedDataFree_f = unsafe extern "C" fn(hServer: SoHServer, pTaggedData: *mut TaggedData) -> ESerror_t;
pub type SoServerCallLiveObject_f = unsafe extern "C" fn(hServer: SoHServer, hObject: SoHObject, method: *mut c_char, argc: i32, argv: *mut TaggedData, pResult: *mut TaggedData) -> ESerror_t;
pub type SoServerGetLiveObject_f = unsafe extern "C" fn(hServer: SoHServer, hObject: SoHObject, method: *mut c_char, pResult: *mut TaggedData) -> ESerror_t;
pub type SoServerPutLiveObject_f = unsafe extern "C" fn(hServer: SoHServer, hObject: SoHObject, method: *mut c_char, pValue: *mut TaggedData) -> ESerror_t;

// Client interface types
pub type SoCClient_f = unsafe extern "C" fn(
    eReason: SoCClient_e,
    pServer: *mut SoServerInterface,
    hServer: SoHServer,
) -> ESerror_t;

#[repr(C)]
#[derive(Copy, Clone, Debug)]
pub enum SoCClient_e {
    Init = 0,
    Term = 1,
}

// External function declarations that need to be implemented
extern "C" {
    pub fn SoCClientInitialize(client: SoCClient_f, memory: *mut SoMemoryInterface) -> ESerror_t;
    pub fn SoCClientTerminate(client: SoCClient_f) -> ESerror_t;
    pub fn SoCClientTerminateAll() -> ESerror_t;
}