11#![ allow( non_snake_case) ]
22
3+ #[ pymodule]
4+ mod _winapi {
5+ #[ pyattr]
6+ use winapi:: {
7+ shared:: winerror:: WAIT_TIMEOUT ,
8+ um:: {
9+ winbase:: {
10+ ABOVE_NORMAL_PRIORITY_CLASS , BELOW_NORMAL_PRIORITY_CLASS ,
11+ CREATE_BREAKAWAY_FROM_JOB , CREATE_DEFAULT_ERROR_MODE , CREATE_NEW_CONSOLE ,
12+ CREATE_NEW_PROCESS_GROUP , CREATE_NO_WINDOW , DETACHED_PROCESS , FILE_TYPE_CHAR ,
13+ FILE_TYPE_DISK , FILE_TYPE_PIPE , FILE_TYPE_REMOTE , FILE_TYPE_UNKNOWN ,
14+ HIGH_PRIORITY_CLASS , IDLE_PRIORITY_CLASS , INFINITE , NORMAL_PRIORITY_CLASS ,
15+ REALTIME_PRIORITY_CLASS , STARTF_USESHOWWINDOW , STARTF_USESTDHANDLES ,
16+ STD_ERROR_HANDLE , STD_INPUT_HANDLE , STD_OUTPUT_HANDLE , WAIT_ABANDONED ,
17+ WAIT_ABANDONED_0 , WAIT_OBJECT_0 ,
18+ } ,
19+ winnt:: DUPLICATE_SAME_ACCESS ,
20+ winuser:: SW_HIDE ,
21+ } ,
22+ } ;
23+ }
24+
325use super :: os:: errno_err;
426use crate :: {
527 builtins:: { PyListRef , PyStrRef } ,
@@ -10,8 +32,8 @@ use crate::{
1032use std:: ptr:: { null, null_mut} ;
1133use winapi:: shared:: winerror;
1234use winapi:: um:: {
13- fileapi, handleapi, namedpipeapi, processenv, processthreadsapi, synchapi, winbase, winnt ,
14- winnt:: HANDLE , winuser ,
35+ fileapi, handleapi, namedpipeapi, processenv, processthreadsapi, synchapi, winbase,
36+ winnt:: HANDLE ,
1537} ;
1638
1739fn GetLastError ( ) -> u32 {
@@ -354,8 +376,9 @@ fn _winapi_TerminateProcess(h: usize, exit_code: u32, vm: &VirtualMachine) -> Py
354376}
355377
356378pub fn make_module ( vm : & VirtualMachine ) -> PyObjectRef {
379+ let module = _winapi:: make_module ( vm) ;
357380 let ctx = & vm. ctx ;
358- py_module ! ( vm, "_winapi" , {
381+ extend_module ! ( vm, module , {
359382 "CloseHandle" => named_function!( ctx, _winapi, CloseHandle ) ,
360383 "GetStdHandle" => named_function!( ctx, _winapi, GetStdHandle ) ,
361384 "CreatePipe" => named_function!( ctx, _winapi, CreatePipe ) ,
@@ -365,35 +388,6 @@ pub fn make_module(vm: &VirtualMachine) -> PyObjectRef {
365388 "WaitForSingleObject" => named_function!( ctx, _winapi, WaitForSingleObject ) ,
366389 "GetExitCodeProcess" => named_function!( ctx, _winapi, GetExitCodeProcess ) ,
367390 "TerminateProcess" => named_function!( ctx, _winapi, TerminateProcess ) ,
368-
369- "WAIT_OBJECT_0" => ctx. new_int( winbase:: WAIT_OBJECT_0 ) ,
370- "WAIT_ABANDONED" => ctx. new_int( winbase:: WAIT_ABANDONED ) ,
371- "WAIT_ABANDONED_0" => ctx. new_int( winbase:: WAIT_ABANDONED_0 ) ,
372- "WAIT_TIMEOUT" => ctx. new_int( winerror:: WAIT_TIMEOUT ) ,
373- "INFINITE" => ctx. new_int( winbase:: INFINITE ) ,
374- "CREATE_NEW_CONSOLE" => ctx. new_int( winbase:: CREATE_NEW_CONSOLE ) ,
375- "CREATE_NEW_PROCESS_GROUP" => ctx. new_int( winbase:: CREATE_NEW_PROCESS_GROUP ) ,
376- "STD_INPUT_HANDLE" => ctx. new_int( winbase:: STD_INPUT_HANDLE ) ,
377- "STD_OUTPUT_HANDLE" => ctx. new_int( winbase:: STD_OUTPUT_HANDLE ) ,
378- "STD_ERROR_HANDLE" => ctx. new_int( winbase:: STD_ERROR_HANDLE ) ,
379- "SW_HIDE" => ctx. new_int( winuser:: SW_HIDE ) ,
380- "STARTF_USESTDHANDLES" => ctx. new_int( winbase:: STARTF_USESTDHANDLES ) ,
381- "STARTF_USESHOWWINDOW" => ctx. new_int( winbase:: STARTF_USESHOWWINDOW ) ,
382- "ABOVE_NORMAL_PRIORITY_CLASS" => ctx. new_int( winbase:: ABOVE_NORMAL_PRIORITY_CLASS ) ,
383- "BELOW_NORMAL_PRIORITY_CLASS" => ctx. new_int( winbase:: BELOW_NORMAL_PRIORITY_CLASS ) ,
384- "HIGH_PRIORITY_CLASS" => ctx. new_int( winbase:: HIGH_PRIORITY_CLASS ) ,
385- "IDLE_PRIORITY_CLASS" => ctx. new_int( winbase:: IDLE_PRIORITY_CLASS ) ,
386- "NORMAL_PRIORITY_CLASS" => ctx. new_int( winbase:: NORMAL_PRIORITY_CLASS ) ,
387- "REALTIME_PRIORITY_CLASS" => ctx. new_int( winbase:: REALTIME_PRIORITY_CLASS ) ,
388- "CREATE_NO_WINDOW" => ctx. new_int( winbase:: CREATE_NO_WINDOW ) ,
389- "DETACHED_PROCESS" => ctx. new_int( winbase:: DETACHED_PROCESS ) ,
390- "CREATE_DEFAULT_ERROR_MODE" => ctx. new_int( winbase:: CREATE_DEFAULT_ERROR_MODE ) ,
391- "CREATE_BREAKAWAY_FROM_JOB" => ctx. new_int( winbase:: CREATE_BREAKAWAY_FROM_JOB ) ,
392- "DUPLICATE_SAME_ACCESS" => ctx. new_int( winnt:: DUPLICATE_SAME_ACCESS ) ,
393- "FILE_TYPE_CHAR" => ctx. new_int( winbase:: FILE_TYPE_CHAR ) ,
394- "FILE_TYPE_DISK" => ctx. new_int( winbase:: FILE_TYPE_DISK ) ,
395- "FILE_TYPE_PIPE" => ctx. new_int( winbase:: FILE_TYPE_PIPE ) ,
396- "FILE_TYPE_REMOTE" => ctx. new_int( winbase:: FILE_TYPE_REMOTE ) ,
397- "FILE_TYPE_UNKNOWN" => ctx. new_int( winbase:: FILE_TYPE_UNKNOWN ) ,
398- } )
391+ } ) ;
392+ module
399393}
0 commit comments