drop python27

This commit is contained in:
Nikolay Kim 2017-05-12 19:59:20 -07:00
parent ef5bd982bc
commit 3bb7a64db5
70 changed files with 0 additions and 5763 deletions

View File

@ -8,7 +8,6 @@ readme = "README.md"
keywords = [
"python",
"cpython",
"libpython27",
]
homepage = "https://github.com/dgrunwald/rust-cpython"
repository = "https://github.com/dgrunwald/rust-cpython.git"
@ -20,8 +19,6 @@ exclude = [
".travis.yml",
"appveyor.yml",
".cargo/config",
"python27-sys",
"python3-sys",
"extensions"
]
build = "build.rs"
@ -34,13 +31,6 @@ appveyor = { repository = "dgrunwald/rust-cpython" }
libc = "0.2"
num-traits = "0.1"
# These features are both optional, but you must pick one to
# indicate which python ffi you are trying to bind to.
[dependencies.python27-sys]
optional = true
# version = "0.1.2"
path = "./python27-sys/"
[dependencies.python3-sys]
optional = true
# version = "0.1.3"
@ -56,19 +46,3 @@ nightly = []
# It tells the linker to keep the python symbols unresolved,
# so that the module can also be used with statically linked python interpreters.
extension-module = [ "python3-sys/extension-module" ]
# Unfortunately we can't use the forward the same feature to either python27-sys
# or python3-sys. (honestly, we should probably merge both crates into 'python-sys')
extension-module-2-7 = [ "python27-sys/extension-module" ]
# Optional features to support explicitly specifying python minor version.
# If you don't care which minor version, just specify python3-sys as a
# feature.
python-3-6 = ["python3-sys/python-3-6"]
python-3-5 = ["python3-sys/python-3-5"]
python-3-4 = ["python3-sys/python-3-4"]
#pep-384 = ["python3-sys/pep-384"]
[workspace]
members = ["extensions/hello"]

View File

@ -3,10 +3,6 @@ environment:
TARGET: x86_64-pc-windows-msvc
# matrix:
# - TARGET: x86_64-pc-windows-msvc
# PY: 2
# PYTHONPATH: C:\Python27-x64
# FEATURES: python27-sys
# - TARGET: x86_64-pc-windows-msvc
# PY: 3
# PYTHONPATH: C:\Python34-x64
# FEATURES: python3-sys
@ -20,8 +16,6 @@ install:
- cargo -V
- python --version
build_script:
- set PATH=C:\Python27-x64;%PATH%&& cargo build --verbose --features python27-sys --no-default-features
- set PATH=C:\Python34-x64;%PATH%&& cargo build --verbose --features python3-sys --no-default-features
test_script:
- set PATH=C:\Python27-x64;%PATH%&& cargo test --verbose --features python27-sys --no-default-features
- set PATH=C:\Python34-x64;%PATH%&& cargo test --verbose --features python3-sys --no-default-features

View File

@ -3,9 +3,6 @@ use std::io::Write;
const CFG_KEY: &'static str = "py_sys_config";
#[cfg(feature="python27-sys")]
const PYTHONSYS_ENV_VAR: &'static str = "DEP_PYTHON27_PYTHON_FLAGS";
#[cfg(feature="python3-sys")]
const PYTHONSYS_ENV_VAR: &'static str = "DEP_PYTHON3_PYTHON_FLAGS";

View File

@ -1,20 +0,0 @@
extern crate cpython;
use cpython::{Python, PyDict, PyResult};
fn main() {
let gil = Python::acquire_gil();
hello(gil.python()).unwrap();
}
fn hello(py: Python) -> PyResult<()> {
let sys = py.import("sys")?;
let version: String = sys.get(py, "version")?.extract(py)?;
let locals = PyDict::new(py);
locals.set_item(py, "os", py.import("os")?)?;
let user: String = py.eval("os.getenv('USER') or os.getenv('USERNAME')", None, Some(&locals))?.extract(py)?;
println!("Hello {}, I'm Python {}", user, version);
Ok(())
}

View File

@ -1,21 +0,0 @@
[package]
name = "hello"
version = "0.1.0"
authors = ["Daniel Grunwald <daniel@danielgrunwald.de>"]
[lib]
## Python extension modules should be compiled as 'cdylib'
crate-type = ["cdylib"]
[dependencies.cpython]
path = "../.."
features = ["extension-module"]
# The 'extension-module' feature allows using the resulting binary module
# with statically linked python interpreters.
## By default, cpython will use whichever Python 3.x interpreter is found in PATH.
## To target Python 2.7, use:
#default-features=false
#features = ["python27-sys", "extension-module-2-7"]

View File

@ -1,38 +0,0 @@
#[macro_use] extern crate cpython;
use cpython::{PyObject, PyResult, Python, PyTuple, PyDict};
// Our module is named 'hello', and can be imported using `import hello`.
// This requires that the output binary file is named `hello.so` (or Windows: `hello.pyd`).
// As the output name cannot be configured in cargo (https://github.com/rust-lang/cargo/issues/1970),
// you'll have to rename the output file.
py_module_initializer!(hello, inithello, PyInit_hello, |py, m| {
m.add(py, "__doc__", "Module documentation string")?;
m.add(py, "func", py_fn!(py, func(a: &str, b: i32)))?;
m.add(py, "run", py_fn!(py, run(*args, **kwargs)))?;
Ok(())
});
// The py_fn!()-macro can translate between Python and Rust values,
// so you can use `&str`, `i32` or `String` in the signature of a function
// callable from Python.
// The first argument of type `Python<'p>` is used to indicate that your
// function may assume that the current thread holds the global interpreter lock.
// Most functions in the `cpython` crate require that you pass this argument.
fn func(_: Python, a: &str, b: i32) -> PyResult<String> {
Ok(format!("func({}, {})", a, b))
}
fn run(py: Python, args: &PyTuple, kwargs: Option<&PyDict>) -> PyResult<PyObject> {
println!("Rust says: Hello Python!");
for arg in args.iter(py) {
println!("Rust got {}", arg);
}
if let Some(kwargs) = kwargs {
for (key, val) in kwargs.items(py) {
println!("{} = {}", key, val);
}
}
Ok(py.None())
}

View File

@ -1,5 +0,0 @@
stamps
*.out
*.so
*_expanded.rs

View File

@ -1,62 +0,0 @@
TARGETDIR=../../target/debug
rwildcard=$(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2) $(filter $(subst *,%,$2),$d))
.PHONY: all clean
SHELL=/bin/bash -o pipefail
ifndef PY
PY := $(word 2, $(subst ., ,$(shell python --version 2>&1)))
endif
ifndef NIGHTLY
ifeq ($(word 3, $(subst -, ,$(shell rustc --version 2>&1))),nightly)
NIGHTLY := 1
else
NIGHTLY := 0
endif
endif
all:
clean:
-rm *.so
-rm *.out
-rm *_expanded.rs
-rm -r stamps
stamps:
mkdir stamps
stamps/rust-cpython-$(PY): $(call rwildcard,../../src,*.rs) Makefile | stamps
-rm stamps/rust-cpython-*
cd ../.. && make build PY=$(PY)
touch "$@"
%.so: %.rs stamps/rust-cpython-$(PY)
rustc $< -g -L $(TARGETDIR) -L $(TARGETDIR)/deps -o $@
%_expanded.rs: %.rs stamps/rust-cpython-$(PY)
rustc $< -g -L $(TARGETDIR) -L $(TARGETDIR)/deps -Z unstable-options --pretty=expanded -o $@
hello.out: hello.so
python$(PY) -c "import hello; hello.run(hello.val())" 2>&1 | tee $@
all: stamps/test-hello
stamps/test-hello: hello.out
@grep "Rust says: Hello Python!" hello.out >/dev/null
@grep "Rust got 42" hello.out >/dev/null
@touch $@
custom_class.out: custom_class.so
python$(PY) -c "import custom_class; custom_class.MyType(42).a()" 2>&1 | tee $@
all: stamps/test-custom_class
stamps/test-custom_class: custom_class.out
@grep "a() was called with self=42" custom_class.out >/dev/null
@touch $@
all: stamps/test-btree
stamps/test-btree: test_btree.py btree.so
python$(PY) test_btree.py
@touch $@

View File

@ -1,52 +0,0 @@
#![crate_type = "dylib"]
#[macro_use] extern crate cpython;
use cpython::{PyObject, PyResult};
use std::{cell, cmp, collections};
py_module_initializer!(btree, initbtree, PyInit_btree, |py, m| {
try!(m.add(py, "__doc__", "Rust BTreeSet for Python."));
try!(m.add_class::<BTreeSet>(py));
Ok(())
});
/// Newtype around PyObject that implements Ord using python value comparisons.
/// Python exceptions are converted into Rust panics.
struct OrdPyObject(PyObject);
impl PartialEq for OrdPyObject {
fn eq(&self, _other: &Self) -> bool {
false
}
}
impl Eq for OrdPyObject {}
impl PartialOrd for OrdPyObject {
fn partial_cmp(&self, _other: &Self) -> Option<cmp::Ordering> {
None
}
}
impl Ord for OrdPyObject {
fn cmp(&self, _other: &Self) -> cmp::Ordering {
unimplemented!()
}
}
py_class!(class BTreeSet |py| {
data set: cell::RefCell<collections::BTreeSet<OrdPyObject>>;
def __new__(_cls) -> PyResult<BTreeSet> {
BTreeSet::create_instance(py,
cell::RefCell::new(collections::BTreeSet::new()))
}
// def __bool__(&self) -> PyResult<bool> {
// Ok(!self.set(py).borrow().is_empty())
// }
def __len__(&self) -> PyResult<usize> {
Ok(self.set(py).borrow().len())
}
});

View File

@ -1,23 +0,0 @@
#![crate_type = "dylib"]
#[macro_use] extern crate cpython;
use cpython::{PyObject, PyResult};
py_module_initializer!(custom_class, initcustom_class, PyInit_custom_class, |py, m| {
try!(m.add(py, "__doc__", "Module documentation string"));
try!(m.add_class::<MyType>(py));
Ok(())
});
py_class!(class MyType |py| {
data data: i32;
def __new__(_cls, arg: i32) -> PyResult<MyType> {
MyType::create_instance(py, arg)
}
def a(&self) -> PyResult<PyObject> {
println!("a() was called with self={:?}", self.data(py));
Ok(py.None())
}
});

View File

@ -1,30 +0,0 @@
#![crate_type = "dylib"]
#[macro_use] extern crate cpython;
use cpython::{PyObject, PyResult, Python, PyTuple, PyDict};
py_module_initializer!(hello, inithello, PyInit_hello, |py, m| {
try!(m.add(py, "__doc__", "Module documentation string"));
try!(m.add(py, "run", py_fn!(py, run(*args, **kwargs))));
try!(m.add(py, "val", py_fn!(py, val())));
Ok(())
});
fn run(py: Python, args: &PyTuple, kwargs: Option<&PyDict>) -> PyResult<PyObject> {
println!("Rust says: Hello Python!");
for arg in args.iter(py) {
println!("Rust got {}", arg);
}
if let Some(kwargs) = kwargs {
for (key, val) in kwargs.items(py) {
println!("{} = {}", key, val);
}
}
Ok(py.None())
}
fn val(_: Python) -> PyResult<i32> {
Ok(42)
}

View File

@ -1,17 +0,0 @@
import random
import unittest
import btree
class TestBTreeSet(unittest.TestCase):
def setUp(self):
self.set = btree.BTreeSet()
def test_empty(self):
# make sure the initial set is empty
# TODO self.assertEqual(bool(self.set), False)
self.assertEqual(len(self.set), 0)
if __name__ == '__main__':
unittest.main()

View File

@ -1,2 +0,0 @@
/target
/Cargo.lock

View File

@ -1,4 +0,0 @@
language: rust
script:
- cargo build

View File

@ -1,46 +0,0 @@
[package]
name = "python27-sys"
version = "0.1.2"
description = "FFI Declarations for Python 2.7"
readme = "README.md"
keywords = [
"python",
"cpython",
"libpython27",
]
homepage = "https://github.com/dgrunwald/rust-cpython/tree/master/python27-sys"
repository = "https://github.com/dgrunwald/rust-cpython/tree/master/python27-sys"
categories = ["external-ffi-bindings"]
license = "Python-2.0"
authors = ["Daniel Grunwald <daniel@danielgrunwald.de>"]
links = "python27"
build = "build.rs"
exclude = [
".gitignore",
".travis.yml",
]
workspace = ".."
[dependencies]
libc = "0.2"
[build-dependencies]
regex = "0.1"
[features]
# This is examined by ./build.rs to determine which python version
# to try to bind to.
#
# According to PEP 404 there will never be a python 2.8, but maybe
# one day we could try to support < 2.7 ?
#
# Similarly functionality is duplicated in python3-sys/Cargo.toml
# where supporting multiple 3.x's is more important.
default = ["python-2-7"]
python-2-7 = []
# Use this feature when building an extension module.
# It tells the linker to keep the python symbols unresolved,
# so that the module can also be used with statically linked python interpreters.
extension-module = [ ]

View File

