@@ -578,13 +578,13 @@ msgstr ""
578578msgid ""
579579"On those platforms it is required to specify the :attr:`~_FuncPtr.argtypes` "
580580"attribute for the regular, non-variadic, function arguments:"
581- msgstr ""
581+ msgstr "在这些平台上要求为常规、非可变函数参数指定 :attr:`~_FuncPtr.argtypes` 属性: "
582582
583583#: ../../library/ctypes.rst:394
584584msgid ""
585585"Because specifying the attribute does not inhibit portability it is advised "
586586"to always specify :attr:`~_FuncPtr.argtypes` for all variadic functions."
587- msgstr ""
587+ msgstr "因为指定该属性不会影响可移植性所以建议总是为所有可变函数指定 :attr:`~_FuncPtr.argtypes`。 "
588588
589589#: ../../library/ctypes.rst:401
590590msgid "Calling functions with your own custom data types"
@@ -598,13 +598,18 @@ msgid ""
598598" The attribute must be an integer, string, bytes, a :mod:`ctypes` instance, "
599599"or an object with an :attr:`!_as_parameter_` attribute::"
600600msgstr ""
601+ "您也可以通过自定义 :mod:`ctypes` 参数转换方式来允许将你自己的类实例作为函数参数。 :mod:`ctypes` 会寻找 "
602+ ":attr:`!_as_parameter_` 属性并使用它作为函数参数。 属性必须是整数、字符串、字节串、:mod:`ctypes` 实例或者带有 "
603+ ":attr:`!_as_parameter_` 属性的对象::"
601604
602605#: ../../library/ctypes.rst:419
603606msgid ""
604607"If you don't want to store the instance's data in the "
605608":attr:`!_as_parameter_` instance variable, you could define a "
606609":class:`property` which makes the attribute available on request."
607610msgstr ""
611+ "如果你不想将实例数据存储在 :attr:`!_as_parameter_` 实例变量中,可以定义一个根据请求提供属性的 "
612+ ":class:`property`。"
608613
609614#: ../../library/ctypes.rst:427
610615msgid "Specifying the required argument types (function prototypes)"
@@ -614,7 +619,7 @@ msgstr "指定必选参数的类型(函数原型)"
614619msgid ""
615620"It is possible to specify the required argument types of functions exported "
616621"from DLLs by setting the :attr:`~_FuncPtr.argtypes` attribute."
617- msgstr ""
622+ msgstr "可以通过设置 :attr:`~_FuncPtr.argtypes` 属性来指定从 DLL 导出函数的必选参数类型。 "
618623
619624#: ../../library/ctypes.rst:432
620625msgid ""
@@ -624,6 +629,8 @@ msgid ""
624629"format string, on the other hand this is quite handy to experiment with this"
625630" feature)::"
626631msgstr ""
632+ ":attr:`~_FuncPtr.argtypes` 必须是一个 C 数据类型的序列(这里 :func:`!printf` "
633+ "函数可能不是一个好例子,因为它会根据格式字符串的不同接受可变数量和不同类型的形参,但另一方面这对尝试此功能来说也很方便)::"
627634
628635#: ../../library/ctypes.rst:443
629636msgid ""
@@ -645,6 +652,11 @@ msgid ""
645652"string, bytes, a :mod:`ctypes` instance, or an object with an "
646653":attr:`!_as_parameter_` attribute."
647654msgstr ""
655+ "如果你定义了自己的类并将其传递给函数调用,则你必须为它们实现 :meth:`~_CData.from_param` 类方法才能够在 "
656+ ":attr:`~_FuncPtr.argtypes` 序列中使用它们。 :meth:`~_CData.from_param` "
657+ "类方法将接受传递给函数调用的 Python 对象,它应该进行类型检查或者其他必要的操作以确保这个对象是可接受的,然后返回对象本身、它的 "
658+ ":attr:`!_as_parameter_` 属性或在此情况下作为 C 函数参数传入的任何东西。 "
659+ "同样,结果应该是整数、字符串、字节串、:mod:`ctypes` 实例或具有 :attr:`!_as_parameter_` 属性的对象。"
648660
649661#: ../../library/ctypes.rst:469
650662msgid "Return types"
@@ -664,10 +676,12 @@ msgid ""
664676":c:type:`time_t` might be of a different type than the default return type "
665677":c:expr:`int`, you should specify the :attr:`!restype` attribute::"
666678msgstr ""
679+ ":c:func:`time` 的 C 原型是 ``time_t time(time_t *)``。 由于 :c:type:`time_t` "
680+ "的类型可能不同于默认返回类型 :c:expr:`int`,你应当指定 :attr:`!restype` 属性::"
667681
668682#: ../../library/ctypes.rst:489
669683msgid "The argument types can be specified using :attr:`~_FuncPtr.argtypes`::"
670- msgstr ""
684+ msgstr "参数类型可以使用 :attr:`~_FuncPtr.argtypes` 来指定:: "
671685
672686#: ../../library/ctypes.rst:493
673687msgid ""
@@ -679,14 +693,16 @@ msgstr "调用该函数时如果要将 ``NULL`` 指针作为第一个参数,
679693msgid ""
680694"Here is a more advanced example, it uses the :func:`strchr` function, which "
681695"expects a string pointer and a char, and returns a pointer to a string::"
682- msgstr ""
696+ msgstr "下面是一个更高级的示例,它使用了 :func:`strchr` 函数,该函数接收一个字符串指针和一个字符,并返回一个字符串指针:: "
683697
684698#: ../../library/ctypes.rst:511
685699msgid ""
686700"If you want to avoid the :func:`ord(\" x\" ) <ord>` calls above, you can set "
687701"the :attr:`~_FuncPtr.argtypes` attribute, and the second argument will be "
688702"converted from a single character Python bytes object into a C char:"
689703msgstr ""
704+ "如果你想要避免上面的 :func:`ord(\" x\" ) <ord>` 调用,你可以设置 :attr:`~_FuncPtr.argtypes` "
705+ "属性,第二个参数将从单字符 Python 字节串对象转换为 C char:"
690706
691707#: ../../library/ctypes.rst:530
692708msgid ""
0 commit comments