(
event_attributes: PyObjectRef,
manual_reset: bool,
initial_state: bool,
name: Option<String>,
vm: &VirtualMachine,
)
| 1937 | |
| 1938 | #[pyfunction] |
| 1939 | fn CreateEvent( |
| 1940 | event_attributes: PyObjectRef, |
| 1941 | manual_reset: bool, |
| 1942 | initial_state: bool, |
| 1943 | name: Option<String>, |
| 1944 | vm: &VirtualMachine, |
| 1945 | ) -> PyResult<isize> { |
| 1946 | if !vm.is_none(&event_attributes) { |
| 1947 | return Err(vm.new_value_error("EventAttributes must be None")); |
| 1948 | } |
| 1949 | |
| 1950 | let name_wide: Option<Vec<u16>> = |
| 1951 | name.map(|n| n.encode_utf16().chain(core::iter::once(0)).collect()); |
| 1952 | let name_ptr = name_wide |
| 1953 | .as_ref() |
| 1954 | .map(|n| n.as_ptr()) |
| 1955 | .unwrap_or(core::ptr::null()); |
| 1956 | |
| 1957 | let event = unsafe { |
| 1958 | windows_sys::Win32::System::Threading::CreateEventW( |
| 1959 | core::ptr::null(), |
| 1960 | if manual_reset { 1 } else { 0 }, |
| 1961 | if initial_state { 1 } else { 0 }, |
| 1962 | name_ptr, |
| 1963 | ) as isize |
| 1964 | }; |
| 1965 | if event == NULL { |
| 1966 | return Err(set_from_windows_err(0, vm)); |
| 1967 | } |
| 1968 | Ok(event) |
| 1969 | } |
| 1970 | |
| 1971 | #[pyfunction] |
| 1972 | fn SetEvent(handle: isize, vm: &VirtualMachine) -> PyResult<()> { |
nothing calls this directly
no test coverage detected