@ -1,254 +0,0 @@
A. HISTORY OF THE SOFTWARE
==========================
Python was created in the early 1990s by Guido van Rossum at Stichting
Mathematisch Centrum (CWI, see http://www.cwi.nl) in the Netherlands
as a successor of a language called ABC. Guido remains Python's
principal author, although it includes many contributions from others.
In 1995, Guido continued his work on Python at the Corporation for
National Research Initiatives (CNRI, see http://www.cnri.reston.va.us)
in Reston, Virginia where he released several versions of the
software.
In May 2000, Guido and the Python core development team moved to
BeOpen.com to form the BeOpen PythonLabs team. In October of the same
year, the PythonLabs team moved to Digital Creations (now Zope
Corporation, see http://www.zope.com). In 2001, the Python Software
Foundation (PSF, see http://www.python.org/psf/) was formed, a
non-profit organization created specifically to own Python-related
Intellectual Property. Zope Corporation is a sponsoring member of
the PSF.
All Python releases are Open Source (see http://www.opensource.org for
the Open Source Definition). Historically, most, but not all, Python
releases have also been GPL-compatible; the table below summarizes
the various releases.
Release Derived Year Owner GPL-
from compatible? (1)
0.9.0 thru 1.2 1991-1995 CWI yes
1.3 thru 1.5.2 1.2 1995-1999 CNRI yes
1.6 1.5.2 2000 CNRI no
2.0 1.6 2000 BeOpen.com no
1.6.1 1.6 2001 CNRI yes (2)
2.1 2.0+1.6.1 2001 PSF no
2.0.1 2.0+1.6.1 2001 PSF yes
2.1.1 2.1+2.0.1 2001 PSF yes
2.1.2 2.1.1 2002 PSF yes
2.1.3 2.1.2 2002 PSF yes
2.2 and above 2.1.1 2001-now PSF yes
Footnotes:
(1) GPL-compatible doesn't mean that we're distributing Python under
the GPL. All Python licenses, unlike the GPL, let you distribute
a modified version without making your changes open source. The
GPL-compatible licenses make it possible to combine Python with
other software that is released under the GPL; the others don't.
(2) According to Richard Stallman, 1.6.1 is not GPL-compatible,
because its license has a choice of law clause. According to
CNRI, however, Stallman's lawyer has told CNRI's lawyer that 1.6.1
is "not incompatible" with the GPL.
Thanks to the many outside volunteers who have worked under Guido's
direction to make these releases possible.
B. TERMS AND CONDITIONS FOR ACCESSING OR OTHERWISE USING PYTHON
===============================================================
PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
--------------------------------------------
1. This LICENSE AGREEMENT is between the Python Software Foundation
("PSF"), and the Individual or Organization ("Licensee") accessing and
otherwise using this software ("Python") in source or binary form and
its associated documentation.
2. Subject to the terms and conditions of this License Agreement, PSF hereby
grants Licensee a nonexclusive, royalty-free, world-wide license to reproduce,
analyze, test, perform and/or display publicly, prepare derivative works,
distribute, and otherwise use Python alone or in any derivative version,
provided, however, that PSF's License Agreement and PSF's notice of copyright,
i.e., "Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
2011, 2012, 2013 Python Software Foundation; All Rights Reserved" are retained
in Python alone or in any derivative version prepared by Licensee.
3. In the event Licensee prepares a derivative work that is based on
or incorporates Python or any part thereof, and wants to make
the derivative work available to others as provided herein, then
Licensee hereby agrees to include in any such work a brief summary of
the changes made to Python.
4. PSF is making Python available to Licensee on an "AS IS"
basis. PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND
DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS
FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON WILL NOT
INFRINGE ANY THIRD PARTY RIGHTS.
5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON
FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS
A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON,
OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
6. This License Agreement will automatically terminate upon a material
breach of its terms and conditions.
7. Nothing in this License Agreement shall be deemed to create any
relationship of agency, partnership, or joint venture between PSF and
Licensee. This License Agreement does not grant permission to use PSF
trademarks or trade name in a trademark sense to endorse or promote
products or services of Licensee, or any third party.
8. By copying, installing or otherwise using Python, Licensee
agrees to be bound by the terms and conditions of this License
Agreement.
BEOPEN.COM LICENSE AGREEMENT FOR PYTHON 2.0
-------------------------------------------
BEOPEN PYTHON OPEN SOURCE LICENSE AGREEMENT VERSION 1
1. This LICENSE AGREEMENT is between BeOpen.com ("BeOpen"), having an
office at 160 Saratoga Avenue, Santa Clara, CA 95051, and the
Individual or Organization ("Licensee") accessing and otherwise using
this software in source or binary form and its associated
documentation ("the Software").
2. Subject to the terms and conditions of this BeOpen Python License
Agreement, BeOpen hereby grants Licensee a non-exclusive,
royalty-free, world-wide license to reproduce, analyze, test, perform
and/or display publicly, prepare derivative works, distribute, and
otherwise use the Software alone or in any derivative version,
provided, however, that the BeOpen Python License is retained in the
Software, alone or in any derivative version prepared by Licensee.
3. BeOpen is making the Software available to Licensee on an "AS IS"
basis. BEOPEN MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, BEOPEN MAKES NO AND
DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS
FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE WILL NOT
INFRINGE ANY THIRD PARTY RIGHTS.
4. BEOPEN SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF THE
SOFTWARE FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS
AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THE SOFTWARE, OR ANY
DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
5. This License Agreement will automatically terminate upon a material
breach of its terms and conditions.
6. This License Agreement shall be governed by and interpreted in all
respects by the law of the State of California, excluding conflict of
law provisions. Nothing in this License Agreement shall be deemed to
create any relationship of agency, partnership, or joint venture
between BeOpen and Licensee. This License Agreement does not grant
permission to use BeOpen trademarks or trade names in a trademark
sense to endorse or promote products or services of Licensee, or any
third party. As an exception, the "BeOpen Python" logos available at
http://www.pythonlabs.com/logos.html may be used according to the
permissions granted on that web page.
7. By copying, installing or otherwise using the software, Licensee
agrees to be bound by the terms and conditions of this License
Agreement.
CNRI LICENSE AGREEMENT FOR PYTHON 1.6.1
---------------------------------------
1. This LICENSE AGREEMENT is between the Corporation for National
Research Initiatives, having an office at 1895 Preston White Drive,
Reston, VA 20191 ("CNRI"), and the Individual or Organization
("Licensee") accessing and otherwise using Python 1.6.1 software in
source or binary form and its associated documentation.
2. Subject to the terms and conditions of this License Agreement, CNRI
hereby grants Licensee a nonexclusive, royalty-free, world-wide
license to reproduce, analyze, test, perform and/or display publicly,
prepare derivative works, distribute, and otherwise use Python 1.6.1
alone or in any derivative version, provided, however, that CNRI's
License Agreement and CNRI's notice of copyright, i.e., "Copyright (c)
1995-2001 Corporation for National Research Initiatives; All Rights
Reserved" are retained in Python 1.6.1 alone or in any derivative
version prepared by Licensee. Alternately, in lieu of CNRI's License
Agreement, Licensee may substitute the following text (omitting the
quotes): "Python 1.6.1 is made available subject to the terms and
conditions in CNRI's License Agreement. This Agreement together with
Python 1.6.1 may be located on the Internet using the following
unique, persistent identifier (known as a handle): 1895.22/1013. This
Agreement may also be obtained from a proxy server on the Internet
using the following URL: http://hdl.handle.net/1895.22/1013".
3. In the event Licensee prepares a derivative work that is based on
or incorporates Python 1.6.1 or any part thereof, and wants to make
the derivative work available to others as provided herein, then
Licensee hereby agrees to include in any such work a brief summary of
the changes made to Python 1.6.1.
4. CNRI is making Python 1.6.1 available to Licensee on an "AS IS"
basis. CNRI MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, CNRI MAKES NO AND
DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS
FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON 1.6.1 WILL NOT
INFRINGE ANY THIRD PARTY RIGHTS.
5. CNRI SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON
1.6.1 FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS
A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON 1.6.1,
OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
6. This License Agreement will automatically terminate upon a material
breach of its terms and conditions.
7. This License Agreement shall be governed by the federal
intellectual property law of the United States, including without
limitation the federal copyright law, and, to the extent such
U.S. federal law does not apply, by the law of the Commonwealth of
Virginia, excluding Virginia's conflict of law provisions.
Notwithstanding the foregoing, with regard to derivative works based
on Python 1.6.1 that incorporate non-separable material that was
previously distributed under the GNU General Public License (GPL), the
law of the Commonwealth of Virginia shall govern this License
Agreement only as to issues arising under or with respect to
Paragraphs 4, 5, and 7 of this License Agreement. Nothing in this
License Agreement shall be deemed to create any relationship of
agency, partnership, or joint venture between CNRI and Licensee. This
License Agreement does not grant permission to use CNRI trademarks or
trade name in a trademark sense to endorse or promote products or
services of Licensee, or any third party.
8. By clicking on the "ACCEPT" button where indicated, or by copying,
installing or otherwise using Python 1.6.1, Licensee agrees to be
bound by the terms and conditions of this License Agreement.
ACCEPT
CWI LICENSE AGREEMENT FOR PYTHON 0.9.0 THROUGH 1.2
--------------------------------------------------
Copyright (c) 1991 - 1995, Stichting Mathematisch Centrum Amsterdam,
The Netherlands. All rights reserved.
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the name of Stichting Mathematisch
Centrum or CWI not be used in advertising or publicity pertaining to
distribution of the software without specific, written prior
permission.
STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

View File

@ -1,29 +0,0 @@
rust-python27-sys [![Build Status](https://travis-ci.org/dgrunwald/rust-python27-sys.svg?branch=master)](https://travis-ci.org/dgrunwald/rust-python27-sys)
====================
[Rust](http://www.rust-lang.org/) FFI declarations for Python 2.7.
---
This [cargo -sys package](http://doc.crates.io/build-script.html#*-sys-packages) provides `python27` declarations.
Licensed under the Python license (see `LICENSE`).
For a safe high-level API, see [rust-cpython](https://github.com/dgrunwald/rust-cpython).
# Usage
[`python27-sys` is available on crates.io](https://crates.io/crates/python27-sys) so you can use it like this (in your `Cargo.toml`):
```toml
[dependencies.python27-sys]
version = "*"
```
In Rust, import the crate like this:
```rust
extern crate python27_sys as py;
```
Documentation for the python API is available on [https://docs.python.org/2/c-api/].

View File

@ -1,427 +0,0 @@
//[[[cog
//import os
//import cog
//HERE = os.path.dirname(cog.inFile)
//for line in open(os.path.join(HERE, '../python3-sys/build.rs')):
// if line.strip():
// cog.out(line)
// else:
// cog.out("// ~~~~~~~~~~ generated file, modify `python3-sys/build.rs` ~~~~~~~~~~" + line)
//]]]
extern crate regex;
// ~~~~~~~~~~ generated file, modify `python3-sys/build.rs` ~~~~~~~~~~
use std::process::Command;
use std::collections::HashMap;
use std::env;
use regex::Regex;
use std::fmt;
// ~~~~~~~~~~ generated file, modify `python3-sys/build.rs` ~~~~~~~~~~
struct PythonVersion {
major: u8,
// minor == None means any minor version will do
minor: Option<u8>
}
// ~~~~~~~~~~ generated file, modify `python3-sys/build.rs` ~~~~~~~~~~
impl fmt::Display for PythonVersion {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
try!(self.major.fmt(f));
try!(f.write_str("."));
match self.minor {
Some(minor) => try!(minor.fmt(f)),
None => try!(f.write_str("*"))
};
Ok(())
}
}
// ~~~~~~~~~~ generated file, modify `python3-sys/build.rs` ~~~~~~~~~~
const CFG_KEY: &'static str = "py_sys_config";
// ~~~~~~~~~~ generated file, modify `python3-sys/build.rs` ~~~~~~~~~~
// windows' python writes out lines with the windows crlf sequence;
// posix platforms and mac os should write out lines with just lf.
#[cfg(target_os="windows")]
static NEWLINE_SEQUENCE: &'static str = "\r\n";
// ~~~~~~~~~~ generated file, modify `python3-sys/build.rs` ~~~~~~~~~~
#[cfg(not(target_os="windows"))]
static NEWLINE_SEQUENCE: &'static str = "\n";
// ~~~~~~~~~~ generated file, modify `python3-sys/build.rs` ~~~~~~~~~~
// A list of python interpreter compile-time preprocessor defines that
// we will pick up and pass to rustc via --cfg=py_sys_config={varname};
// this allows using them conditional cfg attributes in the .rs files, so
//
// #[cfg(py_sys_config="{varname}"]
//
// is the equivalent of #ifdef {varname} name in C.
//
// see Misc/SpecialBuilds.txt in the python source for what these mean.
//
// (hrm, this is sort of re-implementing what distutils does, except
// by passing command line args instead of referring to a python.h)
#[cfg(not(target_os="windows"))]
static SYSCONFIG_FLAGS: [&'static str; 7] = [
"Py_USING_UNICODE",
"Py_UNICODE_WIDE",
"WITH_THREAD",
"Py_DEBUG",
"Py_REF_DEBUG",
"Py_TRACE_REFS",
"COUNT_ALLOCS",
];
// ~~~~~~~~~~ generated file, modify `python3-sys/build.rs` ~~~~~~~~~~
static SYSCONFIG_VALUES: [&'static str; 1] = [
// cfg doesn't support flags with values, just bools - so flags
// below are translated into bools as {varname}_{val}
//
// for example, Py_UNICODE_SIZE_2 or Py_UNICODE_SIZE_4
"Py_UNICODE_SIZE" // note - not present on python 3.3+, which is always wide
];
// ~~~~~~~~~~ generated file, modify `python3-sys/build.rs` ~~~~~~~~~~
/// Examine python's compile flags to pass to cfg by launching
/// the interpreter and printing variables of interest from
/// sysconfig.get_config_vars.
#[cfg(not(target_os="windows"))]
fn get_config_vars(python_path: &String) -> Result<HashMap<String, String>, String> {
let mut script = "import sysconfig; \
config = sysconfig.get_config_vars();".to_owned();
// ~~~~~~~~~~ generated file, modify `python3-sys/build.rs` ~~~~~~~~~~
for k in SYSCONFIG_FLAGS.iter().chain(SYSCONFIG_VALUES.iter()) {
script.push_str(&format!("print(config.get('{}', {}))", k,
if is_value(k) { "None" } else { "0" } ));
script.push_str(";");
}
// ~~~~~~~~~~ generated file, modify `python3-sys/build.rs` ~~~~~~~~~~
let mut cmd = Command::new(python_path);
cmd.arg("-c").arg(script);
// ~~~~~~~~~~ generated file, modify `python3-sys/build.rs` ~~~~~~~~~~
let out = try!(cmd.output().map_err(|e| {
format!("failed to run python interpreter `{:?}`: {}", cmd, e)
}));
// ~~~~~~~~~~ generated file, modify `python3-sys/build.rs` ~~~~~~~~~~
if !out.status.success() {
let stderr = String::from_utf8(out.stderr).unwrap();
let mut msg = format!("python script failed with stderr:\n\n");
msg.push_str(&stderr);
return Err(msg);
}
// ~~~~~~~~~~ generated file, modify `python3-sys/build.rs` ~~~~~~~~~~
let stdout = String::from_utf8(out.stdout).unwrap();
let split_stdout: Vec<&str> = stdout.trim_right().split(NEWLINE_SEQUENCE).collect();
if split_stdout.len() != SYSCONFIG_VALUES.len() + SYSCONFIG_FLAGS.len() {
return Err(
format!("python stdout len didn't return expected number of lines:
{}", split_stdout.len()).to_string());
}
let all_vars = SYSCONFIG_FLAGS.iter().chain(SYSCONFIG_VALUES.iter());
// let var_map: HashMap<String, String> = HashMap::new();
Ok(all_vars.zip(split_stdout.iter())
.fold(HashMap::new(), |mut memo: HashMap<String, String>, (&k, &v)| {
if !(v.to_owned() == "None" && is_value(k)) {
memo.insert(k.to_owned(), v.to_owned());
}
memo
}))
}
// ~~~~~~~~~~ generated file, modify `python3-sys/build.rs` ~~~~~~~~~~
#[cfg(target_os="windows")]
fn get_config_vars(_: &String) -> Result<HashMap<String, String>, String> {
// sysconfig is missing all the flags on windows, so we can't actually
// query the interpreter directly for its build flags.
//
// For the time being, this is the flags as defined in the python source's
// PC\pyconfig.h. This won't work correctly if someone has built their
// python with a modified pyconfig.h - sorry if that is you, you will have
// to comment/uncomment the lines below.
let mut map: HashMap<String, String> = HashMap::new();
map.insert("Py_USING_UNICODE".to_owned(), "1".to_owned());
map.insert("Py_UNICODE_WIDE".to_owned(), "0".to_owned());
map.insert("WITH_THREAD".to_owned(), "1".to_owned());
map.insert("Py_UNICODE_SIZE".to_owned(), "2".to_owned());
// ~~~~~~~~~~ generated file, modify `python3-sys/build.rs` ~~~~~~~~~~
// This is defined #ifdef _DEBUG. The visual studio build seems to produce
// a specially named pythonXX_d.exe and pythonXX_d.dll when you build the
// Debug configuration, which this script doesn't currently support anyway.
// map.insert("Py_DEBUG", "1");
// ~~~~~~~~~~ generated file, modify `python3-sys/build.rs` ~~~~~~~~~~
// Uncomment these manually if your python was built with these and you want
// the cfg flags to be set in rust.
//
// map.insert("Py_REF_DEBUG", "1");
// map.insert("Py_TRACE_REFS", "1");
// map.insert("COUNT_ALLOCS", 1");
Ok(map)
}
// ~~~~~~~~~~ generated file, modify `python3-sys/build.rs` ~~~~~~~~~~
fn is_value(key: &str) -> bool {
SYSCONFIG_VALUES.iter().find(|x| **x == key).is_some()
}
// ~~~~~~~~~~ generated file, modify `python3-sys/build.rs` ~~~~~~~~~~
fn cfg_line_for_var(key: &str, val: &str) -> Option<String> {
if is_value(key) {
// is a value; suffix the key name with the value
Some(format!("cargo:rustc-cfg={}=\"{}_{}\"\n", CFG_KEY, key, val))
} else if val != "0" {
// is a flag that isn't zero
Some(format!("cargo:rustc-cfg={}=\"{}\"", CFG_KEY, key))
} else {
// is a flag that is zero
None
}
}
// ~~~~~~~~~~ generated file, modify `python3-sys/build.rs` ~~~~~~~~~~
/// Run a python script using the specified interpreter binary.
fn run_python_script(interpreter: &str, script: &str) -> Result<String, String> {
let mut cmd = Command::new(interpreter);
cmd.arg("-c").arg(script);
// ~~~~~~~~~~ generated file, modify `python3-sys/build.rs` ~~~~~~~~~~
let out = try!(cmd.output().map_err(|e| {
format!("failed to run python interpreter `{:?}`: {}", cmd, e)
}));
// ~~~~~~~~~~ generated file, modify `python3-sys/build.rs` ~~~~~~~~~~
if !out.status.success() {
let stderr = String::from_utf8(out.stderr).unwrap();
let mut msg = format!("python script failed with stderr:\n\n");
msg.push_str(&stderr);
return Err(msg);
}
// ~~~~~~~~~~ generated file, modify `python3-sys/build.rs` ~~~~~~~~~~
let out = String::from_utf8(out.stdout).unwrap();
return Ok(out);
}
// ~~~~~~~~~~ generated file, modify `python3-sys/build.rs` ~~~~~~~~~~
#[cfg(not(target_os="macos"))]
#[cfg(not(target_os="windows"))]
fn get_rustc_link_lib(_: &PythonVersion, ld_version: &str, enable_shared: bool) -> Result<String, String> {
if enable_shared {
Ok(format!("cargo:rustc-link-lib=python{}", ld_version))
} else {
Ok(format!("cargo:rustc-link-lib=static=python{}", ld_version))
}
}
// ~~~~~~~~~~ generated file, modify `python3-sys/build.rs` ~~~~~~~~~~
#[cfg(target_os="macos")]
fn get_macos_linkmodel() -> Result<String, String> {
let script = "import sysconfig; print('framework' if sysconfig.get_config_var('PYTHONFRAMEWORK') else ('shared' if sysconfig.get_config_var('Py_ENABLE_SHARED') else 'static'));";
let out = run_python_script("python", script).unwrap();
Ok(out.trim_right().to_owned())
}
// ~~~~~~~~~~ generated file, modify `python3-sys/build.rs` ~~~~~~~~~~
#[cfg(target_os="macos")]
fn get_rustc_link_lib(_: &PythonVersion, ld_version: &str, _: bool) -> Result<String, String> {
// os x can be linked to a framework or static or dynamic, and
// Py_ENABLE_SHARED is wrong; framework means shared library
match get_macos_linkmodel().unwrap().as_ref() {
"static" => Ok(format!("cargo:rustc-link-lib=static=python{}",
ld_version)),
"shared" => Ok(format!("cargo:rustc-link-lib=python{}",
ld_version)),
"framework" => Ok(format!("cargo:rustc-link-lib=python{}",
ld_version)),
other => Err(format!("unknown linkmodel {}", other))
}
}
// ~~~~~~~~~~ generated file, modify `python3-sys/build.rs` ~~~~~~~~~~
/// Parse string as interpreter version.
fn get_interpreter_version(line: &str) -> Result<PythonVersion, String> {
let version_re = Regex::new(r"\((\d+), (\d+)\)").unwrap();
match version_re.captures(&line) {
Some(cap) => Ok(PythonVersion {
major: cap.at(1).unwrap().parse().unwrap(),
minor: Some(cap.at(2).unwrap().parse().unwrap())
}),
None => Err(
format!("Unexpected response to version query {}", line))
}
}
// ~~~~~~~~~~ generated file, modify `python3-sys/build.rs` ~~~~~~~~~~
#[cfg(target_os="windows")]
fn get_rustc_link_lib(version: &PythonVersion, _: &str, _: bool) -> Result<String, String> {
// Py_ENABLE_SHARED doesn't seem to be present on windows.
Ok(format!("cargo:rustc-link-lib=pythonXY:python{}{}", version.major,
match version.minor {
Some(minor) => minor.to_string(),
None => "".to_owned()
}))
}
// ~~~~~~~~~~ generated file, modify `python3-sys/build.rs` ~~~~~~~~~~
fn matching_version(expected_version: &PythonVersion, actual_version: &PythonVersion) -> bool {
actual_version.major == expected_version.major &&
(expected_version.minor.is_none() ||
actual_version.minor == expected_version.minor)
}
// ~~~~~~~~~~ generated file, modify `python3-sys/build.rs` ~~~~~~~~~~
/// Locate a suitable python interpreter and extract config from it.
/// If the environment variable `PYTHON_SYS_EXECUTABLE`, use the provided
/// path a Python executable, and raises an error if the version doesn't match.
/// Else tries to execute the interpreter as "python", "python{major version}",
/// "python{major version}.{minor version}" in order until one
/// is of the version we are expecting.
fn find_interpreter_and_get_config(expected_version: &PythonVersion) ->
Result<(PythonVersion, String, Vec<String>), String> {
if let Some(sys_executable) = env::var_os("PYTHON_SYS_EXECUTABLE") {
let interpreter_path = sys_executable.to_str()
.expect("Unable to get PYTHON_SYS_EXECUTABLE value");
let (interpreter_version, lines) = try!(get_config_from_interpreter(interpreter_path));
if matching_version(expected_version, &interpreter_version) {
return Ok((interpreter_version, interpreter_path.to_owned(), lines));
} else {
return Err(format!("Wrong python version in PYTHON_SYS_EXECUTABLE={}\n\
\texpected {} != found {}",
interpreter_path,
expected_version,
interpreter_version));
}
}
{
let interpreter_path = "python";
let (interpreter_version, lines) =
try!(get_config_from_interpreter(interpreter_path));
if matching_version(expected_version, &interpreter_version) {
return Ok((interpreter_version, interpreter_path.to_owned(), lines));
}
}
{
let major_interpreter_path = &format!("python{}", expected_version.major);
let (interpreter_version, lines) = try!(get_config_from_interpreter(
major_interpreter_path));
if matching_version(expected_version, &interpreter_version) {
return Ok((interpreter_version, major_interpreter_path.to_owned(), lines));
}
}
if let Some(minor) = expected_version.minor {
let minor_interpreter_path = &format!("python{}.{}",
expected_version.major, minor);
let (interpreter_version, lines) = try!(get_config_from_interpreter(
minor_interpreter_path));
if matching_version(expected_version, &interpreter_version) {
return Ok((interpreter_version, minor_interpreter_path.to_owned(), lines));
}
}
Err(format!("No python interpreter found of version {}",
expected_version))
}
// ~~~~~~~~~~ generated file, modify `python3-sys/build.rs` ~~~~~~~~~~
/// Extract compilation vars from the specified interpreter.
fn get_config_from_interpreter(interpreter: &str) -> Result<(PythonVersion, Vec<String>), String> {
let script = "import sys; import sysconfig; print(sys.version_info[0:2]); \
print(sysconfig.get_config_var('LIBDIR')); \
print(sysconfig.get_config_var('Py_ENABLE_SHARED')); \
print(sysconfig.get_config_var('LDVERSION') or sysconfig.get_config_var('py_version_short')); \
print(sys.exec_prefix);";
let out = try!(run_python_script(interpreter, script));
let lines: Vec<String> = out.split(NEWLINE_SEQUENCE).map(|line| line.to_owned()).collect();
let interpreter_version = try!(get_interpreter_version(&lines[0]));
Ok((interpreter_version, lines))
}
// ~~~~~~~~~~ generated file, modify `python3-sys/build.rs` ~~~~~~~~~~
/// Deduce configuration from the 'python' in the current PATH and print
/// cargo vars to stdout.
///
/// Note that if the python doesn't satisfy expected_version, this will error.
fn configure_from_path(expected_version: &PythonVersion) -> Result<String, String> {
let (interpreter_version, interpreter_path, lines) =
try!(find_interpreter_and_get_config(expected_version));
let libpath: &str = &lines[1];
let enable_shared: &str = &lines[2];
let ld_version: &str = &lines[3];
let exec_prefix: &str = &lines[4];
// ~~~~~~~~~~ generated file, modify `python3-sys/build.rs` ~~~~~~~~~~
let is_extension_module = env::var_os("CARGO_FEATURE_EXTENSION_MODULE").is_some();
if !is_extension_module || cfg!(target_os="windows") {
println!("{}", get_rustc_link_lib(&interpreter_version,
ld_version, enable_shared == "1").unwrap());
if libpath != "None" {
println!("cargo:rustc-link-search=native={}", libpath);
} else if cfg!(target_os="windows") {
println!("cargo:rustc-link-search=native={}\\libs", exec_prefix);
}
}
// ~~~~~~~~~~ generated file, modify `python3-sys/build.rs` ~~~~~~~~~~
// ~~~~~~~~~~ generated file, modify `python3-sys/build.rs` ~~~~~~~~~~
if let PythonVersion { major: 3, minor: some_minor} = interpreter_version {
if env::var_os("CARGO_FEATURE_PEP_384").is_some() {
println!("cargo:rustc-cfg=Py_LIMITED_API");
}
if let Some(minor) = some_minor {
for i in 4..(minor+1) {
println!("cargo:rustc-cfg=Py_3_{}", i);
}
}
}
// ~~~~~~~~~~ generated file, modify `python3-sys/build.rs` ~~~~~~~~~~
return Ok(interpreter_path);
}
// ~~~~~~~~~~ generated file, modify `python3-sys/build.rs` ~~~~~~~~~~
/// Determine the python version we're supposed to be building
/// from the features passed via the environment.
///
/// The environment variable can choose to omit a minor
/// version if the user doesn't care.
fn version_from_env() -> Result<PythonVersion, String> {
let re = Regex::new(r"CARGO_FEATURE_PYTHON_(\d+)(_(\d+))?").unwrap();
// sort env::vars so we get more explicit version specifiers first
// so if the user passes e.g. the python-3 feature and the python-3-5
// feature, python-3-5 takes priority.
let mut vars = env::vars().collect::<Vec<_>>();
vars.sort_by(|a, b| b.cmp(a));
for (key, _) in vars {
match re.captures(&key) {
Some(cap) => return Ok(PythonVersion {
major: cap.at(1).unwrap().parse().unwrap(),
minor: match cap.at(3) {
Some(s) => Some(s.parse().unwrap()),
None => None
}
}),
None => ()
}
}
Err("Python version feature was not found. At least one python version \
feature must be enabled.".to_owned())
}
// ~~~~~~~~~~ generated file, modify `python3-sys/build.rs` ~~~~~~~~~~
fn main() {
// 1. Setup cfg variables so we can do conditional compilation in this
// library based on the python interpeter's compilation flags. This is
// necessary for e.g. matching the right unicode and threading interfaces.
//
// This locates the python interpreter based on the PATH, which should
// work smoothly with an activated virtualenv.
//
// If you have troubles with your shell accepting '.' in a var name,
// try using 'env' (sorry but this isn't our fault - it just has to
// match the pkg-config package name, which is going to have a . in it).
let version = version_from_env().unwrap();
let python_interpreter_path = configure_from_path(&version).unwrap();
let config_map = get_config_vars(&python_interpreter_path).unwrap();
for (key, val) in &config_map {
match cfg_line_for_var(key, val) {
Some(line) => println!("{}", line),
None => ()
}
}
// ~~~~~~~~~~ generated file, modify `python3-sys/build.rs` ~~~~~~~~~~
// 2. Export python interpreter compilation flags as cargo variables that
// will be visible to dependents. All flags will be available to dependent
// build scripts in the environment variable DEP_PYTHON27_PYTHON_FLAGS as
// comma separated list; each item in the list looks like
//
// {VAL,FLAG}_{flag_name}=val;
//
// FLAG indicates the variable is always 0 or 1
// VAL indicates it can take on any value
//
// rust-cypthon/build.rs contains an example of how to unpack this data
// into cfg flags that replicate the ones present in this library, so
// you can use the same cfg syntax.
let flags: String = config_map.iter().fold("".to_owned(), |memo, (key, val)| {
if is_value(key) {
memo + format!("VAL_{}={},", key, val).as_ref()
} else if val != "0" {
memo + format!("FLAG_{}={},", key, val).as_ref()
} else {
memo
}
});
println!("cargo:python_flags={}",
if flags.len() > 0 { &flags[..flags.len()-1] } else { "" });
}
//[[[end]]]

View File

@ -1,15 +0,0 @@
extern crate libc;
extern crate python27_sys;
unsafe fn get_str<'a>(s: *const libc::c_char) -> &'a str {
let bytes = std::ffi::CStr::from_ptr(s).to_bytes();
std::str::from_utf8(bytes).unwrap()
}
fn main() {
unsafe {
python27_sys::Py_Initialize();
println!("{}", get_str(python27_sys::Py_GetVersion()));
}
}

View File

@ -1,29 +0,0 @@
use libc::{c_int, c_long};
use object::*;
use intobject::PyIntObject;
pub type PyBoolObject = PyIntObject;
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub static mut PyBool_Type: PyTypeObject;
static mut _Py_ZeroStruct: PyIntObject;
static mut _Py_TrueStruct: PyIntObject;
pub fn PyBool_FromLong(arg1: c_long) -> *mut PyObject;
}
#[inline(always)]
pub unsafe fn PyBool_Check(op : *mut PyObject) -> c_int {
let u : *mut PyTypeObject = &mut PyBool_Type;
(Py_TYPE(op) == u) as c_int
}
#[inline(always)]
pub unsafe fn Py_False() -> *mut PyObject {
&mut _Py_ZeroStruct as *mut PyBoolObject as *mut PyObject
}
#[inline(always)]
pub unsafe fn Py_True() -> *mut PyObject {
&mut _Py_TrueStruct as *mut PyBoolObject as *mut PyObject
}

View File

@ -1,29 +0,0 @@
use libc::{c_void, c_int};
use object::*;
use pyport::Py_ssize_t;
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub static mut PyBuffer_Type: PyTypeObject;
}
#[inline(always)]
pub unsafe fn PyBuffer_Check(op : *mut PyObject) -> c_int {
let u : *mut PyTypeObject = &mut PyBuffer_Type;
(Py_TYPE(op) == u) as c_int
}
pub const Py_END_OF_BUFFER: Py_ssize_t = -1;
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub fn PyBuffer_FromObject(base: *mut PyObject, offset: Py_ssize_t,
size: Py_ssize_t) -> *mut PyObject;
pub fn PyBuffer_FromReadWriteObject(base: *mut PyObject,
offset: Py_ssize_t, size: Py_ssize_t)
-> *mut PyObject;
pub fn PyBuffer_FromMemory(ptr: *mut c_void, size: Py_ssize_t)
-> *mut PyObject;
pub fn PyBuffer_FromReadWriteMemory(ptr: *mut c_void,
size: Py_ssize_t) -> *mut PyObject;
pub fn PyBuffer_New(size: Py_ssize_t) -> *mut PyObject;
}

View File

@ -1,59 +0,0 @@
use libc::{c_char, c_int};
use pyport::Py_ssize_t;
use object::*;
/*#[repr(C)]
#[deriving(Copy)]
struct PyByteArrayObject {
#[cfg(py_sys_config="Py_TRACE_REFS")]
pub _ob_next: *mut PyObject,
#[cfg(py_sys_config="Py_TRACE_REFS")]
pub _ob_prev: *mut PyObject,
pub ob_refcnt: Py_ssize_t,
pub ob_type: *mut PyTypeObject,
pub ob_size: Py_ssize_t,
pub ob_exports: c_int,
pub ob_alloc: Py_ssize_t,
pub ob_bytes: *mut c_char,
}*/
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub static mut PyByteArray_Type: PyTypeObject;
pub static mut PyByteArrayIter_Type: PyTypeObject;
}
pub unsafe fn PyByteArray_Check(op : *mut PyObject) -> c_int {
PyObject_TypeCheck(op, &mut PyByteArray_Type)
}
pub unsafe fn PyByteArray_CheckExact(op : *mut PyObject) -> c_int {
let u : *mut PyTypeObject = &mut PyByteArray_Type;
(Py_TYPE(op) == u) as c_int
}
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub fn PyByteArray_FromObject(o: *mut PyObject) -> *mut PyObject;
pub fn PyByteArray_Concat(a: *mut PyObject, b: *mut PyObject)
-> *mut PyObject;
pub fn PyByteArray_FromStringAndSize(string: *const c_char,
len: Py_ssize_t) -> *mut PyObject;
pub fn PyByteArray_Size(bytearray: *mut PyObject) -> Py_ssize_t;
pub fn PyByteArray_AsString(bytearray: *mut PyObject) -> *mut c_char;
pub fn PyByteArray_Resize(bytearray: *mut PyObject, len: Py_ssize_t)
-> c_int;
}
#[inline(always)]
pub unsafe fn PyByteArray_AS_STRING(o: *mut PyObject) -> *mut c_char {
PyByteArray_AsString(o)
// #define PyByteArray_AS_STRING(self) \
// (assert(PyByteArray_Check(self)), \
// Py_SIZE(self) ? ((PyByteArrayObject *)(self))->ob_bytes : _PyByteArray_empty_string)
}
#[inline(always)]
pub unsafe fn PyByteArray_GET_SIZE(o: *mut PyObject) -> Py_ssize_t {
// #define PyByteArray_GET_SIZE(self) (assert(PyByteArray_Check(self)),Py_SIZE(self))
PyByteArray_Size(o)
}

View File

@ -1,17 +0,0 @@
pub use stringobject::PyStringObject as PyBytesObject;
pub use stringobject::PyString_Type as PyBytes_Type;
pub use stringobject::PyString_Check as PyBytes_Check;
pub use stringobject::PyString_CheckExact as PyBytes_CheckExact;
pub use stringobject::PyString_AS_STRING as PyBytes_AS_STRING;
pub use stringobject::PyString_GET_SIZE as PyBytes_GET_SIZE;
pub use object::Py_TPFLAGS_STRING_SUBCLASS as Py_TPFLAGS_BYTES_SUBCLASS;
pub use stringobject::PyString_FromStringAndSize as PyBytes_FromStringAndSize;
pub use stringobject::PyString_FromString as PyBytes_FromString;
pub use stringobject::PyString_FromFormat as PyBytes_FromFormat;
pub use stringobject::PyString_Size as PyBytes_Size;
pub use stringobject::PyString_AsString as PyBytes_AsString;
pub use stringobject::PyString_Concat as PyBytes_Concat;
pub use stringobject::PyString_ConcatAndDel as PyBytes_ConcatAndDel;
pub use stringobject::PyString_Format as PyBytes_Format;
pub use stringobject::PyString_AsStringAndSize as PyBytes_AsStringAndSize;

View File

@ -1,41 +0,0 @@
use libc::c_int;
use pyport::Py_ssize_t;
use object::*;
#[repr(C)]
#[derive(Copy, Clone)]
struct PyCellObject {
#[cfg(py_sys_config="Py_TRACE_REFS")]
pub _ob_next: *mut PyObject,
#[cfg(py_sys_config="Py_TRACE_REFS")]
pub _ob_prev: *mut PyObject,
pub ob_refcnt: Py_ssize_t,
pub ob_type: *mut PyTypeObject,
pub ob_ref: *mut PyObject
}
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub static mut PyCell_Type: PyTypeObject;
}
#[inline(always)]
pub unsafe fn PyCell_Check(op: *mut PyObject) -> c_int {
(Py_TYPE(op) == &mut PyCell_Type) as c_int
}
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub fn PyCell_New(obj: *mut PyObject) -> *mut PyObject;
pub fn PyCell_Get(op: *mut PyObject) -> *mut PyObject;
pub fn PyCell_Set(op: *mut PyObject, obj: *mut PyObject) -> c_int;
}
#[inline(always)]
pub unsafe fn PyCell_GET(op: *mut PyObject) -> *mut PyObject {
(*(op as *mut PyCellObject)).ob_ref
}
#[inline(always)]
pub unsafe fn PyCell_SET(op: *mut PyObject, obj: *mut PyObject) {
(*(op as *mut PyCellObject)).ob_ref = obj;
}

View File

@ -1,65 +0,0 @@
use libc::{c_void, c_char, c_int};
use pyport::Py_ssize_t;
use object::PyObject;
use frameobject::PyFrameObject;
use pystate::{PyThreadState, Py_tracefunc};
use pythonrun::PyCompilerFlags;
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub fn PyEval_CallObjectWithKeywords(callable: *mut PyObject,
args: *mut PyObject,
kwds: *mut PyObject)
-> *mut PyObject;
pub fn PyEval_CallFunction(obj: *mut PyObject,
format: *const c_char, ...)
-> *mut PyObject;
pub fn PyEval_CallMethod(obj: *mut PyObject,
methodname: *const c_char,
format: *const c_char, ...)
-> *mut PyObject;
pub fn PyEval_SetProfile(func: Option<Py_tracefunc>, obj: *mut PyObject);
pub fn PyEval_SetTrace(func: Option<Py_tracefunc>, obj: *mut PyObject);
pub fn PyEval_GetBuiltins() -> *mut PyObject;
pub fn PyEval_GetGlobals() -> *mut PyObject;
pub fn PyEval_GetLocals() -> *mut PyObject;
pub fn PyEval_GetFrame() -> *mut PyFrameObject;
pub fn PyEval_GetRestricted() -> c_int;
pub fn PyEval_MergeCompilerFlags(cf: *mut PyCompilerFlags)
-> c_int;
pub fn Py_FlushLine() -> c_int;
pub fn Py_AddPendingCall(func:
Option<extern "C" fn
(arg1:
*mut c_void)
-> c_int>,
arg: *mut c_void) -> c_int;
pub fn Py_MakePendingCalls() -> c_int;
pub fn Py_SetRecursionLimit(arg1: c_int);
pub fn Py_GetRecursionLimit() -> c_int;
fn _Py_CheckRecursiveCall(_where: *mut c_char)
-> c_int;
pub fn PyEval_GetFuncName(arg1: *mut PyObject) -> *const c_char;
pub fn PyEval_GetFuncDesc(arg1: *mut PyObject) -> *const c_char;
pub fn PyEval_GetCallStats(arg1: *mut PyObject) -> *mut PyObject;
pub fn PyEval_EvalFrame(arg1: *mut PyFrameObject) -> *mut PyObject;
pub fn PyEval_EvalFrameEx(f: *mut PyFrameObject, exc: c_int)
-> *mut PyObject;
pub fn PyEval_SaveThread() -> *mut PyThreadState;
pub fn PyEval_RestoreThread(arg1: *mut PyThreadState);
fn _PyEval_SliceIndex(arg1: *mut PyObject, arg2: *mut Py_ssize_t)
-> c_int;
}
#[cfg(py_sys_config="WITH_THREAD")]
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub fn PyEval_ThreadsInitialized() -> c_int;
pub fn PyEval_InitThreads();
pub fn PyEval_AcquireLock();
pub fn PyEval_ReleaseLock();
pub fn PyEval_AcquireThread(tstate: *mut PyThreadState);
pub fn PyEval_ReleaseThread(tstate: *mut PyThreadState);
pub fn PyEval_ReInitThreads();
}

View File

@ -1,109 +0,0 @@
use libc::c_int;
use pyport::Py_ssize_t;
use object::*;
#[repr(C)]
#[derive(Copy, Clone)]
pub struct PyClassObject {
#[cfg(py_sys_config="Py_TRACE_REFS")]
pub _ob_next: *mut PyObject,
#[cfg(py_sys_config="Py_TRACE_REFS")]
pub _ob_prev: *mut PyObject,
pub ob_refcnt: Py_ssize_t,
pub ob_type: *mut PyTypeObject,
pub cl_bases: *mut PyObject,
pub cl_dict: *mut PyObject,
pub cl_name: *mut PyObject,
pub cl_getattr: *mut PyObject,
pub cl_setattr: *mut PyObject,
pub cl_delattr: *mut PyObject,
pub cl_weakreflist: *mut PyObject,
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct PyInstanceObject {
#[cfg(py_sys_config="Py_TRACE_REFS")]
pub _ob_next: *mut PyObject,
#[cfg(py_sys_config="Py_TRACE_REFS")]
pub _ob_prev: *mut PyObject,
pub ob_refcnt: Py_ssize_t,
pub ob_type: *mut PyTypeObject,
pub in_class: *mut PyClassObject,
pub in_dict: *mut PyObject,
pub in_weakreflist: *mut PyObject,
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct PyMethodObject {
#[cfg(py_sys_config="Py_TRACE_REFS")]
pub _ob_next: *mut PyObject,
#[cfg(py_sys_config="Py_TRACE_REFS")]
pub _ob_prev: *mut PyObject,
pub ob_refcnt: Py_ssize_t,
pub ob_type: *mut PyTypeObject,
pub im_func: *mut PyObject,
pub im_self: *mut PyObject,
pub im_class: *mut PyObject,
pub im_weakreflist: *mut PyObject,
}
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub static mut PyClass_Type: PyTypeObject;
pub static mut PyInstance_Type: PyTypeObject;
pub static mut PyMethod_Type: PyTypeObject;
}
#[inline(always)]
pub unsafe fn PyClass_Check(op : *mut PyObject) -> c_int {
let u : *mut PyTypeObject = &mut PyClass_Type;
(Py_TYPE(op) == u) as c_int
}
#[inline(always)]
pub unsafe fn PyInstance_Check(op : *mut PyObject) -> c_int {
let u : *mut PyTypeObject = &mut PyInstance_Type;
(Py_TYPE(op) == u) as c_int
}
#[inline(always)]
pub unsafe fn PyMethod_Check(op : *mut PyObject) -> c_int {
let u : *mut PyTypeObject = &mut PyMethod_Type;
(Py_TYPE(op) == u) as c_int
}
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub fn PyClass_New(arg1: *mut PyObject, arg2: *mut PyObject,
arg3: *mut PyObject) -> *mut PyObject;
pub fn PyInstance_New(arg1: *mut PyObject, arg2: *mut PyObject,
arg3: *mut PyObject) -> *mut PyObject;
pub fn PyInstance_NewRaw(arg1: *mut PyObject, arg2: *mut PyObject)
-> *mut PyObject;
pub fn PyMethod_New(arg1: *mut PyObject, arg2: *mut PyObject,
arg3: *mut PyObject) -> *mut PyObject;
pub fn PyMethod_Function(arg1: *mut PyObject) -> *mut PyObject;
pub fn PyMethod_Self(arg1: *mut PyObject) -> *mut PyObject;
pub fn PyMethod_Class(arg1: *mut PyObject) -> *mut PyObject;
fn _PyInstance_Lookup(pinst: *mut PyObject, name: *mut PyObject)
-> *mut PyObject;
pub fn PyClass_IsSubclass(arg1: *mut PyObject, arg2: *mut PyObject)
-> c_int;
pub fn PyMethod_ClearFreeList() -> c_int;
}
#[inline(always)]
pub unsafe fn PyMethod_GET_FUNCTION(meth : *mut PyObject) -> *mut PyObject {
(*(meth as *mut PyMethodObject)).im_func
}
#[inline(always)]
pub unsafe fn PyMethod_GET_SELF(meth : *mut PyObject) -> *mut PyObject {
(*(meth as *mut PyMethodObject)).im_self
}
#[inline(always)]
pub unsafe fn PyMethod_GET_CLASS(meth : *mut PyObject) -> *mut PyObject {
(*(meth as *mut PyMethodObject)).im_class
}

View File

@ -1,37 +0,0 @@
use libc::{c_void, c_char, c_int};
use object::*;
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub static mut PyCObject_Type: PyTypeObject;
}
#[inline(always)]
pub unsafe fn PyCObject_Check(op : *mut PyObject) -> c_int {
(Py_TYPE(op) == &mut PyCObject_Type) as c_int
}
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub fn PyCObject_FromVoidPtr(cobj: *mut c_void,
destruct:
Option<unsafe extern "C" fn
(arg1:
*mut c_void)>)
-> *mut PyObject;
pub fn PyCObject_FromVoidPtrAndDesc(cobj: *mut c_void,
desc: *mut c_void,
destruct:
Option<unsafe extern "C" fn
(arg1:
*mut c_void,
arg2:
*mut c_void)>)
-> *mut PyObject;
pub fn PyCObject_AsVoidPtr(arg1: *mut PyObject) -> *mut c_void;
pub fn PyCObject_GetDesc(arg1: *mut PyObject) -> *mut c_void;
pub fn PyCObject_Import(module_name: *mut c_char,
cobject_name: *mut c_char)
-> *mut c_void;
pub fn PyCObject_SetVoidPtr(_self: *mut PyObject,
cobj: *mut c_void) -> c_int;
}

View File

@ -1,87 +0,0 @@
use libc::{c_char, c_int, c_void};
use pyport::Py_ssize_t;
use object::*;
#[repr(C)]
#[derive(Copy, Clone)]
pub struct PyCodeObject {
#[cfg(py_sys_config="Py_TRACE_REFS")]
pub _ob_next: *mut PyObject,
#[cfg(py_sys_config="Py_TRACE_REFS")]
pub _ob_prev: *mut PyObject,
pub ob_refcnt: Py_ssize_t,
pub ob_type: *mut PyTypeObject,
pub co_argcount: c_int,
pub co_nlocals: c_int,
pub co_stacksize: c_int,
pub co_flags: c_int,
pub co_code: *mut PyObject,
pub co_consts: *mut PyObject,
pub co_names: *mut PyObject,
pub co_varnames: *mut PyObject,
pub co_freevars: *mut PyObject,
pub co_cellvars: *mut PyObject,
pub co_filename: *mut PyObject,
pub co_name: *mut PyObject,
pub co_firstlineno: c_int,
pub co_lnotab: *mut PyObject,
pub co_zombieframe: *mut c_void,
pub co_weakreflist: *mut PyObject,
}
/* Masks for co_flags */
pub const CO_OPTIMIZED : c_int = 0x0001;
pub const CO_NEWLOCALS : c_int = 0x0002;
pub const CO_VARARGS : c_int = 0x0004;
pub const CO_VARKEYWORDS : c_int = 0x0008;
pub const CO_NESTED : c_int = 0x0010;
pub const CO_GENERATOR : c_int = 0x0020;
/* The CO_NOFREE flag is set if there are no free or cell variables.
This information is redundant, but it allows a single flag test
to determine whether there is any extra work to be done when the
call frame it setup.
*/
pub const CO_NOFREE : c_int = 0x0040;
pub const CO_FUTURE_DIVISION : c_int = 0x2000;
pub const CO_FUTURE_ABSOLUTE_IMPORT : c_int = 0x4000; /* do absolute imports by default */
pub const CO_FUTURE_WITH_STATEMENT : c_int = 0x8000;
pub const CO_FUTURE_PRINT_FUNCTION : c_int = 0x10000;
pub const CO_FUTURE_UNICODE_LITERALS : c_int = 0x20000;
pub const CO_MAXBLOCKS : usize = 20;
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub static mut PyCode_Type: PyTypeObject;
pub fn PyCode_New(arg1: c_int, arg2: c_int,
arg3: c_int, arg4: c_int,
arg5: *mut PyObject, arg6: *mut PyObject,
arg7: *mut PyObject, arg8: *mut PyObject,
arg9: *mut PyObject, arg10: *mut PyObject,
arg11: *mut PyObject, arg12: *mut PyObject,
arg13: c_int, arg14: *mut PyObject)
-> *mut PyCodeObject;
pub fn PyCode_NewEmpty(filename: *const c_char,
funcname: *const c_char,
firstlineno: c_int) -> *mut PyCodeObject;
pub fn PyCode_Addr2Line(arg1: *mut PyCodeObject, arg2: c_int)
-> c_int;
//fn _PyCode_CheckLineNumber(co: *mut PyCodeObject,
// lasti: c_int,
// bounds: *mut PyAddrPair) -> c_int;
pub fn PyCode_Optimize(code: *mut PyObject, consts: *mut PyObject,
names: *mut PyObject, lineno_obj: *mut PyObject)
-> *mut PyObject;
}
#[inline(always)]
pub unsafe fn PyCode_Check(op : *mut PyObject) -> c_int {
(Py_TYPE(op) == &mut PyCode_Type) as c_int
}
#[inline]
pub unsafe fn PyCode_GetNumFree(op : *mut PyCodeObject) -> Py_ssize_t {
::tupleobject::PyTuple_GET_SIZE((*op).co_freevars)
}

