static RclCppDotnetDelegates() { dllLoadUtils = DllLoadUtilsFactory.GetDllLoadUtils(); IntPtr pDll = dllLoadUtils.LoadLibrary("rclcppdotnet"); IntPtr native_rclcpp_init_ptr = dllLoadUtils.GetProcAddress(pDll, "native_rclcpp_init"); RclCppDotnetDelegates.native_rclcpp_init = (NativeRclcppInitType)Marshal.GetDelegateForFunctionPointer( native_rclcpp_init_ptr, typeof(NativeRclcppInitType)); IntPtr native_rclcpp_shutdown_ptr = dllLoadUtils.GetProcAddress(pDll, "native_rclcpp_shutdown"); RclCppDotnetDelegates.native_rclcpp_shutdown = (NativeRclcppShutdownType)Marshal.GetDelegateForFunctionPointer( native_rclcpp_shutdown_ptr, typeof(NativeRclcppShutdownType)); }
public static T LoadFunction <T>(string name, DllLoadUtils utils, IntPtr handle) where T : class { IntPtr address = utils.GetProcAddress(handle, name); System.Delegate fn_ptr = Marshal.GetDelegateForFunctionPointer(address, typeof(T)); return(fn_ptr as T); }
public Delegate Invoke(string funcName, Type type) { var functionHandle = dllLoadUtils.GetProcAddress(dllHandle, funcName); var method = Marshal.GetDelegateForFunctionPointer(functionHandle, type); return(method); }
static PublisherDelegates() { dllLoadUtils = DllLoadUtilsFactory.GetDllLoadUtils(); IntPtr nativelibrary = dllLoadUtils.LoadLibrary("rcldotnet_publisher"); IntPtr native_rcl_publish_ptr = dllLoadUtils.GetProcAddress(nativelibrary, "native_rcl_publish"); PublisherDelegates.native_rcl_publish = (NativeRCLPublishType)Marshal.GetDelegateForFunctionPointer( native_rcl_publish_ptr, typeof(NativeRCLPublishType)); }
static NodeDelegates() { dllLoadUtils = DllLoadUtilsFactory.GetDllLoadUtils(); IntPtr nativelibrary = dllLoadUtils.LoadLibrary("rcldotnet_node"); IntPtr native_rcl_create_publisher_handle_ptr = dllLoadUtils.GetProcAddress( nativelibrary, "native_rcl_create_publisher_handle"); NodeDelegates.native_rcl_create_publisher_handle = (NativeRCLCreatePublisherHandleType)Marshal.GetDelegateForFunctionPointer( native_rcl_create_publisher_handle_ptr, typeof(NativeRCLCreatePublisherHandleType)); IntPtr native_rcl_create_subscription_handle_ptr = dllLoadUtils.GetProcAddress( nativelibrary, "native_rcl_create_subscription_handle"); NodeDelegates.native_rcl_create_subscription_handle = (NativeRCLCreateSubscriptionHandleType)Marshal.GetDelegateForFunctionPointer( native_rcl_create_subscription_handle_ptr, typeof(NativeRCLCreateSubscriptionHandleType)); }
static TransformListenerDelegates() { dllLoadUtils = DllLoadUtilsFactory.GetDllLoadUtils(); IntPtr nativeLibTFL = dllLoadUtils.LoadLibrary("transform_listener"); IntPtr native_construct_buffer_ptr = dllLoadUtils.GetProcAddress(nativeLibTFL, "native_construct_buffer"); TransformListenerDelegates.native_construct_buffer = (NativeConstructBufferType)Marshal.GetDelegateForFunctionPointer( native_construct_buffer_ptr, typeof(NativeConstructBufferType)); IntPtr native_delete_buffer_ptr = dllLoadUtils.GetProcAddress(nativeLibTFL, "native_delete_buffer"); TransformListenerDelegates.native_delete_buffer = (NativeDeleteBufferType)Marshal.GetDelegateForFunctionPointer( native_delete_buffer_ptr, typeof(NativeDeleteBufferType)); IntPtr native_construct_listener_ptr = dllLoadUtils.GetProcAddress(nativeLibTFL, "native_construct_listener"); TransformListenerDelegates.native_construct_listener = (NativeConstructListenerType)Marshal.GetDelegateForFunctionPointer( native_construct_listener_ptr, typeof(NativeConstructListenerType)); IntPtr native_delete_listener_ptr = dllLoadUtils.GetProcAddress(nativeLibTFL, "native_delete_listener"); TransformListenerDelegates.native_delete_listener = (NativeDeleteListenerType)Marshal.GetDelegateForFunctionPointer( native_delete_listener_ptr, typeof(NativeDeleteListenerType)); IntPtr native_construct_time_ptr = dllLoadUtils.GetProcAddress(nativeLibTFL, "native_construct_time"); TransformListenerDelegates.native_construct_time = (NativeConstructTimeType)Marshal.GetDelegateForFunctionPointer( native_construct_time_ptr, typeof(NativeConstructTimeType)); IntPtr native_lookup_transform_ptr = dllLoadUtils.GetProcAddress(nativeLibTFL, "native_lookup_transform"); TransformListenerDelegates.native_lookup_transform = (NativeLookupTransformType)Marshal.GetDelegateForFunctionPointer( native_lookup_transform_ptr, typeof(NativeLookupTransformType)); IntPtr native_retrieve_translation_ptr = dllLoadUtils.GetProcAddress(nativeLibTFL, "native_retrieve_translation"); TransformListenerDelegates.native_retrieve_translation = (NativeRetrieveTranslationType)Marshal.GetDelegateForFunctionPointer( native_retrieve_translation_ptr, typeof(NativeRetrieveTranslationType)); IntPtr native_retrieve_rotation_ptr = dllLoadUtils.GetProcAddress(nativeLibTFL, "native_retrieve_rotation"); TransformListenerDelegates.native_retrieve_rotation = (NativeRetrieveRotationType)Marshal.GetDelegateForFunctionPointer( native_retrieve_rotation_ptr, typeof(NativeRetrieveRotationType)); }
static RCLdotnetDelegates() { dllLoadUtils = DllLoadUtilsFactory.GetDllLoadUtils(); string library_name = "rcldotnet"; IntPtr pDll = dllLoadUtils.LoadLibrary(library_name); IntPtr native_rcl_init_ptr = dllLoadUtils.GetProcAddress(pDll, "native_rcl_init"); RCLdotnetDelegates.native_rcl_init = (NativeRCLInitType)Marshal.GetDelegateForFunctionPointer( native_rcl_init_ptr, typeof(NativeRCLInitType)); IntPtr native_rcl_get_rmw_identifier_ptr = dllLoadUtils.GetProcAddress(pDll, "native_rcl_get_rmw_identifier"); RCLdotnetDelegates.native_rcl_get_rmw_identifier = (NativeRCLGetRMWIdentifierType)Marshal.GetDelegateForFunctionPointer( native_rcl_get_rmw_identifier_ptr, typeof(NativeRCLGetRMWIdentifierType)); IntPtr native_rcl_ok_ptr = dllLoadUtils.GetProcAddress(pDll, "native_rcl_ok"); RCLdotnetDelegates.native_rcl_ok = (NativeRCLOkType)Marshal.GetDelegateForFunctionPointer( native_rcl_ok_ptr, typeof(NativeRCLOkType)); IntPtr native_rcl_create_node_handle_ptr = dllLoadUtils.GetProcAddress(pDll, "native_rcl_create_node_handle"); RCLdotnetDelegates.native_rcl_create_node_handle = (NativeRCLCreateNodeHandleType)Marshal.GetDelegateForFunctionPointer( native_rcl_create_node_handle_ptr, typeof(NativeRCLCreateNodeHandleType)); IntPtr native_rcl_get_zero_initialized_wait_set_ptr = dllLoadUtils.GetProcAddress(pDll, "native_rcl_get_zero_initialized_wait_set"); RCLdotnetDelegates.native_rcl_get_zero_initialized_wait_set = (NativeRCLGetZeroInitializedWaitSetType)Marshal.GetDelegateForFunctionPointer( native_rcl_get_zero_initialized_wait_set_ptr, typeof(NativeRCLGetZeroInitializedWaitSetType)); IntPtr native_rcl_wait_set_init_ptr = dllLoadUtils.GetProcAddress(pDll, "native_rcl_wait_set_init"); RCLdotnetDelegates.native_rcl_wait_set_init = (NativeRCLWaitSetInitType)Marshal.GetDelegateForFunctionPointer( native_rcl_wait_set_init_ptr, typeof(NativeRCLWaitSetInitType)); IntPtr native_rcl_wait_set_clear_ptr = dllLoadUtils.GetProcAddress(pDll, "native_rcl_wait_set_clear"); RCLdotnetDelegates.native_rcl_wait_set_clear = (NativeRCLWaitSetClearType)Marshal.GetDelegateForFunctionPointer( native_rcl_wait_set_clear_ptr, typeof(NativeRCLWaitSetClearType)); IntPtr native_rcl_wait_set_add_subscription_ptr = dllLoadUtils.GetProcAddress(pDll, "native_rcl_wait_set_add_subscription"); RCLdotnetDelegates.native_rcl_wait_set_add_subscription = (NativeRCLWaitSetAddSubscriptionType)Marshal.GetDelegateForFunctionPointer( native_rcl_wait_set_add_subscription_ptr, typeof(NativeRCLWaitSetAddSubscriptionType)); IntPtr native_rcl_destroy_wait_set_ptr = dllLoadUtils.GetProcAddress(pDll, "native_rcl_destroy_wait_set"); RCLdotnetDelegates.native_rcl_destroy_wait_set = (NativeRCLDestroyWaitSetType)Marshal.GetDelegateForFunctionPointer( native_rcl_destroy_wait_set_ptr, typeof(NativeRCLDestroyWaitSetType)); IntPtr native_rcl_wait_ptr = dllLoadUtils.GetProcAddress(pDll, "native_rcl_wait"); RCLdotnetDelegates.native_rcl_wait = (NativeRCLWaitType)Marshal.GetDelegateForFunctionPointer( native_rcl_wait_ptr, typeof(NativeRCLWaitType) ); IntPtr native_rcl_take_ptr = dllLoadUtils.GetProcAddress(pDll, "native_rcl_take"); RCLdotnetDelegates.native_rcl_take = (NativeRCLTakeType)Marshal.GetDelegateForFunctionPointer( native_rcl_take_ptr, typeof(NativeRCLTakeType)); }