mirror of
https://github.com/hakril/PythonForWindows
synced 2026-06-08 14:31:45 +00:00
Add real doc for windows.generated_def
This commit is contained in:
@@ -206,11 +206,11 @@ class InitialDefGenerator(CtypesGenerator):
|
||||
def __getnewargs__(self, *args):
|
||||
return self.name, long(self)
|
||||
|
||||
class StrFlags(str):
|
||||
class StrFlag(str):
|
||||
def __new__(cls, name, value):
|
||||
if isinstance(value, cls):
|
||||
return value
|
||||
return super(StrFlags, cls).__new__(cls, value)
|
||||
return super(StrFlag, cls).__new__(cls, value)
|
||||
|
||||
def __init__(self, name, value):
|
||||
self.name = name
|
||||
@@ -227,8 +227,7 @@ class InitialDefGenerator(CtypesGenerator):
|
||||
def make_flag(name, value):
|
||||
if isinstance(value, (int, long)):
|
||||
return Flag(name, value)
|
||||
return StrFlags(name, value)
|
||||
|
||||
return StrFlag(name, value)
|
||||
|
||||
""")
|
||||
|
||||
@@ -350,9 +349,10 @@ class StructGenerator(CtypesGenerator):
|
||||
all_lines = [".. currentmodule:: windows.generated_def\n"
|
||||
"Winstructs\n"
|
||||
"----------\n"]
|
||||
struct_separator = "'"
|
||||
structs, enums = self.parse()
|
||||
for struct in structs:
|
||||
all_lines.append("{0}\n{1}\n".format(struct.name, "-" * len(struct.name)))
|
||||
all_lines.append("{0}\n{1}\n".format(struct.name, struct_separator * len(struct.name)))
|
||||
for name, type in struct.typedef.items():
|
||||
all_lines.append(".. class:: {0}\n\n".format(name))
|
||||
if hasattr(type, "type"):
|
||||
@@ -365,8 +365,9 @@ class StructGenerator(CtypesGenerator):
|
||||
array_str = " ``[{nb}]``".format(nb=nb) if nb > 1 else ""
|
||||
all_lines.append("\n .. attribute:: {0}\n\n :class:`{1}`{2}\n\n".format(fname, ftype.name, array_str))
|
||||
|
||||
all_lines += ["WinEnums\n--------\n"]
|
||||
for enum in enums:
|
||||
all_lines.append("{0}\n{1}\n".format(enum.name, "-" * len(enum.name)))
|
||||
all_lines.append("{0}\n{1}\n".format(enum.name, struct_separator * len(enum.name)))
|
||||
for name, type in enum.typedef.items():
|
||||
all_lines.append(".. class:: {0}\n\n".format(name))
|
||||
if hasattr(type, "type"):
|
||||
|
||||
@@ -365,3 +365,13 @@ epub_exclude_files = ['search.html']
|
||||
|
||||
# Example configuration for intersphinx: refer to the Python standard library.
|
||||
intersphinx_mapping = {'http://docs.python.org/': None}
|
||||
|
||||
|
||||
def get_rst(app, what, name, obj, options, lines):
|
||||
pass
|
||||
|
||||
def get_rst2(app, what, name, obj, options, signature, return_annotation):
|
||||
pass
|
||||
|
||||
def setup(app):
|
||||
pass
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
``windows.generated_def`` -- generated Windows defines and structures
|
||||
*********************************************************************
|
||||
|
||||
.. module:: windows.generated_def
|
||||
|
||||
:mod:`windows.generated_def` contains ``Python`` files generated by ``ctypes_generation``.
|
||||
|
||||
Those generated files includes:
|
||||
|
||||
- some Windows structures and enums
|
||||
- some Windows defines including some ``NTSTATUS``
|
||||
- some Windows function prototypes
|
||||
|
||||
|
||||
Each value in ``windef`` and ``ntstatus`` is a :class:`Flag` or a :class:`StrFlag`.
|
||||
|
||||
Here is every generated definition by type:
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
:numbered:
|
||||
|
||||
windef_generated.rst
|
||||
ntstatus_generated.rst
|
||||
winstructs_generated.rst
|
||||
|
||||
|
||||
|
||||
.. class:: Flag
|
||||
|
||||
A :class:`long` with a name
|
||||
|
||||
|
||||
.. class:: StrFlag
|
||||
|
||||
A :class:`str` with a name
|
||||
|
||||
|
||||
Example
|
||||
--------
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
>>> import windows.generated_def
|
||||
>>> import windows.generated_def as gdef
|
||||
>>> gdef
|
||||
<module 'windows.generated_def' from 'c:\users\hakril\documents\work\pythonforwindows\windows\generated_def\__init__.pyc'>
|
||||
|
||||
>>> gdef.PAGE_EXECUTE_READWRITE
|
||||
PAGE_EXECUTE_READWRITE(0x40L)
|
||||
|
||||
>>> gdef.PAGE_EXECUTE_READWRITE == 0x40
|
||||
True
|
||||
|
||||
>>> gdef.PAGE_EXECUTE_READWRITE + 1
|
||||
65L
|
||||
|
||||
>>> gdef.STATUS_ACCESS_VIOLATION
|
||||
STATUS_ACCESS_VIOLATION(0xc0000005L)
|
||||
|
||||
>>> gdef.LDR_DATA_TABLE_ENTRY
|
||||
<class 'windows.generated_def.winstructs._LDR_DATA_TABLE_ENTRY'>
|
||||
|
||||
>>> gdef.LDR_DATA_TABLE_ENTRY._fields_
|
||||
[('Reserved1', <class 'windows.generated_def.winstructs.c_void_p_Array_2'>), ...]
|
||||
|
||||
>>> gdef.MEMORY_INFORMATION_CLASS
|
||||
<class 'windows.generated_def.winstructs._MEMORY_INFORMATION_CLASS'>
|
||||
|
||||
>>> gdef.MEMORY_INFORMATION_CLASS.values
|
||||
[_MEMORY_INFORMATION_CLASS.MemoryBasicInformation(0x0L), _MEMORY_INFORMATION_CLASS.MemoryWorkingSetList(0x1L),
|
||||
_MEMORY_INFORMATION_CLASS.MemorySectionName(0x2L), _MEMORY_INFORMATION_CLASS.MemoryBasicVlmInformation(0x3L),
|
||||
_MEMORY_INFORMATION_CLASS.MemoryWorkingSetListEx(0x4L)]
|
||||
|
||||
>>> gdef.MemoryBasicInformation
|
||||
_MEMORY_INFORMATION_CLASS.MemoryBasicInformation(0x0L)
|
||||
@@ -22,12 +22,11 @@ Contents:
|
||||
com.rst
|
||||
crypto.rst
|
||||
alpc.rst
|
||||
generated.rst
|
||||
iat_hook.rst
|
||||
wip.rst
|
||||
internals.rst
|
||||
sample.rst
|
||||
windef.rst
|
||||
testing.rst
|
||||
|
||||
|
||||
Indices and tables
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
Test generated !
|
||||
****************
|
||||
|
||||
.. module:: windows.generated_def
|
||||
|
||||
List of flags definition in :mod:`windows.generated_def`.
|
||||
Each one inherit from :class:`long` but embded the name of the define and can be used in place of :class:`int`/:class:`long` for context.
|
||||
|
||||
|
||||
Contents:
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -27,11 +27,11 @@ class Flag(long):
|
||||
def __getnewargs__(self, *args):
|
||||
return self.name, long(self)
|
||||
|
||||
class StrFlags(str):
|
||||
class StrFlag(str):
|
||||
def __new__(cls, name, value):
|
||||
if isinstance(value, cls):
|
||||
return value
|
||||
return super(StrFlags, cls).__new__(cls, value)
|
||||
return super(StrFlag, cls).__new__(cls, value)
|
||||
|
||||
def __init__(self, name, value):
|
||||
self.name = name
|
||||
@@ -48,8 +48,7 @@ class StrFlags(str):
|
||||
def make_flag(name, value):
|
||||
if isinstance(value, (int, long)):
|
||||
return Flag(name, value)
|
||||
return StrFlags(name, value)
|
||||
|
||||
return StrFlag(name, value)
|
||||
|
||||
|
||||
from ntstatus import *
|
||||
|
||||
Reference in New Issue
Block a user