View File

@ -1,31 +0,0 @@
use libc::{c_char, c_int};
use pythonrun::*;
use code::*;
use pyarena::PyArena;
#[repr(C)]
#[derive(Copy, Clone)]
pub struct PyFutureFeatures {
pub ff_features: c_int,
pub ff_lineno: c_int,
}
pub const FUTURE_NESTED_SCOPES : &'static str = "nested_scopes";
pub const FUTURE_GENERATORS : &'static str = "generators";
pub const FUTURE_DIVISION : &'static str = "division";
pub const FUTURE_ABSOLUTE_IMPORT : &'static str = "absolute_import";
pub const FUTURE_WITH_STATEMENT : &'static str = "with_statement";
pub const FUTURE_PRINT_FUNCTION : &'static str = "print_function";
pub const FUTURE_UNICODE_LITERALS : &'static str = "unicode_literals";
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub fn PyNode_Compile(arg1: *mut Struct__node,
arg2: *const c_char) -> *mut PyCodeObject;
pub fn PyAST_Compile(arg1: *mut Struct__mod, arg2: *const c_char,
arg3: *mut PyCompilerFlags, arg4: *mut PyArena)
-> *mut PyCodeObject;
pub fn PyFuture_FromAST(arg1: *mut Struct__mod,
arg2: *const c_char)
-> *mut PyFutureFeatures;
}

View File

@ -1,63 +0,0 @@
use libc::{c_double, c_int};
use pyport::Py_ssize_t;
use object::*;
#[repr(C)]
#[derive(Copy, Clone)]
pub struct Py_complex {
pub real: c_double,
pub imag: c_double
}
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub fn _Py_c_sum(left: Py_complex, right: Py_complex) -> Py_complex;
pub fn _Py_c_diff(left: Py_complex, right: Py_complex) -> Py_complex;
pub fn _Py_c_neg(complex: Py_complex) -> Py_complex;
pub fn _Py_c_prod(left: Py_complex, right: Py_complex) -> Py_complex;
pub fn _Py_c_quot(dividend: Py_complex, divisor: Py_complex) -> Py_complex;
pub fn _Py_c_pow(num: Py_complex, exp: Py_complex) -> Py_complex;
pub fn _Py_c_abs(arg: Py_complex) -> c_double;
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct PyComplexObject {
#[cfg(py_sys_config="Py_TRACE_REFS")]
pub _ob_next: *mut PyObject,
#[cfg(py_sys_config="Py_TRACE_REFS")]
pub _ob_prev: *mut PyObject,
pub ob_refcnt: Py_ssize_t,
pub ob_type: *mut PyTypeObject,
pub cval: Py_complex
}
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub static mut PyComplex_Type: PyTypeObject;
}
#[inline(always)]
pub unsafe fn PyComplex_Check(op : *mut PyObject) -> c_int {
PyObject_TypeCheck(op, &mut PyComplex_Type)
}
#[inline(always)]
pub unsafe fn PyComplex_CheckExact(op : *mut PyObject) -> c_int {
let u : *mut PyTypeObject = &mut PyComplex_Type;
(Py_TYPE(op) == u) as c_int
}
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub fn PyComplex_FromCComplex(v: Py_complex) -> *mut PyObject;
pub fn PyComplex_FromDoubles(real: c_double,
imag: c_double) -> *mut PyObject;
pub fn PyComplex_RealAsDouble(op: *mut PyObject) -> c_double;
pub fn PyComplex_ImagAsDouble(op: *mut PyObject) -> c_double;
pub fn PyComplex_AsCComplex(op: *mut PyObject) -> Py_complex;
//fn _PyComplex_FormatAdvanced(obj: *mut PyObject,
// format_spec: *mut c_char,
// format_spec_len: Py_ssize_t)
// -> *mut PyObject;
}

View File

@ -1,90 +0,0 @@
use libc::{c_void, c_char, c_int};
use object::{PyObject, PyTypeObject, Py_TYPE};
use structmember::PyMemberDef;
use methodobject::PyMethodDef;
pub type getter =
unsafe extern "C" fn
(slf: *mut PyObject, closure: *mut c_void)
-> *mut PyObject;
pub type setter =
unsafe extern "C" fn
(slf: *mut PyObject, value: *mut PyObject,
closure: *mut c_void) -> c_int;
#[repr(C)]
#[derive(Copy)]
pub struct PyGetSetDef {
pub name: *mut c_char,
pub get: Option<getter>,
pub set: Option<setter>,
pub doc: *mut c_char,
pub closure: *mut c_void,
}
impl Clone for PyGetSetDef {
#[inline] fn clone(&self) -> PyGetSetDef { *self }
}
pub type wrapperfunc =
unsafe extern "C" fn(slf: *mut PyObject, args: *mut PyObject,
wrapped: *mut c_void) -> *mut PyObject;
pub type wrapperfunc_kwds =
unsafe extern "C" fn(slf: *mut PyObject, args: *mut PyObject,
wrapped: *mut c_void, kwds: *mut PyObject) -> *mut PyObject;
#[repr(C)]
#[derive(Copy)]
pub struct wrapperbase {
pub name: *mut c_char,
pub offset: c_int,
pub function: *mut c_void,
pub wrapper: Option<wrapperfunc>,
pub doc: *mut c_char,
pub flags: c_int,
pub name_strobj: *mut PyObject
}
impl Clone for wrapperbase {
#[inline] fn clone(&self) -> wrapperbase { *self }
}
pub const PyWrapperFlag_KEYWORDS : c_int = 1;
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub static mut PyWrapperDescr_Type: PyTypeObject;
pub static mut PyDictProxy_Type: PyTypeObject;
pub static mut PyGetSetDescr_Type: PyTypeObject;
pub static mut PyMemberDescr_Type: PyTypeObject;
pub static mut PyProperty_Type: PyTypeObject;
pub fn PyDescr_NewMethod(arg1: *mut PyTypeObject, arg2: *mut PyMethodDef)
-> *mut PyObject;
pub fn PyDescr_NewClassMethod(arg1: *mut PyTypeObject,
arg2: *mut PyMethodDef) -> *mut PyObject;
pub fn PyDescr_NewMember(arg1: *mut PyTypeObject,
arg2: *mut PyMemberDef) -> *mut PyObject;
pub fn PyDescr_NewGetSet(arg1: *mut PyTypeObject,
arg2: *mut PyGetSetDef) -> *mut PyObject;
pub fn PyDescr_NewWrapper(arg1: *mut PyTypeObject,
arg2: *mut wrapperbase,
arg3: *mut c_void) -> *mut PyObject;
}
#[inline(always)]
pub unsafe fn PyDescr_IsData(d: *mut PyObject) -> c_int {
(*Py_TYPE(d)).tp_descr_set.is_some() as c_int
}
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
//pub fn PyDictProxy_New(arg1: *mut PyObject) -> *mut PyObject;
// PyDictProxy_New is also defined in dictobject.h
pub fn PyWrapper_New(arg1: *mut PyObject, arg2: *mut PyObject)
-> *mut PyObject;
}

View File

@ -1,71 +0,0 @@
use libc::{c_char, c_int};
use pyport::Py_ssize_t;
use object::*;
//pub enum PyDictObject { /* representation hidden */ }
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub static mut PyDict_Type: PyTypeObject;
pub static mut PyDictIterKey_Type: PyTypeObject;
pub static mut PyDictIterValue_Type: PyTypeObject;
pub static mut PyDictIterItem_Type: PyTypeObject;
pub static mut PyDictKeys_Type: PyTypeObject;
pub static mut PyDictItems_Type: PyTypeObject;
pub static mut PyDictValues_Type: PyTypeObject;
}
#[inline(always)]
pub unsafe fn PyDict_Check(op : *mut PyObject) -> c_int {
PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_DICT_SUBCLASS)
}
#[inline(always)]
pub unsafe fn PyDict_CheckExact(op : *mut PyObject) -> c_int {
let u : *mut PyTypeObject = &mut PyDict_Type;
(Py_TYPE(op) == u) as c_int
}
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub fn PyDict_New() -> *mut PyObject;
pub fn PyDictProxy_New(dict: *mut PyObject) -> *mut PyObject;
pub fn PyDict_Clear(mp: *mut PyObject);
pub fn PyDict_Contains(mp: *mut PyObject, key: *mut PyObject)
-> c_int;
pub fn PyDict_Copy(mp: *mut PyObject) -> *mut PyObject;
pub fn PyDict_GetItem(mp: *mut PyObject, key: *mut PyObject)
-> *mut PyObject;
pub fn PyDict_SetItem(mp: *mut PyObject, key: *mut PyObject,
item: *mut PyObject) -> c_int;
pub fn PyDict_DelItem(mp: *mut PyObject, key: *mut PyObject)
-> c_int;
pub fn PyDict_GetItemString(dp: *mut PyObject, key: *const c_char)
-> *mut PyObject;
pub fn PyDict_SetItemString(dp: *mut PyObject, key: *const c_char,
item: *mut PyObject) -> c_int;
pub fn PyDict_DelItemString(dp: *mut PyObject, key: *const c_char)
-> c_int;
pub fn PyDict_Keys(mp: *mut PyObject) -> *mut PyObject;
pub fn PyDict_Values(mp: *mut PyObject) -> *mut PyObject;
pub fn PyDict_Items(mp: *mut PyObject) -> *mut PyObject;
pub fn PyDict_Size(mp: *mut PyObject) -> Py_ssize_t;
pub fn PyDict_Next(mp: *mut PyObject, pos: *mut Py_ssize_t,
key: *mut *mut PyObject, value: *mut *mut PyObject)
-> c_int;
/*pub fn _PyDict_Next(mp: *mut PyObject, pos: *mut Py_ssize_t,
key: *mut *mut PyObject, value: *mut *mut PyObject,
hash: *mut c_long) -> c_int;
pub fn _PyDict_Contains(mp: *mut PyObject, key: *mut PyObject,
hash: c_long) -> c_int;
pub fn _PyDict_NewPresized(minused: Py_ssize_t) -> *mut PyObject;
pub fn _PyDict_MaybeUntrack(mp: *mut PyObject);*/
pub fn PyDict_Update(mp: *mut PyObject, other: *mut PyObject)
-> c_int;
pub fn PyDict_Merge(mp: *mut PyObject, other: *mut PyObject,
_override: c_int) -> c_int;
pub fn PyDict_MergeFromSeq2(d: *mut PyObject, seq2: *mut PyObject,
_override: c_int) -> c_int;
}

View File

@ -1,7 +0,0 @@
use object::PyTypeObject;
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub static mut PyEnum_Type: PyTypeObject;
pub static mut PyReversed_Type: PyTypeObject;
}

View File

@ -1,17 +0,0 @@
use libc::c_int;
use object::PyObject;
use code::PyCodeObject;
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub fn PyEval_EvalCode(arg1: *mut PyCodeObject, arg2: *mut PyObject,
arg3: *mut PyObject) -> *mut PyObject;
pub fn PyEval_EvalCodeEx(co: *mut PyCodeObject, globals: *mut PyObject,
locals: *mut PyObject, args: *mut *mut PyObject,
argc: c_int, kwds: *mut *mut PyObject,
kwdc: c_int, defs: *mut *mut PyObject,
defc: c_int, closure: *mut PyObject)
-> *mut PyObject;
fn _PyEval_CallTracing(func: *mut PyObject, args: *mut PyObject)
-> *mut PyObject;
}

View File

@ -1,61 +0,0 @@
use libc::{c_char, c_int, size_t, FILE};
use object::*;
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub static mut PyFile_Type: PyTypeObject;
}
#[inline(always)]
pub unsafe fn PyFile_Check(op : *mut PyObject) -> c_int {
PyObject_TypeCheck(op, &mut PyFile_Type)
}
#[inline(always)]
pub unsafe fn PyFile_CheckExact(op : *mut PyObject) -> c_int {
(Py_TYPE(op) == &mut PyFile_Type) as c_int
}
pub const PY_STDIOTEXTMODE : &'static str = "b";
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub fn PyFile_FromString(arg1: *mut c_char,
arg2: *mut c_char) -> *mut PyObject;
pub fn PyFile_SetBufSize(arg1: *mut PyObject, arg2: c_int);
pub fn PyFile_SetEncoding(arg1: *mut PyObject,
arg2: *const c_char) -> c_int;
pub fn PyFile_SetEncodingAndErrors(arg1: *mut PyObject,
arg2: *const c_char,
errors: *mut c_char)
-> c_int;
pub fn PyFile_FromFile(arg1: *mut FILE, arg2: *mut c_char,
arg3: *mut c_char,
arg4:
Option<unsafe extern "C" fn
(arg1: *mut FILE)
-> c_int>)
-> *mut PyObject;
pub fn PyFile_AsFile(arg1: *mut PyObject) -> *mut FILE;
//pub fn PyFile_IncUseCount(arg1: *mut PyFileObject);
//pub fn PyFile_DecUseCount(arg1: *mut PyFileObject);
pub fn PyFile_Name(arg1: *mut PyObject) -> *mut PyObject;
pub fn PyFile_GetLine(arg1: *mut PyObject, arg2: c_int)
-> *mut PyObject;
pub fn PyFile_WriteObject(arg1: *mut PyObject, arg2: *mut PyObject,
arg3: c_int) -> c_int;
pub fn PyFile_SoftSpace(arg1: *mut PyObject, arg2: c_int)
-> c_int;
pub fn PyFile_WriteString(arg1: *const c_char,
arg2: *mut PyObject) -> c_int;
pub fn PyObject_AsFileDescriptor(arg1: *mut PyObject) -> c_int;
pub fn Py_UniversalNewlineFgets(arg1: *mut c_char,
arg2: c_int, arg3: *mut FILE,
arg4: *mut PyObject)
-> *mut c_char;
pub fn Py_UniversalNewlineFread(arg1: *mut c_char, arg2: size_t,
arg3: *mut FILE, arg4: *mut PyObject)
-> size_t;
pub static mut Py_FileSystemDefaultEncoding: *const c_char;
}

View File

@ -1,50 +0,0 @@
use libc::{c_char, c_int, c_double};
use pyport::Py_ssize_t;
use object::*;
#[repr(C)]
#[derive(Copy, Clone)]
struct PyFloatObject {
#[cfg(py_sys_config="Py_TRACE_REFS")]
pub _ob_next: *mut PyObject,
#[cfg(py_sys_config="Py_TRACE_REFS")]
pub _ob_prev: *mut PyObject,
pub ob_refcnt: Py_ssize_t,
pub ob_type: *mut PyTypeObject,
pub ob_fval: c_double
}
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub static mut PyFloat_Type: PyTypeObject;
}
#[inline(always)]
pub unsafe fn PyFloat_Check(op : *mut PyObject) -> c_int {
PyObject_TypeCheck(op, &mut PyFloat_Type)
}
#[inline(always)]
pub unsafe fn PyFloat_CheckExact(op : *mut PyObject) -> c_int {
let u : *mut PyTypeObject = &mut PyFloat_Type;
(Py_TYPE(op) == u) as c_int
}
pub const PyFloat_STR_PRECISION : c_int = 12;
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub fn PyFloat_FromString(str: *mut PyObject,
pend: *mut *mut c_char)
-> *mut PyObject;
pub fn PyFloat_FromDouble(v: c_double) -> *mut PyObject;
pub fn PyFloat_AsDouble(pyfloat: *mut PyObject) -> c_double;
pub fn PyFloat_GetInfo() -> *mut PyObject;
pub fn PyFloat_GetMax() -> c_double;
pub fn PyFloat_GetMin() -> c_double;
pub fn PyFloat_ClearFreeList() -> c_int;
}
pub unsafe fn PyFloat_AS_DOUBLE(pyfloat: *mut PyObject) -> c_double {
(*(pyfloat as *mut PyFloatObject)).ob_fval
}

View File

@ -1,82 +0,0 @@
use libc::c_int;
use object::*;
use pyport::Py_ssize_t;
use code::{PyCodeObject, CO_MAXBLOCKS};
use pystate::PyThreadState;
#[repr(C)]
#[derive(Copy, Clone)]
pub struct PyTryBlock {
pub b_type : c_int,
pub b_handler : c_int,
pub b_level : c_int,
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct PyFrameObject {
#[cfg(py_sys_config="Py_TRACE_REFS")]
pub _ob_next: *mut PyObject,
#[cfg(py_sys_config="Py_TRACE_REFS")]
pub _ob_prev: *mut PyObject,
pub ob_refcnt: Py_ssize_t,
pub ob_type: *mut PyTypeObject,
pub ob_size: Py_ssize_t,
pub f_back: *mut PyFrameObject, /* previous frame, or NULL */
pub f_code: *mut PyCodeObject, /* code segment */
pub f_builtins: *mut PyObject, /* builtin symbol table (PyDictObject) */
pub f_globals: *mut PyObject, /* global symbol table (PyDictObject) */
pub f_locals: *mut PyObject, /* local symbol table (any mapping) */
pub f_valuestack: *mut *mut PyObject, /* points after the last local */
/* Next free slot in f_valuestack. Frame creation sets to f_valuestack.
Frame evaluation usually NULLs it, but a frame that yields sets it
to the current stack top. */
pub f_stacktop: *mut *mut PyObject,
pub f_trace: *mut PyObject, /* Trace function */
pub f_exc_type: *mut PyObject,
pub f_exc_value: *mut PyObject,
pub f_exc_traceback: *mut PyObject,
pub f_tstate: *mut PyThreadState,
pub f_lasti: c_int, /* Last instruction if called */
/* Call PyFrame_GetLineNumber() instead of reading this field
directly. As of 2.3 f_lineno is only valid when tracing is
active (i.e. when f_trace is set). At other times we use
PyCode_Addr2Line to calculate the line from the current
bytecode index. */
pub f_lineno: c_int, /* Current line number */
pub f_iblock: c_int, /* index in f_blockstack */
pub f_blockstack: [PyTryBlock; CO_MAXBLOCKS], /* for try and loop blocks */
pub f_localsplus: [*mut PyObject; 1] /* locals+stack, dynamically sized */
}
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub static mut PyFrame_Type: PyTypeObject;
}
#[inline]
pub unsafe fn PyFrame_Check(op: *mut PyObject) -> c_int {
((*op).ob_type == &mut PyFrame_Type) as c_int
}
//#[inline]
//pub unsafe fn PyFrame_IsRestricted(f: *mut PyFrameObject) -> c_int {
// ((*f).f_builtins != (*(*(*f).f_tstate).interp).builtins) as c_int
//}
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub fn PyFrame_New(tstate: *mut PyThreadState, code: *mut PyCodeObject,
globals: *mut PyObject, locals: *mut PyObject) -> *mut PyFrameObject;
pub fn PyFrame_BlockSetup(f: *mut PyFrameObject, _type: c_int, handler: c_int, level: c_int) -> ();
pub fn PyFrame_BlockPop(f: *mut PyFrameObject) -> *mut PyTryBlock;
pub fn PyFrame_LocalsToFast(f: *mut PyFrameObject, clear: c_int) -> ();
pub fn PyFrame_FastToLocals(f: *mut PyFrameObject) -> ();
pub fn PyFrame_ClearFreeList() -> c_int;
pub fn PyFrame_GetLineNumber(f: *mut PyFrameObject) -> c_int;
}

View File

@ -1,34 +0,0 @@
use libc::c_int;
use object::*;
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub static mut PyFunction_Type: PyTypeObject;
}
#[inline(always)]
pub unsafe fn PyFunction_Check(op : *mut PyObject) -> c_int {
let u : *mut PyTypeObject = &mut PyFunction_Type;
(Py_TYPE(op) == u) as c_int
}
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub fn PyFunction_New(code: *mut PyObject, globals: *mut PyObject)
-> *mut PyObject;
pub fn PyFunction_GetCode(f: *mut PyObject) -> *mut PyObject;
pub fn PyFunction_GetGlobals(f: *mut PyObject) -> *mut PyObject;
pub fn PyFunction_GetModule(f: *mut PyObject) -> *mut PyObject;
pub fn PyFunction_GetDefaults(f: *mut PyObject) -> *mut PyObject;
pub fn PyFunction_SetDefaults(f: *mut PyObject, defaults: *mut PyObject)
-> c_int;
pub fn PyFunction_GetClosure(f: *mut PyObject) -> *mut PyObject;
pub fn PyFunction_SetClosure(f: *mut PyObject, closure: *mut PyObject)
-> c_int;
pub static mut PyClassMethod_Type: PyTypeObject;
pub static mut PyStaticMethod_Type: PyTypeObject;
pub fn PyClassMethod_New(arg1: *mut PyObject) -> *mut PyObject;
pub fn PyStaticMethod_New(arg1: *mut PyObject) -> *mut PyObject;
}

View File

@ -1,39 +0,0 @@
use libc::c_int;
use pyport::Py_ssize_t;
use object::*;
use frameobject::PyFrameObject;
#[repr(C)]
#[derive(Copy, Clone)]
pub struct PyGenObject {
#[cfg(py_sys_config="Py_TRACE_REFS")]
pub _ob_next: *mut PyObject,
#[cfg(py_sys_config="Py_TRACE_REFS")]
pub _ob_prev: *mut PyObject,
pub ob_refcnt: Py_ssize_t,
pub ob_type: *mut PyTypeObject,
pub gi_frame: *mut PyFrameObject,
pub gi_running: c_int,
pub gi_code: *mut PyObject,
pub gi_weakreflist: *mut PyObject
}
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub static mut PyGen_Type: PyTypeObject;
}
#[inline(always)]
pub unsafe fn PyGen_Check(op: *mut PyObject) -> c_int {
PyObject_TypeCheck(op, &mut PyGen_Type)
}
#[inline(always)]
pub unsafe fn PyGen_CheckExact(op: *mut PyObject) -> c_int {
(Py_TYPE(op) == &mut PyGen_Type) as c_int
}
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub fn PyGen_New(frame: *mut PyFrameObject) -> *mut PyObject;
pub fn PyGen_NeedsFinalizing(op: *mut PyGenObject) -> c_int;
}

View File

@ -1,86 +0,0 @@
use libc::{c_char, c_uchar, c_int, c_long};
use object::*;
#[repr(C)]
#[derive(Copy)]
pub struct PyImport_Struct_inittab {
pub name: *mut c_char,
pub initfunc: Option<unsafe extern "C" fn()>,
}
impl Clone for PyImport_Struct_inittab {
#[inline] fn clone(&self) -> PyImport_Struct_inittab { *self }
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct PyImport_Struct_frozen {
pub name: *mut c_char,
pub code: *mut c_uchar,
pub size: c_int,
}
#[inline]
pub unsafe fn PyImport_ImportModuleEx(name: *mut c_char,
globals: *mut PyObject,
locals: *mut PyObject,
fromlist: *mut PyObject) -> *mut PyObject {
PyImport_ImportModuleLevel(name, globals, locals, fromlist, -1)
}
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub fn PyImport_ImportModule(name: *const c_char)
-> *mut PyObject;
pub fn PyImport_ImportModuleNoBlock(name: *const c_char)
-> *mut PyObject;
pub fn PyImport_ImportModuleLevel(name: *mut c_char,
globals: *mut PyObject,
locals: *mut PyObject,
fromlist: *mut PyObject,
level: c_int) -> *mut PyObject;
pub fn PyImport_Import(name: *mut PyObject) -> *mut PyObject;
pub fn PyImport_ReloadModule(m: *mut PyObject) -> *mut PyObject;
pub fn PyImport_AddModule(name: *const c_char) -> *mut PyObject;
pub fn PyImport_ExecCodeModule(name: *mut c_char,
co: *mut PyObject) -> *mut PyObject;
pub fn PyImport_ExecCodeModuleEx(name: *mut c_char,
co: *mut PyObject,
pathname: *mut c_char)
-> *mut PyObject;
pub fn PyImport_GetMagicNumber() -> c_long;
pub fn PyImport_GetImporter(path: *mut PyObject) -> *mut PyObject;
pub fn PyImport_GetModuleDict() -> *mut PyObject;
pub fn PyImport_ImportFrozenModule(name: *mut c_char)
-> c_int;
pub fn PyImport_AppendInittab(name: *const c_char,
initfunc:
Option<unsafe extern "C" fn()>)
-> c_int;
pub fn PyImport_ExtendInittab(newtab: *mut PyImport_Struct_inittab)
-> c_int;
pub static mut PyImport_Inittab: *mut PyImport_Struct_inittab;
pub static mut PyImport_FrozenModules: *mut PyImport_Struct_frozen;
/*for internal use only:
pub fn PyImport_Cleanup();
pub fn _PyImport_AcquireLock();
pub fn _PyImport_ReleaseLock() -> c_int;
pub fn _PyImport_FindModule(arg1: *const c_char,
arg2: *mut PyObject,
arg3: *mut c_char, arg4: size_t,
arg5: *mut *mut FILE,
arg6: *mut *mut PyObject)
-> *mut Struct_filedescr;
pub fn _PyImport_IsScript(arg1: *mut Struct_filedescr) -> c_int;
pub fn _PyImport_ReInitLock();
pub fn _PyImport_FindExtension(arg1: *mut c_char,
arg2: *mut c_char)
-> *mut PyObject;
pub fn _PyImport_FixupExtension(arg1: *mut c_char,
arg2: *mut c_char)
-> *mut PyObject;*/
}

View File

@ -1,67 +0,0 @@
use libc::{c_char, c_int, c_long, c_ulong, c_ulonglong, size_t};
use pyport::Py_ssize_t;
use object::*;
#[repr(C)]
#[derive(Copy, Clone)]
pub struct PyIntObject {
#[cfg(py_sys_config="Py_TRACE_REFS")]
pub _ob_next: *mut PyObject,
#[cfg(py_sys_config="Py_TRACE_REFS")]
pub _ob_prev: *mut PyObject,
pub ob_refcnt: Py_ssize_t,
pub ob_type: *mut PyTypeObject,
pub ob_ival: c_long
}
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub static mut PyInt_Type: PyTypeObject;
}
#[inline(always)]
pub unsafe fn PyInt_Check(op : *mut PyObject) -> c_int {
PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_INT_SUBCLASS)
}
#[inline(always)]
pub unsafe fn PyInt_CheckExact(op : *mut PyObject) -> c_int {
let u : *mut PyTypeObject = &mut PyInt_Type;
(Py_TYPE(op) == u) as c_int
}
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub fn PyInt_FromString(str: *mut c_char,
pend: *mut *mut c_char,
base: c_int) -> *mut PyObject;
#[cfg(py_sys_config="Py_USING_UNICODE")]
pub fn PyInt_FromUnicode(u: *mut ::unicodeobject::Py_UNICODE, length: Py_ssize_t,
base: c_int) -> *mut PyObject;
pub fn PyInt_FromLong(ival: c_long) -> *mut PyObject;
pub fn PyInt_FromSize_t(ival: size_t) -> *mut PyObject;
pub fn PyInt_FromSsize_t(ival: Py_ssize_t) -> *mut PyObject;
pub fn PyInt_AsLong(io: *mut PyObject) -> c_long;
pub fn PyInt_AsSsize_t(io: *mut PyObject) -> Py_ssize_t;
fn _PyInt_AsInt(io: *mut PyObject) -> c_int;
pub fn PyInt_AsUnsignedLongMask(io: *mut PyObject) -> c_ulong;
pub fn PyInt_AsUnsignedLongLongMask(io: *mut PyObject)
-> c_ulonglong;
pub fn PyInt_GetMax() -> c_long;
//fn PyOS_strtoul(arg1: *mut c_char,
// arg2: *mut *mut c_char, arg3: c_int)
// -> c_ulong;
//fn PyOS_strtol(arg1: *mut c_char,
// arg2: *mut *mut c_char, arg3: c_int)
// -> c_long;
pub fn PyInt_ClearFreeList() -> c_int;
//fn _PyInt_Format(v: *mut PyIntObject, base: c_int,
// newstyle: c_int) -> *mut PyObject;
//fn _PyInt_FormatAdvanced(obj: *mut PyObject,
// format_spec: *mut c_char,
// format_spec_len: Py_ssize_t)
// -> *mut PyObject;
}
pub unsafe fn PyInt_AS_LONG(io: *mut PyObject) -> c_long {
(*(io as *mut PyIntObject)).ob_ival
}

