@@ -1114,7 +1114,7 @@ msgstr ""
11141114
11151115#: ../../library/ctypes.rst:1053
11161116msgid "Accessing values exported from dlls"
1117- msgstr "访问 dll 中导出的值 "
1117+ msgstr "访问 dll 的导出变量 "
11181118
11191119#: ../../library/ctypes.rst:1055
11201120msgid ""
@@ -1123,30 +1123,37 @@ msgid ""
11231123"an integer set to 0, 1, or 2, depending on the :option:`-O` or :option:`-OO`"
11241124" flag given on startup."
11251125msgstr ""
1126+ "一些动态链接库不仅仅导出函数,也会导出变量。一个例子就是 Python 库本身的 :c:data:`Py_OptimizeFlag` ,根据启动选项 "
1127+ ":option:`-O` 、 :option:`-OO` 的不同,它是值可能为 0、1、2 的整型。"
11261128
11271129#: ../../library/ctypes.rst:1060
11281130msgid ""
11291131":mod:`ctypes` can access values like this with the :meth:`in_dll` class "
11301132"methods of the type. *pythonapi* is a predefined symbol giving access to "
11311133"the Python C api::"
11321134msgstr ""
1135+ ":mod:`ctypes` 可以通过 :meth:`in_dll` 类方法访问这类变量 。 *pythonapi* 是用于访问 Python C "
1136+ "接口的预定义符号::"
11331137
11341138#: ../../library/ctypes.rst:1069
11351139msgid ""
11361140"If the interpreter would have been started with :option:`-O`, the sample "
11371141"would have printed ``c_long(1)``, or ``c_long(2)`` if :option:`-OO` would "
11381142"have been specified."
11391143msgstr ""
1144+ "如果解释器使用 :option:`-O` 选项启动,这个例子会打印 ``c_long(1)`` , 如果使用 :option:`-OO` 启动,则会打印"
1145+ " ``c_long(2)`` 。"
11401146
11411147#: ../../library/ctypes.rst:1073
11421148msgid ""
11431149"An extended example which also demonstrates the use of pointers accesses the"
11441150" :c:data:`PyImport_FrozenModules` pointer exported by Python."
11451151msgstr ""
1152+ "一个扩展例子, 同时也展示了使用指针访问 Python 导出的 :c:data:`PyImport_FrozenModules` 指针对象。"
11461153
11471154#: ../../library/ctypes.rst:1076
11481155msgid "Quoting the docs for that value:"
1149- msgstr ""
1156+ msgstr "对文档中这个值的解释说明 "
11501157
11511158#: ../../library/ctypes.rst:1078
11521159msgid ""
@@ -1156,18 +1163,20 @@ msgid ""
11561163"could play tricks with this to provide a dynamically created collection of "
11571164"frozen modules."
11581165msgstr ""
1166+ "该指针被初始化为指向 :c:type:`struct _frozen` 数组,以 ``NULL`` 或者 0 "
1167+ "作为结束标记。当一个冻结模块被导入,首先要在这个表中搜索。第三方库可以以此来提供动态创建的冻结模块集合。"
11591168
11601169#: ../../library/ctypes.rst:1083
11611170msgid ""
11621171"So manipulating this pointer could even prove useful. To restrict the "
11631172"example size, we show only how this table can be read with :mod:`ctypes`::"
1164- msgstr ""
1173+ msgstr "这足以证明修改这个指针是很有用的。为了让实例大小不至于太长,这里只展示如何使用 :mod:`ctypes` 读取这个表:: "
11651174
11661175#: ../../library/ctypes.rst:1095
11671176msgid ""
11681177"We have defined the :c:type:`struct _frozen` data type, so we can get the "
11691178"pointer to the table::"
1170- msgstr ""
1179+ msgstr "我们定义了 :c:type:`struct _frozen` 数据类型,接着就可以获取这张表的指针了:: "
11711180
11721181#: ../../library/ctypes.rst:1102
11731182msgid ""
@@ -1177,13 +1186,18 @@ msgid ""
11771186" crash with an access violation or whatever, so it's better to break out of "
11781187"the loop when we hit the ``NULL`` entry::"
11791188msgstr ""
1189+ "由于 ``table`` 是指向 ``struct_frozen`` 数组的 ``指针`` "
1190+ ",我们可以遍历它,只不过需要自己判断循环是否结束,因为指针本身并不包含长度。它早晚会因为访问到野指针或者什么的把自己搞崩溃,所以我们最好在遇到 "
1191+ "``NULL`` 后就让它退出循环::"
11801192
11811193#: ../../library/ctypes.rst:1120
11821194msgid ""
11831195"The fact that standard Python has a frozen module and a frozen package "
11841196"(indicated by the negative ``size`` member) is not well known, it is only "
11851197"used for testing. Try it out with ``import __hello__`` for example."
11861198msgstr ""
1199+ "Python 的冻结模块和冻结包(由负 ``size`` 成员表示)并不是广为人知的事情,它们仅仅用于实验。例如,可以使用 ``import "
1200+ "__hello__`` 尝试一下这个功能。"
11871201
11881202#: ../../library/ctypes.rst:1128
11891203msgid "Surprises"
0 commit comments