예제 #1
0
    def from_string(string):
        """
        Build a Object for a Python string object.
        """

        py_from_string = \
            Function.named(
                "PyString_FromString",
                object_ptr_type,
                [llvm.Type.pointer(llvm.Type.int(8))],
                )

        return Object(py_from_string(qy.string_literal(string))._value)
예제 #2
0
    def get(self, name):
        """
        Get an attribute.
        """

        object_ptr_type = qy.object_ptr_type

        get_attr = \
            Function.named(
                "PyObject_GetAttrString",
                object_ptr_type,
                [object_ptr_type, llvm.Type.pointer(llvm.Type.int(8))],
                )

        result = get_attr(self, qy.string_literal(name))

        qy.py_check_null(result)

        return Object(result._value)