View File

@ -1,23 +0,0 @@
use libc::c_int;
use object::*;
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub static mut PySeqIter_Type: PyTypeObject;
pub static mut PyCallIter_Type: PyTypeObject;
pub fn PySeqIter_New(arg1: *mut PyObject) -> *mut PyObject;
pub fn PyCallIter_New(arg1: *mut PyObject, arg2: *mut PyObject)
-> *mut PyObject;
}
#[inline(always)]
pub unsafe fn PySeqIter_Check(op: *mut PyObject) -> c_int {
(Py_TYPE(op) == &mut PySeqIter_Type) as c_int
}
#[inline(always)]
pub unsafe fn PyCallIter_Check(op: *mut PyObject) -> c_int {
(Py_TYPE(op) == &mut PyCallIter_Type) as c_int
}

View File

@ -1,140 +0,0 @@
#![no_std]
#![allow(non_camel_case_types, non_upper_case_globals, non_snake_case)]
extern crate libc;
pub use pyport::*;
pub use pymem::*;
pub use object::*;
pub use objimpl::*;
pub use pydebug::*;
#[cfg(py_sys_config="Py_USING_UNICODE")]
pub use unicodeobject::*;
pub use intobject::*;
pub use boolobject::*;
pub use longobject::*;
pub use floatobject::*;
pub use complexobject::*;
pub use rangeobject::*;
pub use memoryobject::*;
pub use bufferobject::*;
pub use stringobject::*;
pub use bytesobject::*;
pub use bytearrayobject::*;
pub use tupleobject::*;
pub use listobject::*;
pub use dictobject::*;
pub use enumobject::*;
pub use setobject::*;
pub use pyerrors::*;
pub use pystate::*;
pub use pystate::PyGILState_STATE::*;
pub use methodobject::*;
pub use moduleobject::*;
pub use funcobject::*;
pub use classobject::*;
pub use fileobject::*;
pub use cobject::*;
pub use pycapsule::*;
pub use traceback::*;
pub use sliceobject::*;
pub use cellobject::*;
pub use iterobject::*;
pub use genobject::*;
pub use descrobject::*;
pub use warnings::*;
pub use weakrefobject::*;
pub use pyarena::*;
pub use modsupport::*;
pub use pythonrun::*;
pub use ceval::*;
pub use import::*;
pub use objectabstract::*;
pub use code::*;
pub use compile::*;
pub use eval::*;
pub use structmember::PyMemberDef;
pub use frameobject::PyFrameObject;
mod pyport;
mod pymem;
mod object;
mod objimpl;
mod pydebug;
#[cfg(py_sys_config="Py_USING_UNICODE")]
mod unicodeobject; // TODO: incomplete
mod intobject;
mod boolobject;
mod longobject;
mod floatobject;
mod complexobject;
mod rangeobject;
mod stringobject;
mod memoryobject;
mod bufferobject;
mod bytesobject;
mod bytearrayobject;
mod tupleobject;
mod listobject;
mod dictobject;
mod enumobject;
mod setobject;
mod methodobject;
mod moduleobject;
mod funcobject;
mod classobject;
mod fileobject;
mod cobject;
mod pycapsule;
mod traceback;
mod sliceobject;
mod cellobject;
mod iterobject;
mod genobject;
mod descrobject;
mod warnings;
mod weakrefobject;
// mod codecs; // TODO: incomplete
mod pyerrors;
mod pystate;
mod pyarena;
mod modsupport;
mod pythonrun;
mod ceval;
// mod sysmodule; // TODO: incomplete
// mod intrcheck; // TODO: incomplete
mod import;
mod objectabstract;
mod code;
mod compile;
mod eval;
// mod pyctype; // TODO: incomplete
// mod pystrtod; // TODO: incomplete
// mod pystrcmp; // TODO: incomplete
// mod dtoa; // TODO: incomplete
// mod pyfpe; // TODO: incomplete
// Additional headers that are not exported by Python.h
pub mod structmember;
pub mod frameobject;
pub const Py_single_input: libc::c_int = 256;
pub const Py_file_input: libc::c_int = 257;
pub const Py_eval_input: libc::c_int = 258;
#[cfg(not(py_sys_config="Py_USING_UNICODE"))]
#[inline(always)]
pub fn PyUnicode_Check(op : *mut PyObject) -> libc::c_int { 0 }
#[cfg(not(py_sys_config="Py_USING_UNICODE"))]
#[inline(always)]
pub fn PyUnicode_CheckExact(op : *mut PyObject) -> libc::c_int { 0 }

View File

@ -1,74 +0,0 @@
use libc::c_int;
use pyport::Py_ssize_t;
use object::*;
#[repr(C)]
#[derive(Copy, Clone)]
pub struct PyListObject {
#[cfg(py_sys_config="Py_TRACE_REFS")]
pub _ob_next: *mut PyObject,
#[cfg(py_sys_config="Py_TRACE_REFS")]
pub _ob_prev: *mut PyObject,
pub ob_refcnt: Py_ssize_t,
pub ob_type: *mut PyTypeObject,
pub ob_size: Py_ssize_t,
pub ob_item: *mut *mut PyObject,
pub allocated: Py_ssize_t,
}
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub static mut PyList_Type: PyTypeObject;
}
#[inline(always)]
pub unsafe fn PyList_Check(op : *mut PyObject) -> c_int {
PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_LIST_SUBCLASS)
}
#[inline(always)]
pub unsafe fn PyList_CheckExact(op : *mut PyObject) -> c_int {
let u : *mut PyTypeObject = &mut PyList_Type;
(Py_TYPE(op) == u) as c_int
}
// Macro, trading safety for speed
#[inline(always)]
pub unsafe fn PyList_GET_ITEM(op: *mut PyObject, i: Py_ssize_t) -> *mut PyObject {
*(*(op as *mut PyListObject)).ob_item.offset(i as isize)
}
#[inline(always)]
pub unsafe fn PyList_GET_SIZE(op: *mut PyObject) -> Py_ssize_t {
Py_SIZE(op)
}
/// Macro, *only* to be used to fill in brand new lists
#[inline(always)]
pub unsafe fn PyList_SET_ITEM(op: *mut PyObject, i: Py_ssize_t, v: *mut PyObject) {
*(*(op as *mut PyListObject)).ob_item.offset(i as isize) = v;
}
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub fn PyList_New(size: Py_ssize_t) -> *mut PyObject;
pub fn PyList_Size(list: *mut PyObject) -> Py_ssize_t;
pub fn PyList_GetItem(list: *mut PyObject, index: Py_ssize_t)
-> *mut PyObject;
pub fn PyList_SetItem(list: *mut PyObject, index: Py_ssize_t,
item: *mut PyObject) -> c_int;
pub fn PyList_Insert(list: *mut PyObject, index: Py_ssize_t,
item: *mut PyObject) -> c_int;
pub fn PyList_Append(list: *mut PyObject, item: *mut PyObject)
-> c_int;
pub fn PyList_GetSlice(list: *mut PyObject, low: Py_ssize_t,
high: Py_ssize_t) -> *mut PyObject;
pub fn PyList_SetSlice(list: *mut PyObject, low: Py_ssize_t,
high: Py_ssize_t, itemlist: *mut PyObject)
-> c_int;
pub fn PyList_Sort(list: *mut PyObject) -> c_int;
pub fn PyList_Reverse(list: *mut PyObject) -> c_int;
pub fn PyList_AsTuple(list: *mut PyObject) -> *mut PyObject;
//fn _PyList_Extend(arg1: *mut PyListObject, arg2: *mut PyObject)
//-> *mut PyObject;
}

View File

@ -1,82 +0,0 @@
use libc::{c_void, c_char, c_int, c_long, c_ulong, c_longlong, c_ulonglong, c_double, size_t};
use pyport::Py_ssize_t;
use object::*;
//enum PyLongObject { /* representation hidden */ }
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub static mut PyLong_Type: PyTypeObject;
}
#[inline(always)]
pub unsafe fn PyLong_Check(op : *mut PyObject) -> c_int {
PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_LONG_SUBCLASS)
}
#[inline(always)]
pub unsafe fn PyLong_CheckExact(op : *mut PyObject) -> c_int {
let u : *mut PyTypeObject = &mut PyLong_Type;
(Py_TYPE(op) == u) as c_int
}
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub fn PyLong_FromLong(v: c_long) -> *mut PyObject;
pub fn PyLong_FromUnsignedLong(v: c_ulong) -> *mut PyObject;
pub fn PyLong_FromSsize_t(v: Py_ssize_t) -> *mut PyObject;
pub fn PyLong_FromSize_t(v: size_t) -> *mut PyObject;
pub fn PyLong_FromLongLong(v: c_longlong) -> *mut PyObject;
pub fn PyLong_FromUnsignedLongLong(v: c_ulonglong)
-> *mut PyObject;
pub fn PyLong_FromDouble(v: c_double) -> *mut PyObject;
pub fn PyLong_FromString(str: *mut c_char,
pend: *mut *mut c_char,
base: c_int) -> *mut PyObject;
#[cfg(py_sys_config="Py_USING_UNICODE")]
pub fn PyLong_FromUnicode(u: *mut ::unicodeobject::Py_UNICODE, length: Py_ssize_t,
base: c_int) -> *mut PyObject;
pub fn PyLong_FromVoidPtr(p: *mut c_void) -> *mut PyObject;
pub fn PyLong_AsLong(pylong: *mut PyObject) -> c_long;
pub fn PyLong_AsLongAndOverflow(pylong: *mut PyObject,
overflow: *mut c_int)
-> c_long;
pub fn PyLong_AsLongLongAndOverflow(pylong: *mut PyObject,
overflow: *mut c_int)
-> c_longlong;
pub fn PyLong_AsSsize_t(pylong: *mut PyObject) -> Py_ssize_t;
pub fn PyLong_AsUnsignedLong(pylong: *mut PyObject) -> c_ulong;
pub fn PyLong_AsLongLong(pylong: *mut PyObject) -> c_longlong;
pub fn PyLong_AsUnsignedLongLong(pylong: *mut PyObject)
-> c_ulonglong;
pub fn PyLong_AsUnsignedLongMask(pylong: *mut PyObject) -> c_ulong;
pub fn PyLong_AsUnsignedLongLongMask(pylong: *mut PyObject)
-> c_ulonglong;
pub fn PyLong_AsDouble(pylong: *mut PyObject) -> c_double;
pub fn PyLong_AsVoidPtr(pylong: *mut PyObject) -> *mut c_void;
pub fn PyLong_GetInfo() -> *mut PyObject;
/*
pub fn _PyLong_AsInt(arg1: *mut PyObject) -> c_int;
pub fn _PyLong_Frexp(a: *mut PyLongObject, e: *mut Py_ssize_t)
-> c_double;
pub fn _PyLong_Sign(v: *mut PyObject) -> c_int;
pub fn _PyLong_NumBits(v: *mut PyObject) -> size_t;
pub fn _PyLong_FromByteArray(bytes: *const c_uchar, n: size_t,
little_endian: c_int,
is_signed: c_int) -> *mut PyObject;
pub fn _PyLong_AsByteArray(v: *mut PyLongObject,
bytes: *mut c_uchar, n: size_t,
little_endian: c_int,
is_signed: c_int) -> c_int;
pub fn _PyLong_Format(aa: *mut PyObject, base: c_int,
addL: c_int, newstyle: c_int)
-> *mut PyObject;
pub fn _PyLong_FormatAdvanced(obj: *mut PyObject,
format_spec: *mut c_char,
format_spec_len: Py_ssize_t)
-> *mut PyObject;*/
}

View File

@ -1,46 +0,0 @@
use libc::{c_int, c_char};
use pyport::Py_ssize_t;
use object::*;
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub static mut PyMemoryView_Type: PyTypeObject;
}
#[inline(always)]
pub unsafe fn PyMemoryView_Check(op : *mut PyObject) -> c_int {
let u : *mut PyTypeObject = &mut PyMemoryView_Type;
(Py_TYPE(op) == u) as c_int
}
#[inline(always)]
pub unsafe fn PyMemoryView_GET_BUFFER(op : *mut PyObject) -> *mut Py_buffer {
&mut (*(op as *mut PyMemoryViewObject)).view
}
#[inline(always)]
pub unsafe fn PyMemoryView_GET_BASE(op : *mut PyObject) -> *mut PyObject {
(*(op as *mut PyMemoryViewObject)).view.obj
}
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub fn PyMemoryView_GetContiguous(base: *mut PyObject,
buffertype: c_int,
fort: c_char) -> *mut PyObject;
pub fn PyMemoryView_FromObject(base: *mut PyObject) -> *mut PyObject;
pub fn PyMemoryView_FromBuffer(info: *mut Py_buffer) -> *mut PyObject;
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct PyMemoryViewObject {
#[cfg(py_sys_config="Py_TRACE_REFS")]
pub _ob_next: *mut PyObject,
#[cfg(py_sys_config="Py_TRACE_REFS")]
pub _ob_prev: *mut PyObject,
pub ob_refcnt: Py_ssize_t,
pub ob_type: *mut PyTypeObject,
pub base: *mut PyObject,
pub view: Py_buffer,
}

View File

@ -1,109 +0,0 @@
use libc::{c_char, c_int};
use core::ptr;
//use pyport::Py_ssize_t;
use object::{PyObject, PyTypeObject, Py_TYPE};
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub static mut PyCFunction_Type: PyTypeObject;
}
#[inline(always)]
pub unsafe fn PyCFunction_Check(op : *mut PyObject) -> c_int {
let u : *mut PyTypeObject = &mut PyCFunction_Type;
(Py_TYPE(op) == u) as c_int
}
pub type PyCFunction =
unsafe extern "C" fn
(slf: *mut PyObject, args: *mut PyObject)
-> *mut PyObject;
pub type PyCFunctionWithKeywords =
unsafe extern "C" fn
(slf: *mut PyObject, args: *mut PyObject,
kwds: *mut PyObject) -> *mut PyObject;
pub type PyNoArgsFunction =
unsafe extern "C" fn(slf: *mut PyObject)
-> *mut PyObject;
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub fn PyCFunction_GetFunction(f: *mut PyObject) -> Option<PyCFunction>;
pub fn PyCFunction_GetSelf(f: *mut PyObject) -> *mut PyObject;
pub fn PyCFunction_GetFlags(f: *mut PyObject) -> c_int;
pub fn PyCFunction_Call(f: *mut PyObject, args: *mut PyObject,
kwds: *mut PyObject) -> *mut PyObject;
}
#[repr(C)]
#[derive(Copy)]
pub struct PyMethodDef {
pub ml_name: *const c_char,
pub ml_meth: Option<PyCFunction>,
pub ml_flags: c_int,
pub ml_doc: *const c_char,
}
impl Clone for PyMethodDef {
#[inline] fn clone(&self) -> PyMethodDef { *self }
}
/* Flag passed to newmethodobject */
pub const METH_OLDARGS : c_int = 0x0000;
pub const METH_VARARGS : c_int = 0x0001;
pub const METH_KEYWORDS : c_int = 0x0002;
/* METH_NOARGS and METH_O must not be combined with the flags above. */
pub const METH_NOARGS : c_int = 0x0004;
pub const METH_O : c_int = 0x0008;
/* METH_CLASS and METH_STATIC are a little different; these control
the construction of methods for a class. These cannot be used for
functions in modules. */
pub const METH_CLASS : c_int = 0x0010;
pub const METH_STATIC : c_int = 0x0020;
/* METH_COEXIST allows a method to be entered eventhough a slot has
already filled the entry. When defined, the flag allows a separate
method, "__contains__" for example, to coexist with a defined
slot like sq_contains. */
pub const METH_COEXIST : c_int = 0x0040;
#[repr(C)]
#[derive(Copy, Clone)]
pub struct PyMethodChain {
pub methods: *mut PyMethodDef,
pub link: *mut PyMethodChain,
}
/*
#[repr(C)]
#[derive(Copy)]
struct PyCFunctionObject {
#[cfg(py_sys_config="Py_TRACE_REFS")]
pub _ob_next: *mut PyObject,
#[cfg(py_sys_config="Py_TRACE_REFS")]
pub _ob_prev: *mut PyObject,
pub ob_refcnt: Py_ssize_t,
pub ob_type: *mut PyTypeObject,
pub m_ml: *mut PyMethodDef,
pub m_self: *mut PyObject,
pub m_module: *mut PyObject,
}
*/
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub fn Py_FindMethod(methods: *mut PyMethodDef, slf: *mut PyObject,
name: *const c_char) -> *mut PyObject;
pub fn PyCFunction_NewEx(ml: *mut PyMethodDef, slf: *mut PyObject,
module: *mut PyObject) -> *mut PyObject;
pub fn Py_FindMethodInChain(chain: *mut PyMethodChain, slf: *mut PyObject,
name: *const c_char) -> *mut PyObject;
pub fn PyCFunction_ClearFreeList() -> c_int;
}
#[inline(always)]
pub unsafe fn PyCFunction_New(ml: *mut PyMethodDef, slf: *mut PyObject) -> *mut PyObject {
PyCFunction_NewEx(ml, slf, ptr::null_mut())
}

View File

@ -1,101 +0,0 @@
use libc::{c_char, c_int, c_long};
use core::ptr;
use pyport::Py_ssize_t;
use object::PyObject;
use methodobject::PyMethodDef;
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub fn PyArg_Parse(args: *mut PyObject, format: *const c_char, ...)
-> c_int;
pub fn PyArg_ParseTuple(args: *mut PyObject,
format: *const c_char, ...)
-> c_int;
pub fn PyArg_ParseTupleAndKeywords(args: *mut PyObject,
kw: *mut PyObject,
format: *const c_char,
keywords: *mut *mut c_char, ...)
-> c_int;
pub fn PyArg_UnpackTuple(args: *mut PyObject, name: *const c_char,
min: Py_ssize_t, max: Py_ssize_t, ...)
-> c_int;
pub fn Py_BuildValue(format: *const c_char, ...) -> *mut PyObject;
//fn _Py_BuildValue_SizeT(arg1: *const c_char, ...)
// -> *mut PyObject;
//fn _PyArg_NoKeywords(funcname: *const c_char,
// kw: *mut PyObject) -> c_int;
pub fn PyModule_AddObject(module: *mut PyObject,
name: *const c_char,
value: *mut PyObject) -> c_int;
pub fn PyModule_AddIntConstant(module: *mut PyObject,
name: *const c_char,
value: c_long) -> c_int;
pub fn PyModule_AddStringConstant(module: *mut PyObject,
name: *const c_char,
value: *const c_char)
-> c_int;
#[cfg(all(target_pointer_width = "64", not(py_sys_config = "Py_TRACE_REFS")))]
fn Py_InitModule4_64(name: *const c_char,
methods: *mut PyMethodDef,
doc: *const c_char, _self: *mut PyObject,
apiver: c_int) -> *mut PyObject;
#[cfg(all(target_pointer_width = "64", py_sys_config = "Py_TRACE_REFS"))]
fn Py_InitModule4TraceRefs_64(name: *const c_char,
methods: *mut PyMethodDef,
doc: *const c_char, _self: *mut PyObject,
apiver: c_int) -> *mut PyObject;
#[cfg(all(not(target_pointer_width = "64"), not(py_sys_config = "Py_TRACE_REFS")))]
pub fn Py_InitModule4(name: *const c_char,
methods: *mut PyMethodDef,
doc: *const c_char, _self: *mut PyObject,
apiver: c_int) -> *mut PyObject;
#[cfg(all(not(target_pointer_width = "64"), py_sys_config = "Py_TRACE_REFS"))]
fn Py_InitModule4TraceRefs(name: *const c_char,
methods: *mut PyMethodDef,
doc: *const c_char, _self: *mut PyObject,
apiver: c_int) -> *mut PyObject;
}
pub const PYTHON_API_VERSION : c_int = 1013;
#[cfg(all(target_pointer_width = "64", not(py_sys_config = "Py_TRACE_REFS")))]
#[inline(always)]
pub unsafe fn Py_InitModule4(name: *const c_char,
methods: *mut PyMethodDef,
doc: *const c_char, _self: *mut PyObject,
apiver: c_int) -> *mut PyObject {
Py_InitModule4_64(name, methods, doc, _self, apiver)
}
#[cfg(all(target_pointer_width = "64", py_sys_config = "Py_TRACE_REFS"))]
#[inline(always)]
pub unsafe fn Py_InitModule4(name: *const c_char,
methods: *mut PyMethodDef,
doc: *const c_char, _self: *mut PyObject,
apiver: c_int) -> *mut PyObject {
Py_InitModule4TraceRefs_64(name, methods, doc, _self, apiver)
}
#[cfg(all(not(target_pointer_width = "64"), py_sys_config = "Py_TRACE_REFS"))]
#[inline(always)]
pub unsafe fn Py_InitModule4(name: *const c_char,
methods: *mut PyMethodDef,
doc: *const c_char, _self: *mut PyObject,
apiver: c_int) -> *mut PyObject {
Py_InitModule4TraceRefs(name, methods, doc, _self, apiver)
}
#[inline(always)]
pub unsafe fn Py_InitModule(name: *const c_char, methods: *mut PyMethodDef) -> *mut PyObject {
Py_InitModule4(name, methods, ptr::null(), ptr::null_mut(), PYTHON_API_VERSION)
}
#[inline(always)]
pub unsafe fn Py_InitModule3(name: *const c_char, methods: *mut PyMethodDef, doc : *const c_char) -> *mut PyObject {
Py_InitModule4(name, methods, doc, ptr::null_mut(), PYTHON_API_VERSION)
}

View File

@ -1,24 +0,0 @@
use libc::{c_char, c_int};
use object::*;
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub static mut PyModule_Type: PyTypeObject;
pub fn PyModule_New(name: *const c_char) -> *mut PyObject;
pub fn PyModule_GetDict(module: *mut PyObject) -> *mut PyObject;
pub fn PyModule_GetName(module: *mut PyObject) -> *mut c_char;
pub fn PyModule_GetFilename(module: *mut PyObject) -> *mut c_char;
//fn _PyModule_Clear(arg1: *mut PyObject);
}
#[inline(always)]
pub unsafe fn PyModule_Check(op : *mut PyObject) -> c_int {
PyObject_TypeCheck(op, &mut PyModule_Type)
}
#[inline(always)]
pub unsafe fn PyModule_CheckExact(op : *mut PyObject) -> c_int {
let u : *mut PyTypeObject = &mut PyModule_Type;
(Py_TYPE(op) == u) as c_int
}

View File

@ -1,916 +0,0 @@
use core::ptr;
use libc::{c_void, c_int, c_uint, c_long, c_char, c_double, FILE};
use pyport::Py_ssize_t;
use methodobject::PyMethodDef;
#[repr(C)]
#[derive(Copy, Clone)]
pub struct PyObject {
#[cfg(py_sys_config="Py_TRACE_REFS")]
pub _ob_next: *mut PyObject,
#[cfg(py_sys_config="Py_TRACE_REFS")]
pub _ob_prev: *mut PyObject,
pub ob_refcnt: Py_ssize_t,
pub ob_type: *mut PyTypeObject,
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct PyVarObject {
#[cfg(py_sys_config="Py_TRACE_REFS")]
pub _ob_next: *mut PyObject,
#[cfg(py_sys_config="Py_TRACE_REFS")]
pub _ob_prev: *mut PyObject,
pub ob_refcnt: Py_ssize_t,
pub ob_type: *mut PyTypeObject,
pub ob_size: Py_ssize_t,
}
#[inline(always)]
pub unsafe fn Py_REFCNT(ob : *mut PyObject) -> Py_ssize_t {
(*ob).ob_refcnt
}
#[inline(always)]
pub unsafe fn Py_TYPE(ob : *mut PyObject) -> *mut PyTypeObject {
(*ob).ob_type
}
#[inline(always)]
pub unsafe fn Py_SIZE(ob : *mut PyObject) -> Py_ssize_t {
(*(ob as *mut PyVarObject)).ob_size
}
pub type unaryfunc =
unsafe extern "C" fn(arg1: *mut PyObject)
-> *mut PyObject;
pub type binaryfunc =
unsafe extern "C" fn
(arg1: *mut PyObject, arg2: *mut PyObject)
-> *mut PyObject;
pub type ternaryfunc =
unsafe extern "C" fn
(arg1: *mut PyObject, arg2: *mut PyObject,
arg3: *mut PyObject) -> *mut PyObject;
pub type inquiry =
unsafe extern "C" fn(arg1: *mut PyObject)
-> c_int;
pub type lenfunc =
unsafe extern "C" fn(arg1: *mut PyObject) -> Py_ssize_t;
pub type coercion =
unsafe extern "C" fn
(arg1: *mut *mut PyObject,
arg2: *mut *mut PyObject) -> c_int;
pub type ssizeargfunc =
unsafe extern "C" fn(arg1: *mut PyObject, arg2: Py_ssize_t)
-> *mut PyObject;
pub type ssizessizeargfunc =
unsafe extern "C" fn
(arg1: *mut PyObject, arg2: Py_ssize_t,
arg3: Py_ssize_t) -> *mut PyObject;
pub type intobjargproc =
unsafe extern "C" fn
(arg1: *mut PyObject, arg2: c_int,
arg3: *mut PyObject) -> c_int;
pub type intintobjargproc =
unsafe extern "C" fn
(arg1: *mut PyObject, arg2: c_int,
arg3: c_int, arg4: *mut PyObject)
-> c_int;
pub type ssizeobjargproc =
unsafe extern "C" fn
(arg1: *mut PyObject, arg2: Py_ssize_t,
arg3: *mut PyObject) -> c_int;
pub type ssizessizeobjargproc =
unsafe extern "C" fn
(arg1: *mut PyObject, arg2: Py_ssize_t,
arg3: Py_ssize_t, arg4: *mut PyObject)
-> c_int;
pub type objobjargproc =
unsafe extern "C" fn
(arg1: *mut PyObject, arg2: *mut PyObject,
arg3: *mut PyObject) -> c_int;
pub type getreadbufferproc =
unsafe extern "C" fn
(arg1: *mut PyObject, arg2: c_int,
arg3: *mut *mut c_void)
-> c_int;
pub type getwritebufferproc =
unsafe extern "C" fn
(arg1: *mut PyObject, arg2: c_int,
arg3: *mut *mut c_void)
-> c_int;
pub type getsegcountproc =
unsafe extern "C" fn
(arg1: *mut PyObject, arg2: *mut c_int)
-> c_int;
pub type getcharbufferproc =
unsafe extern "C" fn
(arg1: *mut PyObject, arg2: c_int,
arg3: *mut *mut c_char)
-> c_int;
pub type readbufferproc =
unsafe extern "C" fn
(arg1: *mut PyObject, arg2: Py_ssize_t,
arg3: *mut *mut c_void) -> Py_ssize_t;
pub type writebufferproc =
unsafe extern "C" fn
(arg1: *mut PyObject, arg2: Py_ssize_t,
arg3: *mut *mut c_void) -> Py_ssize_t;
pub type segcountproc =
unsafe extern "C" fn
(arg1: *mut PyObject, arg2: *mut Py_ssize_t)
-> Py_ssize_t;
pub type charbufferproc =
unsafe extern "C" fn
(arg1: *mut PyObject, arg2: Py_ssize_t,
arg3: *mut *mut c_char) -> Py_ssize_t;
#[repr(C)]
#[derive(Copy, Clone)]
pub struct Py_buffer {
pub buf: *mut c_void,
pub obj: *mut PyObject,
pub len: Py_ssize_t,
pub itemsize: Py_ssize_t,
pub readonly: c_int,
pub ndim: c_int,
pub format: *mut c_char,
pub shape: *mut Py_ssize_t,
pub strides: *mut Py_ssize_t,
pub suboffsets: *mut Py_ssize_t,
pub smalltable: [Py_ssize_t; 2],
pub internal: *mut c_void,
}
pub type getbufferproc =
unsafe extern "C" fn
(arg1: *mut PyObject, arg2: *mut Py_buffer,
arg3: c_int) -> c_int;
pub type releasebufferproc =
unsafe extern "C" fn
(arg1: *mut PyObject, arg2: *mut Py_buffer);
// flags:
pub const PyBUF_SIMPLE : c_int = 0;
pub const PyBUF_WRITABLE : c_int = 0x0001;
pub const PyBUF_FORMAT : c_int = 0x0004;
pub const PyBUF_ND : c_int = 0x0008;
pub const PyBUF_STRIDES : c_int = (0x0010 | PyBUF_ND);
pub const PyBUF_C_CONTIGUOUS : c_int = (0x0020 | PyBUF_STRIDES);
pub const PyBUF_F_CONTIGUOUS : c_int = (0x0040 | PyBUF_STRIDES);
pub const PyBUF_ANY_CONTIGUOUS : c_int = (0x0080 | PyBUF_STRIDES);
pub const PyBUF_INDIRECT : c_int = (0x0100 | PyBUF_STRIDES);
pub const PyBUF_CONTIG : c_int = (PyBUF_ND | PyBUF_WRITABLE);
pub const PyBUF_CONTIG_RO : c_int = (PyBUF_ND);
pub const PyBUF_STRIDED : c_int = (PyBUF_STRIDES | PyBUF_WRITABLE);
pub const PyBUF_STRIDED_RO : c_int = (PyBUF_STRIDES);
pub const PyBUF_RECORDS : c_int = (PyBUF_STRIDES | PyBUF_WRITABLE | PyBUF_FORMAT);
pub const PyBUF_RECORDS_RO : c_int = (PyBUF_STRIDES | PyBUF_FORMAT);
pub const PyBUF_FULL : c_int = (PyBUF_INDIRECT | PyBUF_WRITABLE | PyBUF_FORMAT);
pub const PyBUF_FULL_RO : c_int = (PyBUF_INDIRECT | PyBUF_FORMAT);
// buffertype:
pub const PyBUF_READ : c_int = 0x100;
pub const PyBUF_WRITE : c_int = 0x200;
pub const PyBUF_SHADOW : c_int = 0x400;
pub type objobjproc =
unsafe extern "C" fn
(arg1: *mut PyObject, arg2: *mut PyObject)
-> c_int;
pub type visitproc =
unsafe extern "C" fn
(object: *mut PyObject, arg: *mut c_void)
-> c_int;
pub type traverseproc =
unsafe extern "C" fn
(slf: *mut PyObject, visit: visitproc,
arg: *mut c_void) -> c_int;
#[repr(C)]
#[derive(Copy)]
pub struct PyNumberMethods {
pub nb_add: Option<binaryfunc>,
pub nb_subtract: Option<binaryfunc>,
pub nb_multiply: Option<binaryfunc>,
pub nb_divide: Option<binaryfunc>,
pub nb_remainder: Option<binaryfunc>,
pub nb_divmod: Option<binaryfunc>,
pub nb_power: Option<ternaryfunc>,
pub nb_negative: Option<unaryfunc>,
pub nb_positive: Option<unaryfunc>,
pub nb_absolute: Option<unaryfunc>,
pub nb_nonzero: Option<inquiry>,
pub nb_invert: Option<unaryfunc>,
pub nb_lshift: Option<binaryfunc>,
pub nb_rshift: Option<binaryfunc>,
pub nb_and: Option<binaryfunc>,
pub nb_xor: Option<binaryfunc>,
pub nb_or: Option<binaryfunc>,
pub nb_coerce: Option<coercion>,
pub nb_c_int: Option<unaryfunc>,
pub nb_long: Option<unaryfunc>,
pub nb_float: Option<unaryfunc>,
pub nb_oct: Option<unaryfunc>,
pub nb_hex: Option<unaryfunc>,
pub nb_inplace_add: Option<binaryfunc>,
pub nb_inplace_subtract: Option<binaryfunc>,
pub nb_inplace_multiply: Option<binaryfunc>,
pub nb_inplace_divide: Option<binaryfunc>,
pub nb_inplace_remainder: Option<binaryfunc>,
pub nb_inplace_power: Option<ternaryfunc>,
pub nb_inplace_lshift: Option<binaryfunc>,
pub nb_inplace_rshift: Option<binaryfunc>,
pub nb_inplace_and: Option<binaryfunc>,
pub nb_inplace_xor: Option<binaryfunc>,
pub nb_inplace_or: Option<binaryfunc>,
pub nb_floor_divide: Option<binaryfunc>,
pub nb_true_divide: Option<binaryfunc>,
pub nb_inplace_floor_divide: Option<binaryfunc>,
pub nb_inplace_true_divide: Option<binaryfunc>,
pub nb_index: Option<unaryfunc>,
}
impl Clone for PyNumberMethods {
#[inline] fn clone(&self) -> PyNumberMethods { *self }
}
pub const PyNumberMethods_INIT : PyNumberMethods = PyNumberMethods {
nb_add: None,
nb_subtract: None,
nb_multiply: None,
nb_divide: None,
nb_remainder: None,
nb_divmod: None,
nb_power: None,
nb_negative: None,
nb_positive: None,
nb_absolute: None,
nb_nonzero: None,
nb_invert: None,
nb_lshift: None,
nb_rshift: None,
nb_and: None,
nb_xor: None,
nb_or: None,
nb_coerce: None,
nb_c_int: None,
nb_long: None,
nb_float: None,
nb_oct: None,
nb_hex: None,
nb_inplace_add: None,
nb_inplace_subtract: None,
nb_inplace_multiply: None,
nb_inplace_divide: None,
nb_inplace_remainder: None,
nb_inplace_power: None,
nb_inplace_lshift: None,
nb_inplace_rshift: None,
nb_inplace_and: None,
nb_inplace_xor: None,
nb_inplace_or: None,
nb_floor_divide: None,
nb_true_divide: None,
nb_inplace_floor_divide: None,
nb_inplace_true_divide: None,
nb_index: None,
};
#[repr(C)]
#[derive(Copy)]
pub struct PySequenceMethods {
pub sq_length: Option<lenfunc>,
pub sq_concat: Option<binaryfunc>,
pub sq_repeat: Option<ssizeargfunc>,
pub sq_item: Option<ssizeargfunc>,
pub sq_slice: Option<ssizessizeargfunc>,
pub sq_ass_item: Option<ssizeobjargproc>,
pub sq_ass_slice: Option<ssizessizeobjargproc>,
pub sq_contains: Option<objobjproc>,
pub sq_inplace_concat: Option<binaryfunc>,
pub sq_inplace_repeat: Option<ssizeargfunc>,
}
impl Clone for PySequenceMethods {
#[inline] fn clone(&self) -> PySequenceMethods { *self }
}
pub const PySequenceMethods_INIT : PySequenceMethods = PySequenceMethods {
sq_length: None,
sq_concat: None,
sq_repeat: None,
sq_item: None,
sq_slice: None,
sq_ass_item: None,
sq_ass_slice: None,
sq_contains: None,
sq_inplace_concat: None,
sq_inplace_repeat: None,
};
#[repr(C)]
#[derive(Copy)]
pub struct PyMappingMethods {
pub mp_length: Option<lenfunc>,
pub mp_subscript: Option<binaryfunc>,
pub mp_ass_subscript: Option<objobjargproc>,
}
impl Clone for PyMappingMethods {
#[inline] fn clone(&self) -> PyMappingMethods { *self }
}
pub const PyMappingMethods_INIT : PyMappingMethods = PyMappingMethods {
mp_length: None,
mp_subscript: None,
mp_ass_subscript: None,
};
#[repr(C)]
#[derive(Copy)]
pub struct PyBufferProcs {
pub bf_getreadbuffer: Option<readbufferproc>,
pub bf_getwritebuffer: Option<writebufferproc>,
pub bf_getsegcount: Option<segcountproc>,
pub bf_getcharbuffer: Option<charbufferproc>,
pub bf_getbuffer: Option<getbufferproc>,
pub bf_releasebuffer: Option<releasebufferproc>,
}
impl Clone for PyBufferProcs {
#[inline] fn clone(&self) -> PyBufferProcs { *self }
}
pub const PyBufferProcs_INIT : PyBufferProcs = PyBufferProcs {
bf_getreadbuffer: None,
bf_getwritebuffer: None,
bf_getsegcount: None,
bf_getcharbuffer: None,
bf_getbuffer: None,
bf_releasebuffer: None,
};
pub type freefunc =
unsafe extern "C" fn(arg1: *mut c_void);
pub type destructor =
unsafe extern "C" fn(arg1: *mut PyObject);
pub type printfunc =
unsafe extern "C" fn
(arg1: *mut PyObject, arg2: *mut FILE,
arg3: c_int) -> c_int;
pub type getattrfunc =
unsafe extern "C" fn
(arg1: *mut PyObject, arg2: *mut c_char)
-> *mut PyObject;
pub type getattrofunc =
unsafe extern "C" fn
(arg1: *mut PyObject, arg2: *mut PyObject)
-> *mut PyObject;
pub type setattrfunc =
unsafe extern "C" fn
(arg1: *mut PyObject, arg2: *mut c_char,
arg3: *mut PyObject) -> c_int;
pub type setattrofunc =
unsafe extern "C" fn
(arg1: *mut PyObject, arg2: *mut PyObject,
arg3: *mut PyObject) -> c_int;
pub type cmpfunc =
unsafe extern "C" fn
(arg1: *mut PyObject, arg2: *mut PyObject)
-> c_int;
pub type reprfunc =
unsafe extern "C" fn(arg1: *mut PyObject)
-> *mut PyObject;
pub type hashfunc =
unsafe extern "C" fn(arg1: *mut PyObject)
-> c_long;
pub type richcmpfunc =
unsafe extern "C" fn
(arg1: *mut PyObject, arg2: *mut PyObject,
arg3: c_int) -> *mut PyObject;
pub type getiterfunc =
unsafe extern "C" fn(arg1: *mut PyObject)
-> *mut PyObject;
pub type iternextfunc =
unsafe extern "C" fn(arg1: *mut PyObject)
-> *mut PyObject;
pub type descrgetfunc =
unsafe extern "C" fn
(arg1: *mut PyObject, arg2: *mut PyObject,
arg3: *mut PyObject) -> *mut PyObject;
pub type descrsetfunc =
unsafe extern "C" fn
(arg1: *mut PyObject, arg2: *mut PyObject,
arg3: *mut PyObject) -> c_int;
pub type initproc =
unsafe extern "C" fn
(arg1: *mut PyObject, arg2: *mut PyObject,
arg3: *mut PyObject) -> c_int;
pub type newfunc =
unsafe extern "C" fn
(arg1: *mut PyTypeObject,
arg2: *mut PyObject, arg3: *mut PyObject)
-> *mut PyObject;
pub type allocfunc =
unsafe extern "C" fn
(arg1: *mut PyTypeObject,
arg2: Py_ssize_t) -> *mut PyObject;
#[repr(C)]
#[derive(Copy)]
pub struct PyTypeObject {
pub ob_refcnt: Py_ssize_t,
pub ob_type: *mut PyTypeObject,
pub ob_size: Py_ssize_t,
pub tp_name: *const c_char,
pub tp_basicsize: Py_ssize_t,
pub tp_itemsize: Py_ssize_t,
pub tp_dealloc: Option<destructor>,
pub tp_print: Option<printfunc>,
pub tp_getattr: Option<getattrfunc>,
pub tp_setattr: Option<setattrfunc>,
pub tp_compare: Option<cmpfunc>,
pub tp_repr: Option<reprfunc>,
pub tp_as_number: *mut PyNumberMethods,
pub tp_as_sequence: *mut PySequenceMethods,
pub tp_as_mapping: *mut PyMappingMethods,
pub tp_hash: Option<hashfunc>,
pub tp_call: Option<ternaryfunc>,
pub tp_str: Option<reprfunc>,
pub tp_getattro: Option<getattrofunc>,
pub tp_setattro: Option<setattrofunc>,
pub tp_as_buffer: *mut PyBufferProcs,
pub tp_flags: c_long,
pub tp_doc: *const c_char,
pub tp_traverse: Option<traverseproc>,
pub tp_clear: Option<inquiry>,
pub tp_richcompare: Option<richcmpfunc>,
pub tp_weaklistoffset: Py_ssize_t,
pub tp_iter: Option<getiterfunc>,
pub tp_iternext: Option<iternextfunc>,
pub tp_methods: *mut PyMethodDef,
pub tp_members: *mut ::structmember::PyMemberDef,
pub tp_getset: *mut ::descrobject::PyGetSetDef,
pub tp_base: *mut PyTypeObject,
pub tp_dict: *mut PyObject,
pub tp_descr_get: Option<descrgetfunc>,
pub tp_descr_set: Option<descrsetfunc>,
pub tp_dictoffset: Py_ssize_t,
pub tp_init: Option<initproc>,
pub tp_alloc: Option<allocfunc>,
pub tp_new: Option<newfunc>,
pub tp_free: Option<freefunc>,
pub tp_is_gc: Option<inquiry>,
pub tp_bases: *mut PyObject,
pub tp_mro: *mut PyObject,
pub tp_cache: *mut PyObject,
pub tp_subclasses: *mut PyObject,
pub tp_weaklist: *mut PyObject,
pub tp_del: Option<destructor>,
pub tp_version_tag: c_uint,
}
impl Clone for PyTypeObject {
#[inline] fn clone(&self) -> PyTypeObject { *self }
}
#[cfg(py_sys_config="Py_TRACE_REFS")]
pub const PyTypeObject_INIT : PyTypeObject = PyTypeObject {
_ob_next: 0 as *mut PyObject,
_ob_prev: 0 as *mut PyObject,
ob_refcnt: 1,
ob_type: 0 as *mut PyTypeObject,
ob_size: 0,
tp_name: 0 as *const c_char,
tp_basicsize: 0,
tp_itemsize: 0,
tp_dealloc: None,
tp_print: None,
tp_getattr: None,
tp_setattr: None,
tp_compare: None,
tp_repr: None,
tp_as_number: 0 as *mut PyNumberMethods,
tp_as_sequence: 0 as *mut PySequenceMethods,
tp_as_mapping: 0 as *mut PyMappingMethods,
tp_hash: None,
tp_call: None,
tp_str: None,
tp_getattro: None,
tp_setattro: None,
tp_as_buffer: 0 as *mut PyBufferProcs,
tp_flags: Py_TPFLAGS_DEFAULT,
tp_doc: 0 as *const c_char,
tp_traverse: None,
tp_clear: None,
tp_richcompare: None,
tp_weaklistoffset: 0,
tp_iter: None,
tp_iternext: None,
tp_methods: 0 as *mut PyMethodDef,
tp_members: 0 as *mut ::structmember::PyMemberDef,
tp_getset: 0 as *mut ::descrobject::PyGetSetDef,
tp_base: 0 as *mut PyTypeObject,
tp_dict: 0 as *mut PyObject,
tp_descr_get: None,
tp_descr_set: None,
tp_dictoffset: 0,
tp_init: None,
tp_alloc: None,
tp_new: None,
tp_free: None,
tp_is_gc: None,
tp_bases: 0 as *mut PyObject,
tp_mro: 0 as *mut PyObject,
tp_cache: 0 as *mut PyObject,
tp_subclasses: 0 as *mut PyObject,
tp_weaklist: 0 as *mut PyObject,
tp_del: None,
tp_version_tag: 0,
};
#[cfg(not(py_sys_config="Py_TRACE_REFS"))]
pub const PyTypeObject_INIT : PyTypeObject = PyTypeObject {
ob_refcnt: 1,
ob_type: 0 as *mut PyTypeObject,
ob_size: 0,
tp_name: 0 as *const c_char,
tp_basicsize: 0,
tp_itemsize: 0,
tp_dealloc: None,
tp_print: None,
tp_getattr: None,
tp_setattr: None,
tp_compare: None,
tp_repr: None,
tp_as_number: 0 as *mut PyNumberMethods,
tp_as_sequence: 0 as *mut PySequenceMethods,
tp_as_mapping: 0 as *mut PyMappingMethods,
tp_hash: None,
tp_call: None,
tp_str: None,
tp_getattro: None,
tp_setattro: None,
tp_as_buffer: 0 as *mut PyBufferProcs,
tp_flags: Py_TPFLAGS_DEFAULT,
tp_doc: 0 as *const c_char,
tp_traverse: None,
tp_clear: None,
tp_richcompare: None,
tp_weaklistoffset: 0,
tp_iter: None,
tp_iternext: None,
tp_methods: 0 as *mut PyMethodDef,
tp_members: 0 as *mut ::structmember::PyMemberDef,
tp_getset: 0 as *mut ::descrobject::PyGetSetDef,
tp_base: 0 as *mut PyTypeObject,
tp_dict: 0 as *mut PyObject,
tp_descr_get: None,
tp_descr_set: None,
tp_dictoffset: 0,
tp_init: None,
tp_alloc: None,
tp_new: None,
tp_free: None,
tp_is_gc: None,
tp_bases: 0 as *mut PyObject,
tp_mro: 0 as *mut PyObject,
tp_cache: 0 as *mut PyObject,
tp_subclasses: 0 as *mut PyObject,
tp_weaklist: 0 as *mut PyObject,
tp_del: None,
tp_version_tag: 0,
};
#[repr(C)]
#[derive(Copy)]
pub struct PyHeapTypeObject {
pub ht_type: PyTypeObject,
pub as_number: PyNumberMethods,
pub as_mapping: PyMappingMethods,
pub as_sequence: PySequenceMethods,
pub as_buffer: PyBufferProcs,
pub ht_name: *mut PyObject,
pub ht_slots: *mut PyObject,
}
impl Clone for PyHeapTypeObject {
#[inline] fn clone(&self) -> PyHeapTypeObject { *self }
}
// access macro to the members which are floating "behind" the object
#[inline]
pub unsafe fn PyHeapType_GET_MEMBERS(etype: *mut PyHeapTypeObject) -> *mut ::structmember::PyMemberDef {
let basicsize = (*Py_TYPE(etype as *mut PyObject)).tp_basicsize;
(etype as *mut u8).offset(basicsize as isize) as *mut ::structmember::PyMemberDef
}
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub fn PyType_IsSubtype(a: *mut PyTypeObject, b: *mut PyTypeObject) -> c_int;
}
#[inline(always)]
pub unsafe fn PyObject_TypeCheck(ob: *mut PyObject, tp: *mut PyTypeObject) -> c_int {
(Py_TYPE(ob) == tp || PyType_IsSubtype(Py_TYPE(ob), tp) != 0) as c_int
}
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub static mut PyType_Type: PyTypeObject;
pub static mut PyBaseObject_Type: PyTypeObject;
pub static mut PySuper_Type: PyTypeObject;
}
#[inline(always)]
pub unsafe fn PyType_Check(op: *mut PyObject) -> c_int {
PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_TYPE_SUBCLASS)
}
#[inline(always)]
pub unsafe fn PyType_CheckExact(op: *mut PyObject) -> c_int {
(Py_TYPE(op) == (&mut PyType_Type as *mut _)) as c_int
}
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub fn PyType_Ready(t: *mut PyTypeObject) -> c_int;
pub fn PyType_GenericAlloc(t: *mut PyTypeObject, nitems: Py_ssize_t)
-> *mut PyObject;
pub fn PyType_GenericNew(t: *mut PyTypeObject, args: *mut PyObject,
kwds: *mut PyObject) -> *mut PyObject;
fn _PyType_Lookup(arg1: *mut PyTypeObject, arg2: *mut PyObject)
-> *mut PyObject;
fn _PyObject_LookupSpecial(arg1: *mut PyObject,
arg2: *mut c_char,
arg3: *mut *mut PyObject) -> *mut PyObject;
pub fn PyType_ClearCache() -> c_uint;
pub fn PyType_Modified(t: *mut PyTypeObject);
pub fn PyObject_Print(o: *mut PyObject, fp: *mut FILE,
flags: c_int) -> c_int;
fn _PyObject_Dump(o: *mut PyObject);
pub fn PyObject_Repr(o: *mut PyObject) -> *mut PyObject;
fn _PyObject_Str(o: *mut PyObject) -> *mut PyObject;
pub fn PyObject_Str(o: *mut PyObject) -> *mut PyObject;
}
#[inline(always)]
pub unsafe fn PyObject_Bytes(o: *mut PyObject) -> *mut PyObject {
PyObject_Str(o)
}
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
#[cfg(py_sys_config="Py_USING_UNICODE")]
pub fn PyObject_Unicode(o: *mut PyObject) -> *mut PyObject;
pub fn PyObject_Compare(arg1: *mut PyObject, arg2: *mut PyObject)
-> c_int;
pub fn PyObject_RichCompare(arg1: *mut PyObject, arg2: *mut PyObject,
arg3: c_int) -> *mut PyObject;
pub fn PyObject_RichCompareBool(arg1: *mut PyObject, arg2: *mut PyObject,
arg3: c_int) -> c_int;
pub fn PyObject_GetAttrString(arg1: *mut PyObject,
arg2: *const c_char)
-> *mut PyObject;
pub fn PyObject_SetAttrString(arg1: *mut PyObject,
arg2: *const c_char,
arg3: *mut PyObject) -> c_int;
pub fn PyObject_HasAttrString(arg1: *mut PyObject,
arg2: *const c_char)
-> c_int;
pub fn PyObject_GetAttr(arg1: *mut PyObject, arg2: *mut PyObject)
-> *mut PyObject;
pub fn PyObject_SetAttr(arg1: *mut PyObject, arg2: *mut PyObject,
arg3: *mut PyObject) -> c_int;
pub fn PyObject_HasAttr(arg1: *mut PyObject, arg2: *mut PyObject)
-> c_int;
fn _PyObject_GetDictPtr(arg1: *mut PyObject) -> *mut *mut PyObject;
pub fn PyObject_SelfIter(arg1: *mut PyObject) -> *mut PyObject;
pub fn PyObject_GenericGetAttr(arg1: *mut PyObject, arg2: *mut PyObject)
-> *mut PyObject;
pub fn PyObject_GenericSetAttr(arg1: *mut PyObject, arg2: *mut PyObject,
arg3: *mut PyObject) -> c_int;
pub fn PyObject_Hash(arg1: *mut PyObject) -> c_long;
pub fn PyObject_HashNotImplemented(arg1: *mut PyObject) -> c_long;
pub fn PyObject_IsTrue(arg1: *mut PyObject) -> c_int;
pub fn PyObject_Not(arg1: *mut PyObject) -> c_int;
pub fn PyCallable_Check(arg1: *mut PyObject) -> c_int;
pub fn PyNumber_Coerce(arg1: *mut *mut PyObject, arg2: *mut *mut PyObject)
-> c_int;
pub fn PyNumber_CoerceEx(arg1: *mut *mut PyObject,
arg2: *mut *mut PyObject) -> c_int;
pub fn PyObject_ClearWeakRefs(arg1: *mut PyObject);
fn _PyObject_SlotCompare(arg1: *mut PyObject, arg2: *mut PyObject)
-> c_int;
fn _PyObject_GenericGetAttrWithDict(arg1: *mut PyObject,
arg2: *mut PyObject,
arg3: *mut PyObject)
-> *mut PyObject;
fn _PyObject_GenericSetAttrWithDict(arg1: *mut PyObject,
arg2: *mut PyObject,
arg3: *mut PyObject,
arg4: *mut PyObject)
-> c_int;
pub fn PyObject_Dir(arg1: *mut PyObject) -> *mut PyObject;
pub fn Py_ReprEnter(arg1: *mut PyObject) -> c_int;
pub fn Py_ReprLeave(arg1: *mut PyObject);
fn _Py_HashDouble(arg1: c_double) -> c_long;
fn _Py_HashPointer(arg1: *mut c_void) -> c_long;
}
// Flag bits for printing:
pub const Py_PRINT_RAW : c_int = 1; // No string quotes etc.
/// PyBufferProcs contains bf_getcharbuffer
pub const Py_TPFLAGS_HAVE_GETCHARBUFFER : c_long = (1<<0);
/// PySequenceMethods contains sq_contains
pub const Py_TPFLAGS_HAVE_SEQUENCE_IN : c_long = (1<<1);
/// PySequenceMethods and PyNumberMethods contain in-place operators
pub const Py_TPFLAGS_HAVE_INPLACEOPS : c_long = (1<<3);
/// PyNumberMethods do their own coercion
pub const Py_TPFLAGS_CHECKTYPES : c_long = (1<<4);
/// tp_richcompare is defined
pub const Py_TPFLAGS_HAVE_RICHCOMPARE : c_long = (1<<5);
/// Objects which are weakly referencable if their tp_weaklistoffset is >0
pub const Py_TPFLAGS_HAVE_WEAKREFS : c_long = (1<<6);
/// tp_iter is defined
pub const Py_TPFLAGS_HAVE_ITER : c_long = (1<<7);
/// New members introduced by Python 2.2 exist
pub const Py_TPFLAGS_HAVE_CLASS : c_long = (1<<8);
/// Set if the type object is dynamically allocated
pub const Py_TPFLAGS_HEAPTYPE : c_long = (1<<9);
/// Set if the type allows subclassing
pub const Py_TPFLAGS_BASETYPE : c_long = (1<<10);
/// Set if the type is 'ready' -- fully initialized
pub const Py_TPFLAGS_READY : c_long = (1<<12);
/// Set while the type is being 'readied', to prevent recursive ready calls
pub const Py_TPFLAGS_READYING : c_long = (1<<13);
/// Objects support garbage collection (see objimp.h)
pub const Py_TPFLAGS_HAVE_GC : c_long = (1<<14);
// Two bits are preserved for Stackless Python, next after this is 17.
const Py_TPFLAGS_HAVE_STACKLESS_EXTENSION : c_long = 0;
/// Objects support nb_index in PyNumberMethods
pub const Py_TPFLAGS_HAVE_INDEX : c_long = (1<<17);
/// Objects support type attribute cache
pub const Py_TPFLAGS_HAVE_VERSION_TAG : c_long = (1<<18);
pub const Py_TPFLAGS_VALID_VERSION_TAG : c_long = (1<<19);
/* Type is abstract and cannot be instantiated */
pub const Py_TPFLAGS_IS_ABSTRACT : c_long = (1<<20);
/* Has the new buffer protocol */
pub const Py_TPFLAGS_HAVE_NEWBUFFER : c_long = (1<<21);
/* These flags are used to determine if a type is a subclass. */
pub const Py_TPFLAGS_INT_SUBCLASS : c_long = (1<<23);
pub const Py_TPFLAGS_LONG_SUBCLASS : c_long = (1<<24);
pub const Py_TPFLAGS_LIST_SUBCLASS : c_long = (1<<25);
pub const Py_TPFLAGS_TUPLE_SUBCLASS : c_long = (1<<26);
pub const Py_TPFLAGS_STRING_SUBCLASS : c_long = (1<<27);
pub const Py_TPFLAGS_UNICODE_SUBCLASS : c_long = (1<<28);
pub const Py_TPFLAGS_DICT_SUBCLASS : c_long = (1<<29);
pub const Py_TPFLAGS_BASE_EXC_SUBCLASS : c_long = (1<<30);
pub const Py_TPFLAGS_TYPE_SUBCLASS : c_long = (1<<31);
pub const Py_TPFLAGS_DEFAULT : c_long = (
Py_TPFLAGS_HAVE_GETCHARBUFFER |
Py_TPFLAGS_HAVE_SEQUENCE_IN |
Py_TPFLAGS_HAVE_INPLACEOPS |
Py_TPFLAGS_HAVE_RICHCOMPARE |
Py_TPFLAGS_HAVE_WEAKREFS |
Py_TPFLAGS_HAVE_ITER |
Py_TPFLAGS_HAVE_CLASS |
Py_TPFLAGS_HAVE_STACKLESS_EXTENSION |
Py_TPFLAGS_HAVE_INDEX |
0);
#[inline(always)]
pub unsafe fn PyType_HasFeature(t : *mut PyTypeObject, f : c_long) -> c_int {
(((*t).tp_flags & f) != 0) as c_int
}
#[inline(always)]
pub unsafe fn PyType_FastSubclass(t : *mut PyTypeObject, f : c_long) -> c_int {
PyType_HasFeature(t, f)
}
// Reference counting macros.
#[inline(always)]
pub unsafe fn Py_INCREF(op : *mut PyObject) {
if cfg!(py_sys_config="Py_REF_DEBUG") {
Py_IncRef(op)
} else {
(*op).ob_refcnt += 1
}
}
#[inline(always)]
pub unsafe fn Py_DECREF(op: *mut PyObject) {
if cfg!(py_sys_config="Py_REF_DEBUG") || cfg!(py_sys_config="COUNT_ALLOCS") {
Py_DecRef(op)
} else {
(*op).ob_refcnt -= 1;
if (*op).ob_refcnt == 0 {
(*Py_TYPE(op)).tp_dealloc.unwrap()(op)
}
}
}
#[inline(always)]
pub unsafe fn Py_CLEAR(op: &mut *mut PyObject) {
let tmp = *op;
if !tmp.is_null() {
*op = ptr::null_mut();
Py_DECREF(tmp);
}
}
#[inline(always)]
pub unsafe fn Py_XINCREF(op : *mut PyObject) {
if !op.is_null() {
Py_INCREF(op)
}
}
#[inline(always)]
pub unsafe fn Py_XDECREF(op : *mut PyObject) {
if !op.is_null() {
Py_DECREF(op)
}
}
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub fn Py_IncRef(o: *mut PyObject);
pub fn Py_DecRef(o: *mut PyObject);
static mut _Py_NoneStruct: PyObject;
static mut _Py_NotImplementedStruct: PyObject;
}
#[inline(always)]
pub unsafe fn Py_None() -> *mut PyObject {
&mut _Py_NoneStruct
}
#[inline(always)]
pub unsafe fn Py_NotImplemented() -> *mut PyObject {
&mut _Py_NotImplementedStruct
}
/* Rich comparison opcodes */
pub const Py_LT : c_int = 0;
pub const Py_LE : c_int = 1;
pub const Py_EQ : c_int = 2;
pub const Py_NE : c_int = 3;
pub const Py_GT : c_int = 4;
pub const Py_GE : c_int = 5;
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
fn _PyTrash_thread_deposit_object(o: *mut PyObject);
fn _PyTrash_thread_destroy_chain();
}
pub const PyTrash_UNWIND_LEVEL : c_int = 50;
#[inline(always)]
pub unsafe fn Py_TRASHCAN<F : FnOnce() -> ()>(op: *mut PyObject, body: F) {
let tstate = ::pystate::PyThreadState_GET();
if tstate.is_null() || (*tstate).trash_delete_nesting < PyTrash_UNWIND_LEVEL {
if !tstate.is_null() {
(*tstate).trash_delete_nesting += 1;
}
body();
if !tstate.is_null() {
(*tstate).trash_delete_nesting -= 1;
if !(*tstate).trash_delete_later.is_null() && (*tstate).trash_delete_nesting <= 0 {
_PyTrash_thread_destroy_chain();
}
}
} else {
_PyTrash_thread_deposit_object(op)
}
}

View File

@ -1,309 +0,0 @@
use libc::{c_void, c_char, c_int};
use pyport::Py_ssize_t;
use core::ptr;
use object::*;
#[inline]
pub unsafe fn PyObject_DelAttrString(o: *mut PyObject, attr_name: *const c_char) -> c_int {
PyObject_SetAttrString(o, attr_name, ptr::null_mut())
}
#[inline]
pub unsafe fn PyObject_DelAttr(o: *mut PyObject, attr_name: *mut PyObject) -> c_int {
PyObject_SetAttr(o, attr_name, ptr::null_mut())
}
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub fn PyObject_Cmp(o1: *mut PyObject, o2: *mut PyObject,
result: *mut c_int) -> c_int;
pub fn PyObject_Call(callable_object: *mut PyObject, args: *mut PyObject,
kw: *mut PyObject) -> *mut PyObject;
pub fn PyObject_CallObject(callable_object: *mut PyObject,
args: *mut PyObject) -> *mut PyObject;
pub fn PyObject_CallFunction(callable_object: *mut PyObject,
format: *mut c_char, ...)
-> *mut PyObject;
pub fn PyObject_CallMethod(o: *mut PyObject, m: *mut c_char,
format: *mut c_char, ...)
-> *mut PyObject;
fn _PyObject_CallFunction_SizeT(callable: *mut PyObject,
format: *mut c_char, ...)
-> *mut PyObject;
fn _PyObject_CallMethod_SizeT(o: *mut PyObject,
name: *mut c_char,
format: *mut c_char, ...)
-> *mut PyObject;
pub fn PyObject_CallFunctionObjArgs(callable: *mut PyObject, ...)
-> *mut PyObject;
pub fn PyObject_CallMethodObjArgs(o: *mut PyObject, m: *mut PyObject, ...)
-> *mut PyObject;
pub fn PyObject_Type(o: *mut PyObject) -> *mut PyObject;
pub fn PyObject_Size(o: *mut PyObject) -> Py_ssize_t;
pub fn _PyObject_LengthHint(o: *mut PyObject, arg1: Py_ssize_t)
-> Py_ssize_t;
pub fn PyObject_GetItem(o: *mut PyObject, key: *mut PyObject)
-> *mut PyObject;
pub fn PyObject_SetItem(o: *mut PyObject, key: *mut PyObject,
v: *mut PyObject) -> c_int;
pub fn PyObject_DelItemString(o: *mut PyObject, key: *mut c_char)
-> c_int;
pub fn PyObject_DelItem(o: *mut PyObject, key: *mut PyObject)
-> c_int;
pub fn PyObject_AsCharBuffer(obj: *mut PyObject,
buffer: *mut *const c_char,
buffer_len: *mut Py_ssize_t)
-> c_int;
pub fn PyObject_CheckReadBuffer(obj: *mut PyObject) -> c_int;
pub fn PyObject_AsReadBuffer(obj: *mut PyObject,
buffer: *mut *const c_void,
buffer_len: *mut Py_ssize_t)
-> c_int;
pub fn PyObject_AsWriteBuffer(obj: *mut PyObject,
buffer: *mut *mut c_void,
buffer_len: *mut Py_ssize_t)
-> c_int;
pub fn PyObject_GetBuffer(obj: *mut PyObject, view: *mut Py_buffer,
flags: c_int) -> c_int;
pub fn PyBuffer_GetPointer(view: *mut Py_buffer, indices: *mut Py_ssize_t)
-> *mut c_void;
pub fn PyBuffer_ToContiguous(buf: *mut c_void,
view: *mut Py_buffer, len: Py_ssize_t,
fort: c_char) -> c_int;
pub fn PyBuffer_FromContiguous(view: *mut Py_buffer,
buf: *mut c_void, len: Py_ssize_t,
fort: c_char) -> c_int;
pub fn PyObject_CopyData(dest: *mut PyObject, src: *mut PyObject)
-> c_int;
pub fn PyBuffer_IsContiguous(view: *mut Py_buffer, fort: c_char)
-> c_int;
pub fn PyBuffer_FillContiguousStrides(ndims: c_int,
shape: *mut Py_ssize_t,
strides: *mut Py_ssize_t,
itemsize: c_int,
fort: c_char);
pub fn PyBuffer_FillInfo(view: *mut Py_buffer, o: *mut PyObject,
buf: *mut c_void, len: Py_ssize_t,
readonly: c_int, flags: c_int)
-> c_int;
pub fn PyBuffer_Release(view: *mut Py_buffer);
pub fn PyObject_Format(obj: *mut PyObject, format_spec: *mut PyObject)
-> *mut PyObject;
pub fn PyObject_GetIter(arg1: *mut PyObject) -> *mut PyObject;
pub fn PyIter_Next(arg1: *mut PyObject) -> *mut PyObject;
fn _PyObject_NextNotImplemented(arg1: *mut PyObject) -> *mut PyObject;
pub fn PyNumber_Check(o: *mut PyObject) -> c_int;
pub fn PyNumber_Add(o1: *mut PyObject, o2: *mut PyObject)
-> *mut PyObject;
pub fn PyNumber_Subtract(o1: *mut PyObject, o2: *mut PyObject)
-> *mut PyObject;
pub fn PyNumber_Multiply(o1: *mut PyObject, o2: *mut PyObject)
-> *mut PyObject;
pub fn PyNumber_Divide(o1: *mut PyObject, o2: *mut PyObject)
-> *mut PyObject;
pub fn PyNumber_FloorDivide(o1: *mut PyObject, o2: *mut PyObject)
-> *mut PyObject;
pub fn PyNumber_TrueDivide(o1: *mut PyObject, o2: *mut PyObject)
-> *mut PyObject;
pub fn PyNumber_Remainder(o1: *mut PyObject, o2: *mut PyObject)
-> *mut PyObject;
pub fn PyNumber_Divmod(o1: *mut PyObject, o2: *mut PyObject)
-> *mut PyObject;
pub fn PyNumber_Power(o1: *mut PyObject, o2: *mut PyObject,
o3: *mut PyObject) -> *mut PyObject;
pub fn PyNumber_Negative(o: *mut PyObject) -> *mut PyObject;
pub fn PyNumber_Positive(o: *mut PyObject) -> *mut PyObject;
pub fn PyNumber_Absolute(o: *mut PyObject) -> *mut PyObject;
pub fn PyNumber_Invert(o: *mut PyObject) -> *mut PyObject;
pub fn PyNumber_Lshift(o1: *mut PyObject, o2: *mut PyObject)
-> *mut PyObject;
pub fn PyNumber_Rshift(o1: *mut PyObject, o2: *mut PyObject)
-> *mut PyObject;
pub fn PyNumber_And(o1: *mut PyObject, o2: *mut PyObject)
-> *mut PyObject;
pub fn PyNumber_Xor(o1: *mut PyObject, o2: *mut PyObject)
-> *mut PyObject;
pub fn PyNumber_Or(o1: *mut PyObject, o2: *mut PyObject) -> *mut PyObject;
pub fn PyNumber_Index(o: *mut PyObject) -> *mut PyObject;
pub fn PyNumber_AsSsize_t(o: *mut PyObject, exc: *mut PyObject)
-> Py_ssize_t;
fn _PyNumber_ConvertIntegralToInt(integral: *mut PyObject,
error_format: *const c_char)
-> *mut PyObject;
pub fn PyNumber_Int(o: *mut PyObject) -> *mut PyObject;
pub fn PyNumber_Long(o: *mut PyObject) -> *mut PyObject;
pub fn PyNumber_Float(o: *mut PyObject) -> *mut PyObject;
pub fn PyNumber_InPlaceAdd(o1: *mut PyObject, o2: *mut PyObject)
-> *mut PyObject;
pub fn PyNumber_InPlaceSubtract(o1: *mut PyObject, o2: *mut PyObject)
-> *mut PyObject;
pub fn PyNumber_InPlaceMultiply(o1: *mut PyObject, o2: *mut PyObject)
-> *mut PyObject;
pub fn PyNumber_InPlaceDivide(o1: *mut PyObject, o2: *mut PyObject)
-> *mut PyObject;
pub fn PyNumber_InPlaceFloorDivide(o1: *mut PyObject, o2: *mut PyObject)
-> *mut PyObject;
pub fn PyNumber_InPlaceTrueDivide(o1: *mut PyObject, o2: *mut PyObject)
-> *mut PyObject;
pub fn PyNumber_InPlaceRemainder(o1: *mut PyObject, o2: *mut PyObject)
-> *mut PyObject;
pub fn PyNumber_InPlacePower(o1: *mut PyObject, o2: *mut PyObject,
o3: *mut PyObject) -> *mut PyObject;
pub fn PyNumber_InPlaceLshift(o1: *mut PyObject, o2: *mut PyObject)
-> *mut PyObject;
pub fn PyNumber_InPlaceRshift(o1: *mut PyObject, o2: *mut PyObject)
-> *mut PyObject;
pub fn PyNumber_InPlaceAnd(o1: *mut PyObject, o2: *mut PyObject)
-> *mut PyObject;
pub fn PyNumber_InPlaceXor(o1: *mut PyObject, o2: *mut PyObject)
-> *mut PyObject;
pub fn PyNumber_InPlaceOr(o1: *mut PyObject, o2: *mut PyObject)
-> *mut PyObject;
pub fn PyNumber_ToBase(n: *mut PyObject, base: c_int)
-> *mut PyObject;
pub fn PySequence_Check(o: *mut PyObject) -> c_int;
pub fn PySequence_Size(o: *mut PyObject) -> Py_ssize_t;
pub fn PySequence_Length(o: *mut PyObject) -> Py_ssize_t;
pub fn PySequence_Concat(o1: *mut PyObject, o2: *mut PyObject)
-> *mut PyObject;
pub fn PySequence_Repeat(o: *mut PyObject, count: Py_ssize_t)
-> *mut PyObject;
pub fn PySequence_GetItem(o: *mut PyObject, i: Py_ssize_t)
-> *mut PyObject;
pub fn PySequence_GetSlice(o: *mut PyObject, i1: Py_ssize_t,
i2: Py_ssize_t) -> *mut PyObject;
pub fn PySequence_SetItem(o: *mut PyObject, i: Py_ssize_t,
v: *mut PyObject) -> c_int;
pub fn PySequence_DelItem(o: *mut PyObject, i: Py_ssize_t)
-> c_int;
pub fn PySequence_SetSlice(o: *mut PyObject, i1: Py_ssize_t,
i2: Py_ssize_t, v: *mut PyObject)
-> c_int;
pub fn PySequence_DelSlice(o: *mut PyObject, i1: Py_ssize_t,
i2: Py_ssize_t) -> c_int;
pub fn PySequence_Tuple(o: *mut PyObject) -> *mut PyObject;
pub fn PySequence_List(o: *mut PyObject) -> *mut PyObject;
pub fn PySequence_Fast(o: *mut PyObject, m: *const c_char)
-> *mut PyObject;
pub fn PySequence_Count(o: *mut PyObject, value: *mut PyObject)
-> Py_ssize_t;
pub fn PySequence_Contains(seq: *mut PyObject, ob: *mut PyObject)
-> c_int;
pub fn _PySequence_IterSearch(seq: *mut PyObject, obj: *mut PyObject,
operation: c_int) -> Py_ssize_t;
pub fn PySequence_In(o: *mut PyObject, value: *mut PyObject)
-> c_int;
pub fn PySequence_Index(o: *mut PyObject, value: *mut PyObject)
-> Py_ssize_t;
pub fn PySequence_InPlaceConcat(o1: *mut PyObject, o2: *mut PyObject)
-> *mut PyObject;
pub fn PySequence_InPlaceRepeat(o: *mut PyObject, count: Py_ssize_t)
-> *mut PyObject;
pub fn PyMapping_Check(o: *mut PyObject) -> c_int;
pub fn PyMapping_Size(o: *mut PyObject) -> Py_ssize_t;
pub fn PyMapping_Length(o: *mut PyObject) -> Py_ssize_t;
pub fn PyMapping_HasKeyString(o: *mut PyObject, key: *mut c_char)
-> c_int;
pub fn PyMapping_HasKey(o: *mut PyObject, key: *mut PyObject)
-> c_int;
pub fn PyMapping_GetItemString(o: *mut PyObject, key: *mut c_char)
-> *mut PyObject;
pub fn PyMapping_SetItemString(o: *mut PyObject, key: *mut c_char,
value: *mut PyObject) -> c_int;
pub fn PyObject_IsInstance(object: *mut PyObject,
typeorclass: *mut PyObject) -> c_int;
pub fn PyObject_IsSubclass(object: *mut PyObject,
typeorclass: *mut PyObject) -> c_int;
}
#[inline]
pub unsafe fn PyObject_CheckBuffer(obj: *mut PyObject) -> c_int {
let t = (*obj).ob_type;
let b = (*t).tp_as_buffer;
(!b.is_null() &&
(PyType_HasFeature(t, Py_TPFLAGS_HAVE_NEWBUFFER) != 0) &&
((*b).bf_getbuffer.is_some())) as c_int
}
#[inline]
pub unsafe fn PyIter_Check(obj: *mut PyObject) -> c_int {
let t = (*obj).ob_type;
(PyType_HasFeature(t, Py_TPFLAGS_HAVE_ITER) != 0 &&
match (*t).tp_iternext {
None => false,
Some(f) => f as *const c_void != _PyObject_NextNotImplemented as *const c_void,
}) as c_int
}
#[inline]
pub unsafe fn PyIndex_Check(obj: *mut PyObject) -> c_int {
let t = (*obj).ob_type;
let n = (*t).tp_as_number;
(!n.is_null() && PyType_HasFeature(t, Py_TPFLAGS_HAVE_INDEX) != 0 && (*n).nb_index.is_some()) as c_int
}
#[inline]
pub unsafe fn PySequence_Fast_GET_SIZE(o : *mut PyObject) -> Py_ssize_t {
if ::listobject::PyList_Check(o) != 0 {
::listobject::PyList_GET_SIZE(o)
} else {
::tupleobject::PyTuple_GET_SIZE(o)
}
}
#[inline]
pub unsafe fn PySequence_Fast_GET_ITEM(o : *mut PyObject, i : Py_ssize_t) -> *mut PyObject {
if ::listobject::PyList_Check(o) != 0 {
::listobject::PyList_GET_ITEM(o, i)
} else {
::tupleobject::PyTuple_GET_ITEM(o, i)
}
}
#[inline]
pub unsafe fn PySequence_Fast_ITEMS(o : *mut PyObject) -> *mut *mut PyObject {
if ::listobject::PyList_Check(o) != 0 {
(*(o as *mut ::listobject::PyListObject)).ob_item
} else {
(*(o as *mut ::tupleobject::PyTupleObject)).ob_item.as_mut_ptr()
}
}
#[inline]
pub unsafe fn PySequence_ITEM(o : *mut PyObject, i : Py_ssize_t) -> *mut PyObject {
(*(*Py_TYPE(o)).tp_as_sequence).sq_item.unwrap()(o, i)
}
pub const PY_ITERSEARCH_COUNT : c_int = 1;
pub const PY_ITERSEARCH_INDEX : c_int = 2;
pub const PY_ITERSEARCH_CONTAINS : c_int = 3;
#[inline]
pub unsafe fn PyMapping_DelItemString(o : *mut PyObject, key : *mut c_char) -> c_int {
PyObject_DelItemString(o, key)
}
#[inline]
pub unsafe fn PyMapping_DelItem(o : *mut PyObject, key : *mut PyObject) -> c_int {
PyObject_DelItem(o, key)
}
#[inline]
pub unsafe fn PyMapping_Keys(o : *mut PyObject) -> *mut PyObject {
PyObject_CallMethod(o, "keys\0".as_ptr() as *mut i8, ptr::null_mut())
}
#[inline]
pub unsafe fn PyMapping_Values(o : *mut PyObject) -> *mut PyObject {
PyObject_CallMethod(o, "values\0".as_ptr() as *mut i8, ptr::null_mut())
}
#[inline]
pub unsafe fn PyMapping_Items(o : *mut PyObject) -> *mut PyObject {
PyObject_CallMethod(o, "items\0".as_ptr() as *mut i8, ptr::null_mut())
}

View File

@ -1,60 +0,0 @@
use libc::{c_void, c_char, c_int, size_t};
use pyport::Py_ssize_t;
use object::*;
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub fn PyObject_Malloc(arg1: size_t) -> *mut c_void;
pub fn PyObject_Realloc(arg1: *mut c_void, arg2: size_t)
-> *mut c_void;
pub fn PyObject_Free(arg1: *mut c_void);
pub fn PyObject_Init(arg1: *mut PyObject, arg2: *mut PyTypeObject)
-> *mut PyObject;
pub fn PyObject_InitVar(arg1: *mut PyVarObject, arg2: *mut PyTypeObject,
arg3: Py_ssize_t) -> *mut PyVarObject;
pub fn _PyObject_New(arg1: *mut PyTypeObject) -> *mut PyObject;
pub fn _PyObject_NewVar(arg1: *mut PyTypeObject, arg2: Py_ssize_t)
-> *mut PyVarObject;
// GC Support
pub fn PyGC_Collect() -> Py_ssize_t;
pub fn _PyObject_GC_Resize(arg1: *mut PyVarObject, arg2: Py_ssize_t)
-> *mut PyVarObject;
pub fn _PyObject_GC_Malloc(arg1: size_t) -> *mut PyObject;
pub fn _PyObject_GC_New(arg1: *mut PyTypeObject) -> *mut PyObject;
pub fn _PyObject_GC_NewVar(arg1: *mut PyTypeObject, arg2: Py_ssize_t)
-> *mut PyVarObject;
pub fn PyObject_GC_Track(arg1: *mut c_void);
pub fn PyObject_GC_UnTrack(arg1: *mut c_void);
pub fn PyObject_GC_Del(arg1: *mut c_void);
}
/// Test if a type has a GC head
#[inline(always)]
pub unsafe fn PyType_IS_GC(t : *mut PyTypeObject) -> c_int {
PyType_HasFeature((t), Py_TPFLAGS_HAVE_GC)
}
/// Test if an object has a GC head
#[inline(always)]
pub unsafe fn PyObject_IS_GC(o : *mut PyObject) -> c_int {
(PyType_IS_GC(Py_TYPE(o)) != 0 &&
match (*Py_TYPE(o)).tp_is_gc {
Some(tp_is_gc) => tp_is_gc(o) != 0,
None => true
}) as c_int
}
/* Test if a type supports weak references */
#[inline(always)]
pub unsafe fn PyType_SUPPORTS_WEAKREFS(t : *mut PyTypeObject) -> c_int {
(PyType_HasFeature((t), Py_TPFLAGS_HAVE_WEAKREFS) != 0
&& ((*t).tp_weaklistoffset > 0)) as c_int
}
#[inline(always)]
pub unsafe fn PyObject_GET_WEAKREFS_LISTPTR(o : *mut PyObject) -> *mut *mut PyObject {
let weaklistoffset = (*Py_TYPE(o)).tp_weaklistoffset as isize;
(o as *mut c_char).offset(weaklistoffset) as *mut *mut PyObject
}

View File

@ -1,15 +0,0 @@
use libc::{c_void, c_int, size_t};
use object::PyObject;
#[allow(missing_copy_implementations)]
pub enum PyArena { }
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub fn PyArena_New() -> *mut PyArena;
pub fn PyArena_Free(arg1: *mut PyArena);
pub fn PyArena_Malloc(arg1: *mut PyArena, size: size_t)
-> *mut c_void;
pub fn PyArena_AddPyObject(arg1: *mut PyArena, arg2: *mut PyObject)
-> c_int;
}

View File

@ -1,43 +0,0 @@
use libc::{c_void, c_char, c_int};
use object::*;
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub static mut PyCapsule_Type: PyTypeObject;
}
pub type PyCapsule_Destructor = unsafe extern "C" fn(o: *mut PyObject);
#[inline]
pub unsafe fn PyCapsule_CheckExact(ob: *mut PyObject) -> c_int {
(Py_TYPE(ob) == &mut PyCapsule_Type) as c_int
}
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub fn PyCapsule_New(pointer: *mut c_void,
name: *const c_char,
destructor: Option<PyCapsule_Destructor>) -> *mut PyObject;
pub fn PyCapsule_GetPointer(capsule: *mut PyObject,
name: *const c_char)
-> *mut c_void;
pub fn PyCapsule_GetDestructor(capsule: *mut PyObject)
-> Option<PyCapsule_Destructor>;
pub fn PyCapsule_GetName(capsule: *mut PyObject) -> *const c_char;
pub fn PyCapsule_GetContext(capsule: *mut PyObject)
-> *mut c_void;
pub fn PyCapsule_IsValid(capsule: *mut PyObject,
name: *const c_char) -> c_int;
pub fn PyCapsule_SetPointer(capsule: *mut PyObject,
pointer: *mut c_void)
-> c_int;
pub fn PyCapsule_SetDestructor(capsule: *mut PyObject,
destructor: Option<PyCapsule_Destructor>)
-> c_int;
pub fn PyCapsule_SetName(capsule: *mut PyObject,
name: *const c_char) -> c_int;
pub fn PyCapsule_SetContext(capsule: *mut PyObject,
context: *mut c_void)
-> c_int;
pub fn PyCapsule_Import(name: *const c_char,
no_block: c_int) -> *mut c_void;
}

View File

@ -1,25 +0,0 @@
use libc::{c_char, c_int};
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub static mut Py_DebugFlag: c_int;
pub static mut Py_VerboseFlag: c_int;
pub static mut Py_InteractiveFlag: c_int;
pub static mut Py_InspectFlag: c_int;
pub static mut Py_OptimizeFlag: c_int;
pub static mut Py_NoSiteFlag: c_int;
pub static mut Py_BytesWarningFlag: c_int;
pub static mut Py_UseClassExceptionsFlag: c_int;
pub static mut Py_FrozenFlag: c_int;
pub static mut Py_TabcheckFlag: c_int;
pub static mut Py_UnicodeFlag: c_int;
pub static mut Py_IgnoreEnvironmentFlag: c_int;
pub static mut Py_DivisionWarningFlag: c_int;
pub static mut Py_DontWriteBytecodeFlag: c_int;
pub static mut Py_NoUserSiteDirectory: c_int;
pub static mut _Py_QnewFlag: c_int;
pub static mut Py_Py3kWarningFlag: c_int;
pub static mut Py_HashRandomizationFlag: c_int;
pub fn Py_FatalError(message: *const c_char);
}

View File

@ -1,216 +0,0 @@
use libc::{c_char, c_int};
use pyport::Py_ssize_t;
use object::*;
use classobject::*;
use stringobject::PyString_AS_STRING;
#[cfg(py_sys_config="Py_USING_UNICODE")]
use unicodeobject::Py_UNICODE;
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub fn PyErr_SetNone(arg1: *mut PyObject);
pub fn PyErr_SetObject(arg1: *mut PyObject, arg2: *mut PyObject);
pub fn PyErr_SetString(arg1: *mut PyObject, arg2: *const c_char);
pub fn PyErr_Occurred() -> *mut PyObject;
pub fn PyErr_Clear();
pub fn PyErr_Fetch(arg1: *mut *mut PyObject, arg2: *mut *mut PyObject,
arg3: *mut *mut PyObject);
pub fn PyErr_Restore(arg1: *mut PyObject, arg2: *mut PyObject,
arg3: *mut PyObject);
pub fn PyErr_GivenExceptionMatches(arg1: *mut PyObject,
arg2: *mut PyObject) -> c_int;
pub fn PyErr_ExceptionMatches(arg1: *mut PyObject) -> c_int;
pub fn PyErr_NormalizeException(arg1: *mut *mut PyObject,
arg2: *mut *mut PyObject,
arg3: *mut *mut PyObject);
}
#[inline]
pub unsafe fn PyExceptionClass_Check(x: *mut PyObject) -> c_int {
(PyClass_Check((x)) != 0 || (PyType_Check((x)) != 0 &&
PyType_FastSubclass(x as *mut PyTypeObject, Py_TPFLAGS_BASE_EXC_SUBCLASS) != 0)) as c_int
}
#[inline]
pub unsafe fn PyExceptionInstance_Check(x: *mut PyObject) -> c_int {
(PyInstance_Check((x)) != 0 ||
PyType_FastSubclass((*x).ob_type, Py_TPFLAGS_BASE_EXC_SUBCLASS) != 0) as c_int
}
#[inline]
pub unsafe fn PyExceptionClass_Name(x: *mut PyObject) -> *const c_char {
if PyClass_Check(x) != 0 {
PyString_AS_STRING((*(x as *mut PyClassObject)).cl_name)
} else {
(*(x as *mut PyTypeObject)).tp_name
}
}
#[inline]
pub unsafe fn PyExceptionInstance_Class(x: *mut PyObject) -> *mut PyObject {
if PyInstance_Check(x) != 0 {
(*(x as *mut PyInstanceObject)).in_class as *mut PyObject
} else {
(*x).ob_type as *mut PyObject
}
}
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub static mut PyExc_BaseException: *mut PyObject;
pub static mut PyExc_Exception: *mut PyObject;
pub static mut PyExc_StopIteration: *mut PyObject;
pub static mut PyExc_GeneratorExit: *mut PyObject;
pub static mut PyExc_StandardError: *mut PyObject;
pub static mut PyExc_ArithmeticError: *mut PyObject;
pub static mut PyExc_LookupError: *mut PyObject;
pub static mut PyExc_AssertionError: *mut PyObject;
pub static mut PyExc_AttributeError: *mut PyObject;
pub static mut PyExc_EOFError: *mut PyObject;
pub static mut PyExc_FloatingPointError: *mut PyObject;
pub static mut PyExc_EnvironmentError: *mut PyObject;
pub static mut PyExc_IOError: *mut PyObject;
pub static mut PyExc_OSError: *mut PyObject;
pub static mut PyExc_ImportError: *mut PyObject;
pub static mut PyExc_IndexError: *mut PyObject;
pub static mut PyExc_KeyError: *mut PyObject;
pub static mut PyExc_KeyboardInterrupt: *mut PyObject;
pub static mut PyExc_MemoryError: *mut PyObject;
pub static mut PyExc_NameError: *mut PyObject;
pub static mut PyExc_OverflowError: *mut PyObject;
pub static mut PyExc_RuntimeError: *mut PyObject;
pub static mut PyExc_NotImplementedError: *mut PyObject;
pub static mut PyExc_SyntaxError: *mut PyObject;
pub static mut PyExc_IndentationError: *mut PyObject;
pub static mut PyExc_TabError: *mut PyObject;
pub static mut PyExc_ReferenceError: *mut PyObject;
pub static mut PyExc_SystemError: *mut PyObject;
pub static mut PyExc_SystemExit: *mut PyObject;
pub static mut PyExc_TypeError: *mut PyObject;
pub static mut PyExc_UnboundLocalError: *mut PyObject;
pub static mut PyExc_UnicodeError: *mut PyObject;
pub static mut PyExc_UnicodeEncodeError: *mut PyObject;
pub static mut PyExc_UnicodeDecodeError: *mut PyObject;
pub static mut PyExc_UnicodeTranslateError: *mut PyObject;
pub static mut PyExc_ValueError: *mut PyObject;
pub static mut PyExc_ZeroDivisionError: *mut PyObject;
#[cfg(windows)] pub static mut PyExc_WindowsError: *mut PyObject;
pub static mut PyExc_BufferError: *mut PyObject;
pub static mut PyExc_MemoryErrorInst: *mut PyObject;
pub static mut PyExc_RecursionErrorInst: *mut PyObject;
pub static mut PyExc_Warning: *mut PyObject;
pub static mut PyExc_UserWarning: *mut PyObject;
pub static mut PyExc_DeprecationWarning: *mut PyObject;
pub static mut PyExc_PendingDeprecationWarning: *mut PyObject;
pub static mut PyExc_SyntaxWarning: *mut PyObject;
pub static mut PyExc_RuntimeWarning: *mut PyObject;
pub static mut PyExc_FutureWarning: *mut PyObject;
pub static mut PyExc_ImportWarning: *mut PyObject;
pub static mut PyExc_UnicodeWarning: *mut PyObject;
pub static mut PyExc_BytesWarning: *mut PyObject;
pub fn PyErr_BadArgument() -> c_int;
pub fn PyErr_NoMemory() -> *mut PyObject;
pub fn PyErr_SetFromErrno(arg1: *mut PyObject) -> *mut PyObject;
pub fn PyErr_SetFromErrnoWithFilenameObject(arg1: *mut PyObject,
arg2: *mut PyObject)
-> *mut PyObject;
pub fn PyErr_SetFromErrnoWithFilename(arg1: *mut PyObject,
arg2: *const c_char)
-> *mut PyObject;
pub fn PyErr_Format(arg1: *mut PyObject, arg2: *const c_char, ...)
-> *mut PyObject;
pub fn PyErr_BadInternalCall();
pub fn _PyErr_BadInternalCall(filename: *mut c_char,
lineno: c_int);
pub fn PyErr_NewException(name: *mut c_char, base: *mut PyObject,
dict: *mut PyObject) -> *mut PyObject;
pub fn PyErr_NewExceptionWithDoc(name: *mut c_char,
doc: *mut c_char,
base: *mut PyObject, dict: *mut PyObject)
-> *mut PyObject;
pub fn PyErr_WriteUnraisable(arg1: *mut PyObject);
pub fn PyErr_CheckSignals() -> c_int;
pub fn PyErr_SetInterrupt();
pub fn PySignal_SetWakeupFd(fd: c_int) -> c_int;
pub fn PyErr_SyntaxLocation(arg1: *const c_char,
arg2: c_int);
pub fn PyErr_ProgramText(arg1: *const c_char, arg2: c_int)
-> *mut PyObject;
}
#[cfg(py_sys_config="Py_USING_UNICODE")]
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub fn PyUnicodeDecodeError_Create(arg1: *const c_char,
arg2: *const c_char,
arg3: Py_ssize_t, arg4: Py_ssize_t,
arg5: Py_ssize_t,
arg6: *const c_char)
-> *mut PyObject;
pub fn PyUnicodeEncodeError_Create(arg1: *const c_char,
arg2: *const Py_UNICODE,
arg3: Py_ssize_t, arg4: Py_ssize_t,
arg5: Py_ssize_t,
arg6: *const c_char)
-> *mut PyObject;
pub fn PyUnicodeTranslateError_Create(arg1: *const Py_UNICODE,
arg2: Py_ssize_t, arg3: Py_ssize_t,
arg4: Py_ssize_t,
arg5: *const c_char)
-> *mut PyObject;
pub fn PyUnicodeEncodeError_GetEncoding(arg1: *mut PyObject)
-> *mut PyObject;
pub fn PyUnicodeDecodeError_GetEncoding(arg1: *mut PyObject)
-> *mut PyObject;
pub fn PyUnicodeEncodeError_GetObject(arg1: *mut PyObject)
-> *mut PyObject;
pub fn PyUnicodeDecodeError_GetObject(arg1: *mut PyObject)
-> *mut PyObject;
pub fn PyUnicodeTranslateError_GetObject(arg1: *mut PyObject)
-> *mut PyObject;
pub fn PyUnicodeEncodeError_GetStart(arg1: *mut PyObject,
arg2: *mut Py_ssize_t)
-> c_int;
pub fn PyUnicodeDecodeError_GetStart(arg1: *mut PyObject,
arg2: *mut Py_ssize_t)
-> c_int;
pub fn PyUnicodeTranslateError_GetStart(arg1: *mut PyObject,
arg2: *mut Py_ssize_t)
-> c_int;
pub fn PyUnicodeEncodeError_SetStart(arg1: *mut PyObject,
arg2: Py_ssize_t) -> c_int;
pub fn PyUnicodeDecodeError_SetStart(arg1: *mut PyObject,
arg2: Py_ssize_t) -> c_int;
pub fn PyUnicodeTranslateError_SetStart(arg1: *mut PyObject,
arg2: Py_ssize_t)
-> c_int;
pub fn PyUnicodeEncodeError_GetEnd(arg1: *mut PyObject,
arg2: *mut Py_ssize_t)
-> c_int;
pub fn PyUnicodeDecodeError_GetEnd(arg1: *mut PyObject,
arg2: *mut Py_ssize_t)
-> c_int;
pub fn PyUnicodeTranslateError_GetEnd(arg1: *mut PyObject,
arg2: *mut Py_ssize_t)
-> c_int;
pub fn PyUnicodeEncodeError_SetEnd(arg1: *mut PyObject, arg2: Py_ssize_t)
-> c_int;
pub fn PyUnicodeDecodeError_SetEnd(arg1: *mut PyObject, arg2: Py_ssize_t)
-> c_int;
pub fn PyUnicodeTranslateError_SetEnd(arg1: *mut PyObject,
arg2: Py_ssize_t) -> c_int;
pub fn PyUnicodeEncodeError_GetReason(arg1: *mut PyObject)
-> *mut PyObject;
pub fn PyUnicodeDecodeError_GetReason(arg1: *mut PyObject)
-> *mut PyObject;
pub fn PyUnicodeTranslateError_GetReason(arg1: *mut PyObject)
-> *mut PyObject;
pub fn PyUnicodeEncodeError_SetReason(arg1: *mut PyObject,
arg2: *const c_char)
-> c_int;
pub fn PyUnicodeDecodeError_SetReason(arg1: *mut PyObject,
arg2: *const c_char)
-> c_int;
pub fn PyUnicodeTranslateError_SetReason(arg1: *mut PyObject,
arg2: *const c_char)
-> c_int;
}

View File

@ -1,9 +0,0 @@
use libc::{c_void, size_t};
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub fn PyMem_Malloc(n: size_t) -> *mut c_void;
pub fn PyMem_Realloc(p: *mut c_void, n: size_t)
-> *mut c_void;
pub fn PyMem_Free(p: *mut c_void);
}

View File

@ -1,8 +0,0 @@
pub type Py_uintptr_t = ::libc::uintptr_t;
pub type Py_intptr_t = ::libc::intptr_t;
pub type Py_ssize_t = ::libc::ssize_t;
pub const PY_SSIZE_T_MIN : Py_ssize_t = ::core::isize::MIN as Py_ssize_t;
pub const PY_SSIZE_T_MAX : Py_ssize_t = ::core::isize::MAX as Py_ssize_t;

View File

@ -1,107 +0,0 @@
use libc::{c_int, c_long};
use object::PyObject;
use frameobject::PyFrameObject;
pub enum PyInterpreterState { }
pub type Py_tracefunc =
unsafe extern "C" fn
(arg1: *mut PyObject, arg2: *mut PyFrameObject,
arg3: c_int, arg4: *mut PyObject)
-> c_int;
/* The following values are used for 'what' for tracefunc functions: */
pub const PyTrace_CALL : c_int = 0;
pub const PyTrace_EXCEPTION : c_int = 1;
pub const PyTrace_LINE : c_int = 2;
pub const PyTrace_RETURN : c_int = 3;
pub const PyTrace_C_CALL : c_int = 4;
pub const PyTrace_C_EXCEPTION : c_int = 5;
pub const PyTrace_C_RETURN : c_int = 6;
#[repr(C)]
#[derive(Copy)]
pub struct PyThreadState {
pub next: *mut PyThreadState,
pub interp: *mut PyInterpreterState,
pub frame: *mut PyFrameObject,
pub recursion_depth: c_int,
pub tracing: c_int,
pub use_tracing: c_int,
pub c_profilefunc: Option<Py_tracefunc>,
pub c_tracefunc: Option<Py_tracefunc>,
pub c_profileobj: *mut PyObject,
pub c_traceobj: *mut PyObject,
pub curexc_type: *mut PyObject,
pub curexc_value: *mut PyObject,
pub curexc_traceback: *mut PyObject,
pub exc_type: *mut PyObject,
pub exc_value: *mut PyObject,
pub exc_traceback: *mut PyObject,
pub dict: *mut PyObject,
pub tick_counter: c_int,
pub gilstate_counter: c_int,
pub async_exc: *mut PyObject,
pub thread_id: c_long,
pub trash_delete_nesting: c_int,
pub trash_delete_later: *mut PyObject,
}
impl Clone for PyThreadState {
#[inline] fn clone(&self) -> PyThreadState { *self }
}
#[repr(C)]
#[derive(Copy, Clone)]
pub enum PyGILState_STATE {
PyGILState_LOCKED,
PyGILState_UNLOCKED
}
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
static mut _PyThreadState_Current: *mut PyThreadState;
//static mut _PyThreadState_GetFrame: PyThreadFrameGetter;
pub fn PyInterpreterState_New() -> *mut PyInterpreterState;
pub fn PyInterpreterState_Clear(arg1: *mut PyInterpreterState);
pub fn PyInterpreterState_Delete(arg1: *mut PyInterpreterState);
pub fn PyThreadState_New(arg1: *mut PyInterpreterState)
-> *mut PyThreadState;
pub fn _PyThreadState_Prealloc(arg1: *mut PyInterpreterState)
-> *mut PyThreadState;
pub fn _PyThreadState_Init(arg1: *mut PyThreadState);
pub fn PyThreadState_Clear(arg1: *mut PyThreadState);
pub fn PyThreadState_Delete(arg1: *mut PyThreadState);
#[cfg(py_sys_config="WITH_THREAD")]
pub fn PyThreadState_DeleteCurrent();
pub fn PyThreadState_Get() -> *mut PyThreadState;
pub fn PyThreadState_Swap(arg1: *mut PyThreadState) -> *mut PyThreadState;
pub fn PyThreadState_GetDict() -> *mut PyObject;
pub fn PyThreadState_SetAsyncExc(arg1: c_long,
arg2: *mut PyObject) -> c_int;
pub fn PyGILState_Ensure() -> PyGILState_STATE;
pub fn PyGILState_Release(arg1: PyGILState_STATE);
pub fn PyGILState_GetThisThreadState() -> *mut PyThreadState;
fn _PyThread_CurrentFrames() -> *mut PyObject;
pub fn PyInterpreterState_Head() -> *mut PyInterpreterState;
pub fn PyInterpreterState_Next(arg1: *mut PyInterpreterState)
-> *mut PyInterpreterState;
pub fn PyInterpreterState_ThreadHead(arg1: *mut PyInterpreterState)
-> *mut PyThreadState;
pub fn PyThreadState_Next(arg1: *mut PyThreadState) -> *mut PyThreadState;
}
#[cfg(py_sys_config="Py_DEBUG")]
#[inline(always)]
pub unsafe fn PyThreadState_GET() -> *mut PyThreadState {
PyThreadState_Get()
}
#[cfg(not(py_sys_config="Py_DEBUG"))]
#[inline(always)]
pub unsafe fn PyThreadState_GET() -> *mut PyThreadState {
_PyThreadState_Current
}

View File

@ -1,121 +0,0 @@
use libc::{c_char, c_int, FILE};
use object::*;
use code::*;
use pystate::PyThreadState;
use pyarena::PyArena;
pub const PyCF_MASK : c_int = (CO_FUTURE_DIVISION | CO_FUTURE_ABSOLUTE_IMPORT |
CO_FUTURE_WITH_STATEMENT | CO_FUTURE_PRINT_FUNCTION |
CO_FUTURE_UNICODE_LITERALS);
pub const PyCF_MASK_OBSOLETE : c_int = (CO_NESTED);
pub const PyCF_SOURCE_IS_UTF8 : c_int = 0x0100;
pub const PyCF_DONT_IMPLY_DEDENT : c_int = 0x0200;
pub const PyCF_ONLY_AST : c_int = 0x0400;
#[repr(C)]
#[derive(Copy, Clone)]
pub struct PyCompilerFlags {
cf_flags : c_int
}
#[allow(missing_copy_implementations)]
pub enum Struct__mod { }
#[allow(missing_copy_implementations)]
pub enum Struct__node { }
#[allow(missing_copy_implementations)]
pub enum Struct_symtable { }
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub fn Py_SetProgramName(arg1: *mut c_char);
pub fn Py_GetProgramName() -> *mut c_char;
pub fn Py_SetPythonHome(arg1: *mut c_char);
pub fn Py_GetPythonHome() -> *mut c_char;
pub fn Py_Initialize();
pub fn Py_InitializeEx(arg1: c_int);
pub fn Py_Finalize();
pub fn Py_IsInitialized() -> c_int;
pub fn Py_NewInterpreter() -> *mut PyThreadState;
pub fn Py_EndInterpreter(arg1: *mut PyThreadState);
pub fn PyRun_AnyFileFlags(arg1: *mut FILE, arg2: *const c_char,
arg3: *mut PyCompilerFlags) -> c_int;
pub fn PyRun_AnyFileExFlags(arg1: *mut FILE, arg2: *const c_char,
arg3: c_int,
arg4: *mut PyCompilerFlags) -> c_int;
pub fn PyRun_SimpleStringFlags(arg1: *const c_char,
arg2: *mut PyCompilerFlags)
-> c_int;
pub fn PyRun_SimpleFileExFlags(arg1: *mut FILE,
arg2: *const c_char,
arg3: c_int,
arg4: *mut PyCompilerFlags)
-> c_int;
pub fn PyRun_InteractiveOneFlags(arg1: *mut FILE,
arg2: *const c_char,
arg3: *mut PyCompilerFlags)
-> c_int;
pub fn PyRun_InteractiveLoopFlags(arg1: *mut FILE,
arg2: *const c_char,
arg3: *mut PyCompilerFlags)
-> c_int;
pub fn PyParser_ASTFromString(arg1: *const c_char,
arg2: *const c_char,
arg3: c_int,
flags: *mut PyCompilerFlags,
arg4: *mut PyArena) -> *mut Struct__mod;
pub fn PyParser_ASTFromFile(arg1: *mut FILE, arg2: *const c_char,
arg3: c_int,
arg4: *mut c_char,
arg5: *mut c_char,
arg6: *mut PyCompilerFlags,
arg7: *mut c_int, arg8: *mut PyArena)
-> *mut Struct__mod;
pub fn PyParser_SimpleParseStringFlags(arg1: *const c_char,
arg2: c_int,
arg3: c_int)
-> *mut Struct__node;
pub fn PyParser_SimpleParseFileFlags(arg1: *mut FILE,
arg2: *const c_char,
arg3: c_int,
arg4: c_int)
-> *mut Struct__node;
pub fn PyRun_StringFlags(arg1: *const c_char, arg2: c_int,
arg3: *mut PyObject, arg4: *mut PyObject,
arg5: *mut PyCompilerFlags) -> *mut PyObject;
pub fn PyRun_FileExFlags(arg1: *mut FILE, arg2: *const c_char,
arg3: c_int, arg4: *mut PyObject,
arg5: *mut PyObject, arg6: c_int,
arg7: *mut PyCompilerFlags) -> *mut PyObject;
pub fn Py_CompileStringFlags(arg1: *const c_char,
arg2: *const c_char,
arg3: c_int,
arg4: *mut PyCompilerFlags) -> *mut PyObject;
pub fn Py_SymtableString(arg1: *const c_char,
arg2: *const c_char, arg3: c_int)
-> *mut Struct_symtable;
pub fn PyErr_Print();
pub fn PyErr_PrintEx(arg1: c_int);
pub fn PyErr_Display(arg1: *mut PyObject, arg2: *mut PyObject,
arg3: *mut PyObject);
pub fn Py_AtExit(func: Option<unsafe extern "C" fn()>)
-> c_int;
pub fn Py_Exit(arg1: c_int);
pub fn Py_FdIsInteractive(arg1: *mut FILE, arg2: *const c_char)
-> c_int;
pub fn Py_Main(argc: c_int, argv: *mut *mut c_char)
-> c_int;
pub fn Py_GetProgramFullPath() -> *mut c_char;
pub fn Py_GetPrefix() -> *mut c_char;
pub fn Py_GetExecPrefix() -> *mut c_char;
pub fn Py_GetPath() -> *mut c_char;
pub fn Py_GetVersion() -> *const c_char;
pub fn Py_GetPlatform() -> *const c_char;
pub fn Py_GetCopyright() -> *const c_char;
pub fn Py_GetCompiler() -> *const c_char;
pub fn Py_GetBuildInfo() -> *const c_char;
fn _Py_svnversion() -> *const c_char;
pub fn Py_SubversionRevision() -> *const c_char;
pub fn Py_SubversionShortBranch() -> *const c_char;
fn _Py_hgidentifier() -> *const c_char;
fn _Py_hgversion() -> *const c_char;
}

View File

@ -1,13 +0,0 @@
use libc::c_int;
use object::*;
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub static mut PyRange_Type: PyTypeObject;
}
#[inline(always)]
pub unsafe fn PyRange_Check(op : *mut PyObject) -> c_int {
let u : *mut PyTypeObject = &mut PyRange_Type;
(Py_TYPE(op) == u) as c_int
}

View File

@ -1,63 +0,0 @@
use libc::c_int;
use pyport::Py_ssize_t;
use object::*;
//enum PySetObject { /* representation hidden */ }
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub static mut PySet_Type: PyTypeObject;
pub static mut PyFrozenSet_Type: PyTypeObject;
}
#[inline]
pub unsafe fn PyFrozenSet_CheckExact(ob : *mut PyObject) -> c_int {
let f : *mut PyTypeObject = &mut PyFrozenSet_Type;
(Py_TYPE(ob) == f) as c_int
}
#[inline]
pub unsafe fn PyAnySet_CheckExact(ob : *mut PyObject) -> c_int {
let s : *mut PyTypeObject = &mut PySet_Type;
let f : *mut PyTypeObject = &mut PyFrozenSet_Type;
(Py_TYPE(ob) == s || Py_TYPE(ob) == f) as c_int
}
#[inline]
pub unsafe fn PyAnySet_Check(ob : *mut PyObject) -> c_int {
(PyAnySet_CheckExact(ob) != 0 ||
PyType_IsSubtype(Py_TYPE(ob), &mut PySet_Type) != 0 ||
PyType_IsSubtype(Py_TYPE(ob), &mut PyFrozenSet_Type) != 0) as c_int
}
#[inline]
pub unsafe fn PySet_Check(ob : *mut PyObject) -> c_int {
let s : *mut PyTypeObject = &mut PySet_Type;
(Py_TYPE(ob) == s || PyType_IsSubtype(Py_TYPE(ob), s) != 0) as c_int
}
#[inline]
pub unsafe fn PyFrozenSet_Check(ob : *mut PyObject) -> c_int {
let f : *mut PyTypeObject = &mut PyFrozenSet_Type;
(Py_TYPE(ob) == f || PyType_IsSubtype(Py_TYPE(ob), f) != 0) as c_int
}
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub fn PySet_New(iterable: *mut PyObject) -> *mut PyObject;
pub fn PyFrozenSet_New(iterable: *mut PyObject) -> *mut PyObject;
pub fn PySet_Size(anyset: *mut PyObject) -> Py_ssize_t;
pub fn PySet_Clear(set: *mut PyObject) -> c_int;
pub fn PySet_Contains(anyset: *mut PyObject, key: *mut PyObject)
-> c_int;
pub fn PySet_Discard(set: *mut PyObject, key: *mut PyObject)
-> c_int;
pub fn PySet_Add(set: *mut PyObject, key: *mut PyObject) -> c_int;
//pub fn _PySet_Next(set: *mut PyObject, pos: *mut Py_ssize_t,
// key: *mut *mut PyObject) -> c_int;
//pub fn _PySet_NextEntry(set: *mut PyObject, pos: *mut Py_ssize_t,
// key: *mut *mut PyObject,
// hash: *mut c_long) -> c_int;
pub fn PySet_Pop(set: *mut PyObject) -> *mut PyObject;
//pub fn _PySet_Update(set: *mut PyObject, iterable: *mut PyObject)
// -> c_int;
}

View File

@ -1,50 +0,0 @@
use libc::c_int;
use pyport::Py_ssize_t;
use object::*;
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
static mut _Py_EllipsisObject: PyObject;
}
#[inline(always)]
pub unsafe fn Py_Ellipsis() -> *mut PyObject {
&mut _Py_EllipsisObject
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct PySliceObject {
#[cfg(py_sys_config="Py_TRACE_REFS")]
pub _ob_next: *mut PyObject,
#[cfg(py_sys_config="Py_TRACE_REFS")]
pub _ob_prev: *mut PyObject,
pub ob_refcnt: Py_ssize_t,
pub ob_type: *mut PyTypeObject,
pub start: *mut PyObject,
pub stop: *mut PyObject,
pub step: *mut PyObject
}
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub static mut PySlice_Type: PyTypeObject;
pub static mut PyEllipsis_Type: PyTypeObject;
}
#[inline(always)]
pub unsafe fn PySlice_Check(op: *mut PyObject) -> c_int {
(Py_TYPE(op) == &mut PySlice_Type) as c_int
}
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub fn PySlice_New(start: *mut PyObject, stop: *mut PyObject,
step: *mut PyObject) -> *mut PyObject;
pub fn PySlice_GetIndices(r: *mut PyObject, length: Py_ssize_t,
start: *mut Py_ssize_t, stop: *mut Py_ssize_t,
step: *mut Py_ssize_t) -> c_int;
pub fn PySlice_GetIndicesEx(r: *mut PyObject, length: Py_ssize_t,
start: *mut Py_ssize_t, stop: *mut Py_ssize_t,
step: *mut Py_ssize_t,
slicelength: *mut Py_ssize_t)
-> c_int;
}

View File

@ -1,134 +0,0 @@
use libc::{c_char, c_int, c_long};
use pyport::Py_ssize_t;
use object::*;
#[repr(C)]
#[allow(missing_copy_implementations)]
pub struct PyStringObject {
#[cfg(py_sys_config="Py_TRACE_REFS")]
pub _ob_next: *mut PyObject,
#[cfg(py_sys_config="Py_TRACE_REFS")]
pub _ob_prev: *mut PyObject,
pub ob_refcnt: Py_ssize_t,
pub ob_type: *mut PyTypeObject,
pub ob_size: Py_ssize_t,
pub ob_shash: c_long,
pub ob_sstate: c_int,
pub ob_sval: [c_char; 1],
}
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub static mut PyBaseString_Type: PyTypeObject;
pub static mut PyString_Type: PyTypeObject;
}
#[inline(always)]
pub unsafe fn PyString_Check(op : *mut PyObject) -> c_int {
PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_STRING_SUBCLASS)
}
#[inline(always)]
pub unsafe fn PyString_CheckExact(op : *mut PyObject) -> c_int {
let u : *mut PyTypeObject = &mut PyString_Type;
(Py_TYPE(op) == u) as c_int
}
#[inline(always)]
pub unsafe fn PyString_GET_SIZE(op : *mut PyObject) -> Py_ssize_t {
(*(op as *mut PyStringObject)).ob_size
}
#[inline(always)]
pub unsafe fn PyString_AS_STRING(op : *mut PyObject) -> *mut c_char {
(*(op as *mut PyStringObject)).ob_sval.as_mut_ptr()
}
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub fn PyString_FromString(v: *const c_char) -> *mut PyObject;
pub fn PyString_FromStringAndSize(v: *const c_char,
len: Py_ssize_t) -> *mut PyObject;
pub fn PyString_FromFormat(format: *const c_char, ...)
-> *mut PyObject;
pub fn PyString_Size(string: *mut PyObject) -> Py_ssize_t;
pub fn PyString_AsString(string: *mut PyObject) -> *mut c_char;
pub fn PyString_AsStringAndSize(obj: *mut PyObject,
s: *mut *mut c_char,
len: *mut Py_ssize_t) -> c_int;
pub fn PyString_Concat(string: *mut *mut PyObject, newpart: *mut PyObject);
pub fn PyString_ConcatAndDel(string: *mut *mut PyObject,
newpart: *mut PyObject);
pub fn _PyString_Resize(string: *mut *mut PyObject, newsize: Py_ssize_t)
-> c_int;
pub fn PyString_Format(format: *mut PyObject, args: *mut PyObject)
-> *mut PyObject;
pub fn PyString_InternInPlace(string: *mut *mut PyObject);
pub fn PyString_InternFromString(v: *const c_char)
-> *mut PyObject;
pub fn PyString_Decode(s: *const c_char, size: Py_ssize_t,
encoding: *const c_char,
errors: *const c_char) -> *mut PyObject;
pub fn PyString_AsDecodedObject(str: *mut PyObject,
encoding: *const c_char,
errors: *const c_char)
-> *mut PyObject;
pub fn PyString_Encode(s: *const c_char, size: Py_ssize_t,
encoding: *const c_char,
errors: *const c_char) -> *mut PyObject;
pub fn PyString_AsEncodedObject(str: *mut PyObject,
encoding: *const c_char,
errors: *const c_char)
-> *mut PyObject;
/*
pub fn PyString_Repr(arg1: *mut PyObject, arg2: c_int)
-> *mut PyObject;
pub fn _PyString_Eq(arg1: *mut PyObject, arg2: *mut PyObject)
-> c_int;
pub fn _PyString_FormatLong(arg1: *mut PyObject, arg2: c_int,
arg3: c_int, arg4: c_int,
arg5: *mut *mut c_char,
arg6: *mut c_int) -> *mut PyObject;
pub fn PyString_DecodeEscape(arg1: *const c_char,
arg2: Py_ssize_t,
arg3: *const c_char,
arg4: Py_ssize_t,
arg5: *const c_char)
-> *mut PyObject;
pub fn PyString_InternImmortal(arg1: *mut *mut PyObject);
pub fn _Py_ReleaseInternedStrings();
pub fn _PyString_Join(sep: *mut PyObject, x: *mut PyObject)
-> *mut PyObject;
pub fn PyString_AsEncodedString(str: *mut PyObject,
encoding: *const c_char,
errors: *const c_char)
-> *mut PyObject;
pub fn PyString_AsDecodedString(str: *mut PyObject,
encoding: *const c_char,
errors: *const c_char)
-> *mut PyObject;
pub fn _PyString_InsertThousandsGroupingLocale(buffer:
*mut c_char,
n_buffer: Py_ssize_t,
digits:
*mut c_char,
n_digits: Py_ssize_t,
min_width: Py_ssize_t)
-> Py_ssize_t;
pub fn _PyString_InsertThousandsGrouping(buffer: *mut c_char,
n_buffer: Py_ssize_t,
digits: *mut c_char,
n_digits: Py_ssize_t,
min_width: Py_ssize_t,
grouping: *const c_char,
thousands_sep:
*const c_char)
-> Py_ssize_t;
pub fn _PyBytes_FormatAdvanced(obj: *mut PyObject,
format_spec: *mut c_char,
format_spec_len: Py_ssize_t)
-> *mut PyObject;*/
}

View File

@ -1,60 +0,0 @@
use libc::{c_char, c_int};
use pyport::Py_ssize_t;
use object::PyObject;
#[repr(C)]
#[derive(Copy, Clone)]
pub struct PyMemberDef {
pub name: *mut c_char,
pub type_code: c_int,
pub offset: Py_ssize_t,
pub flags: c_int,
pub doc: *mut c_char
}
/* Types */
pub const T_SHORT : c_int = 0;
pub const T_INT : c_int = 1;
pub const T_LONG : c_int = 2;
pub const T_FLOAT : c_int = 3;
pub const T_DOUBLE : c_int = 4;
pub const T_STRING : c_int = 5;
pub const T_OBJECT : c_int = 6;
/* XXX the ordering here is weird for binary compatibility */
pub const T_CHAR : c_int = 7; /* 1-character string */
pub const T_BYTE : c_int = 8; /* 8-bit signed int */
/* unsigned variants: */
pub const T_UBYTE : c_int = 9;
pub const T_USHORT : c_int = 10;
pub const T_UINT : c_int = 11;
pub const T_ULONG : c_int = 12;
/* Added by Jack: strings contained in the structure */
pub const T_STRING_INPLACE : c_int = 13;
/* Added by Lillo: bools contained in the structure (assumed char) */
pub const T_BOOL : c_int = 14;
pub const T_OBJECT_EX : c_int = 16; /* Like T_OBJECT, but raises AttributeError
when the value is NULL, instead of
converting to None. */
pub const T_LONGLONG : c_int = 17;
pub const T_ULONGLONG : c_int = 18;
pub const T_PYSSIZET : c_int = 19; /* Py_ssize_t */
/* Flags */
pub const READONLY : c_int = 1;
pub const RO : c_int = READONLY; /* Shorthand */
pub const READ_RESTRICTED : c_int = 2;
pub const PY_WRITE_RESTRICTED : c_int = 4;
pub const RESTRICTED : c_int = (READ_RESTRICTED | PY_WRITE_RESTRICTED);
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub fn PyMember_GetOne(addr: *const c_char, l: *mut PyMemberDef) -> *mut PyObject;
pub fn PyMember_SetOne(addr: *mut c_char, l: *mut PyMemberDef, value: *mut PyObject) -> c_int;
}

View File

@ -1,33 +0,0 @@
use libc::c_int;
use object::*;
use pyport::Py_ssize_t;
use frameobject::PyFrameObject;
#[repr(C)]
#[derive(Copy, Clone)]
pub struct PyTracebackObject {
#[cfg(py_sys_config="Py_TRACE_REFS")]
pub _ob_next: *mut PyObject,
#[cfg(py_sys_config="Py_TRACE_REFS")]
pub _ob_prev: *mut PyObject,
pub ob_refcnt: Py_ssize_t,
pub ob_type: *mut PyTypeObject,
pub tb_next: *mut PyTracebackObject,
pub tb_frame: *mut PyFrameObject,
pub tb_lasti: c_int,
pub tb_lineno: c_int
}
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub fn PyTraceBack_Here(arg1: *mut PyFrameObject) -> c_int;
pub fn PyTraceBack_Print(arg1: *mut PyObject, arg2: *mut PyObject)
-> c_int;
pub static mut PyTraceBack_Type: PyTypeObject;
}
#[inline(always)]
pub unsafe fn PyTraceBack_Check(op : *mut PyObject) -> c_int {
(Py_TYPE(op) == &mut PyTraceBack_Type) as c_int
}

View File

@ -1,66 +0,0 @@
use libc::c_int;
use pyport::Py_ssize_t;
use object::*;
#[repr(C)]
#[derive(Copy, Clone)]
pub struct PyTupleObject {
#[cfg(py_sys_config="Py_TRACE_REFS")]
pub _ob_next: *mut PyObject,
#[cfg(py_sys_config="Py_TRACE_REFS")]
pub _ob_prev: *mut PyObject,
pub ob_refcnt: Py_ssize_t,
pub ob_type: *mut PyTypeObject,
pub ob_size: Py_ssize_t,
pub ob_item: [*mut PyObject; 1],
}
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub static mut PyTuple_Type: PyTypeObject;
}
#[inline(always)]
pub unsafe fn PyTuple_Check(op : *mut PyObject) -> c_int {
PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_TUPLE_SUBCLASS)
}
#[inline(always)]
pub unsafe fn PyTuple_CheckExact(op : *mut PyObject) -> c_int {
let u : *mut PyTypeObject = &mut PyTuple_Type;
(Py_TYPE(op) == u) as c_int
}
// Macro, trading safety for speed
#[inline(always)]
pub unsafe fn PyTuple_GET_ITEM(op: *mut PyObject, i: Py_ssize_t) -> *mut PyObject {
*(*(op as *mut PyTupleObject)).ob_item.as_ptr().offset(i as isize)
}
#[inline(always)]
pub unsafe fn PyTuple_GET_SIZE(op: *mut PyObject) -> Py_ssize_t {
Py_SIZE(op)
}
/// Macro, *only* to be used to fill in brand new tuples
#[inline(always)]
pub unsafe fn PyTuple_SET_ITEM(op: *mut PyObject, i: Py_ssize_t, v: *mut PyObject) {
*(*(op as *mut PyTupleObject)).ob_item.as_mut_ptr().offset(i as isize) = v;
}
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub fn PyTuple_New(size: Py_ssize_t) -> *mut PyObject;
pub fn PyTuple_Size(p: *mut PyObject) -> Py_ssize_t;
pub fn PyTuple_GetItem(p: *mut PyObject, pos: Py_ssize_t)
-> *mut PyObject;
pub fn PyTuple_SetItem(p: *mut PyObject, pos: Py_ssize_t,
o: *mut PyObject) -> c_int;
pub fn PyTuple_GetSlice(p: *mut PyObject, low: Py_ssize_t,
high: Py_ssize_t) -> *mut PyObject;
pub fn _PyTuple_Resize(p: *mut *mut PyObject, newsize: Py_ssize_t)
-> c_int;
pub fn PyTuple_Pack(n: Py_ssize_t, ...) -> *mut PyObject;
//pub fn _PyTuple_MaybeUntrack(arg1: *mut PyObject);
pub fn PyTuple_ClearFreeList() -> c_int;
}

View File

@ -1,581 +0,0 @@
use libc::{c_char, c_int, c_long, c_double, wchar_t};
use pyport::Py_ssize_t;
use object::*;
#[cfg(py_sys_config="Py_UNICODE_SIZE_4")]
pub const Py_UNICODE_SIZE : Py_ssize_t = 4;
#[cfg(not(py_sys_config="Py_UNICODE_SIZE_4"))]
pub const Py_UNICODE_SIZE : Py_ssize_t = 2;
pub type Py_UCS4 = u32;
#[cfg(py_sys_config="Py_UNICODE_SIZE_4")]
pub type Py_UNICODE = u32;
#[cfg(not(py_sys_config="Py_UNICODE_SIZE_4"))]
pub type Py_UNICODE = u16;
#[repr(C)]
#[derive(Copy, Clone)]
pub struct PyUnicodeObject {
#[cfg(py_sys_config="Py_TRACE_REFS")]
pub _ob_next: *mut PyObject,
#[cfg(py_sys_config="Py_TRACE_REFS")]
pub _ob_prev: *mut PyObject,
pub ob_refcnt: Py_ssize_t,
pub ob_type: *mut PyTypeObject,
pub length: Py_ssize_t,
pub data: *mut Py_UNICODE,
pub hash: c_long,
pub defenc: *mut PyObject,
}
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub static mut PyUnicode_Type: PyTypeObject;
}
#[inline(always)]
pub unsafe fn PyUnicode_Check(op : *mut PyObject) -> c_int {
PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_UNICODE_SUBCLASS)
}
#[inline(always)]
pub unsafe fn PyUnicode_CheckExact(op : *mut PyObject) -> c_int {
let u : *mut PyTypeObject = &mut PyUnicode_Type;
(Py_TYPE(op) == u) as c_int
}
#[inline(always)]
pub unsafe fn PyUnicode_GET_SIZE(o: *mut PyObject) -> Py_ssize_t {
(*(o as *mut PyUnicodeObject)).length
}
#[inline(always)]
pub unsafe fn PyUnicode_GET_DATA_SIZE(o: *mut PyObject) -> Py_ssize_t {
(*(o as *mut PyUnicodeObject)).length * Py_UNICODE_SIZE
}
#[inline(always)]
pub unsafe fn PyUnicode_AS_UNICODE(o: *mut PyObject) -> *mut Py_UNICODE {
(*(o as *mut PyUnicodeObject)).data
}
#[inline(always)]
pub unsafe fn PyUnicode_AS_DATA(o: *mut PyObject) -> *const c_char {
(*(o as *mut PyUnicodeObject)).data as *const c_char
}
pub const Py_UNICODE_REPLACEMENT_CHARACTER : Py_UNICODE = 0xFFFD;
#[allow(dead_code)]
#[cfg(py_sys_config="Py_UNICODE_SIZE_4")]
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
fn PyUnicodeUCS4_FromUnicode(u: *const Py_UNICODE, size: Py_ssize_t)
-> *mut PyObject;
fn PyUnicodeUCS4_FromStringAndSize(u: *const c_char,
size: Py_ssize_t) -> *mut PyObject;
fn PyUnicodeUCS4_FromString(u: *const c_char)
-> *mut PyObject;
fn PyUnicodeUCS4_AsUnicode(unicode: *mut PyObject) -> *mut Py_UNICODE;
fn PyUnicodeUCS4_GetSize(unicode: *mut PyObject) -> Py_ssize_t;
fn PyUnicodeUCS4_GetMax() -> Py_UNICODE;
fn PyUnicodeUCS4_Resize(unicode: *mut *mut PyObject,
length: Py_ssize_t) -> c_int;
fn PyUnicodeUCS4_FromEncodedObject(obj: *mut PyObject,
encoding: *const c_char,
errors: *const c_char)
-> *mut PyObject;
fn PyUnicodeUCS4_FromObject(obj: *mut PyObject) -> *mut PyObject;
fn PyUnicodeUCS4_FromFormatV(arg1: *const c_char,
...) -> *mut PyObject;
fn PyUnicodeUCS4_FromFormat(arg1: *const c_char, ...)
-> *mut PyObject;
fn _PyUnicode_FormatAdvanced(obj: *mut PyObject,
format_spec: *mut Py_UNICODE,
format_spec_len: Py_ssize_t)
-> *mut PyObject;
fn PyUnicodeUCS4_FromWideChar(w: *const wchar_t, size: Py_ssize_t)
-> *mut PyObject;
fn PyUnicodeUCS4_AsWideChar(unicode: *mut PyUnicodeObject,
w: *mut wchar_t, size: Py_ssize_t)
-> Py_ssize_t;
fn PyUnicodeUCS4_FromOrdinal(ordinal: c_int) -> *mut PyObject;
fn PyUnicodeUCS4_ClearFreelist() -> c_int;
fn _PyUnicodeUCS4_AsDefaultEncodedString(arg1: *mut PyObject,
arg2: *const c_char)
-> *mut PyObject;
fn PyUnicodeUCS4_GetDefaultEncoding() -> *const c_char;
fn PyUnicodeUCS4_SetDefaultEncoding(encoding: *const c_char)
-> c_int;
fn PyUnicodeUCS4_Decode(s: *const c_char, size: Py_ssize_t,
encoding: *const c_char,
errors: *const c_char)
-> *mut PyObject;
fn PyUnicodeUCS4_Encode(s: *const Py_UNICODE, size: Py_ssize_t,
encoding: *const c_char,
errors: *const c_char)
-> *mut PyObject;
fn PyUnicodeUCS4_AsEncodedObject(unicode: *mut PyObject,
encoding: *const c_char,
errors: *const c_char)
-> *mut PyObject;
fn PyUnicodeUCS4_AsEncodedString(unicode: *mut PyObject,
encoding: *const c_char,
errors: *const c_char)
-> *mut PyObject;
fn PyUnicode_BuildEncodingMap(string: *mut PyObject) -> *mut PyObject;
fn PyUnicode_DecodeUTF7(string: *const c_char,
length: Py_ssize_t,
errors: *const c_char)
-> *mut PyObject;
fn PyUnicode_DecodeUTF7Stateful(string: *const c_char,
length: Py_ssize_t,
errors: *const c_char,
consumed: *mut Py_ssize_t)
-> *mut PyObject;
fn PyUnicode_EncodeUTF7(data: *const Py_UNICODE, length: Py_ssize_t,
base64SetO: c_int,
base64WhiteSpace: c_int,
errors: *const c_char)
-> *mut PyObject;
fn PyUnicodeUCS4_DecodeUTF8(string: *const c_char,
length: Py_ssize_t,
errors: *const c_char)
-> *mut PyObject;
fn PyUnicodeUCS4_DecodeUTF8Stateful(string: *const c_char,
length: Py_ssize_t,
errors: *const c_char,
consumed: *mut Py_ssize_t)
-> *mut PyObject;
fn PyUnicodeUCS4_AsUTF8String(unicode: *mut PyObject)
-> *mut PyObject;
fn PyUnicodeUCS4_EncodeUTF8(data: *const Py_UNICODE,
length: Py_ssize_t,
errors: *const c_char)
-> *mut PyObject;
fn PyUnicodeUCS4_DecodeUTF32(string: *const c_char,
length: Py_ssize_t,
errors: *const c_char,
byteorder: *mut c_int)
-> *mut PyObject;
fn PyUnicodeUCS4_DecodeUTF32Stateful(string: *const c_char,
length: Py_ssize_t,
errors: *const c_char,
byteorder: *mut c_int,
consumed: *mut Py_ssize_t)
-> *mut PyObject;
fn PyUnicodeUCS4_AsUTF32String(unicode: *mut PyObject)
-> *mut PyObject;
fn PyUnicodeUCS4_EncodeUTF32(data: *const Py_UNICODE,
length: Py_ssize_t,
errors: *const c_char,
byteorder: c_int)
-> *mut PyObject;
fn PyUnicodeUCS4_DecodeUTF16(string: *const c_char,
length: Py_ssize_t,
errors: *const c_char,
byteorder: *mut c_int)
-> *mut PyObject;
fn PyUnicodeUCS4_DecodeUTF16Stateful(string: *const c_char,
length: Py_ssize_t,
errors: *const c_char,
byteorder: *mut c_int,
consumed: *mut Py_ssize_t)
-> *mut PyObject;
fn PyUnicodeUCS4_AsUTF16String(unicode: *mut PyObject)
-> *mut PyObject;
fn PyUnicodeUCS4_EncodeUTF16(data: *const Py_UNICODE,
length: Py_ssize_t,
errors: *const c_char,
byteorder: c_int)
-> *mut PyObject;
fn PyUnicodeUCS4_DecodeUnicodeEscape(string: *const c_char,
length: Py_ssize_t,
errors: *const c_char)
-> *mut PyObject;
fn PyUnicodeUCS4_AsUnicodeEscapeString(unicode: *mut PyObject)
-> *mut PyObject;
fn PyUnicodeUCS4_EncodeUnicodeEscape(data: *const Py_UNICODE,
length: Py_ssize_t)
-> *mut PyObject;
fn PyUnicodeUCS4_DecodeRawUnicodeEscape(string: *const c_char,
length: Py_ssize_t,
errors: *const c_char)
-> *mut PyObject;
fn PyUnicodeUCS4_AsRawUnicodeEscapeString(unicode: *mut PyObject)
-> *mut PyObject;
fn PyUnicodeUCS4_EncodeRawUnicodeEscape(data: *const Py_UNICODE,
length: Py_ssize_t)
-> *mut PyObject;
fn _PyUnicode_DecodeUnicodeInternal(string: *const c_char,
length: Py_ssize_t,
errors: *const c_char)
-> *mut PyObject;
fn PyUnicodeUCS4_DecodeLatin1(string: *const c_char,
length: Py_ssize_t,
errors: *const c_char)
-> *mut PyObject;
fn PyUnicodeUCS4_AsLatin1String(unicode: *mut PyObject)
-> *mut PyObject;
fn PyUnicodeUCS4_EncodeLatin1(data: *const Py_UNICODE,
length: Py_ssize_t,
errors: *const c_char)
-> *mut PyObject;
fn PyUnicodeUCS4_DecodeASCII(string: *const c_char,
length: Py_ssize_t,
errors: *const c_char)
-> *mut PyObject;
fn PyUnicodeUCS4_AsASCIIString(unicode: *mut PyObject)
-> *mut PyObject;
fn PyUnicodeUCS4_EncodeASCII(data: *const Py_UNICODE,
length: Py_ssize_t,
errors: *const c_char)
-> *mut PyObject;
fn PyUnicodeUCS4_DecodeCharmap(string: *const c_char,
length: Py_ssize_t,
mapping: *mut PyObject,
errors: *const c_char)
-> *mut PyObject;
fn PyUnicodeUCS4_AsCharmapString(unicode: *mut PyObject,
mapping: *mut PyObject)
-> *mut PyObject;
fn PyUnicodeUCS4_EncodeCharmap(data: *const Py_UNICODE,
length: Py_ssize_t,
mapping: *mut PyObject,
errors: *const c_char)
-> *mut PyObject;
fn PyUnicodeUCS4_TranslateCharmap(data: *const Py_UNICODE,
length: Py_ssize_t,
table: *mut PyObject,
errors: *const c_char)
-> *mut PyObject;
fn PyUnicodeUCS4_EncodeDecimal(s: *mut Py_UNICODE, length: Py_ssize_t,
output: *mut c_char,
errors: *const c_char)
-> c_int;
fn PyUnicodeUCS4_Concat(left: *mut PyObject, right: *mut PyObject)
-> *mut PyObject;
fn PyUnicodeUCS4_Split(s: *mut PyObject, sep: *mut PyObject,
maxsplit: Py_ssize_t) -> *mut PyObject;
fn PyUnicodeUCS4_Splitlines(s: *mut PyObject, keepends: c_int)
-> *mut PyObject;
fn PyUnicodeUCS4_Partition(s: *mut PyObject, sep: *mut PyObject)
-> *mut PyObject;
fn PyUnicodeUCS4_RPartition(s: *mut PyObject, sep: *mut PyObject)
-> *mut PyObject;
fn PyUnicodeUCS4_RSplit(s: *mut PyObject, sep: *mut PyObject,
maxsplit: Py_ssize_t) -> *mut PyObject;
fn PyUnicodeUCS4_Translate(str: *mut PyObject, table: *mut PyObject,
errors: *const c_char)
-> *mut PyObject;
fn PyUnicodeUCS4_Join(separator: *mut PyObject, seq: *mut PyObject)
-> *mut PyObject;
fn PyUnicodeUCS4_Tailmatch(str: *mut PyObject, substr: *mut PyObject,
start: Py_ssize_t, end: Py_ssize_t,
direction: c_int) -> Py_ssize_t;
fn PyUnicodeUCS4_Find(str: *mut PyObject, substr: *mut PyObject,
start: Py_ssize_t, end: Py_ssize_t,
direction: c_int) -> Py_ssize_t;
fn PyUnicodeUCS4_Count(str: *mut PyObject, substr: *mut PyObject,
start: Py_ssize_t, end: Py_ssize_t)
-> Py_ssize_t;
fn PyUnicodeUCS4_Replace(str: *mut PyObject, substr: *mut PyObject,
replstr: *mut PyObject, maxcount: Py_ssize_t)
-> *mut PyObject;
fn PyUnicodeUCS4_Compare(left: *mut PyObject, right: *mut PyObject)
-> c_int;
fn PyUnicodeUCS4_RichCompare(left: *mut PyObject,
right: *mut PyObject, op: c_int)
-> *mut PyObject;
fn PyUnicodeUCS4_Format(format: *mut PyObject, args: *mut PyObject)
-> *mut PyObject;
fn PyUnicodeUCS4_Contains(container: *mut PyObject,
element: *mut PyObject) -> c_int;
fn _PyUnicode_XStrip(_self: *mut PyUnicodeObject,
striptype: c_int, sepobj: *mut PyObject)
-> *mut PyObject;
fn _PyUnicodeUCS4_IsLowercase(ch: Py_UNICODE) -> c_int;
fn _PyUnicodeUCS4_IsUppercase(ch: Py_UNICODE) -> c_int;
fn _PyUnicodeUCS4_IsTitlecase(ch: Py_UNICODE) -> c_int;
fn _PyUnicodeUCS4_IsWhitespace(ch: Py_UNICODE) -> c_int;
fn _PyUnicodeUCS4_IsLinebreak(ch: Py_UNICODE) -> c_int;
fn _PyUnicodeUCS4_ToLowercase(ch: Py_UNICODE) -> Py_UNICODE;
fn _PyUnicodeUCS4_ToUppercase(ch: Py_UNICODE) -> Py_UNICODE;
fn _PyUnicodeUCS4_ToTitlecase(ch: Py_UNICODE) -> Py_UNICODE;
fn _PyUnicodeUCS4_ToDecimalDigit(ch: Py_UNICODE) -> c_int;
fn _PyUnicodeUCS4_ToDigit(ch: Py_UNICODE) -> c_int;
fn _PyUnicodeUCS4_ToNumeric(ch: Py_UNICODE) -> c_double;
fn _PyUnicodeUCS4_IsDecimalDigit(ch: Py_UNICODE) -> c_int;
fn _PyUnicodeUCS4_IsDigit(ch: Py_UNICODE) -> c_int;
fn _PyUnicodeUCS4_IsNumeric(ch: Py_UNICODE) -> c_int;
fn _PyUnicodeUCS4_IsAlpha(ch: Py_UNICODE) -> c_int;
}
#[allow(dead_code)]
#[cfg(not(py_sys_config="Py_UNICODE_SIZE_4"))]
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
fn PyUnicodeUCS2_FromUnicode(u: *const Py_UNICODE, size: Py_ssize_t)
-> *mut PyObject;
fn PyUnicodeUCS2_FromStringAndSize(u: *const c_char,
size: Py_ssize_t) -> *mut PyObject;
fn PyUnicodeUCS2_FromString(u: *const c_char)
-> *mut PyObject;
fn PyUnicodeUCS2_AsUnicode(unicode: *mut PyObject) -> *mut Py_UNICODE;
fn PyUnicodeUCS2_GetSize(unicode: *mut PyObject) -> Py_ssize_t;
fn PyUnicodeUCS2_GetMax() -> Py_UNICODE;
fn PyUnicodeUCS2_Resize(unicode: *mut *mut PyObject,
length: Py_ssize_t) -> c_int;
fn PyUnicodeUCS2_FromEncodedObject(obj: *mut PyObject,
encoding: *const c_char,
errors: *const c_char)
-> *mut PyObject;
fn PyUnicodeUCS2_FromObject(obj: *mut PyObject) -> *mut PyObject;
fn PyUnicodeUCS2_FromFormatV(arg1: *const c_char,
...) -> *mut PyObject;
fn PyUnicodeUCS2_FromFormat(arg1: *const c_char, ...)
-> *mut PyObject;
fn _PyUnicode_FormatAdvanced(obj: *mut PyObject,
format_spec: *mut Py_UNICODE,
format_spec_len: Py_ssize_t)
-> *mut PyObject;
fn PyUnicodeUCS2_FromWideChar(w: *const wchar_t, size: Py_ssize_t)
-> *mut PyObject;
fn PyUnicodeUCS2_AsWideChar(unicode: *mut PyUnicodeObject,
w: *mut wchar_t, size: Py_ssize_t)
-> Py_ssize_t;
fn PyUnicodeUCS2_FromOrdinal(ordinal: c_int) -> *mut PyObject;
fn PyUnicodeUCS2_ClearFreelist() -> c_int;
fn _PyUnicodeUCS2_AsDefaultEncodedString(arg1: *mut PyObject,
arg2: *const c_char)
-> *mut PyObject;
fn PyUnicodeUCS2_GetDefaultEncoding() -> *const c_char;
fn PyUnicodeUCS2_SetDefaultEncoding(encoding: *const c_char)
-> c_int;
fn PyUnicodeUCS2_Decode(s: *const c_char, size: Py_ssize_t,
encoding: *const c_char,
errors: *const c_char)
-> *mut PyObject;
fn PyUnicodeUCS2_Encode(s: *const Py_UNICODE, size: Py_ssize_t,
encoding: *const c_char,
errors: *const c_char)
-> *mut PyObject;
fn PyUnicodeUCS2_AsEncodedObject(unicode: *mut PyObject,
encoding: *const c_char,
errors: *const c_char)
-> *mut PyObject;
fn PyUnicodeUCS2_AsEncodedString(unicode: *mut PyObject,
encoding: *const c_char,
errors: *const c_char)
-> *mut PyObject;
fn PyUnicode_BuildEncodingMap(string: *mut PyObject) -> *mut PyObject;
fn PyUnicode_DecodeUTF7(string: *const c_char,
length: Py_ssize_t,
errors: *const c_char)
-> *mut PyObject;
fn PyUnicode_DecodeUTF7Stateful(string: *const c_char,
length: Py_ssize_t,
errors: *const c_char,
consumed: *mut Py_ssize_t)
-> *mut PyObject;
fn PyUnicode_EncodeUTF7(data: *const Py_UNICODE, length: Py_ssize_t,
base64SetO: c_int,
base64WhiteSpace: c_int,
errors: *const c_char)
-> *mut PyObject;
fn PyUnicodeUCS2_DecodeUTF8(string: *const c_char,
length: Py_ssize_t,
errors: *const c_char)
-> *mut PyObject;
fn PyUnicodeUCS2_DecodeUTF8Stateful(string: *const c_char,
length: Py_ssize_t,
errors: *const c_char,
consumed: *mut Py_ssize_t)
-> *mut PyObject;
fn PyUnicodeUCS2_AsUTF8String(unicode: *mut PyObject)
-> *mut PyObject;
fn PyUnicodeUCS2_EncodeUTF8(data: *const Py_UNICODE,
length: Py_ssize_t,
errors: *const c_char)
-> *mut PyObject;
fn PyUnicodeUCS2_DecodeUTF32(string: *const c_char,
length: Py_ssize_t,
errors: *const c_char,
byteorder: *mut c_int)
-> *mut PyObject;
fn PyUnicodeUCS2_DecodeUTF32Stateful(string: *const c_char,
length: Py_ssize_t,
errors: *const c_char,
byteorder: *mut c_int,
consumed: *mut Py_ssize_t)
-> *mut PyObject;
fn PyUnicodeUCS2_AsUTF32String(unicode: *mut PyObject)
-> *mut PyObject;
fn PyUnicodeUCS2_EncodeUTF32(data: *const Py_UNICODE,
length: Py_ssize_t,
errors: *const c_char,
byteorder: c_int)
-> *mut PyObject;
fn PyUnicodeUCS2_DecodeUTF16(string: *const c_char,
length: Py_ssize_t,
errors: *const c_char,
byteorder: *mut c_int)
-> *mut PyObject;
fn PyUnicodeUCS2_DecodeUTF16Stateful(string: *const c_char,
length: Py_ssize_t,
errors: *const c_char,
byteorder: *mut c_int,
consumed: *mut Py_ssize_t)
-> *mut PyObject;
fn PyUnicodeUCS2_AsUTF16String(unicode: *mut PyObject)
-> *mut PyObject;
fn PyUnicodeUCS2_EncodeUTF16(data: *const Py_UNICODE,
length: Py_ssize_t,
errors: *const c_char,
byteorder: c_int)
-> *mut PyObject;
fn PyUnicodeUCS2_DecodeUnicodeEscape(string: *const c_char,
length: Py_ssize_t,
errors: *const c_char)
-> *mut PyObject;
fn PyUnicodeUCS2_AsUnicodeEscapeString(unicode: *mut PyObject)
-> *mut PyObject;
fn PyUnicodeUCS2_EncodeUnicodeEscape(data: *const Py_UNICODE,
length: Py_ssize_t)
-> *mut PyObject;
fn PyUnicodeUCS2_DecodeRawUnicodeEscape(string: *const c_char,
length: Py_ssize_t,
errors: *const c_char)
-> *mut PyObject;
fn PyUnicodeUCS2_AsRawUnicodeEscapeString(unicode: *mut PyObject)
-> *mut PyObject;
fn PyUnicodeUCS2_EncodeRawUnicodeEscape(data: *const Py_UNICODE,
length: Py_ssize_t)
-> *mut PyObject;
fn _PyUnicode_DecodeUnicodeInternal(string: *const c_char,
length: Py_ssize_t,
errors: *const c_char)
-> *mut PyObject;
fn PyUnicodeUCS2_DecodeLatin1(string: *const c_char,
length: Py_ssize_t,
errors: *const c_char)
-> *mut PyObject;
fn PyUnicodeUCS2_AsLatin1String(unicode: *mut PyObject)
-> *mut PyObject;
fn PyUnicodeUCS2_EncodeLatin1(data: *const Py_UNICODE,
length: Py_ssize_t,
errors: *const c_char)
-> *mut PyObject;
fn PyUnicodeUCS2_DecodeASCII(string: *const c_char,
length: Py_ssize_t,
errors: *const c_char)
-> *mut PyObject;
fn PyUnicodeUCS2_AsASCIIString(unicode: *mut PyObject)
-> *mut PyObject;
fn PyUnicodeUCS2_EncodeASCII(data: *const Py_UNICODE,
length: Py_ssize_t,
errors: *const c_char)
-> *mut PyObject;
fn PyUnicodeUCS2_DecodeCharmap(string: *const c_char,
length: Py_ssize_t,
mapping: *mut PyObject,
errors: *const c_char)
-> *mut PyObject;
fn PyUnicodeUCS2_AsCharmapString(unicode: *mut PyObject,
mapping: *mut PyObject)
-> *mut PyObject;
fn PyUnicodeUCS2_EncodeCharmap(data: *const Py_UNICODE,
length: Py_ssize_t,
mapping: *mut PyObject,
errors: *const c_char)
-> *mut PyObject;
fn PyUnicodeUCS2_TranslateCharmap(data: *const Py_UNICODE,
length: Py_ssize_t,
table: *mut PyObject,
errors: *const c_char)
-> *mut PyObject;
fn PyUnicodeUCS2_EncodeDecimal(s: *mut Py_UNICODE, length: Py_ssize_t,
output: *mut c_char,
errors: *const c_char)
-> c_int;
fn PyUnicodeUCS2_Concat(left: *mut PyObject, right: *mut PyObject)
-> *mut PyObject;
fn PyUnicodeUCS2_Split(s: *mut PyObject, sep: *mut PyObject,
maxsplit: Py_ssize_t) -> *mut PyObject;
fn PyUnicodeUCS2_Splitlines(s: *mut PyObject, keepends: c_int)
-> *mut PyObject;
fn PyUnicodeUCS2_Partition(s: *mut PyObject, sep: *mut PyObject)
-> *mut PyObject;
fn PyUnicodeUCS2_RPartition(s: *mut PyObject, sep: *mut PyObject)
-> *mut PyObject;
fn PyUnicodeUCS2_RSplit(s: *mut PyObject, sep: *mut PyObject,
maxsplit: Py_ssize_t) -> *mut PyObject;
fn PyUnicodeUCS2_Translate(str: *mut PyObject, table: *mut PyObject,
errors: *const c_char)
-> *mut PyObject;
fn PyUnicodeUCS2_Join(separator: *mut PyObject, seq: *mut PyObject)
-> *mut PyObject;
fn PyUnicodeUCS2_Tailmatch(str: *mut PyObject, substr: *mut PyObject,
start: Py_ssize_t, end: Py_ssize_t,
direction: c_int) -> Py_ssize_t;
fn PyUnicodeUCS2_Find(str: *mut PyObject, substr: *mut PyObject,
start: Py_ssize_t, end: Py_ssize_t,
direction: c_int) -> Py_ssize_t;
fn PyUnicodeUCS2_Count(str: *mut PyObject, substr: *mut PyObject,
start: Py_ssize_t, end: Py_ssize_t)
-> Py_ssize_t;
fn PyUnicodeUCS2_Replace(str: *mut PyObject, substr: *mut PyObject,
replstr: *mut PyObject, maxcount: Py_ssize_t)
-> *mut PyObject;
fn PyUnicodeUCS2_Compare(left: *mut PyObject, right: *mut PyObject)
-> c_int;
fn PyUnicodeUCS2_RichCompare(left: *mut PyObject,
right: *mut PyObject, op: c_int)
-> *mut PyObject;
fn PyUnicodeUCS2_Format(format: *mut PyObject, args: *mut PyObject)
-> *mut PyObject;
fn PyUnicodeUCS2_Contains(container: *mut PyObject,
element: *mut PyObject) -> c_int;
fn _PyUnicode_XStrip(_self: *mut PyUnicodeObject,
striptype: c_int, sepobj: *mut PyObject)
-> *mut PyObject;
fn _PyUnicodeUCS2_IsLowercase(ch: Py_UNICODE) -> c_int;
fn _PyUnicodeUCS2_IsUppercase(ch: Py_UNICODE) -> c_int;
fn _PyUnicodeUCS2_IsTitlecase(ch: Py_UNICODE) -> c_int;
fn _PyUnicodeUCS2_IsWhitespace(ch: Py_UNICODE) -> c_int;
fn _PyUnicodeUCS2_IsLinebreak(ch: Py_UNICODE) -> c_int;
fn _PyUnicodeUCS2_ToLowercase(ch: Py_UNICODE) -> Py_UNICODE;
fn _PyUnicodeUCS2_ToUppercase(ch: Py_UNICODE) -> Py_UNICODE;
fn _PyUnicodeUCS2_ToTitlecase(ch: Py_UNICODE) -> Py_UNICODE;
fn _PyUnicodeUCS2_ToDecimalDigit(ch: Py_UNICODE) -> c_int;
fn _PyUnicodeUCS2_ToDigit(ch: Py_UNICODE) -> c_int;
fn _PyUnicodeUCS2_ToNumeric(ch: Py_UNICODE) -> c_double;
fn _PyUnicodeUCS2_IsDecimalDigit(ch: Py_UNICODE) -> c_int;
fn _PyUnicodeUCS2_IsDigit(ch: Py_UNICODE) -> c_int;
fn _PyUnicodeUCS2_IsNumeric(ch: Py_UNICODE) -> c_int;
fn _PyUnicodeUCS2_IsAlpha(ch: Py_UNICODE) -> c_int;
}
#[inline(always)]
#[cfg(py_sys_config="Py_UNICODE_SIZE_4")]
pub unsafe fn PyUnicode_FromStringAndSize(u: *const c_char, size: Py_ssize_t) -> *mut PyObject {
PyUnicodeUCS4_FromStringAndSize(u, size)
}
#[inline(always)]
#[cfg(not(py_sys_config="Py_UNICODE_SIZE_4"))]
pub unsafe fn PyUnicode_FromStringAndSize(u: *const c_char, size: Py_ssize_t) -> *mut PyObject {
PyUnicodeUCS2_FromStringAndSize(u, size)
}
#[inline(always)]
#[cfg(py_sys_config="Py_UNICODE_SIZE_4")]
pub unsafe fn PyUnicode_AsUTF8String(u: *mut PyObject) -> *mut PyObject {
PyUnicodeUCS4_AsUTF8String(u)
}
#[inline(always)]
#[cfg(not(py_sys_config="Py_UNICODE_SIZE_4"))]
pub unsafe fn PyUnicode_AsUTF8String(u: *mut PyObject) -> *mut PyObject {
PyUnicodeUCS2_AsUTF8String(u)
}

View File

@ -1,20 +0,0 @@
use libc::{c_char, c_int};
use pyport::Py_ssize_t;
use object::PyObject;
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub fn PyErr_WarnEx(category: *mut PyObject, msg: *const c_char,
stacklevel: Py_ssize_t) -> c_int;
pub fn PyErr_WarnExplicit(arg1: *mut PyObject,
arg2: *const c_char,
arg3: *const c_char,
arg4: c_int,
arg5: *const c_char,
arg6: *mut PyObject) -> c_int;
}
#[inline]
pub unsafe fn PyErr_Warn(category: *mut PyObject, msg: *const c_char) -> c_int {
PyErr_WarnEx(category, msg, 1)
}

View File

@ -1,64 +0,0 @@
use libc::{c_int, c_long};
use pyport::Py_ssize_t;
use object::*;
#[repr(C)]
#[derive(Copy, Clone)]
pub struct PyWeakReference {
#[cfg(py_sys_config="Py_TRACE_REFS")]
pub _ob_next: *mut PyObject,
#[cfg(py_sys_config="Py_TRACE_REFS")]
pub _ob_prev: *mut PyObject,
pub ob_refcnt: Py_ssize_t,
pub ob_type: *mut PyTypeObject,
pub wr_object: *mut PyObject,
pub wr_callback: *mut PyObject,
pub hash: c_long,
pub wr_prev: *mut PyWeakReference,
pub wr_next: *mut PyWeakReference
}
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
static mut _PyWeakref_RefType: PyTypeObject;
static mut _PyWeakref_ProxyType: PyTypeObject;
static mut _PyWeakref_CallableProxyType: PyTypeObject;
}
#[inline(always)]
pub unsafe fn PyWeakref_CheckRef(op: *mut PyObject) -> c_int {
PyObject_TypeCheck(op, &mut _PyWeakref_RefType)
}
#[inline(always)]
pub unsafe fn PyWeakref_CheckRefExact(op: *mut PyObject) -> c_int {
(Py_TYPE(op) == &mut _PyWeakref_RefType) as c_int
}
#[inline(always)]
pub unsafe fn PyWeakref_CheckProxy(op: *mut PyObject) -> c_int {
((Py_TYPE(op) == &mut _PyWeakref_ProxyType) ||
(Py_TYPE(op) == &mut _PyWeakref_CallableProxyType)) as c_int
}
#[inline(always)]
pub unsafe fn PyWeakref_Check(op: *mut PyObject) -> c_int {
(PyWeakref_CheckRef(op) != 0 || PyWeakref_CheckProxy(op) != 0) as c_int
}
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub fn PyWeakref_NewRef(ob: *mut PyObject, callback: *mut PyObject)
-> *mut PyObject;
pub fn PyWeakref_NewProxy(ob: *mut PyObject, callback: *mut PyObject)
-> *mut PyObject;
pub fn PyWeakref_GetObject(_ref: *mut PyObject) -> *mut PyObject;
pub fn _PyWeakref_GetWeakrefCount(head: *mut PyWeakReference) -> Py_ssize_t;
pub fn _PyWeakref_ClearRef(slf: *mut PyWeakReference);
}
#[inline(always)]
pub unsafe fn PyWeakref_GET_OBJECT(_ref: *mut PyObject) -> *mut PyObject {
let obj = (*(_ref as *mut PyWeakReference)).wr_object;
if Py_REFCNT(obj) > 0 { obj } else { Py_None() }
}