added completly new version for haslach 2025

master
fotobox 2025-03-17 03:47:13 +01:00
parent 152832515c
commit 769ab91da8
2333 changed files with 409208 additions and 341 deletions

BIN
.DS_Store vendored Normal file

Binary file not shown.

3
.idea/.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml

10
.idea/fotobox.iml Normal file
View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/venv" />
</content>
<orderEntry type="jdk" jdkName="Python 3.9 (fotobox)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View File

@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>

4
.idea/misc.xml Normal file
View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9 (fotobox)" project-jdk-type="Python SDK" />
</project>

8
.idea/modules.xml Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/fotobox.iml" filepath="$PROJECT_DIR$/.idea/fotobox.iml" />
</modules>
</component>
</project>

6
.idea/vcs.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

76
.venv/bin/activate Normal file
View File

@ -0,0 +1,76 @@
# This file must be used with "source bin/activate" *from bash*
# you cannot run it directly
deactivate () {
# reset old environment variables
if [ -n "${_OLD_VIRTUAL_PATH:-}" ] ; then
PATH="${_OLD_VIRTUAL_PATH:-}"
export PATH
unset _OLD_VIRTUAL_PATH
fi
if [ -n "${_OLD_VIRTUAL_PYTHONHOME:-}" ] ; then
PYTHONHOME="${_OLD_VIRTUAL_PYTHONHOME:-}"
export PYTHONHOME
unset _OLD_VIRTUAL_PYTHONHOME
fi
# This should detect bash and zsh, which have a hash command that must
# be called to get it to forget past commands. Without forgetting
# past commands the $PATH changes we made may not be respected
if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then
hash -r
fi
if [ -n "${_OLD_VIRTUAL_PS1:-}" ] ; then
PS1="${_OLD_VIRTUAL_PS1:-}"
export PS1
unset _OLD_VIRTUAL_PS1
fi
unset VIRTUAL_ENV
if [ ! "$1" = "nondestructive" ] ; then
# Self destruct!
unset -f deactivate
fi
}
# unset irrelevant variables
deactivate nondestructive
VIRTUAL_ENV="/home/pi/fotobox/.venv"
export VIRTUAL_ENV
_OLD_VIRTUAL_PATH="$PATH"
PATH="$VIRTUAL_ENV/bin:$PATH"
export PATH
# unset PYTHONHOME if set
# this will fail if PYTHONHOME is set to the empty string (which is bad anyway)
# could use `if (set -u; : $PYTHONHOME) ;` in bash
if [ -n "${PYTHONHOME:-}" ] ; then
_OLD_VIRTUAL_PYTHONHOME="${PYTHONHOME:-}"
unset PYTHONHOME
fi
if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT:-}" ] ; then
_OLD_VIRTUAL_PS1="${PS1:-}"
if [ "x(.venv) " != x ] ; then
PS1="(.venv) ${PS1:-}"
else
if [ "`basename \"$VIRTUAL_ENV\"`" = "__" ] ; then
# special case for Aspen magic directories
# see http://www.zetadev.com/software/aspen/
PS1="[`basename \`dirname \"$VIRTUAL_ENV\"\``] $PS1"
else
PS1="(`basename \"$VIRTUAL_ENV\"`)$PS1"
fi
fi
export PS1
fi
# This should detect bash and zsh, which have a hash command that must
# be called to get it to forget past commands. Without forgetting
# past commands the $PATH changes we made may not be respected
if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then
hash -r
fi

37
.venv/bin/activate.csh Normal file
View File

@ -0,0 +1,37 @@
# This file must be used with "source bin/activate.csh" *from csh*.
# You cannot run it directly.
# Created by Davide Di Blasi <davidedb@gmail.com>.
# Ported to Python 3.3 venv by Andrew Svetlov <andrew.svetlov@gmail.com>
alias deactivate 'test $?_OLD_VIRTUAL_PATH != 0 && setenv PATH "$_OLD_VIRTUAL_PATH" && unset _OLD_VIRTUAL_PATH; rehash; test $?_OLD_VIRTUAL_PROMPT != 0 && set prompt="$_OLD_VIRTUAL_PROMPT" && unset _OLD_VIRTUAL_PROMPT; unsetenv VIRTUAL_ENV; test "\!:*" != "nondestructive" && unalias deactivate'
# Unset irrelevant variables.
deactivate nondestructive
setenv VIRTUAL_ENV "/home/pi/fotobox/.venv"
set _OLD_VIRTUAL_PATH="$PATH"
setenv PATH "$VIRTUAL_ENV/bin:$PATH"
set _OLD_VIRTUAL_PROMPT="$prompt"
if (! "$?VIRTUAL_ENV_DISABLE_PROMPT") then
if (".venv" != "") then
set env_name = ".venv"
else
if (`basename "VIRTUAL_ENV"` == "__") then
# special case for Aspen magic directories
# see http://www.zetadev.com/software/aspen/
set env_name = `basename \`dirname "$VIRTUAL_ENV"\``
else
set env_name = `basename "$VIRTUAL_ENV"`
endif
endif
set prompt = "[$env_name] $prompt"
unset env_name
endif
alias pydoc python -m pydoc
rehash

75
.venv/bin/activate.fish Normal file
View File

@ -0,0 +1,75 @@
# This file must be used with ". bin/activate.fish" *from fish* (http://fishshell.org)
# you cannot run it directly
function deactivate -d "Exit virtualenv and return to normal shell environment"
# reset old environment variables
if test -n "$_OLD_VIRTUAL_PATH"
set -gx PATH $_OLD_VIRTUAL_PATH
set -e _OLD_VIRTUAL_PATH
end
if test -n "$_OLD_VIRTUAL_PYTHONHOME"
set -gx PYTHONHOME $_OLD_VIRTUAL_PYTHONHOME
set -e _OLD_VIRTUAL_PYTHONHOME
end
if test -n "$_OLD_FISH_PROMPT_OVERRIDE"
functions -e fish_prompt
set -e _OLD_FISH_PROMPT_OVERRIDE
functions -c _old_fish_prompt fish_prompt
functions -e _old_fish_prompt
end
set -e VIRTUAL_ENV
if test "$argv[1]" != "nondestructive"
# Self destruct!
functions -e deactivate
end
end
# unset irrelevant variables
deactivate nondestructive
set -gx VIRTUAL_ENV "/home/pi/fotobox/.venv"
set -gx _OLD_VIRTUAL_PATH $PATH
set -gx PATH "$VIRTUAL_ENV/bin" $PATH
# unset PYTHONHOME if set
if set -q PYTHONHOME
set -gx _OLD_VIRTUAL_PYTHONHOME $PYTHONHOME
set -e PYTHONHOME
end
if test -z "$VIRTUAL_ENV_DISABLE_PROMPT"
# fish uses a function instead of an env var to generate the prompt.
# save the current fish_prompt function as the function _old_fish_prompt
functions -c fish_prompt _old_fish_prompt
# with the original prompt function renamed, we can override with our own.
function fish_prompt
# Save the return status of the last command
set -l old_status $status
# Prompt override?
if test -n "(.venv) "
printf "%s%s" "(.venv) " (set_color normal)
else
# ...Otherwise, prepend env
set -l _checkbase (basename "$VIRTUAL_ENV")
if test $_checkbase = "__"
# special case for Aspen magic directories
# see http://www.zetadev.com/software/aspen/
printf "%s[%s]%s " (set_color -b blue white) (basename (dirname "$VIRTUAL_ENV")) (set_color normal)
else
printf "%s(%s)%s" (set_color -b blue white) (basename "$VIRTUAL_ENV") (set_color normal)
end
end
# Restore the return status of the previous command.
echo "exit $old_status" | .
_old_fish_prompt
end
set -gx _OLD_FISH_PROMPT_OVERRIDE "$VIRTUAL_ENV"
end

10
.venv/bin/easy_install Executable file
View File

@ -0,0 +1,10 @@
#!/home/pi/fotobox/.venv/bin/python3
# -*- coding: utf-8 -*-
import re
import sys
from setuptools.command.easy_install import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
sys.exit(main())

10
.venv/bin/easy_install-3.7 Executable file
View File

@ -0,0 +1,10 @@
#!/home/pi/fotobox/.venv/bin/python3
# -*- coding: utf-8 -*-
import re
import sys
from setuptools.command.easy_install import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
sys.exit(main())

10
.venv/bin/normalizer Executable file
View File

@ -0,0 +1,10 @@
#!/home/pi/fotobox/.venv/bin/python3
# -*- coding: utf-8 -*-
import re
import sys
from charset_normalizer.cli.normalizer import cli_detect
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
sys.exit(cli_detect())

10
.venv/bin/pinout Executable file
View File

@ -0,0 +1,10 @@
#!/home/pi/fotobox/.venv/bin/python3
# -*- coding: utf-8 -*-
import re
import sys
from gpiozerocli.pinout import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
sys.exit(main())

10
.venv/bin/pip Executable file
View File

@ -0,0 +1,10 @@
#!/home/pi/fotobox/.venv/bin/python3
# -*- coding: utf-8 -*-
import re
import sys
from pip._internal import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
sys.exit(main())

10
.venv/bin/pip3 Executable file
View File

@ -0,0 +1,10 @@
#!/home/pi/fotobox/.venv/bin/python3
# -*- coding: utf-8 -*-
import re
import sys
from pip._internal import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
sys.exit(main())

10
.venv/bin/pip3.7 Executable file
View File

@ -0,0 +1,10 @@
#!/home/pi/fotobox/.venv/bin/python3
# -*- coding: utf-8 -*-
import re
import sys
from pip._internal import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
sys.exit(main())

1
.venv/bin/python Symbolic link
View File

@ -0,0 +1 @@
python3

1
.venv/bin/python3 Symbolic link
View File

@ -0,0 +1 @@
/usr/bin/python3

624
.venv/bin/wdc Executable file
View File

@ -0,0 +1,624 @@
#!/usr/bin/python
# PYTHON_ARGCOMPLETE_OK
from __future__ import print_function
import argparse
import getpass
import os
import platform
import shlex
import struct
import subprocess
import sys
from base64 import b64decode, b64encode
from distutils.util import strtobool
import argcomplete
from webdav3.client import Client, WebDavException, NotConnection, Urn
def get_terminal_size():
current_os = platform.system()
tuple_xy = None
if current_os == 'Windows':
tuple_xy = _get_terminal_size_windows()
if tuple_xy is None:
tuple_xy = _get_terminal_size_input()
if current_os in ['Linux', 'Darwin'] or current_os.startswith('CYGWIN'):
tuple_xy = _get_terminal_size_linux()
if tuple_xy is None:
tuple_xy = 80, 25
return tuple_xy
def _get_terminal_size_windows():
try:
from ctypes import windll, create_string_buffer
h = windll.kernel32.GetStdHandle(-12)
csbi = create_string_buffer(22)
res = windll.kernel32.GetConsoleScreenBufferInfo(h, csbi)
if res:
(bufx, bufy, curx, cury, wattr, left, top, right, bottom, maxx, maxy) = struct.unpack("hhhhHhhhhhh", csbi.raw)
sizex = right - left + 1
sizey = bottom - top + 1
return sizex, sizey
except:
pass
def _get_terminal_size_input():
try:
cols = int(subprocess.check_call(shlex.split('tput cols')))
rows = int(subprocess.check_call(shlex.split('tput lines')))
return (cols, rows)
except:
pass
def _get_terminal_size_linux():
def ioctl_GWINSZ(fd):
try:
import fcntl
import termios
return struct.unpack('hh', fcntl.ioctl(fd, termios.TIOCGWINSZ, '1234'))
except:
pass
cr = ioctl_GWINSZ(0) or ioctl_GWINSZ(1) or ioctl_GWINSZ(2)
if not cr:
try:
fd = os.open(os.ctermid(), os.O_RDONLY)
cr = ioctl_GWINSZ(fd)
os.close(fd)
except:
pass
if not cr:
try:
cr = (os.environ['LINES'], os.environ['COLUMNS'])
except:
return None
return int(cr[1]), int(cr[0])
class ProgressBar:
def __init__(self):
self.precise = 0
self.total = 0
def show(self):
progress_line = self._progress_line()
import sys
if self.precise == 100:
print(progress_line, end="")
else:
print(progress_line, end="")
sys.stdout.write("\r")
def _progress_line(self):
sizex, sizey = get_terminal_size()
available_width = sizex
precise = self._get_field_precise()
ratio = self._get_field_ratio()
available_width -= len(precise) + len(ratio)
progress = self._get_field_progress(available_width-2)
return "{precise} {progress} {ratio}".format(precise=precise, progress=progress, ratio=ratio)
def _get_field_precise(self):
line = "{precise}%".format(precise=self.precise)
return "{:<4}".format(line)
def _get_field_ratio(self):
current = float(self.precise * self.total / 100)
total = float(self.total)
current_line = "{:.2f}".format(current)
total_line = "{:.2f}".format(total)
line = "{current}/{total}".format(current=current_line, total=total_line)
available = len(total_line) * 2 + 1
format_line = "{prefix}{value}{sufix}".format(prefix="{:>", value=available, sufix="}")
line = format_line.format(line)
return line
def _get_field_progress(self, width):
available_width = width - 2
current = int(self.precise * available_width / 100)
available_width -= current + 1
tip = ">" if not self.precise == 100 else ""
progress = "{arrow}{tip}{space}".format(arrow="=" * current, tip=tip, space=" " * available_width)
return "[{progress}]".format(progress=progress)
def callback(self, current, total):
if total and not self.total:
self.total = total
if not total:
return
precise = int(float(current) * 100 / total)
if self.precise == precise:
return
else:
self.precise = precise
self.show()
setting_keys = ['webdav_hostname', 'webdav_root', 'webdav_login', 'webdav_password', 'webdav_token',
'proxy_hostname', 'proxy_login', 'proxy_password',
'cert_path', 'key_path']
crypto_keys = ['webdav_password', 'webdav_token', 'proxy_password']
def encoding(source):
if not source:
return ""
return b64encode(source.encode('utf-8'))
def decoding(source):
if not source:
return ""
return b64decode(source).decode('utf-8')
def import_options():
options = dict()
for setting_key in setting_keys:
options[setting_key] = os.environ.get(setting_key.upper())
for crypto_key in crypto_keys:
if not options[crypto_key]:
continue
options[crypto_key] = decoding(options[crypto_key])
return options
def valid(options):
if 'webdav_hostname' not in options:
return False
if not options['webdav_token'] and not options['webdav_login']:
return False
if options['webdav_login'] and not options['webdav_password']:
return False
return True
class Formatter(argparse.RawTextHelpFormatter):
def _get_default_metavar_for_optional(self, action):
if not action.option_strings:
return action.dest
else:
return ""
def _format_action_invocation(self, action):
if not action.option_strings:
default = self._get_default_metavar_for_optional(action)
metavar, = self._metavar_formatter(action, default)(1)
return metavar
else:
parts = []
if action.nargs == 0:
parts.extend(action.option_strings)
else:
default = self._get_default_metavar_for_optional(action)
args_string = self._format_args(action, default)
for option_string in action.option_strings:
parts.append(option_string)
return '%s %s' % (', '.join(parts), args_string)
return ', '.join(parts)
def _metavar_formatter(self, action, default_metavar):
if action.metavar is not None:
result = action.metavar
else:
result = default_metavar
def format(tuple_size):
if isinstance(result, tuple):
return result
else:
return (result, ) * tuple_size
return format
def logging_exception(exception):
print(exception)
def urn_completer(prefix, **kwargs):
options = import_options()
try:
client = Client(options)
prefix_urn = Urn(prefix)
if prefix_urn.is_dir():
return (prefix+filename for filename in client.list(prefix_urn.path()))
else:
parent = prefix_urn.parent()
prefix_filename = prefix_urn.filename()
prefix_filename_length = len(prefix_filename)
return (prefix + filename[prefix_filename_length:] for filename in client.list(parent) if filename.startswith(prefix_filename))
except WebDavException:
pass
return tuple()
if __name__ == "__main__":
epilog = """
Examples:
--------
$ wdc login https://webdav.server.ru
webdav_login: login
webdav_password: password
success
$ wdc login https://webdav.server.ru --token xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
not success
$ wdc check
success
$ wdc check file1
not success
$ wdc free
245234120344
$ wdc ls dir1
file1
...
fileN
$ wdc mkdir dir2
$ wdc copy dir1/file1 -t dir2/file1
$ wdc move dir2/file1 -t dir2/file2
$ wdc download dir1/file1 -t ~/Downloads/file1
$ wdc download dir1/ -t ~/Downloads/dir1/
$ wdc upload dir2/file2 -f ~/Documents/file1
$ wdc upload dir2/ -f ~/Documents/
$ wdc publish di2/file2
https://yadi.sk/i/vWtTUcBucAc6k
$ wdc unpublish dir2/file2
$ wdc pull dir1/ -t ~/Documents/dir1/
$ wdc push dir1/ -f ~/Documents/dir1/
$ wdc info dir1/file1
{'name': 'file1', 'modified': 'Thu, 23 Oct 2014 16:16:37 GMT',
'size': '3460064', 'created': '2014-10-23T16:16:37Z'}
"""
usage = """
wdc [-h] [-v]
wdc login https://webdav.server.ru [--token] [-r] [-p] [-c] [-k]
wdc [action] [path] [-t] [-f]
"""
actions = "login logout check info free ls clean mkdir copy move download upload publish unpublish push pull".split()
actions_help = "check, info, free, ls, clean, mkdir, copy, move,\ndownload, upload, publish, unpublish, push, pull"
parser = argparse.ArgumentParser(prog='wdc', formatter_class=Formatter, epilog=epilog, usage=usage)
parser.add_argument("action", help=actions_help, choices=actions)
from webdav3.client import __version__ as version
version_text = "{name} {version}".format(name="%(prog)s", version=version)
parser.add_argument("-v", '--version', action='version', version=version_text)
parser.add_argument("-r", "--root", help="example: dir1/dir2")
parser.add_argument("--token", help="example: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
parser.add_argument("-c", "--cert-path", help="example: /etc/ssl/certs/certificate.crt")
parser.add_argument("-k", "--key-path", help="example: /etc/ssl/private/certificate.key")
parser.add_argument("-p", "--proxy", help="example: http://127.0.0.1:8080")
parser.add_argument("path", help="example: dir1/dir2/file1", nargs='?').completer = urn_completer
parser.add_argument("-f", '--from-path', help="example: ~/Documents/file1")
parser.add_argument("-t", "--to-path", help="example for download and pull: ~/Download/file1\nexample for copy and move: dir1/dir2").completer = urn_completer
argcomplete.autocomplete(parser, exclude=("-h", "--help", "--proxy", "-p", "-r", "--root", "-c", "--cert-path", "-t", "--to-path", "-v", "--version", "-f", "--from-path", "-k", "--key-path"))
args = parser.parse_args()
action = args.action
if action == 'login':
env = dict()
if not args.path:
try:
env['webdav_hostname'] = raw_input("webdav_hostname: ")
except NameError:
env['webdav_hostname'] = input("webdav_hostname: ")
else:
env['webdav_hostname'] = args.path
if not args.token:
try:
env['webdav_login'] = raw_input("webdav_login: ")
except NameError:
env['webdav_login'] = input("webdav_login: ")
env['webdav_password'] = getpass.getpass("webdav_password: ")
else:
env['webdav_token'] = args.token
if args.proxy:
env['proxy_hostname'] = args.proxy
try:
env['proxy_login'] = raw_input("proxy_login: ")
except NameError:
env['proxy_login'] = input("proxy_login: ")
env['proxy_password'] = getpass.getpass("proxy_password: ")
if args.root:
env['webdav_root'] = args.root
if args.cert_path:
env['cert_path'] = args.cert_path
if args.key_path:
env['key_path'] = args.key_path
try:
client = Client(env)
check = client.check()
text = "success" if check else "not success"
print(text)
if check:
for crypto_key in crypto_keys:
if crypto_key not in env:
continue
if not env[crypto_key]:
continue
env[crypto_key] = encoding(env[crypto_key])
for (key, value) in env.items():
os.putenv(key.upper(), value)
os.system('bash')
except WebDavException as e:
print("not success")
sys.exit()
else:
options = import_options()
if not valid(options):
print("First log on webdav server using the following command: wdc login.")
sys.exit()
elif action == "logout":
os.system("exit")
elif action == 'check':
options = import_options()
try:
client = Client(options)
connection = client.check()
if not connection:
raise NotConnection(options["webdav_hostname"])
check = client.check(args.path) if args.path else client.check()
text = "success" if check else "not success"
print(text)
except WebDavException as e:
logging_exception(e)
elif action == 'free':
options = import_options()
try:
client = Client(options)
connection = client.check()
if not connection:
raise NotConnection(options["webdav_hostname"])
free_size = client.free()
print(free_size)
except WebDavException as e:
logging_exception(e)
elif action == 'ls':
options = import_options()
try:
client = Client(options)
connection = client.check()
if not connection:
raise NotConnection(options["webdav_hostname"])
paths = client.list(args.path) if args.path else client.list()
for path in paths:
print(path)
except WebDavException as e:
logging_exception(e)
elif action == 'clean':
if not args.path:
parser.print_help()
else:
options = import_options()
try:
client = Client(options)
connection = client.check()
if not connection:
raise NotConnection(options["webdav_hostname"])
client.clean(args.path)
except WebDavException as e:
logging_exception(e)
elif action == 'mkdir':
if not args.path:
parser.print_help()
else:
options = import_options()
try:
client = Client(options)
connection = client.check()
if not connection:
raise NotConnection(options["webdav_hostname"])
client.mkdir(args.path)
except WebDavException as e:
logging_exception(e)
elif action == 'copy':
if not args.path or not args.to_path:
parser.print_help()
else:
options = import_options()
try:
client = Client(options)
connection = client.check()
if not connection:
raise NotConnection(options["webdav_hostname"])
client.copy(remote_path_from=args.path, remote_path_to=args.to_path)
except WebDavException as e:
logging_exception(e)
elif action == 'move':
if not args.path or not args.to_path:
parser.print_help()
else:
options = import_options()
try:
client = Client(options)
connection = client.check()
if not connection:
raise NotConnection(options["webdav_hostname"])
client.move(remote_path_from=args.path, remote_path_to=args.to_path)
except WebDavException as e:
logging_exception(e)
elif action == 'download':
if not args.path or not args.to_path:
parser.print_help()
else:
options = import_options()
progress_bar = ProgressBar()
def download_progress(download_t, download_d, upload_t, upload_d):
progress_bar.callback(current=download_d, total=download_t)
try:
client = Client(options)
connection = client.check()
if not connection:
raise NotConnection(options["webdav_hostname"])
if not os.path.exists(path=args.to_path):
client.download(remote_path=args.path, local_path=args.to_path, progress=download_progress)
print("\n")
else:
try:
choice = raw_input("Local path exists, do you want to overwrite it? [Y/n] ")
except NameError:
choice = input("Local path exists, do you want to overwrite it? [Y/n] ")
try:
yes = strtobool(choice.lower())
if yes:
client.download(remote_path=args.path, local_path=args.to_path, progress=download_progress)
print("\n")
except ValueError:
print("Incorrect answer")
except WebDavException as e:
logging_exception(e)
elif action == 'upload':
if not args.path or not args.from_path:
parser.print_help()
else:
options = import_options()
progress_bar = ProgressBar()
def upload_progress(download_t, download_d, upload_t, upload_d):
progress_bar.callback(current=upload_d, total=upload_t)
try:
client = Client(options)
connection = client.check()
if not connection:
raise NotConnection(options["webdav_hostname"])
if not client.check(remote_path=args.path):
client.upload(remote_path=args.path, local_path=args.from_path, progress=upload_progress)
print("\n")
else:
try:
choice = raw_input("Remote resource exists, do you want to overwrite it? [Y/n] ")
except NameError:
choice = input("Remote resource exists, do you want to overwrite it? [Y/n] ")
try:
yes = strtobool(choice.lower())
if yes:
client.upload(remote_path=args.path, local_path=args.from_path, progress=upload_progress)
print("\n")
except ValueError:
print("Incorrect answer")
except WebDavException as e:
logging_exception(e)
elif action == 'publish':
if not args.path:
parser.print_help()
else:
options = import_options()
try:
client = Client(options)
connection = client.check()
if not connection:
raise NotConnection(options["webdav_hostname"])
link = client.publish(args.path)
print(link)
except WebDavException as e:
logging_exception(e)
elif action == 'unpublish':
if not args.path:
parser.print_help()
else:
options = import_options()
try:
client = Client(options)
connection = client.check()
if not connection:
raise NotConnection(options["webdav_hostname"])
client.unpublish(args.path)
except WebDavException as e:
logging_exception(e)
elif action == 'push':
if not args.path or not args.from_path:
parser.print_help()
else:
options = import_options()
try:
client = Client(options)
connection = client.check()
if not connection:
raise NotConnection(options["webdav_hostname"])
client.push(remote_directory=args.path, local_directory=args.from_path)
except WebDavException as e:
logging_exception(e)
elif action == 'pull':
if not args.path or not args.to_path:
parser.print_help()
else:
options = import_options()
try:
client = Client(options)
connection = client.check()
if not connection:
raise NotConnection(options["webdav_hostname"])
client.pull(remote_directory=args.path, local_directory=args.to_path)
except WebDavException as e:
logging_exception(e)
elif action == 'info':
if not args.path:
parser.print_help()
else:
options = import_options()
try:
client = Client(options)
connection = client.check()
if not connection:
raise NotConnection(options["webdav_hostname"])
info = client.info(args.path)
print(info)
except WebDavException as e:
logging_exception(e)
else:
parser.print_help()

View File

@ -0,0 +1,21 @@
#define NO_PYGAME_C_API
#include "_surface.h"
/* The structure passed to the low level blit functions */
typedef struct {
int width;
int height;
Uint8 *s_pixels;
int s_pxskip;
int s_skip;
Uint8 *d_pixels;
int d_pxskip;
int d_skip;
SDL_PixelFormat *src;
SDL_PixelFormat *dst;
Uint8 src_blanket_alpha;
int src_has_colorkey;
Uint32 src_colorkey;
SDL_BlendMode src_blend;
SDL_BlendMode dst_blend;
} SDL_BlitInfo;

View File

@ -0,0 +1,26 @@
/*
pygame - Python Game Library
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _CAMERA_H
#define _CAMERA_H
#include "_pygame.h"
#include "camera.h"
#endif

View File

@ -0,0 +1,374 @@
/*
pygame - Python Game Library
Copyright (C) 2000-2001 Pete Shinners
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Pete Shinners
pete@shinners.org
*/
/* This will use PYGAMEAPI_EXTERN_SLOTS instead
* of PYGAMEAPI_DEFINE_SLOTS for base modules.
*/
#ifndef _PYGAME_INTERNAL_H
#define _PYGAME_INTERNAL_H
#include "pgplatform.h"
/*
If PY_SSIZE_T_CLEAN is defined before including Python.h, length is a
Py_ssize_t rather than an int for all # variants of formats (s#, y#, etc.)
*/
#define PY_SSIZE_T_CLEAN
#include <Python.h>
/* Ensure PyPy-specific code is not in use when running on GraalPython (PR
* #2580) */
#if defined(GRAALVM_PYTHON) && defined(PYPY_VERSION)
#undef PYPY_VERSION
#endif
#include <SDL.h>
/* SDL 1.2 constants removed from SDL 2 */
typedef enum {
SDL_HWSURFACE = 0,
SDL_RESIZABLE = SDL_WINDOW_RESIZABLE,
SDL_ASYNCBLIT = 0,
SDL_OPENGL = SDL_WINDOW_OPENGL,
SDL_OPENGLBLIT = 0,
SDL_ANYFORMAT = 0,
SDL_HWPALETTE = 0,
SDL_DOUBLEBUF = 0,
SDL_FULLSCREEN = SDL_WINDOW_FULLSCREEN,
SDL_HWACCEL = 0,
SDL_SRCCOLORKEY = 0,
SDL_RLEACCELOK = 0,
SDL_SRCALPHA = 0,
SDL_NOFRAME = SDL_WINDOW_BORDERLESS,
SDL_GL_SWAP_CONTROL = 0,
TIMER_RESOLUTION = 0
} PygameVideoFlags;
/* the wheel button constants were removed from SDL 2 */
typedef enum {
PGM_BUTTON_LEFT = SDL_BUTTON_LEFT,
PGM_BUTTON_RIGHT = SDL_BUTTON_RIGHT,
PGM_BUTTON_MIDDLE = SDL_BUTTON_MIDDLE,
PGM_BUTTON_WHEELUP = 4,
PGM_BUTTON_WHEELDOWN = 5,
PGM_BUTTON_X1 = SDL_BUTTON_X1 + 2,
PGM_BUTTON_X2 = SDL_BUTTON_X2 + 2,
PGM_BUTTON_KEEP = 0x80
} PygameMouseFlags;
typedef enum {
/* Any SDL_* events here are for backward compatibility. */
SDL_NOEVENT = 0,
SDL_ACTIVEEVENT = SDL_USEREVENT,
SDL_VIDEORESIZE,
SDL_VIDEOEXPOSE,
PGE_MIDIIN,
PGE_MIDIOUT,
PGE_KEYREPEAT, /* Special internal pygame event, for managing key-presses
*/
/* DO NOT CHANGE THE ORDER OF EVENTS HERE */
PGE_WINDOWSHOWN,
PGE_WINDOWHIDDEN,
PGE_WINDOWEXPOSED,
PGE_WINDOWMOVED,
PGE_WINDOWRESIZED,
PGE_WINDOWSIZECHANGED,
PGE_WINDOWMINIMIZED,
PGE_WINDOWMAXIMIZED,
PGE_WINDOWRESTORED,
PGE_WINDOWENTER,
PGE_WINDOWLEAVE,
PGE_WINDOWFOCUSGAINED,
PGE_WINDOWFOCUSLOST,
PGE_WINDOWCLOSE,
PGE_WINDOWTAKEFOCUS,
PGE_WINDOWHITTEST,
PGE_WINDOWICCPROFCHANGED,
PGE_WINDOWDISPLAYCHANGED,
/* Here we define PGPOST_* events, events that act as a one-to-one
* proxy for SDL events (and some extra events too!), the proxy is used
* internally when pygame users use event.post()
*
* At a first glance, these may look redundant, but they are really
* important, especially with event blocking. If proxy events are
* not there, blocked events dont make it to our event filter, and
* that can break a lot of stuff.
*
* IMPORTANT NOTE: Do not post events directly with these proxy types,
* use the appropriate functions from event.c, that handle these proxy
* events for you.
* Proxy events are for internal use only */
PGPOST_EVENTBEGIN, /* mark start of proxy-events */
PGPOST_ACTIVEEVENT = PGPOST_EVENTBEGIN,
PGPOST_APP_TERMINATING,
PGPOST_APP_LOWMEMORY,
PGPOST_APP_WILLENTERBACKGROUND,
PGPOST_APP_DIDENTERBACKGROUND,
PGPOST_APP_WILLENTERFOREGROUND,
PGPOST_APP_DIDENTERFOREGROUND,
PGPOST_AUDIODEVICEADDED,
PGPOST_AUDIODEVICEREMOVED,
PGPOST_CLIPBOARDUPDATE,
PGPOST_CONTROLLERAXISMOTION,
PGPOST_CONTROLLERBUTTONDOWN,
PGPOST_CONTROLLERBUTTONUP,
PGPOST_CONTROLLERDEVICEADDED,
PGPOST_CONTROLLERDEVICEREMOVED,
PGPOST_CONTROLLERDEVICEREMAPPED,
PGPOST_CONTROLLERTOUCHPADDOWN,
PGPOST_CONTROLLERTOUCHPADMOTION,
PGPOST_CONTROLLERTOUCHPADUP,
PGPOST_CONTROLLERSENSORUPDATE,
PGPOST_DOLLARGESTURE,
PGPOST_DOLLARRECORD,
PGPOST_DROPFILE,
PGPOST_DROPTEXT,
PGPOST_DROPBEGIN,
PGPOST_DROPCOMPLETE,
PGPOST_FINGERMOTION,
PGPOST_FINGERDOWN,
PGPOST_FINGERUP,
PGPOST_KEYDOWN,
PGPOST_KEYMAPCHANGED,
PGPOST_KEYUP,
PGPOST_JOYAXISMOTION,
PGPOST_JOYBALLMOTION,
PGPOST_JOYHATMOTION,
PGPOST_JOYBUTTONDOWN,
PGPOST_JOYBUTTONUP,
PGPOST_JOYDEVICEADDED,
PGPOST_JOYDEVICEREMOVED,
PGPOST_LOCALECHANGED,
PGPOST_MIDIIN,
PGPOST_MIDIOUT,
PGPOST_MOUSEMOTION,
PGPOST_MOUSEBUTTONDOWN,
PGPOST_MOUSEBUTTONUP,
PGPOST_MOUSEWHEEL,
PGPOST_MULTIGESTURE,
PGPOST_NOEVENT,
PGPOST_QUIT,
PGPOST_RENDER_TARGETS_RESET,
PGPOST_RENDER_DEVICE_RESET,
PGPOST_SYSWMEVENT,
PGPOST_TEXTEDITING,
PGPOST_TEXTINPUT,
PGPOST_VIDEORESIZE,
PGPOST_VIDEOEXPOSE,
PGPOST_WINDOWSHOWN,
PGPOST_WINDOWHIDDEN,
PGPOST_WINDOWEXPOSED,
PGPOST_WINDOWMOVED,
PGPOST_WINDOWRESIZED,
PGPOST_WINDOWSIZECHANGED,
PGPOST_WINDOWMINIMIZED,
PGPOST_WINDOWMAXIMIZED,
PGPOST_WINDOWRESTORED,
PGPOST_WINDOWENTER,
PGPOST_WINDOWLEAVE,
PGPOST_WINDOWFOCUSGAINED,
PGPOST_WINDOWFOCUSLOST,
PGPOST_WINDOWCLOSE,
PGPOST_WINDOWTAKEFOCUS,
PGPOST_WINDOWHITTEST,
PGPOST_WINDOWICCPROFCHANGED,
PGPOST_WINDOWDISPLAYCHANGED,
PGE_USEREVENT, /* this event must stay in this position only */
PG_NUMEVENTS =
SDL_LASTEVENT /* Not an event. Indicates end of user events. */
} PygameEventCode;
/* SDL1 ACTIVEEVENT state attribute can take the following values */
/* These constant values are directly picked from SDL1 source */
#define SDL_APPMOUSEFOCUS 0x01
#define SDL_APPINPUTFOCUS 0x02
#define SDL_APPACTIVE 0x04
/* Surface flags: based on SDL 1.2 flags */
typedef enum {
PGS_SWSURFACE = 0x00000000,
PGS_HWSURFACE = 0x00000001,
PGS_ASYNCBLIT = 0x00000004,
PGS_ANYFORMAT = 0x10000000,
PGS_HWPALETTE = 0x20000000,
PGS_DOUBLEBUF = 0x40000000,
PGS_FULLSCREEN = 0x80000000,
PGS_SCALED = 0x00000200,
PGS_OPENGL = 0x00000002,
PGS_OPENGLBLIT = 0x0000000A,
PGS_RESIZABLE = 0x00000010,
PGS_NOFRAME = 0x00000020,
PGS_SHOWN = 0x00000040, /* Added from SDL 2 */
PGS_HIDDEN = 0x00000080, /* Added from SDL 2 */
PGS_HWACCEL = 0x00000100,
PGS_SRCCOLORKEY = 0x00001000,
PGS_RLEACCELOK = 0x00002000,
PGS_RLEACCEL = 0x00004000,
PGS_SRCALPHA = 0x00010000,
PGS_PREALLOC = 0x01000000
} PygameSurfaceFlags;
// TODO Implement check below in a way that does not break CI
/* New buffer protocol (PEP 3118) implemented on all supported Py versions.
#if !defined(Py_TPFLAGS_HAVE_NEWBUFFER)
#error No support for PEP 3118/Py_TPFLAGS_HAVE_NEWBUFFER. Please use a
supported Python version. #endif */
#define RAISE(x, y) (PyErr_SetString((x), (y)), NULL)
#define DEL_ATTR_NOT_SUPPORTED_CHECK(name, value) \
do { \
if (!value) { \
PyErr_Format(PyExc_AttributeError, "Cannot delete attribute %s", \
name); \
return -1; \
} \
} while (0)
#define DEL_ATTR_NOT_SUPPORTED_CHECK_NO_NAME(value) \
do { \
if (!value) { \
PyErr_SetString(PyExc_AttributeError, "Cannot delete attribute"); \
return -1; \
} \
} while (0)
/*
* Initialization checks
*/
#define VIDEO_INIT_CHECK() \
if (!SDL_WasInit(SDL_INIT_VIDEO)) \
return RAISE(pgExc_SDLError, "video system not initialized")
#define JOYSTICK_INIT_CHECK() \
if (!SDL_WasInit(SDL_INIT_JOYSTICK)) \
return RAISE(pgExc_SDLError, "joystick system not initialized")
/* thread check */
#ifdef WITH_THREAD
#define PG_CHECK_THREADS() (1)
#else /* ~WITH_THREAD */
#define PG_CHECK_THREADS() \
(RAISE(PyExc_NotImplementedError, "Python built without thread support"))
#endif /* ~WITH_THREAD */
#define PyType_Init(x) (((x).ob_type) = &PyType_Type)
/* CPython 3.6 had initial and undocumented FASTCALL support, but we play it
* safe by not relying on implementation details */
#if PY_VERSION_HEX < 0x03070000
/* Macro for naming a pygame fastcall wrapper function */
#define PG_FASTCALL_NAME(func) _##func##_fastcall_wrap
/* used to forward declare compat functions */
#define PG_DECLARE_FASTCALL_FUNC(func, self_type) \
static PyObject *PG_FASTCALL_NAME(func)(self_type * self, PyObject * args)
/* Using this macro on a function defined with the FASTCALL calling convention
* adds a wrapper definition that uses regular python VARARGS convention.
* Since it is guaranteed that the 'args' object is a tuple, we can directly
* call PySequence_Fast_ITEMS and PyTuple_GET_SIZE on it (which are macros that
* assume the same, and don't do error checking) */
#define PG_WRAP_FASTCALL_FUNC(func, self_type) \
PG_DECLARE_FASTCALL_FUNC(func, self_type) \
{ \
return func(self, (PyObject *const *)PySequence_Fast_ITEMS(args), \
PyTuple_GET_SIZE(args)); \
}
#define PG_FASTCALL METH_VARARGS
#else /* PY_VERSION_HEX >= 0x03070000 */
/* compat macros are no-op on python versions that support fastcall */
#define PG_FASTCALL_NAME(func) func
#define PG_DECLARE_FASTCALL_FUNC(func, self_type)
#define PG_WRAP_FASTCALL_FUNC(func, self_type)
#define PG_FASTCALL METH_FASTCALL
#endif /* PY_VERSION_HEX >= 0x03070000 */
/*
* event module internals
*/
struct pgEventObject {
PyObject_HEAD int type;
PyObject *dict;
};
/*
* surflock module internals
*/
typedef struct {
PyObject_HEAD PyObject *surface;
PyObject *lockobj;
PyObject *weakrefs;
} pgLifetimeLockObject;
/*
* surface module internals
*/
struct pgSubSurface_Data {
PyObject *owner;
int pixeloffset;
int offsetx, offsety;
};
/*
* color module internals
*/
struct pgColorObject {
PyObject_HEAD Uint8 data[4];
Uint8 len;
};
/*
* include public API
*/
#include "include/_pygame.h"
/* Slot counts.
* Remember to keep these constants up to date.
*/
#define PYGAMEAPI_RECT_NUMSLOTS 5
#define PYGAMEAPI_JOYSTICK_NUMSLOTS 2
#define PYGAMEAPI_DISPLAY_NUMSLOTS 2
#define PYGAMEAPI_SURFACE_NUMSLOTS 4
#define PYGAMEAPI_SURFLOCK_NUMSLOTS 8
#define PYGAMEAPI_RWOBJECT_NUMSLOTS 6
#define PYGAMEAPI_PIXELARRAY_NUMSLOTS 2
#define PYGAMEAPI_COLOR_NUMSLOTS 5
#define PYGAMEAPI_MATH_NUMSLOTS 2
#define PYGAMEAPI_BASE_NUMSLOTS 27
#define PYGAMEAPI_EVENT_NUMSLOTS 6
#endif /* _PYGAME_INTERNAL_H */

View File

@ -0,0 +1,30 @@
/*
pygame - Python Game Library
Copyright (C) 2000-2001 Pete Shinners
Copyright (C) 2007 Marcus von Appen
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Pete Shinners
pete@shinners.org
*/
#ifndef _SURFACE_H
#define _SURFACE_H
#include "_pygame.h"
#include "surface.h"
#endif

View File

@ -0,0 +1,252 @@
#ifndef CAMERA_H
#define CAMERA_H
/*
pygame - Python Game Library
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "pygame.h"
#include "pgcompat.h"
#include "doc/camera_doc.h"
#if defined(__unix__)
#include <structmember.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <fcntl.h> /* low-level i/o */
#include <unistd.h>
#include <errno.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/mman.h>
#include <sys/ioctl.h>
/* on freebsd there is no asm/types */
#ifdef linux
#include <asm/types.h> /* for videodev2.h */
#endif
#include <linux/videodev2.h>
#endif
#if defined(__WIN32__)
#define PYGAME_WINDOWS_CAMERA 1
#include <mfapi.h>
#include <mfobjects.h>
#include <mfidl.h>
#include <mfreadwrite.h>
#include <combaseapi.h>
#include <mftransform.h>
#endif
/* some constants used which are not defined on non-v4l machines. */
#ifndef V4L2_PIX_FMT_RGB24
#define V4L2_PIX_FMT_RGB24 'RGB3'
#endif
#ifndef V4L2_PIX_FMT_RGB444
#define V4L2_PIX_FMT_RGB444 'R444'
#endif
#ifndef V4L2_PIX_FMT_YUYV
#define V4L2_PIX_FMT_YUYV 'YUYV'
#endif
#ifndef V4L2_PIX_FMT_XBGR32
#define V4L2_PIX_FMT_XBGR32 'XR24'
#endif
#define CLEAR(x) memset(&(x), 0, sizeof(x))
#define SAT(c) \
if (c & (~255)) { \
if (c < 0) \
c = 0; \
else \
c = 255; \
}
#define SAT2(c) ((c) & (~255) ? ((c) < 0 ? 0 : 255) : (c))
#define DEFAULT_WIDTH 640
#define DEFAULT_HEIGHT 480
#define RGB_OUT 1
#define YUV_OUT 2
#define HSV_OUT 4
#define CAM_V4L \
1 /* deprecated. the incomplete support in pygame was removed */
#define CAM_V4L2 2
struct buffer {
void *start;
size_t length;
};
#if defined(__unix__)
typedef struct pgCameraObject {
PyObject_HEAD char *device_name;
int camera_type;
unsigned long pixelformat;
unsigned int color_out;
struct buffer *buffers;
unsigned int n_buffers;
int width;
int height;
int size;
int hflip;
int vflip;
int brightness;
int fd;
} pgCameraObject;
#elif defined(PYGAME_WINDOWS_CAMERA)
typedef struct pgCameraObject {
PyObject_HEAD WCHAR *device_name;
IMFSourceReader *reader;
IMFTransform *transform;
IMFVideoProcessorControl *control;
IMFMediaBuffer *buf;
IMFMediaBuffer *raw_buf;
int buffer_ready;
short open; /* used to signal the update_function to exit */
HANDLE t_handle;
HRESULT t_error;
int t_error_line;
int width;
int height;
int hflip;
int vflip;
int last_vflip;
int color_out;
unsigned long pixelformat;
} pgCameraObject;
#else
/* generic definition.
*/
typedef struct pgCameraObject {
PyObject_HEAD char *device_name;
int camera_type;
unsigned long pixelformat;
unsigned int color_out;
struct buffer *buffers;
unsigned int n_buffers;
int width;
int height;
int size;
int hflip;
int vflip;
int brightness;
int fd;
} pgCameraObject;
#endif
/* internal functions for colorspace conversion */
void
colorspace(SDL_Surface *src, SDL_Surface *dst, int cspace);
void
rgb24_to_rgb(const void *src, void *dst, int length, SDL_PixelFormat *format);
void
bgr32_to_rgb(const void *src, void *dst, int length, SDL_PixelFormat *format);
void
rgb444_to_rgb(const void *src, void *dst, int length, SDL_PixelFormat *format);
void
rgb_to_yuv(const void *src, void *dst, int length, unsigned long source,
SDL_PixelFormat *format);
void
rgb_to_hsv(const void *src, void *dst, int length, unsigned long source,
SDL_PixelFormat *format);
void
yuyv_to_rgb(const void *src, void *dst, int length, SDL_PixelFormat *format);
void
yuyv_to_yuv(const void *src, void *dst, int length, SDL_PixelFormat *format);
void
uyvy_to_rgb(const void *src, void *dst, int length, SDL_PixelFormat *format);
void
uyvy_to_yuv(const void *src, void *dst, int length, SDL_PixelFormat *format);
void
sbggr8_to_rgb(const void *src, void *dst, int width, int height,
SDL_PixelFormat *format);
void
yuv420_to_rgb(const void *src, void *dst, int width, int height,
SDL_PixelFormat *format);
void
yuv420_to_yuv(const void *src, void *dst, int width, int height,
SDL_PixelFormat *format);
#if defined(__unix__)
/* internal functions specific to v4l2 */
char **
v4l2_list_cameras(int *num_devices);
int
v4l2_get_control(int fd, int id, int *value);
int
v4l2_set_control(int fd, int id, int value);
PyObject *
v4l2_read_raw(pgCameraObject *self);
int
v4l2_xioctl(int fd, int request, void *arg);
int
v4l2_process_image(pgCameraObject *self, const void *image, int buffer_size,
SDL_Surface *surf);
int
v4l2_query_buffer(pgCameraObject *self);
int
v4l2_read_frame(pgCameraObject *self, SDL_Surface *surf, int *errno_code);
int
v4l2_stop_capturing(pgCameraObject *self);
int
v4l2_start_capturing(pgCameraObject *self);
int
v4l2_uninit_device(pgCameraObject *self);
int
v4l2_init_mmap(pgCameraObject *self);
int
v4l2_init_device(pgCameraObject *self);
int
v4l2_close_device(pgCameraObject *self);
int
v4l2_open_device(pgCameraObject *self);
#elif defined(PYGAME_WINDOWS_CAMERA)
/* internal functions specific to WINDOWS */
WCHAR **
windows_list_cameras(int *num_devices);
int
windows_init_device(pgCameraObject *self);
int
windows_open_device(pgCameraObject *self);
IMFActivate *
windows_device_from_name(WCHAR *device_name);
int
windows_close_device(pgCameraObject *self);
int
windows_read_frame(pgCameraObject *self, SDL_Surface *surf);
int
windows_frame_ready(pgCameraObject *self, int *result);
PyObject *
windows_read_raw(pgCameraObject *self);
int
windows_process_image(pgCameraObject *self, BYTE *data, DWORD buffer_size,
SDL_Surface *surf);
void
windows_dealloc_device(pgCameraObject *self);
int
windows_init_device(pgCameraObject *self);
#endif
#endif /* !CAMERA_H */

View File

@ -0,0 +1,15 @@
#ifndef PGFONT_INTERNAL_H
#define PGFONT_INTERNAL_H
#include <SDL_ttf.h>
/* test font initialization */
#define FONT_INIT_CHECK() \
if (!(*(int *)PyFONT_C_API[2])) \
return RAISE(pgExc_SDLError, "font system not initialized")
#include "include/pygame_font.h"
#define PYGAMEAPI_FONT_NUMSLOTS 3
#endif /* ~PGFONT_INTERNAL_H */

View File

@ -0,0 +1,114 @@
/*
pygame - Python Game Library
Copyright (C) 2009 Vicent Marti
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _PYGAME_FREETYPE_INTERNAL_H_
#define _PYGAME_FREETYPE_INTERNAL_H_
#include "pgcompat.h"
#include "pgplatform.h"
#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_CACHE_H
#include FT_XFREE86_H
#include FT_TRIGONOMETRY_H
/**********************************************************
* Global module constants
**********************************************************/
/* Render styles */
#define FT_STYLE_NORMAL 0x00
#define FT_STYLE_STRONG 0x01
#define FT_STYLE_OBLIQUE 0x02
#define FT_STYLE_UNDERLINE 0x04
#define FT_STYLE_WIDE 0x08
#define FT_STYLE_DEFAULT 0xFF
/* Bounding box modes */
#define FT_BBOX_EXACT FT_GLYPH_BBOX_SUBPIXELS
#define FT_BBOX_EXACT_GRIDFIT FT_GLYPH_BBOX_GRIDFIT
#define FT_BBOX_PIXEL FT_GLYPH_BBOX_TRUNCATE
#define FT_BBOX_PIXEL_GRIDFIT FT_GLYPH_BBOX_PIXELS
/* Rendering flags */
#define FT_RFLAG_NONE (0)
#define FT_RFLAG_ANTIALIAS (1 << 0)
#define FT_RFLAG_AUTOHINT (1 << 1)
#define FT_RFLAG_VERTICAL (1 << 2)
#define FT_RFLAG_HINTED (1 << 3)
#define FT_RFLAG_KERNING (1 << 4)
#define FT_RFLAG_TRANSFORM (1 << 5)
#define FT_RFLAG_PAD (1 << 6)
#define FT_RFLAG_ORIGIN (1 << 7)
#define FT_RFLAG_UCS4 (1 << 8)
#define FT_RFLAG_USE_BITMAP_STRIKES (1 << 9)
#define FT_RFLAG_DEFAULTS \
(FT_RFLAG_HINTED | FT_RFLAG_USE_BITMAP_STRIKES | FT_RFLAG_ANTIALIAS)
#define FT_RENDER_NEWBYTEARRAY 0x0
#define FT_RENDER_NEWSURFACE 0x1
#define FT_RENDER_EXISTINGSURFACE 0x2
/**********************************************************
* Global module types
**********************************************************/
typedef struct _scale_s {
FT_UInt x, y;
} Scale_t;
typedef FT_Angle Angle_t;
struct fontinternals_;
struct freetypeinstance_;
typedef struct {
FT_Long font_index;
FT_Open_Args open_args;
} pgFontId;
typedef struct {
PyObject_HEAD pgFontId id;
PyObject *path;
int is_scalable;
int is_bg_col_set;
Scale_t face_size;
FT_Int16 style;
FT_Int16 render_flags;
double strength;
double underline_adjustment;
FT_UInt resolution;
Angle_t rotation;
FT_Matrix transform;
FT_Byte fgcolor[4];
FT_Byte bgcolor[4];
struct freetypeinstance_ *freetype; /* Personal reference */
struct fontinternals_ *_internals;
} pgFontObject;
#define pgFont_IS_ALIVE(o) (((pgFontObject *)(o))->_internals != 0)
/* import public API */
#include "include/pygame_freetype.h"
#define PYGAMEAPI_FREETYPE_NUMSLOTS 2
#endif /* ~_PYGAME_FREETYPE_INTERNAL_H_ */

View File

@ -0,0 +1,765 @@
/*
pygame - Python Game Library
Copyright (C) 2000-2001 Pete Shinners
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Pete Shinners
pete@shinners.org
*/
#ifndef _PYGAME_H
#define _PYGAME_H
/** This header file includes all the definitions for the
** base pygame extensions. This header only requires
** Python includes (and SDL.h for functions that use SDL types).
** The reason for functions prototyped with #define's is
** to allow for maximum Python portability. It also uses
** Python as the runtime linker, which allows for late binding.
'' For more information on this style of development, read
** the Python docs on this subject.
** http://www.python.org/doc/current/ext/using-cobjects.html
**
** If using this to build your own derived extensions,
** you'll see that the functions available here are mainly
** used to help convert between python objects and SDL objects.
** Since this library doesn't add a lot of functionality to
** the SDL library, it doesn't need to offer a lot either.
**
** When initializing your extension module, you must manually
** import the modules you want to use. (this is the part about
** using python as the runtime linker). Each module has its
** own import_xxx() routine. You need to perform this import
** after you have initialized your own module, and before
** you call any routines from that module. Since every module
** in pygame does this, there are plenty of examples.
**
** The base module does include some useful conversion routines
** that you are free to use in your own extension.
**/
#include "pgplatform.h"
#include <Python.h>
/* version macros (defined since version 1.9.5) */
#define PG_MAJOR_VERSION 2
#define PG_MINOR_VERSION 5
#define PG_PATCH_VERSION 0
#define PG_VERSIONNUM(MAJOR, MINOR, PATCH) \
(1000 * (MAJOR) + 100 * (MINOR) + (PATCH))
#define PG_VERSION_ATLEAST(MAJOR, MINOR, PATCH) \
(PG_VERSIONNUM(PG_MAJOR_VERSION, PG_MINOR_VERSION, PG_PATCH_VERSION) >= \
PG_VERSIONNUM(MAJOR, MINOR, PATCH))
#include "pgcompat.h"
/* Flag indicating a pg_buffer; used for assertions within callbacks */
#ifndef NDEBUG
#define PyBUF_PYGAME 0x4000
#endif
#define PyBUF_HAS_FLAG(f, F) (((f) & (F)) == (F))
/* Array information exchange struct C type; inherits from Py_buffer
*
* Pygame uses its own Py_buffer derived C struct as an internal representation
* of an imported array buffer. The extended Py_buffer allows for a
* per-instance release callback,
*/
typedef void (*pybuffer_releaseproc)(Py_buffer *);
typedef struct pg_bufferinfo_s {
Py_buffer view;
PyObject *consumer; /* Input: Borrowed reference */
pybuffer_releaseproc release_buffer;
} pg_buffer;
#include "pgimport.h"
/*
* BASE module
*/
#ifndef PYGAMEAPI_BASE_INTERNAL
#define pgExc_SDLError ((PyObject *)PYGAMEAPI_GET_SLOT(base, 0))
#define pg_RegisterQuit \
(*(void (*)(void (*)(void)))PYGAMEAPI_GET_SLOT(base, 1))
/**
* \brief Convert number like object *obj* to C int and in *val*.
*
* \param obj The Python object to convert.
* \param val A pointer to the C integer to store the result.
* \returns 1 if the conversion was successful, 0 otherwise.
*
* \note This function will clear any Python errors.
* \note This function will convert floats to integers.
*/
#define pg_IntFromObj \
(*(int (*)(PyObject *, int *))PYGAMEAPI_GET_SLOT(base, 2))
/**
* \brief Convert number like object at position *i* in sequence *obj*
* to C int and place in argument *val*.
*
* \param obj The Python object to convert.
* \param i The index of the object to convert.
* \param val A pointer to the C integer to store the result.
* \returns 1 if the conversion was successful, 0 otherwise.
*
* \note This function will clear any Python errors.
* \note This function will convert floats to integers.
*/
#define pg_IntFromObjIndex \
(*(int (*)(PyObject *, int, int *))PYGAMEAPI_GET_SLOT(base, 3))
/**
* \brief Convert the two number like objects in length 2 sequence *obj* to C
* int and place in arguments *val1* and *val2*.
*
* \param obj The Python two element sequence object to convert.
* \param val A pointer to the C integer to store the result.
* \param val2 A pointer to the C integer to store the result.
* \returns 1 if the conversion was successful, 0 otherwise.
*
* \note This function will clear any Python errors.
* \note This function will convert floats to integers.
*/
#define pg_TwoIntsFromObj \
(*(int (*)(PyObject *, int *, int *))PYGAMEAPI_GET_SLOT(base, 4))
/**
* \brief Convert number like object *obj* to C float and in *val*.
*
* \param obj The Python object to convert.
* \param val A pointer to the C float to store the result.
* \returns 1 if the conversion was successful, 0 otherwise.
*
* \note This function will clear any Python errors.
*/
#define pg_FloatFromObj \
(*(int (*)(PyObject *, float *))PYGAMEAPI_GET_SLOT(base, 5))
/**
* \brief Convert number like object at position *i* in sequence *obj* to C
* float and place in argument *val*.
*
* \param obj The Python object to convert.
* \param i The index of the object to convert.
* \param val A pointer to the C float to store the result.
* \returns 1 if the conversion was successful, 0 otherwise.
*
* \note This function will clear any Python errors.
*/
#define pg_FloatFromObjIndex \
(*(int (*)(PyObject *, int, float *))PYGAMEAPI_GET_SLOT(base, 6))
/**
* \brief Convert the two number like objects in length 2 sequence *obj* to C
* float and place in arguments *val1* and *val2*.
*
* \param obj The Python two element sequence object to convert.
* \param val A pointer to the C float to store the result.
* \param val2 A pointer to the C float to store the result.
* \returns 1 if the conversion was successful, 0 otherwise.
*
* \note This function will clear any Python errors.
*/
#define pg_TwoFloatsFromObj \
(*(int (*)(PyObject *, float *, float *))PYGAMEAPI_GET_SLOT(base, 7))
/**
* \brief Convert number like object *obj* to C Uint32 and in *val*.
*
* \param obj The Python object to convert.
* \param val A pointer to the C int to store the result.
* \returns 1 if the conversion was successful, 0 otherwise.
*/
#define pg_UintFromObj \
(*(int (*)(PyObject *, Uint32 *))PYGAMEAPI_GET_SLOT(base, 8))
/**
* \brief Convert number like object at position *i* in sequence *obj* to C
* Uint32 and place in argument *val*.
*
* \param obj The Python object to convert.
* \param i The index of the object to convert.
* \param val A pointer to the C int to store the result.
* \returns 1 if the conversion was successful, 0 otherwise.
*/
#define pg_UintFromObjIndex \
(*(int (*)(PyObject *, int, Uint32 *))PYGAMEAPI_GET_SLOT(base, 9))
/**
* \brief Initialize all of the pygame modules.
* \returns 1 on success, 0 on failure with PyErr set.
*/
#define pg_mod_autoinit (*(int (*)(const char *))PYGAMEAPI_GET_SLOT(base, 10))
/**
* \brief Quit all of the pygame modules.
*/
#define pg_mod_autoquit (*(void (*)(const char *))PYGAMEAPI_GET_SLOT(base, 11))
/**
* \brief Convert the color represented by object *obj* into a red, green,
* blue, alpha length 4 C array *RGBA*.
*
* The object must be a length 3 or 4 sequence of numbers having values between
* 0 and 255 inclusive. For a length 3 sequence an alpha value of 255 is
* assumed.
*
* \param obj The Python object to convert.
* \param RGBA A pointer to the C array to store the result.
* \returns 1 if the conversion was successful, 0 otherwise.
*/
#define pg_RGBAFromObj \
(*(int (*)(PyObject *, Uint8 *))PYGAMEAPI_GET_SLOT(base, 12))
/**
* \brief Given a Py_buffer, return a python dictionary representing the array
* interface.
*
* \param view_p A pointer to the Py_buffer to convert to a dictionary.
*
* \returns A Python dictionary representing the array interface of the object.
*/
#define pgBuffer_AsArrayInterface \
(*(PyObject * (*)(Py_buffer *)) PYGAMEAPI_GET_SLOT(base, 13))
/**
* \brief Given a Py_buffer, return a python capsule representing the array
* interface.
*
* \param view_p A pointer to the Py_buffer to convert to a capsule.
*
* \returns A Python capsule representing the array interface of the object.
*/
#define pgBuffer_AsArrayStruct \
(*(PyObject * (*)(Py_buffer *)) PYGAMEAPI_GET_SLOT(base, 14))
/**
* \brief Get a buffer object from a given Python object.
*
* \param obj The Python object to get the buffer from.
* \param pg_view_p A pointer to a pg_buffer struct to store the buffer in.
* \param flags The desired buffer access mode.
*
* \returns 0 on success, -1 on failure.
*
* \note This function attempts to get a buffer object from a given Python
* object. If the object supports the buffer protocol, it will be used to
* create the buffer. If not, it will try to get an array interface or
* dictionary representation of the object and use that to create the buffer.
* If none of these methods work, it will raise a ValueError.
*
*/
#define pgObject_GetBuffer \
(*(int (*)(PyObject *, pg_buffer *, int))PYGAMEAPI_GET_SLOT(base, 15))
/**
* \brief Release a pg_buffer object.
*
* \param pg_view_p The pg_buffer object to release.
*
* \note This function releases a pg_buffer object.
* \note some calls to this function expect this function to not clear
* previously set errors.
*/
#define pgBuffer_Release (*(void (*)(pg_buffer *))PYGAMEAPI_GET_SLOT(base, 16))
/**
* \brief Write the array interface dictionary buffer description *dict* into a
* Pygame buffer description struct *pg_view_p*.
*
* \param pg_view_p The Pygame buffer description struct to write into.
* \param dict The array interface dictionary to read from.
* \param flags The PyBUF flags describing the view type requested.
*
* \returns 0 on success, or -1 on failure.
*/
#define pgDict_AsBuffer \
(*(int (*)(pg_buffer *, PyObject *, int))PYGAMEAPI_GET_SLOT(base, 17))
#define pgExc_BufferError ((PyObject *)PYGAMEAPI_GET_SLOT(base, 18))
/**
* \brief Get the default SDL window created by a pygame.display.set_mode()
* call, or *NULL*.
*
* \return The default window, or *NULL* if no window has been created.
*/
#define pg_GetDefaultWindow \
(*(SDL_Window * (*)(void)) PYGAMEAPI_GET_SLOT(base, 19))
/**
* \brief Set the default SDL window created by a pygame.display.set_mode()
* call. The previous window, if any, is destroyed. Argument *win* may be
* *NULL*. This function is called by pygame.display.set_mode().
*
* \param win The new default window. May be NULL.
*/
#define pg_SetDefaultWindow \
(*(void (*)(SDL_Window *))PYGAMEAPI_GET_SLOT(base, 20))
/**
* \brief Return a borrowed reference to the Pygame default window display
* surface, or *NULL* if no default window is open.
*
* \return The default renderer, or *NULL* if no renderer has been created.
*/
#define pg_GetDefaultWindowSurface \
(*(pgSurfaceObject * (*)(void)) PYGAMEAPI_GET_SLOT(base, 21))
/**
* \brief Set the Pygame default window display surface. The previous
* surface, if any, is destroyed. Argument *screen* may be *NULL*. This
* function is called by pygame.display.set_mode().
*
* \param screen The new default window display surface. May be NULL.
*/
#define pg_SetDefaultWindowSurface \
(*(void (*)(pgSurfaceObject *))PYGAMEAPI_GET_SLOT(base, 22))
/**
* \returns NULL if the environment variable PYGAME_BLEND_ALPHA_SDL2 is not
* set, otherwise returns a pointer to the environment variable.
*/
#define pg_EnvShouldBlendAlphaSDL2 \
(*(char *(*)(void))PYGAMEAPI_GET_SLOT(base, 23))
/**
* \brief Convert number like object *obj* to C double and in *val*.
*
* \param obj The Python object to convert.
* \param val A pointer to the C double to store the result.
* \returns 1 if the conversion was successful, 0 otherwise.
*
* \note This function will clear any Python errors.
*/
#define pg_DoubleFromObj \
(*(int (*)(PyObject *, double *))PYGAMEAPI_GET_SLOT(base, 24))
/**
* \brief Convert number like object at position *i* in sequence *obj* to C
* double and place in argument *val*.
*
* \param obj The Python object to convert.
* \param i The index of the object to convert.
* \param val A pointer to the C double to store the result.
* \returns 1 if the conversion was successful, 0 otherwise.
*
* \note This function will clear any Python errors.
*/
#define pg_DoubleFromObjIndex \
(*(int (*)(PyObject *, int, double *))PYGAMEAPI_GET_SLOT(base, 25))
/**
* \brief Convert the two number like objects in length 2 sequence *obj* to C
* double and place in arguments *val1* and *val2*.
*
* \param obj The Python two element sequence object to convert.
* \param val A pointer to the C double to store the result.
* \param val2 A pointer to the C double to store the result.
* \returns 1 if the conversion was successful, 0 otherwise.
*/
#define pg_TwoDoublesFromObj \
(*(int (*)(PyObject *, double *, double *))PYGAMEAPI_GET_SLOT(base, 26))
#define import_pygame_base() IMPORT_PYGAME_MODULE(base)
#endif /* ~PYGAMEAPI_BASE_INTERNAL */
typedef struct {
PyObject_HEAD SDL_Rect r;
PyObject *weakreflist;
} pgRectObject;
#define pgRect_AsRect(x) (((pgRectObject *)x)->r)
#ifndef PYGAMEAPI_RECT_INTERNAL
#define pgRect_Type (*(PyTypeObject *)PYGAMEAPI_GET_SLOT(rect, 0))
#define pgRect_Check(x) ((x)->ob_type == &pgRect_Type)
#define pgRect_New (*(PyObject * (*)(SDL_Rect *)) PYGAMEAPI_GET_SLOT(rect, 1))
#define pgRect_New4 \
(*(PyObject * (*)(int, int, int, int)) PYGAMEAPI_GET_SLOT(rect, 2))
#define pgRect_FromObject \
(*(SDL_Rect * (*)(PyObject *, SDL_Rect *)) PYGAMEAPI_GET_SLOT(rect, 3))
#define pgRect_Normalize (*(void (*)(SDL_Rect *))PYGAMEAPI_GET_SLOT(rect, 4))
#define import_pygame_rect() IMPORT_PYGAME_MODULE(rect)
#endif /* ~PYGAMEAPI_RECT_INTERNAL */
/*
* JOYSTICK module
*/
typedef struct pgJoystickObject {
PyObject_HEAD int id;
SDL_Joystick *joy;
/* Joysticks form an intrusive linked list.
*
* Note that we don't maintain refcounts for these so they are weakrefs
* from the Python side.
*/
struct pgJoystickObject *next;
struct pgJoystickObject *prev;
} pgJoystickObject;
#define pgJoystick_AsID(x) (((pgJoystickObject *)x)->id)
#define pgJoystick_AsSDL(x) (((pgJoystickObject *)x)->joy)
#ifndef PYGAMEAPI_JOYSTICK_INTERNAL
#define pgJoystick_Type (*(PyTypeObject *)PYGAMEAPI_GET_SLOT(joystick, 0))
#define pgJoystick_Check(x) ((x)->ob_type == &pgJoystick_Type)
#define pgJoystick_New (*(PyObject * (*)(int)) PYGAMEAPI_GET_SLOT(joystick, 1))
#define import_pygame_joystick() IMPORT_PYGAME_MODULE(joystick)
#endif
/*
* DISPLAY module
*/
typedef struct {
Uint32 hw_available : 1;
Uint32 wm_available : 1;
Uint32 blit_hw : 1;
Uint32 blit_hw_CC : 1;
Uint32 blit_hw_A : 1;
Uint32 blit_sw : 1;
Uint32 blit_sw_CC : 1;
Uint32 blit_sw_A : 1;
Uint32 blit_fill : 1;
Uint32 video_mem;
SDL_PixelFormat *vfmt;
SDL_PixelFormat vfmt_data;
int current_w;
int current_h;
} pg_VideoInfo;
typedef struct {
PyObject_HEAD pg_VideoInfo info;
} pgVidInfoObject;
#define pgVidInfo_AsVidInfo(x) (((pgVidInfoObject *)x)->info)
#ifndef PYGAMEAPI_DISPLAY_INTERNAL
#define pgVidInfo_Type (*(PyTypeObject *)PYGAMEAPI_GET_SLOT(display, 0))
#define pgVidInfo_Check(x) ((x)->ob_type == &pgVidInfo_Type)
#define pgVidInfo_New \
(*(PyObject * (*)(pg_VideoInfo *)) PYGAMEAPI_GET_SLOT(display, 1))
#define import_pygame_display() IMPORT_PYGAME_MODULE(display)
#endif /* ~PYGAMEAPI_DISPLAY_INTERNAL */
/*
* SURFACE module
*/
struct pgSubSurface_Data;
struct SDL_Surface;
typedef struct {
PyObject_HEAD struct SDL_Surface *surf;
int owner;
struct pgSubSurface_Data *subsurface; /* ptr to subsurface data (if a
* subsurface)*/
PyObject *weakreflist;
PyObject *locklist;
PyObject *dependency;
} pgSurfaceObject;
#define pgSurface_AsSurface(x) (((pgSurfaceObject *)x)->surf)
#ifndef PYGAMEAPI_SURFACE_INTERNAL
#define pgSurface_Type (*(PyTypeObject *)PYGAMEAPI_GET_SLOT(surface, 0))
#define pgSurface_Check(x) \
(PyObject_IsInstance((x), (PyObject *)&pgSurface_Type))
#define pgSurface_New2 \
(*(pgSurfaceObject * (*)(SDL_Surface *, int)) \
PYGAMEAPI_GET_SLOT(surface, 1))
#define pgSurface_SetSurface \
(*(int (*)(pgSurfaceObject *, SDL_Surface *, int))PYGAMEAPI_GET_SLOT( \
surface, 3))
#define pgSurface_Blit \
(*(int (*)(pgSurfaceObject *, pgSurfaceObject *, SDL_Rect *, SDL_Rect *, \
int))PYGAMEAPI_GET_SLOT(surface, 2))
#define import_pygame_surface() \
do { \
IMPORT_PYGAME_MODULE(surface); \
if (PyErr_Occurred() != NULL) \
break; \
IMPORT_PYGAME_MODULE(surflock); \
} while (0)
#define pgSurface_New(surface) pgSurface_New2((surface), 1)
#define pgSurface_NewNoOwn(surface) pgSurface_New2((surface), 0)
#endif /* ~PYGAMEAPI_SURFACE_INTERNAL */
/*
* SURFLOCK module
* auto imported/initialized by surface
*/
#ifndef PYGAMEAPI_SURFLOCK_INTERNAL
#define pgLifetimeLock_Type (*(PyTypeObject *)PYGAMEAPI_GET_SLOT(surflock, 0))
#define pgLifetimeLock_Check(x) ((x)->ob_type == &pgLifetimeLock_Type)
#define pgSurface_Prep(x) \
if ((x)->subsurface) \
(*(*(void (*)(pgSurfaceObject *))PYGAMEAPI_GET_SLOT(surflock, 1)))(x)
#define pgSurface_Unprep(x) \
if ((x)->subsurface) \
(*(*(void (*)(pgSurfaceObject *))PYGAMEAPI_GET_SLOT(surflock, 2)))(x)
#define pgSurface_Lock \
(*(int (*)(pgSurfaceObject *))PYGAMEAPI_GET_SLOT(surflock, 3))
#define pgSurface_Unlock \
(*(int (*)(pgSurfaceObject *))PYGAMEAPI_GET_SLOT(surflock, 4))
#define pgSurface_LockBy \
(*(int (*)(pgSurfaceObject *, PyObject *))PYGAMEAPI_GET_SLOT(surflock, 5))
#define pgSurface_UnlockBy \
(*(int (*)(pgSurfaceObject *, PyObject *))PYGAMEAPI_GET_SLOT(surflock, 6))
#define pgSurface_LockLifetime \
(*(PyObject * (*)(PyObject *, PyObject *)) PYGAMEAPI_GET_SLOT(surflock, 7))
#endif
/*
* EVENT module
*/
typedef struct pgEventObject pgEventObject;
#ifndef PYGAMEAPI_EVENT_INTERNAL
#define pgEvent_Type (*(PyTypeObject *)PYGAMEAPI_GET_SLOT(event, 0))
#define pgEvent_Check(x) ((x)->ob_type == &pgEvent_Type)
#define pgEvent_New \
(*(PyObject * (*)(SDL_Event *)) PYGAMEAPI_GET_SLOT(event, 1))
#define pgEvent_New2 \
(*(PyObject * (*)(int, PyObject *)) PYGAMEAPI_GET_SLOT(event, 2))
#define pgEvent_FillUserEvent \
(*(int (*)(pgEventObject *, SDL_Event *))PYGAMEAPI_GET_SLOT(event, 3))
#define pg_EnableKeyRepeat (*(int (*)(int, int))PYGAMEAPI_GET_SLOT(event, 4))
#define pg_GetKeyRepeat (*(void (*)(int *, int *))PYGAMEAPI_GET_SLOT(event, 5))
#define import_pygame_event() IMPORT_PYGAME_MODULE(event)
#endif
/*
* RWOBJECT module
* the rwobject are only needed for C side work, not accessible from python.
*/
#ifndef PYGAMEAPI_RWOBJECT_INTERNAL
#define pgRWops_FromObject \
(*(SDL_RWops * (*)(PyObject *, char **)) PYGAMEAPI_GET_SLOT(rwobject, 0))
#define pgRWops_IsFileObject \
(*(int (*)(SDL_RWops *))PYGAMEAPI_GET_SLOT(rwobject, 1))
#define pg_EncodeFilePath \
(*(PyObject * (*)(PyObject *, PyObject *)) PYGAMEAPI_GET_SLOT(rwobject, 2))
#define pg_EncodeString \
(*(PyObject * (*)(PyObject *, const char *, const char *, PyObject *)) \
PYGAMEAPI_GET_SLOT(rwobject, 3))
#define pgRWops_FromFileObject \
(*(SDL_RWops * (*)(PyObject *)) PYGAMEAPI_GET_SLOT(rwobject, 4))
#define pgRWops_ReleaseObject \
(*(int (*)(SDL_RWops *))PYGAMEAPI_GET_SLOT(rwobject, 5))
#define import_pygame_rwobject() IMPORT_PYGAME_MODULE(rwobject)
#endif
/*
* PixelArray module
*/
#ifndef PYGAMEAPI_PIXELARRAY_INTERNAL
#define PyPixelArray_Type ((PyTypeObject *)PYGAMEAPI_GET_SLOT(pixelarray, 0))
#define PyPixelArray_Check(x) ((x)->ob_type == &PyPixelArray_Type)
#define PyPixelArray_New (*(PyObject * (*)) PYGAMEAPI_GET_SLOT(pixelarray, 1))
#define import_pygame_pixelarray() IMPORT_PYGAME_MODULE(pixelarray)
#endif /* PYGAMEAPI_PIXELARRAY_INTERNAL */
/*
* Color module
*/
typedef struct pgColorObject pgColorObject;
#ifndef PYGAMEAPI_COLOR_INTERNAL
#define pgColor_Type (*(PyObject *)PYGAMEAPI_GET_SLOT(color, 0))
#define pgColor_Check(x) ((x)->ob_type == &pgColor_Type)
#define pgColor_New (*(PyObject * (*)(Uint8 *)) PYGAMEAPI_GET_SLOT(color, 1))
#define pgColor_NewLength \
(*(PyObject * (*)(Uint8 *, Uint8)) PYGAMEAPI_GET_SLOT(color, 3))
#define pg_RGBAFromColorObj \
(*(int (*)(PyObject *, Uint8 *))PYGAMEAPI_GET_SLOT(color, 2))
#define pg_RGBAFromFuzzyColorObj \
(*(int (*)(PyObject *, Uint8 *))PYGAMEAPI_GET_SLOT(color, 4))
#define pgColor_AsArray(x) (((pgColorObject *)x)->data)
#define pgColor_NumComponents(x) (((pgColorObject *)x)->len)
#define import_pygame_color() IMPORT_PYGAME_MODULE(color)
#endif /* PYGAMEAPI_COLOR_INTERNAL */
/*
* Math module
*/
#ifndef PYGAMEAPI_MATH_INTERNAL
#define pgVector2_Check(x) \
((x)->ob_type == (PyTypeObject *)PYGAMEAPI_GET_SLOT(math, 0))
#define pgVector3_Check(x) \
((x)->ob_type == (PyTypeObject *)PYGAMEAPI_GET_SLOT(math, 1))
/*
#define pgVector2_New \
(*(PyObject*(*)) \
PYGAMEAPI_GET_SLOT(PyGAME_C_API, 1))
*/
#define import_pygame_math() IMPORT_PYGAME_MODULE(math)
#endif /* PYGAMEAPI_MATH_INTERNAL */
#define IMPORT_PYGAME_MODULE _IMPORT_PYGAME_MODULE
/*
* base pygame API slots
* disable slots with NO_PYGAME_C_API
*/
#ifdef PYGAME_H
PYGAMEAPI_DEFINE_SLOTS(base);
PYGAMEAPI_DEFINE_SLOTS(rect);
PYGAMEAPI_DEFINE_SLOTS(cdrom);
PYGAMEAPI_DEFINE_SLOTS(joystick);
PYGAMEAPI_DEFINE_SLOTS(display);
PYGAMEAPI_DEFINE_SLOTS(surface);
PYGAMEAPI_DEFINE_SLOTS(surflock);
PYGAMEAPI_DEFINE_SLOTS(event);
PYGAMEAPI_DEFINE_SLOTS(rwobject);
PYGAMEAPI_DEFINE_SLOTS(pixelarray);
PYGAMEAPI_DEFINE_SLOTS(color);
PYGAMEAPI_DEFINE_SLOTS(math);
#else /* ~PYGAME_H */
PYGAMEAPI_EXTERN_SLOTS(base);
PYGAMEAPI_EXTERN_SLOTS(rect);
PYGAMEAPI_EXTERN_SLOTS(cdrom);
PYGAMEAPI_EXTERN_SLOTS(joystick);
PYGAMEAPI_EXTERN_SLOTS(display);
PYGAMEAPI_EXTERN_SLOTS(surface);
PYGAMEAPI_EXTERN_SLOTS(surflock);
PYGAMEAPI_EXTERN_SLOTS(event);
PYGAMEAPI_EXTERN_SLOTS(rwobject);
PYGAMEAPI_EXTERN_SLOTS(pixelarray);
PYGAMEAPI_EXTERN_SLOTS(color);
PYGAMEAPI_EXTERN_SLOTS(math);
#endif /* ~PYGAME_H */
#endif /* PYGAME_H */
/* Use the end of this file for other cross module inline utility
* functions There seems to be no good reason to stick to macro only
* functions in Python 3.
*/
static PG_INLINE PyObject *
pg_tuple_couple_from_values_int(int val1, int val2)
{
/* This function turns two input integers into a python tuple object.
* Currently, 5th November 2022, this is faster than using Py_BuildValue
* to do the same thing.
*/
PyObject *tup = PyTuple_New(2);
if (!tup) {
return NULL;
}
PyObject *tmp = PyLong_FromLong(val1);
if (!tmp) {
Py_DECREF(tup);
return NULL;
}
PyTuple_SET_ITEM(tup, 0, tmp);
tmp = PyLong_FromLong(val2);
if (!tmp) {
Py_DECREF(tup);
return NULL;
}
PyTuple_SET_ITEM(tup, 1, tmp);
return tup;
}
static PG_INLINE PyObject *
pg_tuple_triple_from_values_int(int val1, int val2, int val3)
{
/* This function turns three input integers into a python tuple object.
* Currently, 5th November 2022, this is faster than using Py_BuildValue
* to do the same thing.
*/
PyObject *tup = PyTuple_New(3);
if (!tup) {
return NULL;
}
PyObject *tmp = PyLong_FromLong(val1);
if (!tmp) {
Py_DECREF(tup);
return NULL;
}
PyTuple_SET_ITEM(tup, 0, tmp);
tmp = PyLong_FromLong(val2);
if (!tmp) {
Py_DECREF(tup);
return NULL;
}
PyTuple_SET_ITEM(tup, 1, tmp);
tmp = PyLong_FromLong(val3);
if (!tmp) {
Py_DECREF(tup);
return NULL;
}
PyTuple_SET_ITEM(tup, 2, tmp);
return tup;
}

View File

@ -0,0 +1,171 @@
/*
Bitmask 1.7 - A pixel-perfect collision detection library.
Copyright (C) 2002-2005 Ulf Ekstrom except for the bitcount
function which is copyright (C) Donald W. Gillies, 1992.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef BITMASK_H
#define BITMASK_H
#ifdef __cplusplus
extern "C" {
#endif
#include <limits.h>
/* Define INLINE for different compilers. If your compiler does not
support inlining then there might be a performance hit in
bitmask_overlap_area().
*/
#ifndef INLINE
#ifdef __GNUC__
#define INLINE inline
#else
#ifdef _MSC_VER
#define INLINE __inline
#else
#define INLINE
#endif
#endif
#endif
#define BITMASK_W unsigned long int
#define BITMASK_W_LEN (sizeof(BITMASK_W) * CHAR_BIT)
#define BITMASK_W_MASK (BITMASK_W_LEN - 1)
#define BITMASK_N(n) ((BITMASK_W)1 << (n))
typedef struct bitmask {
int w, h;
BITMASK_W bits[1];
} bitmask_t;
/* Creates a bitmask of width w and height h, where
w and h must both be greater than or equal to 0.
The mask is automatically cleared when created.
*/
bitmask_t *
bitmask_create(int w, int h);
/* Frees all the memory allocated by bitmask_create for m. */
void
bitmask_free(bitmask_t *m);
/* Create a copy of the given bitmask. */
bitmask_t *
bitmask_copy(bitmask_t *m);
/* Clears all bits in the mask */
void
bitmask_clear(bitmask_t *m);
/* Sets all bits in the mask */
void
bitmask_fill(bitmask_t *m);
/* Flips all bits in the mask */
void
bitmask_invert(bitmask_t *m);
/* Counts the bits in the mask */
unsigned int
bitmask_count(bitmask_t *m);
/* Returns nonzero if the bit at (x,y) is set. Coordinates start at
(0,0) */
static INLINE int
bitmask_getbit(const bitmask_t *m, int x, int y)
{
return (m->bits[x / BITMASK_W_LEN * m->h + y] &
BITMASK_N(x & BITMASK_W_MASK)) != 0;
}
/* Sets the bit at (x,y) */
static INLINE void
bitmask_setbit(bitmask_t *m, int x, int y)
{
m->bits[x / BITMASK_W_LEN * m->h + y] |= BITMASK_N(x & BITMASK_W_MASK);
}
/* Clears the bit at (x,y) */
static INLINE void
bitmask_clearbit(bitmask_t *m, int x, int y)
{
m->bits[x / BITMASK_W_LEN * m->h + y] &= ~BITMASK_N(x & BITMASK_W_MASK);
}
/* Returns nonzero if the masks overlap with the given offset.
The overlap tests uses the following offsets (which may be negative):
+----+----------..
|A | yoffset
| +-+----------..
+--|B
|xoffset
| |
: :
*/
int
bitmask_overlap(const bitmask_t *a, const bitmask_t *b, int xoffset,
int yoffset);
/* Like bitmask_overlap(), but will also give a point of intersection.
x and y are given in the coordinates of mask a, and are untouched
if there is no overlap. */
int
bitmask_overlap_pos(const bitmask_t *a, const bitmask_t *b, int xoffset,
int yoffset, int *x, int *y);
/* Returns the number of overlapping 'pixels' */
int
bitmask_overlap_area(const bitmask_t *a, const bitmask_t *b, int xoffset,
int yoffset);
/* Fills a mask with the overlap of two other masks. A bitwise AND. */
void
bitmask_overlap_mask(const bitmask_t *a, const bitmask_t *b, bitmask_t *c,
int xoffset, int yoffset);
/* Draws mask b onto mask a (bitwise OR). Can be used to compose large
(game background?) mask from several submasks, which may speed up
the testing. */
void
bitmask_draw(bitmask_t *a, const bitmask_t *b, int xoffset, int yoffset);
void
bitmask_erase(bitmask_t *a, const bitmask_t *b, int xoffset, int yoffset);
/* Return a new scaled bitmask, with dimensions w*h. The quality of the
scaling may not be perfect for all circumstances, but it should
be reasonable. If either w or h is 0 a clear 1x1 mask is returned. */
bitmask_t *
bitmask_scale(const bitmask_t *m, int w, int h);
/* Convolve b into a, drawing the output into o, shifted by offset. If offset
* is 0, then the (x,y) bit will be set if and only if
* bitmask_overlap(a, b, x - b->w - 1, y - b->h - 1) returns true.
*
* Modifies bits o[xoffset ... xoffset + a->w + b->w - 1)
* [yoffset ... yoffset + a->h + b->h - 1). */
void
bitmask_convolve(const bitmask_t *a, const bitmask_t *b, bitmask_t *o,
int xoffset, int yoffset);
#ifdef __cplusplus
} /* End of extern "C" { */
#endif
#endif

View File

@ -0,0 +1,102 @@
#if !defined(PGCOMPAT_H)
#define PGCOMPAT_H
#include <Python.h>
/* In CPython, Py_Exit finalises the python interpreter before calling C exit()
* This does not exist on PyPy, so use exit() directly here */
#ifdef PYPY_VERSION
#define PG_EXIT(n) exit(n)
#else
#define PG_EXIT(n) Py_Exit(n)
#endif
/* define common types where SDL is not included */
#ifndef SDL_VERSION_ATLEAST
#ifdef _MSC_VER
typedef unsigned __int8 uint8_t;
typedef unsigned __int32 uint32_t;
#else
#include <stdint.h>
#endif
typedef uint32_t Uint32;
typedef uint8_t Uint8;
#endif /* no SDL */
#if defined(SDL_VERSION_ATLEAST)
#ifndef SDL_WINDOW_VULKAN
#define SDL_WINDOW_VULKAN 0
#endif
#ifndef SDL_WINDOW_ALWAYS_ON_TOP
#define SDL_WINDOW_ALWAYS_ON_TOP 0
#endif
#ifndef SDL_WINDOW_SKIP_TASKBAR
#define SDL_WINDOW_SKIP_TASKBAR 0
#endif
#ifndef SDL_WINDOW_UTILITY
#define SDL_WINDOW_UTILITY 0
#endif
#ifndef SDL_WINDOW_TOOLTIP
#define SDL_WINDOW_TOOLTIP 0
#endif
#ifndef SDL_WINDOW_POPUP_MENU
#define SDL_WINDOW_POPUP_MENU 0
#endif
#ifndef SDL_WINDOW_INPUT_GRABBED
#define SDL_WINDOW_INPUT_GRABBED 0
#endif
#ifndef SDL_WINDOW_INPUT_FOCUS
#define SDL_WINDOW_INPUT_FOCUS 0
#endif
#ifndef SDL_WINDOW_MOUSE_FOCUS
#define SDL_WINDOW_MOUSE_FOCUS 0
#endif
#ifndef SDL_WINDOW_FOREIGN
#define SDL_WINDOW_FOREIGN 0
#endif
#ifndef SDL_WINDOW_ALLOW_HIGHDPI
#define SDL_WINDOW_ALLOW_HIGHDPI 0
#endif
#ifndef SDL_WINDOW_MOUSE_CAPTURE
#define SDL_WINDOW_MOUSE_CAPTURE 0
#endif
#ifndef SDL_WINDOW_ALWAYS_ON_TOP
#define SDL_WINDOW_ALWAYS_ON_TOP 0
#endif
#ifndef SDL_WINDOW_SKIP_TASKBAR
#define SDL_WINDOW_SKIP_TASKBAR 0
#endif
#ifndef SDL_WINDOW_UTILITY
#define SDL_WINDOW_UTILITY 0
#endif
#ifndef SDL_WINDOW_TOOLTIP
#define SDL_WINDOW_TOOLTIP 0
#endif
#ifndef SDL_WINDOW_POPUP_MENU
#define SDL_WINDOW_POPUP_MENU 0
#endif
#ifndef SDL_MOUSEWHEEL_FLIPPED
#define NO_SDL_MOUSEWHEEL_FLIPPED
#endif
#endif /* defined(SDL_VERSION_ATLEAST) */
#endif /* ~defined(PGCOMPAT_H) */

View File

@ -0,0 +1,67 @@
#ifndef PGIMPORT_H
#define PGIMPORT_H
/* Prefix when importing module */
#define IMPPREFIX "pygame."
#include "pgcompat.h"
#define PYGAMEAPI_LOCAL_ENTRY "_PYGAME_C_API"
#define PG_CAPSULE_NAME(m) (IMPPREFIX m "." PYGAMEAPI_LOCAL_ENTRY)
/*
* fill API slots defined by PYGAMEAPI_DEFINE_SLOTS/PYGAMEAPI_EXTERN_SLOTS
*/
#define _IMPORT_PYGAME_MODULE(module) \
{ \
PyObject *_mod_##module = PyImport_ImportModule(IMPPREFIX #module); \
\
if (_mod_##module != NULL) { \
PyObject *_c_api = \
PyObject_GetAttrString(_mod_##module, PYGAMEAPI_LOCAL_ENTRY); \
\
Py_DECREF(_mod_##module); \
if (_c_api != NULL && PyCapsule_CheckExact(_c_api)) { \
void **localptr = (void **)PyCapsule_GetPointer( \
_c_api, PG_CAPSULE_NAME(#module)); \
_PGSLOTS_##module = localptr; \
} \
Py_XDECREF(_c_api); \
} \
}
#define PYGAMEAPI_IS_IMPORTED(module) (_PGSLOTS_##module != NULL)
/*
* source file must include one of these in order to use _IMPORT_PYGAME_MODULE.
* this is set by import_pygame_*() functions.
* disable with NO_PYGAME_C_API
*/
#define PYGAMEAPI_DEFINE_SLOTS(module) void **_PGSLOTS_##module = NULL
#define PYGAMEAPI_EXTERN_SLOTS(module) extern void **_PGSLOTS_##module
#define PYGAMEAPI_GET_SLOT(module, index) _PGSLOTS_##module[(index)]
/*
* disabled API with NO_PYGAME_C_API; do nothing instead
*/
#ifdef NO_PYGAME_C_API
#undef PYGAMEAPI_DEFINE_SLOTS
#undef PYGAMEAPI_EXTERN_SLOTS
#define PYGAMEAPI_DEFINE_SLOTS(module)
#define PYGAMEAPI_EXTERN_SLOTS(module)
/* intentionally leave this defined to cause a compiler error *
#define PYGAMEAPI_GET_SLOT(api_root, index)
#undef PYGAMEAPI_GET_SLOT*/
#undef _IMPORT_PYGAME_MODULE
#define _IMPORT_PYGAME_MODULE(module)
#endif /* NO_PYGAME_C_API */
#define encapsulate_api(ptr, module) \
PyCapsule_New(ptr, PG_CAPSULE_NAME(module), NULL)
#endif /* ~PGIMPORT_H */

View File

@ -0,0 +1,87 @@
/* platform/compiler adjustments */
#ifndef PG_PLATFORM_H
#define PG_PLATFORM_H
#if defined(HAVE_SNPRINTF) /* defined in python.h (pyerrors.h) and SDL.h \
(SDL_config.h) */
#undef HAVE_SNPRINTF /* remove GCC redefine warning */
#endif /* HAVE_SNPRINTF */
#ifndef PG_INLINE
#if defined(__clang__)
#define PG_INLINE __inline__ __attribute__((__unused__))
#elif defined(__GNUC__)
#define PG_INLINE __inline__
#elif defined(_MSC_VER)
#define PG_INLINE __inline
#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
#define PG_INLINE inline
#else
#define PG_INLINE
#endif
#endif /* ~PG_INLINE */
// Worth trying this on MSVC/win32 builds to see if provides any speed up
#ifndef PG_FORCEINLINE
#if defined(__clang__)
#define PG_FORCEINLINE __inline__ __attribute__((__unused__))
#elif defined(__GNUC__)
#define PG_FORCEINLINE __inline__
#elif defined(_MSC_VER)
#define PG_FORCEINLINE __forceinline
#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
#define PG_FORCEINLINE inline
#else
#define PG_FORCEINLINE
#endif
#endif /* ~PG_FORCEINLINE */
/* This is unconditionally defined in Python.h */
#if defined(_POSIX_C_SOURCE)
#undef _POSIX_C_SOURCE
#endif
#if defined(HAVE_SNPRINTF)
#undef HAVE_SNPRINTF
#endif
/* SDL needs WIN32 */
#if !defined(WIN32) && \
(defined(MS_WIN32) || defined(_WIN32) || defined(__WIN32) || \
defined(__WIN32__) || defined(_WINDOWS))
#define WIN32
#endif
/* Commenting out SSE4_2 stuff because it does not do runtime detection.
#ifndef PG_TARGET_SSE4_2
#if defined(__clang__) || (defined(__GNUC__) && ((__GNUC__ == 4 &&
__GNUC_MINOR__ >= 9) || __GNUC__ >= 5 ))
//The old gcc 4.8 on centos used by manylinux1 does not seem to get sse4.2
intrinsics #define PG_FUNCTION_TARGET_SSE4_2 __attribute__((target("sse4.2")))
// No else; we define the fallback later
#endif
#endif
*/
/* ~PG_TARGET_SSE4_2 */
/*
#ifdef PG_FUNCTION_TARGET_SSE4_2
#if !defined(__SSE4_2__) && !defined(PG_COMPILE_SSE4_2)
#if defined(__x86_64__) || defined(__i386__)
#define PG_COMPILE_SSE4_2 1
#endif
#endif
#endif
*/
/* ~PG_TARGET_SSE4_2 */
/* Fallback definition of target attribute */
#ifndef PG_FUNCTION_TARGET_SSE4_2
#define PG_FUNCTION_TARGET_SSE4_2
#endif
#ifndef PG_COMPILE_SSE4_2
#define PG_COMPILE_SSE4_2 0
#endif
#endif /* ~PG_PLATFORM_H */

View File

@ -0,0 +1,34 @@
/*
pygame - Python Game Library
Copyright (C) 2000-2001 Pete Shinners
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Pete Shinners
pete@shinners.org
*/
/* To allow the Pygame C api to be globally shared by all code within an
* extension module built from multiple C files, only include the pygame.h
* header within the top level C file, the one which calls the
* 'import_pygame_*' macros. All other C source files of the module should
* include _pygame.h instead.
*/
#ifndef PYGAME_H
#define PYGAME_H
#include "_pygame.h"
#endif

View File

@ -0,0 +1,56 @@
/*
pygame - Python Game Library
Copyright (C) 2000-2001 Pete Shinners
Copyright (C) 2007 Rene Dudfield, Richard Goedeken
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Pete Shinners
pete@shinners.org
*/
/* Bufferproxy module C api. */
#if !defined(PG_BUFPROXY_HEADER)
#define PG_BUFPROXY_HEADER
#include <Python.h>
typedef PyObject *(*_pgbufproxy_new_t)(PyObject *, getbufferproc);
typedef PyObject *(*_pgbufproxy_get_obj_t)(PyObject *);
typedef int (*_pgbufproxy_trip_t)(PyObject *);
#ifndef PYGAMEAPI_BUFPROXY_INTERNAL
#include "pgimport.h"
PYGAMEAPI_DEFINE_SLOTS(bufferproxy);
#define pgBufproxy_Type (*(PyTypeObject *)PYGAMEAPI_GET_SLOT(bufferproxy, 0))
#define pgBufproxy_Check(x) ((x)->ob_type == &pgBufproxy_Type)
#define pgBufproxy_New (*(_pgbufproxy_new_t)PYGAMEAPI_GET_SLOT(bufferproxy, 1))
#define pgBufproxy_GetParent \
(*(_pgbufproxy_get_obj_t)PYGAMEAPI_GET_SLOT(bufferproxy, 2))
#define pgBufproxy_Trip \
(*(_pgbufproxy_trip_t)PYGAMEAPI_GET_SLOT(bufferproxy, 3))
#define import_pygame_bufferproxy() _IMPORT_PYGAME_MODULE(bufferproxy)
#endif /* ~PYGAMEAPI_BUFPROXY_INTERNAL */
#endif /* ~defined(PG_BUFPROXY_HEADER) */

View File

@ -0,0 +1,50 @@
/*
pygame - Python Game Library
Copyright (C) 2000-2001 Pete Shinners
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Pete Shinners
pete@shinners.org
*/
#include <Python.h>
#include "pgplatform.h"
struct TTF_Font;
typedef struct {
PyObject_HEAD TTF_Font *font;
PyObject *weakreflist;
unsigned int ttf_init_generation;
} PyFontObject;
#define PyFont_AsFont(x) (((PyFontObject *)x)->font)
#ifndef PYGAMEAPI_FONT_INTERNAL
#include "pgimport.h"
PYGAMEAPI_DEFINE_SLOTS(font);
#define PyFont_Type (*(PyTypeObject *)PYGAMEAPI_GET_SLOT(font, 0))
#define PyFont_Check(x) ((x)->ob_type == &PyFont_Type)
#define PyFont_New (*(PyObject * (*)(TTF_Font *)) PYGAMEAPI_GET_SLOT(font, 1))
/*slot 2 taken by FONT_INIT_CHECK*/
#define import_pygame_font() _IMPORT_PYGAME_MODULE(font)
#endif

View File

@ -0,0 +1,42 @@
/*
pygame - Python Game Library
Copyright (C) 2009 Vicent Marti
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef PYGAME_FREETYPE_H_
#define PYGAME_FREETYPE_H_
#include "pgplatform.h"
#include "pgimport.h"
#include "pgcompat.h"
#ifndef PYGAME_FREETYPE_INTERNAL
PYGAMEAPI_DEFINE_SLOTS(_freetype);
#define pgFont_Type (*(PyTypeObject *)PYGAMEAPI_GET_SLOT(_freetype, 0))
#define pgFont_Check(x) ((x)->ob_type == &pgFont_Type)
#define pgFont_New \
(*(PyObject * (*)(const char *, long)) PYGAMEAPI_GET_SLOT(_freetype, 1))
#define import_pygame_freetype() _IMPORT_PYGAME_MODULE(_freetype)
#endif /* PYGAME_FREETYPE_INTERNAL */
#endif /* PYGAME_FREETYPE_H_ */

View File

@ -0,0 +1,45 @@
/*
pygame - Python Game Library
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef PGMASK_H
#define PGMASK_H
#include <Python.h>
#include "bitmask.h"
typedef struct {
PyObject_HEAD bitmask_t *mask;
void *bufdata;
} pgMaskObject;
#define pgMask_AsBitmap(x) (((pgMaskObject *)x)->mask)
#ifndef PYGAMEAPI_MASK_INTERNAL
#include "pgimport.h"
PYGAMEAPI_DEFINE_SLOTS(mask);
#define pgMask_Type (*(PyTypeObject *)PYGAMEAPI_GET_SLOT(mask, 0))
#define pgMask_Check(x) ((x)->ob_type == &pgMask_Type)
#define import_pygame_mask() _IMPORT_PYGAME_MODULE(mask)
#endif /* ~PYGAMEAPI_MASK_INTERNAL */
#endif /* ~PGMASK_H */

View File

@ -0,0 +1,71 @@
/*
pygame - Python Game Library
Copyright (C) 2000-2001 Pete Shinners
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Pete Shinners
pete@shinners.org
*/
#ifndef PGMIXER_H
#define PGMIXER_H
#include <Python.h>
#include <structmember.h>
#include "pgcompat.h"
struct Mix_Chunk;
typedef struct {
PyObject_HEAD Mix_Chunk *chunk;
Uint8 *mem;
PyObject *weakreflist;
} pgSoundObject;
typedef struct {
PyObject_HEAD int chan;
} pgChannelObject;
#define pgSound_AsChunk(x) (((pgSoundObject *)x)->chunk)
#define pgChannel_AsInt(x) (((pgChannelObject *)x)->chan)
#include "pgimport.h"
#ifndef PYGAMEAPI_MIXER_INTERNAL
PYGAMEAPI_DEFINE_SLOTS(mixer);
#define pgSound_Type (*(PyTypeObject *)PYGAMEAPI_GET_SLOT(mixer, 0))
#define pgSound_Check(x) ((x)->ob_type == &pgSound_Type)
#define pgSound_New \
(*(PyObject * (*)(Mix_Chunk *)) PYGAMEAPI_GET_SLOT(mixer, 1))
#define pgSound_Play \
(*(PyObject * (*)(PyObject *, PyObject *)) PYGAMEAPI_GET_SLOT(mixer, 2))
#define pgChannel_Type (*(PyTypeObject *)PYGAMEAPI_GET_SLOT(mixer, 3))
#define pgChannel_Check(x) ((x)->ob_type == &pgChannel_Type)
#define pgChannel_New (*(PyObject * (*)(int)) PYGAMEAPI_GET_SLOT(mixer, 4))
#define import_pygame_mixer() _IMPORT_PYGAME_MODULE(mixer)
#endif /* PYGAMEAPI_MIXER_INTERNAL */
#endif /* ~PGMIXER_H */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,7 @@
#ifndef PGMASK_INTERNAL_H
#define PGMASK_INTERNAL_H
#include "include/pygame_mask.h"
#define PYGAMEAPI_MASK_NUMSLOTS 1
#endif /* ~PGMASK_INTERNAL_H */

View File

@ -0,0 +1,14 @@
#ifndef MIXER_INTERNAL_H
#define MIXER_INTERNAL_H
#include <SDL_mixer.h>
/* test mixer initializations */
#define MIXER_INIT_CHECK() \
if (!SDL_WasInit(SDL_INIT_AUDIO)) \
return RAISE(pgExc_SDLError, "mixer not initialized")
#define PYGAMEAPI_MIXER_NUMSLOTS 5
#include "include/pygame_mixer.h"
#endif /* ~MIXER_INTERNAL_H */

View File

@ -0,0 +1,123 @@
/*
pygame - Python Game Library
Copyright (C) 2000-2001 Pete Shinners
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Pete Shinners
pete@shinners.org
*/
#ifndef PALETTE_H
#define PALETTE_H
#include <SDL.h>
/* SDL 2 does not assign a default palette color scheme to a new 8 bit
* surface. Instead, the palette is set all white. This defines the SDL 1.2
* default palette.
*/
static const SDL_Color default_palette_colors[] = {
{0, 0, 0, 255}, {0, 0, 85, 255}, {0, 0, 170, 255},
{0, 0, 255, 255}, {0, 36, 0, 255}, {0, 36, 85, 255},
{0, 36, 170, 255}, {0, 36, 255, 255}, {0, 73, 0, 255},
{0, 73, 85, 255}, {0, 73, 170, 255}, {0, 73, 255, 255},
{0, 109, 0, 255}, {0, 109, 85, 255}, {0, 109, 170, 255},
{0, 109, 255, 255}, {0, 146, 0, 255}, {0, 146, 85, 255},
{0, 146, 170, 255}, {0, 146, 255, 255}, {0, 182, 0, 255},
{0, 182, 85, 255}, {0, 182, 170, 255}, {0, 182, 255, 255},
{0, 219, 0, 255}, {0, 219, 85, 255}, {0, 219, 170, 255},
{0, 219, 255, 255}, {0, 255, 0, 255}, {0, 255, 85, 255},
{0, 255, 170, 255}, {0, 255, 255, 255}, {85, 0, 0, 255},
{85, 0, 85, 255}, {85, 0, 170, 255}, {85, 0, 255, 255},
{85, 36, 0, 255}, {85, 36, 85, 255}, {85, 36, 170, 255},
{85, 36, 255, 255}, {85, 73, 0, 255}, {85, 73, 85, 255},
{85, 73, 170, 255}, {85, 73, 255, 255}, {85, 109, 0, 255},
{85, 109, 85, 255}, {85, 109, 170, 255}, {85, 109, 255, 255},
{85, 146, 0, 255}, {85, 146, 85, 255}, {85, 146, 170, 255},
{85, 146, 255, 255}, {85, 182, 0, 255}, {85, 182, 85, 255},
{85, 182, 170, 255}, {85, 182, 255, 255}, {85, 219, 0, 255},
{85, 219, 85, 255}, {85, 219, 170, 255}, {85, 219, 255, 255},
{85, 255, 0, 255}, {85, 255, 85, 255}, {85, 255, 170, 255},
{85, 255, 255, 255}, {170, 0, 0, 255}, {170, 0, 85, 255},
{170, 0, 170, 255}, {170, 0, 255, 255}, {170, 36, 0, 255},
{170, 36, 85, 255}, {170, 36, 170, 255}, {170, 36, 255, 255},
{170, 73, 0, 255}, {170, 73, 85, 255}, {170, 73, 170, 255},
{170, 73, 255, 255}, {170, 109, 0, 255}, {170, 109, 85, 255},
{170, 109, 170, 255}, {170, 109, 255, 255}, {170, 146, 0, 255},
{170, 146, 85, 255}, {170, 146, 170, 255}, {170, 146, 255, 255},
{170, 182, 0, 255}, {170, 182, 85, 255}, {170, 182, 170, 255},
{170, 182, 255, 255}, {170, 219, 0, 255}, {170, 219, 85, 255},
{170, 219, 170, 255}, {170, 219, 255, 255}, {170, 255, 0, 255},
{170, 255, 85, 255}, {170, 255, 170, 255}, {170, 255, 255, 255},
{255, 0, 0, 255}, {255, 0, 85, 255}, {255, 0, 170, 255},
{255, 0, 255, 255}, {255, 36, 0, 255}, {255, 36, 85, 255},
{255, 36, 170, 255}, {255, 36, 255, 255}, {255, 73, 0, 255},
{255, 73, 85, 255}, {255, 73, 170, 255}, {255, 73, 255, 255},
{255, 109, 0, 255}, {255, 109, 85, 255}, {255, 109, 170, 255},
{255, 109, 255, 255}, {255, 146, 0, 255}, {255, 146, 85, 255},
{255, 146, 170, 255}, {255, 146, 255, 255}, {255, 182, 0, 255},
{255, 182, 85, 255}, {255, 182, 170, 255}, {255, 182, 255, 255},
{255, 219, 0, 255}, {255, 219, 85, 255}, {255, 219, 170, 255},
{255, 219, 255, 255}, {255, 255, 0, 255}, {255, 255, 85, 255},
{255, 255, 170, 255}, {255, 255, 255, 255}, {0, 0, 0, 255},
{0, 0, 85, 255}, {0, 0, 170, 255}, {0, 0, 255, 255},
{0, 36, 0, 255}, {0, 36, 85, 255}, {0, 36, 170, 255},
{0, 36, 255, 255}, {0, 73, 0, 255}, {0, 73, 85, 255},
{0, 73, 170, 255}, {0, 73, 255, 255}, {0, 109, 0, 255},
{0, 109, 85, 255}, {0, 109, 170, 255}, {0, 109, 255, 255},
{0, 146, 0, 255}, {0, 146, 85, 255}, {0, 146, 170, 255},
{0, 146, 255, 255}, {0, 182, 0, 255}, {0, 182, 85, 255},
{0, 182, 170, 255}, {0, 182, 255, 255}, {0, 219, 0, 255},
{0, 219, 85, 255}, {0, 219, 170, 255}, {0, 219, 255, 255},
{0, 255, 0, 255}, {0, 255, 85, 255}, {0, 255, 170, 255},
{0, 255, 255, 255}, {85, 0, 0, 255}, {85, 0, 85, 255},
{85, 0, 170, 255}, {85, 0, 255, 255}, {85, 36, 0, 255},
{85, 36, 85, 255}, {85, 36, 170, 255}, {85, 36, 255, 255},
{85, 73, 0, 255}, {85, 73, 85, 255}, {85, 73, 170, 255},
{85, 73, 255, 255}, {85, 109, 0, 255}, {85, 109, 85, 255},
{85, 109, 170, 255}, {85, 109, 255, 255}, {85, 146, 0, 255},
{85, 146, 85, 255}, {85, 146, 170, 255}, {85, 146, 255, 255},
{85, 182, 0, 255}, {85, 182, 85, 255}, {85, 182, 170, 255},
{85, 182, 255, 255}, {85, 219, 0, 255}, {85, 219, 85, 255},
{85, 219, 170, 255}, {85, 219, 255, 255}, {85, 255, 0, 255},
{85, 255, 85, 255}, {85, 255, 170, 255}, {85, 255, 255, 255},
{170, 0, 0, 255}, {170, 0, 85, 255}, {170, 0, 170, 255},
{170, 0, 255, 255}, {170, 36, 0, 255}, {170, 36, 85, 255},
{170, 36, 170, 255}, {170, 36, 255, 255}, {170, 73, 0, 255},
{170, 73, 85, 255}, {170, 73, 170, 255}, {170, 73, 255, 255},
{170, 109, 0, 255}, {170, 109, 85, 255}, {170, 109, 170, 255},
{170, 109, 255, 255}, {170, 146, 0, 255}, {170, 146, 85, 255},
{170, 146, 170, 255}, {170, 146, 255, 255}, {170, 182, 0, 255},
{170, 182, 85, 255}, {170, 182, 170, 255}, {170, 182, 255, 255},
{170, 219, 0, 255}, {170, 219, 85, 255}, {170, 219, 170, 255},
{170, 219, 255, 255}, {170, 255, 0, 255}, {170, 255, 85, 255},
{170, 255, 170, 255}, {170, 255, 255, 255}, {255, 0, 0, 255},
{255, 0, 85, 255}, {255, 0, 170, 255}, {255, 0, 255, 255},
{255, 36, 0, 255}, {255, 36, 85, 255}, {255, 36, 170, 255},
{255, 36, 255, 255}, {255, 73, 0, 255}, {255, 73, 85, 255},
{255, 73, 170, 255}, {255, 73, 255, 255}, {255, 109, 0, 255},
{255, 109, 85, 255}, {255, 109, 170, 255}, {255, 109, 255, 255},
{255, 146, 0, 255}, {255, 146, 85, 255}, {255, 146, 170, 255},
{255, 146, 255, 255}, {255, 182, 0, 255}, {255, 182, 85, 255},
{255, 182, 170, 255}, {255, 182, 255, 255}, {255, 219, 0, 255},
{255, 219, 85, 255}, {255, 219, 170, 255}, {255, 219, 255, 255},
{255, 255, 0, 255}, {255, 255, 85, 255}, {255, 255, 170, 255},
{255, 255, 255, 255}};
static const int default_palette_size =
(int)(sizeof(default_palette_colors) / sizeof(SDL_Color));
#endif

View File

@ -0,0 +1,26 @@
/* array structure interface version 3 declarations */
#if !defined(PG_ARRAYINTER_HEADER)
#define PG_ARRAYINTER_HEADER
static const int PAI_CONTIGUOUS = 0x01;
static const int PAI_FORTRAN = 0x02;
static const int PAI_ALIGNED = 0x100;
static const int PAI_NOTSWAPPED = 0x200;
static const int PAI_WRITEABLE = 0x400;
static const int PAI_ARR_HAS_DESCR = 0x800;
typedef struct {
int two; /* contains the integer 2 -- simple sanity check */
int nd; /* number of dimensions */
char typekind; /* kind in array -- character code of typestr */
int itemsize; /* size of each element */
int flags; /* flags indicating how the data should be */
/* interpreted */
Py_intptr_t *shape; /* A length-nd array of shape information */
Py_intptr_t *strides; /* A length-nd array of stride information */
void *data; /* A pointer to the first element of the array */
PyObject *descr; /* NULL or a data-description */
} PyArrayInterface;
#endif

View File

@ -0,0 +1,7 @@
#ifndef PG_BUFPROXY_INTERNAL_H
#define PG_BUFPROXY_INTERNAL_H
#include "include/pygame_bufferproxy.h"
#define PYGAMEAPI_BUFPROXY_NUMSLOTS 4
#endif /* ~PG_BUFPROXY_INTERNAL_H */

View File

@ -0,0 +1,27 @@
/* Python 2.x/3.x compatibility tools (internal)
*/
#ifndef PGCOMPAT_INTERNAL_H
#define PGCOMPAT_INTERNAL_H
#include "include/pgcompat.h"
/* Module init function returns new module instance. */
#define MODINIT_DEFINE(mod_name) PyMODINIT_FUNC PyInit_##mod_name(void)
/* Defaults for unicode file path encoding */
#if defined(MS_WIN32)
#define UNICODE_DEF_FS_ERROR "replace"
#else
#define UNICODE_DEF_FS_ERROR "surrogateescape"
#endif
#define RELATIVE_MODULE(m) ("." m)
#ifndef Py_TPFLAGS_HAVE_NEWBUFFER
#define Py_TPFLAGS_HAVE_NEWBUFFER 0
#endif
#define Slice_GET_INDICES_EX(slice, length, start, stop, step, slicelength) \
PySlice_GetIndicesEx(slice, length, start, stop, step, slicelength)
#endif /* ~PGCOMPAT_INTERNAL_H */

View File

@ -0,0 +1,20 @@
#if !defined(PGOPENGL_H)
#define PGOPENGL_H
/** This header includes definitions of Opengl functions as pointer types for
** use with the SDL function SDL_GL_GetProcAddress.
**/
#if defined(_WIN32)
#define GL_APIENTRY __stdcall
#else
#define GL_APIENTRY
#endif
typedef void(GL_APIENTRY *GL_glReadPixels_Func)(int, int, int, int,
unsigned int, unsigned int,
void *);
typedef void(GL_APIENTRY *GL_glViewport_Func)(int, int, unsigned int,
unsigned int);
#endif

View File

@ -0,0 +1,23 @@
/* platform/compiler adjustments (internal) */
#ifndef PG_PLATFORM_INTERNAL_H
#define PG_PLATFORM_INTERNAL_H
#include "include/pgplatform.h"
#ifndef MIN
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#endif
#ifndef MAX
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#endif
#ifndef ABS
#define ABS(a) (((a) < 0) ? -(a) : (a))
#endif
/* warnings */
#define PG_STRINGIZE_HELPER(x) #x
#define PG_STRINGIZE(x) PG_STRINGIZE_HELPER(x)
#define PG_WARN(desc) \
message(__FILE__ "(" PG_STRINGIZE(__LINE__) "): WARNING: " #desc)
#endif /* ~PG_PLATFORM_INTERNAL_H */

View File

@ -0,0 +1,32 @@
/*
pygame - Python Game Library
Copyright (C) 2000-2001 Pete Shinners
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Pete Shinners
pete@shinners.org
*/
/* This will use PYGAMEAPI_DEFINE_SLOTS instead
* of PYGAMEAPI_EXTERN_SLOTS for base modules.
*/
#ifndef PYGAME_INTERNAL_H
#define PYGAME_INTERNAL_H
#define PYGAME_H
#include "_pygame.h"
#endif /* ~PYGAME_INTERNAL_H */

View File

@ -0,0 +1,147 @@
/*
pygame - Python Game Library
Copyright (C) 2006, 2007 Rene Dudfield, Marcus von Appen
Originally put in the public domain by Sam Lantinga.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef SCRAP_H
#define SCRAP_H
/* This is unconditionally defined in Python.h */
#if defined(_POSIX_C_SOURCE)
#undef _POSIX_C_SOURCE
#endif
#include <Python.h>
/* Handle clipboard text and data in arbitrary formats */
/**
* Predefined supported pygame scrap types.
*/
#define PYGAME_SCRAP_TEXT "text/plain"
#define PYGAME_SCRAP_BMP "image/bmp"
#define PYGAME_SCRAP_PPM "image/ppm"
#define PYGAME_SCRAP_PBM "image/pbm"
/**
* The supported scrap clipboard types.
*
* This is only relevant in a X11 environment, which supports mouse
* selections as well. For Win32 and MacOS environments the default
* clipboard is used, no matter what value is passed.
*/
typedef enum {
SCRAP_CLIPBOARD,
SCRAP_SELECTION /* only supported in X11 environments. */
} ScrapClipType;
/**
* Macro for initialization checks.
*/
#define PYGAME_SCRAP_INIT_CHECK() \
if (!pygame_scrap_initialized()) \
return (PyErr_SetString(pgExc_SDLError, "scrap system not initialized."), \
NULL)
/**
* \brief Checks, whether the pygame scrap module was initialized.
*
* \return 1 if the modules was initialized, 0 otherwise.
*/
extern int
pygame_scrap_initialized(void);
/**
* \brief Initializes the pygame scrap module internals. Call this before any
* other method.
*
* \return 1 on successful initialization, 0 otherwise.
*/
extern int
pygame_scrap_init(void);
/**
* \brief Checks, whether the pygame window lost the clipboard focus or not.
*
* \return 1 if the window lost the focus, 0 otherwise.
*/
extern int
pygame_scrap_lost(void);
/**
* \brief Places content of a specific type into the clipboard.
*
* \note For X11 the following notes are important: The following types
* are reserved for internal usage and thus will throw an error on
* setting them: "TIMESTAMP", "TARGETS", "SDL_SELECTION".
* Setting PYGAME_SCRAP_TEXT ("text/plain") will also automatically
* set the X11 types "STRING" (XA_STRING), "TEXT" and "UTF8_STRING".
*
* For Win32 the following notes are important: Setting
* PYGAME_SCRAP_TEXT ("text/plain") will also automatically set
* the Win32 type "TEXT" (CF_TEXT).
*
* For QNX the following notes are important: Setting
* PYGAME_SCRAP_TEXT ("text/plain") will also automatically set
* the QNX type "TEXT" (Ph_CL_TEXT).
*
* \param type The type of the content.
* \param srclen The length of the content.
* \param src The NULL terminated content.
* \return 1, if the content could be successfully pasted into the clipboard,
* 0 otherwise.
*/
extern int
pygame_scrap_put(char *type, Py_ssize_t srclen, char *src);
/**
* \brief Gets the current content from the clipboard.
*
* \note The received content does not need to be the content previously
* placed in the clipboard using pygame_put_scrap(). See the
* pygame_put_scrap() notes for more details.
*
* \param type The type of the content to receive.
* \param count The size of the returned content.
* \return The content or NULL in case of an error or if no content of the
* specified type was available.
*/
extern char *
pygame_scrap_get(char *type, size_t *count);
/**
* \brief Gets the currently available content types from the clipboard.
*
* \return The different available content types or NULL in case of an
* error or if no content type is available.
*/
extern char **
pygame_scrap_get_types(void);
/**
* \brief Checks whether content for the specified scrap type is currently
* available in the clipboard.
*
* \param type The type to check for.
* \return 1, if there is content and 0 otherwise.
*/
extern int
pygame_scrap_contains(char *type);
#endif /* SCRAP_H */

View File

@ -0,0 +1,84 @@
#define NO_PYGAME_C_API
#include "_surface.h"
#include "_blit_info.h"
#if !defined(PG_ENABLE_ARM_NEON) && defined(__aarch64__)
// arm64 has neon optimisations enabled by default, even when fpu=neon is not
// passed
#define PG_ENABLE_ARM_NEON 1
#endif
int
pg_sse2_at_runtime_but_uncompiled();
int
pg_neon_at_runtime_but_uncompiled();
int
pg_avx2_at_runtime_but_uncompiled();
#if (defined(__SSE2__) || defined(PG_ENABLE_ARM_NEON))
void
alphablit_alpha_sse2_argb_surf_alpha(SDL_BlitInfo *info);
void
alphablit_alpha_sse2_argb_no_surf_alpha(SDL_BlitInfo *info);
void
alphablit_alpha_sse2_argb_no_surf_alpha_opaque_dst(SDL_BlitInfo *info);
void
blit_blend_rgba_mul_sse2(SDL_BlitInfo *info);
void
blit_blend_rgb_mul_sse2(SDL_BlitInfo *info);
void
blit_blend_rgba_add_sse2(SDL_BlitInfo *info);
void
blit_blend_rgb_add_sse2(SDL_BlitInfo *info);
void
blit_blend_rgba_sub_sse2(SDL_BlitInfo *info);
void
blit_blend_rgb_sub_sse2(SDL_BlitInfo *info);
void
blit_blend_rgba_max_sse2(SDL_BlitInfo *info);
void
blit_blend_rgb_max_sse2(SDL_BlitInfo *info);
void
blit_blend_rgba_min_sse2(SDL_BlitInfo *info);
void
blit_blend_rgb_min_sse2(SDL_BlitInfo *info);
void
blit_blend_premultiplied_sse2(SDL_BlitInfo *info);
#endif /* (defined(__SSE2__) || defined(PG_ENABLE_ARM_NEON)) */
/* Deliberately putting these outside of the preprocessor guards as I want to
move to a system of trusting the runtime checks to head to the right
function and having a fallback function there if pygame is not compiled
with the right stuff (this is the strategy used for AVX2 right now.
Potentially I might want to shift both these into a slightly different
file as they are not exactly blits (though v. similar) - or I could rename
the SIMD trilogy of files to replace the word blit with something more
generic like surface_ops*/
void
premul_surf_color_by_alpha_non_simd(SDL_Surface *src, SDL_Surface *dst);
void
premul_surf_color_by_alpha_sse2(SDL_Surface *src, SDL_Surface *dst);
int
pg_has_avx2();
void
blit_blend_rgba_mul_avx2(SDL_BlitInfo *info);
void
blit_blend_rgb_mul_avx2(SDL_BlitInfo *info);
void
blit_blend_rgba_add_avx2(SDL_BlitInfo *info);
void
blit_blend_rgb_add_avx2(SDL_BlitInfo *info);
void
blit_blend_rgba_sub_avx2(SDL_BlitInfo *info);
void
blit_blend_rgb_sub_avx2(SDL_BlitInfo *info);
void
blit_blend_rgba_max_avx2(SDL_BlitInfo *info);
void
blit_blend_rgb_max_avx2(SDL_BlitInfo *info);
void
blit_blend_rgba_min_avx2(SDL_BlitInfo *info);
void
blit_blend_rgb_min_avx2(SDL_BlitInfo *info);

View File

@ -0,0 +1,361 @@
/*
pygame - Python Game Library
Copyright (C) 2000-2001 Pete Shinners
Copyright (C) 2007 Marcus von Appen
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Pete Shinners
pete@shinners.org
*/
#ifndef SURFACE_H
#define SURFACE_H
/* This is defined in SDL.h */
#if defined(_POSIX_C_SOURCE)
#undef _POSIX_C_SOURCE
#endif
#include <SDL.h>
#include "pygame.h"
/* Blend modes */
#define PYGAME_BLEND_ADD 0x1
#define PYGAME_BLEND_SUB 0x2
#define PYGAME_BLEND_MULT 0x3
#define PYGAME_BLEND_MIN 0x4
#define PYGAME_BLEND_MAX 0x5
#define PYGAME_BLEND_RGB_ADD 0x1
#define PYGAME_BLEND_RGB_SUB 0x2
#define PYGAME_BLEND_RGB_MULT 0x3
#define PYGAME_BLEND_RGB_MIN 0x4
#define PYGAME_BLEND_RGB_MAX 0x5
#define PYGAME_BLEND_RGBA_ADD 0x6
#define PYGAME_BLEND_RGBA_SUB 0x7
#define PYGAME_BLEND_RGBA_MULT 0x8
#define PYGAME_BLEND_RGBA_MIN 0x9
#define PYGAME_BLEND_RGBA_MAX 0x10
#define PYGAME_BLEND_PREMULTIPLIED 0x11
#define PYGAME_BLEND_ALPHA_SDL2 0x12
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
#define GET_PIXEL_24(b) (b[0] + (b[1] << 8) + (b[2] << 16))
#else
#define GET_PIXEL_24(b) (b[2] + (b[1] << 8) + (b[0] << 16))
#endif
#define GET_PIXEL(pxl, bpp, source) \
switch (bpp) { \
case 2: \
pxl = *((Uint16 *)(source)); \
break; \
case 4: \
pxl = *((Uint32 *)(source)); \
break; \
default: { \
Uint8 *b = (Uint8 *)source; \
pxl = GET_PIXEL_24(b); \
} break; \
}
#define GET_PIXELVALS(_sR, _sG, _sB, _sA, px, fmt, ppa) \
SDL_GetRGBA(px, fmt, &(_sR), &(_sG), &(_sB), &(_sA)); \
if (!ppa) { \
_sA = 255; \
}
#define GET_PIXELVALS_1(sr, sg, sb, sa, _src, _fmt) \
sr = _fmt->palette->colors[*((Uint8 *)(_src))].r; \
sg = _fmt->palette->colors[*((Uint8 *)(_src))].g; \
sb = _fmt->palette->colors[*((Uint8 *)(_src))].b; \
sa = 255;
/* For 1 byte palette pixels */
#define SET_PIXELVAL(px, fmt, _dR, _dG, _dB, _dA) \
*(px) = (Uint8)SDL_MapRGBA(fmt, _dR, _dG, _dB, _dA)
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
#define SET_OFFSETS_24(or, og, ob, fmt) \
{ \
or = (fmt->Rshift == 0 ? 0 : fmt->Rshift == 8 ? 1 : 2); \
og = (fmt->Gshift == 0 ? 0 : fmt->Gshift == 8 ? 1 : 2); \
ob = (fmt->Bshift == 0 ? 0 : fmt->Bshift == 8 ? 1 : 2); \
}
#define SET_OFFSETS_32(or, og, ob, fmt) \
{ \
or = (fmt->Rshift == 0 ? 0 \
: fmt->Rshift == 8 ? 1 \
: fmt->Rshift == 16 ? 2 \
: 3); \
og = (fmt->Gshift == 0 ? 0 \
: fmt->Gshift == 8 ? 1 \
: fmt->Gshift == 16 ? 2 \
: 3); \
ob = (fmt->Bshift == 0 ? 0 \
: fmt->Bshift == 8 ? 1 \
: fmt->Bshift == 16 ? 2 \
: 3); \
}
#else
#define SET_OFFSETS_24(or, og, ob, fmt) \
{ \
or = (fmt->Rshift == 0 ? 2 : fmt->Rshift == 8 ? 1 : 0); \
og = (fmt->Gshift == 0 ? 2 : fmt->Gshift == 8 ? 1 : 0); \
ob = (fmt->Bshift == 0 ? 2 : fmt->Bshift == 8 ? 1 : 0); \
}
#define SET_OFFSETS_32(or, og, ob, fmt) \
{ \
or = (fmt->Rshift == 0 ? 3 \
: fmt->Rshift == 8 ? 2 \
: fmt->Rshift == 16 ? 1 \
: 0); \
og = (fmt->Gshift == 0 ? 3 \
: fmt->Gshift == 8 ? 2 \
: fmt->Gshift == 16 ? 1 \
: 0); \
ob = (fmt->Bshift == 0 ? 3 \
: fmt->Bshift == 8 ? 2 \
: fmt->Bshift == 16 ? 1 \
: 0); \
}
#endif
#define CREATE_PIXEL(buf, r, g, b, a, bp, ft) \
switch (bp) { \
case 2: \
*((Uint16 *)(buf)) = ((r >> ft->Rloss) << ft->Rshift) | \
((g >> ft->Gloss) << ft->Gshift) | \
((b >> ft->Bloss) << ft->Bshift) | \
((a >> ft->Aloss) << ft->Ashift); \
break; \
case 4: \
*((Uint32 *)(buf)) = ((r >> ft->Rloss) << ft->Rshift) | \
((g >> ft->Gloss) << ft->Gshift) | \
((b >> ft->Bloss) << ft->Bshift) | \
((a >> ft->Aloss) << ft->Ashift); \
break; \
}
/* Pretty good idea from Tom Duff :-). */
#define LOOP_UNROLLED4(code, n, width) \
n = (width + 3) / 4; \
switch (width & 3) { \
case 0: \
do { \
code; \
case 3: \
code; \
case 2: \
code; \
case 1: \
code; \
} while (--n > 0); \
}
/* Used in the srcbpp == dstbpp == 1 blend functions */
#define REPEAT_3(code) \
code; \
code; \
code;
#define REPEAT_4(code) \
code; \
code; \
code; \
code;
#define BLEND_ADD(tmp, sR, sG, sB, sA, dR, dG, dB, dA) \
tmp = dR + sR; \
dR = (tmp <= 255 ? tmp : 255); \
tmp = dG + sG; \
dG = (tmp <= 255 ? tmp : 255); \
tmp = dB + sB; \
dB = (tmp <= 255 ? tmp : 255);
#define BLEND_SUB(tmp, sR, sG, sB, sA, dR, dG, dB, dA) \
tmp = dR - sR; \
dR = (tmp >= 0 ? tmp : 0); \
tmp = dG - sG; \
dG = (tmp >= 0 ? tmp : 0); \
tmp = dB - sB; \
dB = (tmp >= 0 ? tmp : 0);
#define BLEND_MULT(sR, sG, sB, sA, dR, dG, dB, dA) \
dR = (dR && sR) ? ((dR * sR) + 255) >> 8 : 0; \
dG = (dG && sG) ? ((dG * sG) + 255) >> 8 : 0; \
dB = (dB && sB) ? ((dB * sB) + 255) >> 8 : 0;
#define BLEND_MIN(sR, sG, sB, sA, dR, dG, dB, dA) \
if (sR < dR) { \
dR = sR; \
} \
if (sG < dG) { \
dG = sG; \
} \
if (sB < dB) { \
dB = sB; \
}
#define BLEND_MAX(sR, sG, sB, sA, dR, dG, dB, dA) \
if (sR > dR) { \
dR = sR; \
} \
if (sG > dG) { \
dG = sG; \
} \
if (sB > dB) { \
dB = sB; \
}
#define BLEND_RGBA_ADD(tmp, sR, sG, sB, sA, dR, dG, dB, dA) \
tmp = dR + sR; \
dR = (tmp <= 255 ? tmp : 255); \
tmp = dG + sG; \
dG = (tmp <= 255 ? tmp : 255); \
tmp = dB + sB; \
dB = (tmp <= 255 ? tmp : 255); \
tmp = dA + sA; \
dA = (tmp <= 255 ? tmp : 255);
#define BLEND_RGBA_SUB(tmp, sR, sG, sB, sA, dR, dG, dB, dA) \
tmp = dR - sR; \
dR = (tmp >= 0 ? tmp : 0); \
tmp = dG - sG; \
dG = (tmp >= 0 ? tmp : 0); \
tmp = dB - sB; \
dB = (tmp >= 0 ? tmp : 0); \
tmp = dA - sA; \
dA = (tmp >= 0 ? tmp : 0);
#define BLEND_RGBA_MULT(sR, sG, sB, sA, dR, dG, dB, dA) \
dR = (dR && sR) ? ((dR * sR) + 255) >> 8 : 0; \
dG = (dG && sG) ? ((dG * sG) + 255) >> 8 : 0; \
dB = (dB && sB) ? ((dB * sB) + 255) >> 8 : 0; \
dA = (dA && sA) ? ((dA * sA) + 255) >> 8 : 0;
#define BLEND_RGBA_MIN(sR, sG, sB, sA, dR, dG, dB, dA) \
if (sR < dR) { \
dR = sR; \
} \
if (sG < dG) { \
dG = sG; \
} \
if (sB < dB) { \
dB = sB; \
} \
if (sA < dA) { \
dA = sA; \
}
#define BLEND_RGBA_MAX(sR, sG, sB, sA, dR, dG, dB, dA) \
if (sR > dR) { \
dR = sR; \
} \
if (sG > dG) { \
dG = sG; \
} \
if (sB > dB) { \
dB = sB; \
} \
if (sA > dA) { \
dA = sA; \
}
#if 1
/* Choose an alpha blend equation. If the sign is preserved on a right shift
* then use a specialized, faster, equation. Otherwise a more general form,
* where all additions are done before the shift, is needed.
*/
#if (-1 >> 1) < 0
#define ALPHA_BLEND_COMP(sC, dC, sA) ((((sC - dC) * sA + sC) >> 8) + dC)
#else
#define ALPHA_BLEND_COMP(sC, dC, sA) (((dC << 8) + (sC - dC) * sA + sC) >> 8)
#endif
#define ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB, dA) \
do { \
if (dA) { \
dR = ALPHA_BLEND_COMP(sR, dR, sA); \
dG = ALPHA_BLEND_COMP(sG, dG, sA); \
dB = ALPHA_BLEND_COMP(sB, dB, sA); \
dA = sA + dA - ((sA * dA) / 255); \
} \
else { \
dR = sR; \
dG = sG; \
dB = sB; \
dA = sA; \
} \
} while (0)
#define ALPHA_BLEND_PREMULTIPLIED_COMP(sC, dC, sA) \
(sC + dC - ((dC + 1) * sA >> 8))
#define ALPHA_BLEND_PREMULTIPLIED(tmp, sR, sG, sB, sA, dR, dG, dB, dA) \
do { \
dR = ALPHA_BLEND_PREMULTIPLIED_COMP(sR, dR, sA); \
dG = ALPHA_BLEND_PREMULTIPLIED_COMP(sG, dG, sA); \
dB = ALPHA_BLEND_PREMULTIPLIED_COMP(sB, dB, sA); \
dA = ALPHA_BLEND_PREMULTIPLIED_COMP(sA, dA, sA); \
} while (0)
#elif 0
#define ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB, dA) \
do { \
if (sA) { \
if (dA && sA < 255) { \
int dContrib = dA * (255 - sA) / 255; \
dA = sA + dA - ((sA * dA) / 255); \
dR = (dR * dContrib + sR * sA) / dA; \
dG = (dG * dContrib + sG * sA) / dA; \
dB = (dB * dContrib + sB * sA) / dA; \
} \
else { \
dR = sR; \
dG = sG; \
dB = sB; \
dA = sA; \
} \
} \
} while (0)
#endif
int
surface_fill_blend(SDL_Surface *surface, SDL_Rect *rect, Uint32 color,
int blendargs);
void
surface_respect_clip_rect(SDL_Surface *surface, SDL_Rect *rect);
int
pygame_AlphaBlit(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst,
SDL_Rect *dstrect, int the_args);
int
pygame_Blit(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst,
SDL_Rect *dstrect, int the_args);
int
premul_surf_color_by_alpha(SDL_Surface *src, SDL_Surface *dst);
int
pg_warn_simd_at_runtime_but_uncompiled();
#endif /* SURFACE_H */

View File

@ -0,0 +1,20 @@
Copyright (c) 2012-2021 Ben Croston
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -0,0 +1,263 @@
Metadata-Version: 2.1
Name: RPi.GPIO
Version: 0.7.1
Summary: A module to control Raspberry Pi GPIO channels
Home-page: http://sourceforge.net/projects/raspberry-gpio-python/
Author: Ben Croston
Author-email: ben@croston.org
License: MIT
Keywords: Raspberry Pi GPIO
Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
Classifier: Operating System :: POSIX :: Linux
Classifier: License :: OSI Approved :: MIT License
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Software Development
Classifier: Topic :: Home Automation
Classifier: Topic :: System :: Hardware
License-File: LICENCE.txt
This package provides a Python module to control the GPIO on a Raspberry Pi.
Note that this module is unsuitable for real-time or timing critical applications. This is because you
can not predict when Python will be busy garbage collecting. It also runs under the Linux kernel which
is not suitable for real time applications - it is multitasking O/S and another process may be given
priority over the CPU, causing jitter in your program. If you are after true real-time performance and
predictability, buy yourself an Arduino http://www.arduino.cc !
Note that the current release does not support SPI, I2C, hardware PWM or serial functionality on the RPi yet.
This is planned for the near future - watch this space! One-wire functionality is also planned.
Although hardware PWM is not available yet, software PWM is available to use on all channels.
For examples and documentation, visit http://sourceforge.net/p/raspberry-gpio-python/wiki/Home/
Change Log
==========
0.7.1
-------
- Better RPi board + peri_addr detection (issue 190 / 191)
- Fix PyEval_InitThreads deprecation warning for Python 3.9 (issue 188)
- Fix build using GCC 10 (issue 187)
- Fix docstrings to not include licence
- Remove Debian/Raspbian stretch packaging support
- Use setuptools instead of distutils
- Added detection of Zero 2 W
- Tested and working with Python 2.7, 3.7, 3.8, 3.9, 3.10
0.7.0
-----
- Updated RPI_INFO to include RPi 4B
- Fixed pull up/down for Pi4 (issue 168)
- Fix spelling mistake in docstrings
- Tested and working on Raspbian Buster + Python 3.8.0b2
- Fix board detection for aarch64 (Issues 161 / 165)
- Fix checking mmap return value in c_gpio.c (issue 166)
0.6.5
-----
- Fix exception on re-export of /sys/class/gpio/gpioNN
0.6.4
-----
- Event cleanup bug (issue 145)
- Raise exception for duplicate PWM objects (issue 54 - Thijs Schreijer <thijs@thijsschreijer.nl>)
- Fix build warnings (Issue 146 - Dominik George)
- test.py runs unchanged for both python 2+3
- Soft PWM stops running fix (Issues 94, 111, 154)
- Soft PWM segfault fix (Luke Allen pull request)
0.6.3
-----
- Fix code so it builds under PyPy (Gasper Zejn)
- os.system breaks event detection - Matt Kimball (issue 127)
0.6.2
-----
- Rewrote Debian packaging mechanism
- RPI_INFO reports Pi 3
- Changed module layout - moved C components to RPi._GPIO
0.6.1
-----
- Update RPI_INFO to detect more board types
- Issue 118 - add_event_detect sometimes gives runtime error with unpriv user
- Issue 120 - setmode() remembers invalid mode
0.6.0a3
-------
- Now uses /dev/gpiomem if available to avoid being run as root
- Fix warnings with pull up/down on pins 3/5
- Correct base address on Pi 2 when devicetree is disabled
- caddr_t error on compile (Issue 109)
- Error on invalid parameters to setup() (issue 93)
- Add timeout parameter to wait_for_edge() (issue 91)
0.5.11
------
- Fix - pins > 26 missing when using BOARD mode
- Add getmode()
- Raise exception when a mix of modes is used
- GPIO.cleanaup() unsets the current pin mode
0.5.10
------
- Issue 95 - support RPi 2 boards
- Introduce RPI_INFO
- Deprecate RPI_REVISION
- Issue 97 - fixed docstring for setup()
0.5.9
-----
- Issue 87 - warn about pull up/down on i2c pins
- Issue 86/75 - wait_for_edge() bugfix
- Issue 84 - recognise RPi properly when using a custom kernel
- Issue 90 - cleanup() on a list/tuple of channels
0.5.8
-----
- Allow lists/tuples of channels in GPIO.setup()
- GPIO.output() now allows lists/tuples of values
- GPIO.wait_for_edge() bug fixes (issue 78)
0.5.7
-----
- Issue 67 - speed up repeated calls to GPIO.wait_for_event()
- Added bouncetime keyword to GPIO.wait_for_event()
- Added extra edge/interrupt unit tests
- GPIO.wait_for_event() can now be mixed with GPIO.add_event_detect()
- Improved cleanups of events
- Issue 69 resolved
0.5.6
-----
- Issue 68 - support for RPi Model B+
- Fix gpio_function()
0.5.5
-----
- Issue 52 - 'unallocate' a channel
- Issue 35 - use switchbounce with GPIO.event_detected()
- Refactored events code
- Rewrote tests to use unittest mechanism and new test board with loopbacks
- Fixed adding events after a GPIO.cleanup()
- Issue 64 - misleading /dev/mem permissions error
- Issue 59 - name collision with PWM constant and class
0.5.4
-----
- Changed release status (from alpha to full release)
- Warn when GPIO.cleanup() used with nothing to clean up (issue 44)
- Avoid collisions in constants (e.g. HIGH / RISING / PUD_DOWN)
- Accept BOARD numbers in gpio_function (issue 34)
- More return values for gpio_function (INPUT, OUTPUT, SPI, I2C, PWM, SERIAL, UNKNOWN)
- Tidy up docstrings
- Fix /dev/mem access error with gpio_function
0.5.3a
------
- Allow pydoc for non-root users (issue 27)
- Fix add_event_detect error when run as daemon (issue 32)
- Simplified exception types
- Changed from distribute to pip
0.5.2a
------
- Added software PWM (experimental)
- Added switch bounce handling to event callbacks
- Added channel number parameter to event callbacks (issue 31)
- Internal refactoring and code tidy up
0.5.1a
------
- Fixed callbacks for multiple GPIOs (issue 28)
0.5.0a
------
- Added new edge detection events (interrupt handling)
- Added add_event_detect()
- Added remove_event_detect()
- Added add_event_callback()
- Added wait_for_edge()
- Removed old experimental event functions
- Removed set_rising_event()
- Removed set_falling_event()
- Removed set_high_event()
- Removed set_low_event()
- Changed event_detected() for new edge detection functionality
- input() now returns 0/LOW == False or 1/HIGH == True (integers) instead of False or True (booleans).
- Fix error on repeated import (issue 3)
- Change SetupException to a RuntimeError so it can be caught on import (issue 25, Chris Hager <chris@linuxuser.at>)
- Improved docstrings of functions
0.4.2a
------
- Fix for installing on Arch Linux (Python 3.3) (issue 20)
- Initial value when setting a channel as an output (issue 19)
0.4.1a
------
- Added VERSION
- Permit input() of channels set as outputs (Eric Ptak <trouch@trouch.com>)
0.4.0a
------
- Added support for Revision 2 boards
- Added RPI_REVISION
- Added cleanup() function and removed automatic reset functionality on program exit
- Added get_function() to read existing GPIO channel functionality (suggestion from Eric Ptak <trouch@trouch.com>)
- Added set_rising_event()
- Added set_falling_event()
- Added set_high_event()
- Added set_low_event()
- Added event_detected()
- Added test/test.py
- Converted debian to armhf
- Fixed C function short_wait() (thanks to Thibault Porteboeuf <thibaultporteboeuf@gmail.com>)
0.3.1a
------
- Fixed critical bug with swapped high/low state on outputs
- Added pull-up / pull-down setup functionality for inputs
0.3.0a
------
- Rewritten as a C extension
- Now uses /dev/mem and SoC registers instead of /sys/class/gpio
- Faster!
- Make call to GPIO.setmode() mandatory
- Added GPIO.HIGH and GPIO.LOW constants
0.2.0
-----
- Changed status from alpha to beta
- Added setmode() to be able to use BCM GPIO 00.nn channel numbers
- Renamed InvalidPinException to InvalidChannelException
0.1.0
------
- Fixed direction bug
- Added MANIFEST.in (to include missing file)
- Changed GPIO channel number to pin number
- Tested and working!
0.0.3a
------
- Added GPIO table
- Refactored
- Fixed a few critical bugs
- Still completely untested!
0.0.2a
------
- Internal refactoring. Still completely untested!
0.0.1a
------
- First version. Completely untested until I can get hold of a Raspberry Pi!

View File

@ -0,0 +1,11 @@
RPi.GPIO-0.7.1.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
RPi.GPIO-0.7.1.dist-info/LICENCE.txt,sha256=HM8DmgMIjaQr2yGKRGpWQzC4gexx9wIqn7GTDz-2XYo,1061
RPi.GPIO-0.7.1.dist-info/METADATA,sha256=gfz7FOe6QRcrTaYh62yL91Po_-aFTe_id4xBy0lowjs,8250
RPi.GPIO-0.7.1.dist-info/RECORD,,
RPi.GPIO-0.7.1.dist-info/WHEEL,sha256=GMu0CcHnECe7JSPnzBUPyOsrcZoHb7dOBGXgpe8vHSQ,104
RPi.GPIO-0.7.1.dist-info/top_level.txt,sha256=D2ebmx5QNuKCb-J2LbVMXkkhIVNpXvmxlOVIZjPsALw,4
RPi/GPIO/__init__.py,sha256=sdM6clNBKNh1SLlx_Ymapx8w8apBzznBSvq8Nv9WGJQ,1222
RPi/GPIO/__pycache__/__init__.cpython-37.pyc,,
RPi/_GPIO.cpython-37m-arm-linux-gnueabihf.so,sha256=zTt72JfV-vb8B7DxcMdMv864aToVo3qPxlDG9iopXa0,134980
RPi/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
RPi/__pycache__/__init__.cpython-37.pyc,,

View File

@ -0,0 +1,5 @@
Wheel-Version: 1.0
Generator: bdist_wheel (0.32.3)
Root-Is-Purelib: false
Tag: cp37-cp37m-linux_armv7l

View File

@ -0,0 +1,25 @@
# Copyright (c) 2012-2021 Ben Croston
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of
# this software and associated documentation files (the "Software"), to deal in
# the Software without restriction, including without limitation the rights to
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
# of the Software, and to permit persons to whom the Software is furnished to do
# so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
"""This package provides a Python module to control the GPIO on a Raspberry Pi"""
from RPi._GPIO import *
VERSION = '0.7.1'

View File

@ -0,0 +1,13 @@
Copyright aio-libs contributors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@ -0,0 +1,254 @@
Metadata-Version: 2.1
Name: aiohttp
Version: 3.8.6
Summary: Async http client/server framework (asyncio)
Home-page: https://github.com/aio-libs/aiohttp
Maintainer: aiohttp team <team@aiohttp.org>
Maintainer-email: team@aiohttp.org
License: Apache 2
Project-URL: Chat: Matrix, https://matrix.to/#/#aio-libs:matrix.org
Project-URL: Chat: Matrix Space, https://matrix.to/#/#aio-libs-space:matrix.org
Project-URL: CI: GitHub Actions, https://github.com/aio-libs/aiohttp/actions?query=workflow%3ACI
Project-URL: Coverage: codecov, https://codecov.io/github/aio-libs/aiohttp
Project-URL: Docs: Changelog, https://docs.aiohttp.org/en/stable/changes.html
Project-URL: Docs: RTD, https://docs.aiohttp.org
Project-URL: GitHub: issues, https://github.com/aio-libs/aiohttp/issues
Project-URL: GitHub: repo, https://github.com/aio-libs/aiohttp
Classifier: Development Status :: 5 - Production/Stable
Classifier: Framework :: AsyncIO
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Operating System :: POSIX
Classifier: Operating System :: MacOS :: MacOS X
Classifier: Operating System :: Microsoft :: Windows
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Topic :: Internet :: WWW/HTTP
Requires-Python: >=3.6
Description-Content-Type: text/x-rst
License-File: LICENSE.txt
Requires-Dist: attrs >=17.3.0
Requires-Dist: charset-normalizer <4.0,>=2.0
Requires-Dist: multidict <7.0,>=4.5
Requires-Dist: async-timeout <5.0,>=4.0.0a3
Requires-Dist: yarl <2.0,>=1.0
Requires-Dist: frozenlist >=1.1.1
Requires-Dist: aiosignal >=1.1.2
Requires-Dist: idna-ssl >=1.0 ; python_version < "3.7"
Requires-Dist: asynctest ==0.13.0 ; python_version < "3.8"
Requires-Dist: typing-extensions >=3.7.4 ; python_version < "3.8"
Provides-Extra: speedups
Requires-Dist: aiodns ; extra == 'speedups'
Requires-Dist: Brotli ; extra == 'speedups'
Requires-Dist: cchardet ; (python_version < "3.10") and extra == 'speedups'
==================================
Async http client/server framework
==================================
.. image:: https://raw.githubusercontent.com/aio-libs/aiohttp/master/docs/aiohttp-plain.svg
:height: 64px
:width: 64px
:alt: aiohttp logo
|
.. image:: https://github.com/aio-libs/aiohttp/workflows/CI/badge.svg
:target: https://github.com/aio-libs/aiohttp/actions?query=workflow%3ACI
:alt: GitHub Actions status for master branch
.. image:: https://codecov.io/gh/aio-libs/aiohttp/branch/master/graph/badge.svg
:target: https://codecov.io/gh/aio-libs/aiohttp
:alt: codecov.io status for master branch
.. image:: https://badge.fury.io/py/aiohttp.svg
:target: https://pypi.org/project/aiohttp
:alt: Latest PyPI package version
.. image:: https://readthedocs.org/projects/aiohttp/badge/?version=latest
:target: https://docs.aiohttp.org/
:alt: Latest Read The Docs
.. image:: https://img.shields.io/matrix/aio-libs:matrix.org?label=Discuss%20on%20Matrix%20at%20%23aio-libs%3Amatrix.org&logo=matrix&server_fqdn=matrix.org&style=flat
:target: https://matrix.to/#/%23aio-libs:matrix.org
:alt: Matrix Room — #aio-libs:matrix.org
.. image:: https://img.shields.io/matrix/aio-libs-space:matrix.org?label=Discuss%20on%20Matrix%20at%20%23aio-libs-space%3Amatrix.org&logo=matrix&server_fqdn=matrix.org&style=flat
:target: https://matrix.to/#/%23aio-libs-space:matrix.org
:alt: Matrix Space — #aio-libs-space:matrix.org
Key Features
============
- Supports both client and server side of HTTP protocol.
- Supports both client and server Web-Sockets out-of-the-box and avoids
Callback Hell.
- Provides Web-server with middlewares and plugable routing.
Getting started
===============
Client
------
To get something from the web:
.. code-block:: python
import aiohttp
import asyncio
async def main():
async with aiohttp.ClientSession() as session:
async with session.get('http://python.org') as response:
print("Status:", response.status)
print("Content-type:", response.headers['content-type'])
html = await response.text()
print("Body:", html[:15], "...")
asyncio.run(main())
This prints:
.. code-block::
Status: 200
Content-type: text/html; charset=utf-8
Body: <!doctype html> ...
Coming from `requests <https://requests.readthedocs.io/>`_ ? Read `why we need so many lines <https://aiohttp.readthedocs.io/en/latest/http_request_lifecycle.html>`_.
Server
------
An example using a simple server:
.. code-block:: python
# examples/server_simple.py
from aiohttp import web
async def handle(request):
name = request.match_info.get('name', "Anonymous")
text = "Hello, " + name
return web.Response(text=text)
async def wshandle(request):
ws = web.WebSocketResponse()
await ws.prepare(request)
async for msg in ws:
if msg.type == web.WSMsgType.text:
await ws.send_str("Hello, {}".format(msg.data))
elif msg.type == web.WSMsgType.binary:
await ws.send_bytes(msg.data)
elif msg.type == web.WSMsgType.close:
break
return ws
app = web.Application()
app.add_routes([web.get('/', handle),
web.get('/echo', wshandle),
web.get('/{name}', handle)])
if __name__ == '__main__':
web.run_app(app)
Documentation
=============
https://aiohttp.readthedocs.io/
Demos
=====
https://github.com/aio-libs/aiohttp-demos
External links
==============
* `Third party libraries
<http://aiohttp.readthedocs.io/en/latest/third_party.html>`_
* `Built with aiohttp
<http://aiohttp.readthedocs.io/en/latest/built_with.html>`_
* `Powered by aiohttp
<http://aiohttp.readthedocs.io/en/latest/powered_by.html>`_
Feel free to make a Pull Request for adding your link to these pages!
Communication channels
======================
*aio-libs discourse group*: https://aio-libs.discourse.group
*gitter chat* https://gitter.im/aio-libs/Lobby
We support `Stack Overflow
<https://stackoverflow.com/questions/tagged/aiohttp>`_.
Please add *aiohttp* tag to your question there.
Requirements
============
- Python >= 3.6
- async-timeout_
- attrs_
- charset-normalizer_
- multidict_
- yarl_
- frozenlist_
Optionally you may install the cChardet_ and aiodns_ libraries (highly
recommended for sake of speed).
.. _charset-normalizer: https://pypi.org/project/charset-normalizer
.. _aiodns: https://pypi.python.org/pypi/aiodns
.. _attrs: https://github.com/python-attrs/attrs
.. _multidict: https://pypi.python.org/pypi/multidict
.. _frozenlist: https://pypi.org/project/frozenlist/
.. _yarl: https://pypi.python.org/pypi/yarl
.. _async-timeout: https://pypi.python.org/pypi/async_timeout
.. _cChardet: https://pypi.python.org/pypi/cchardet
License
=======
``aiohttp`` is offered under the Apache 2 license.
Keepsafe
========
The aiohttp community would like to thank Keepsafe
(https://www.getkeepsafe.com) for its support in the early days of
the project.
Source code
===========
The latest developer version is available in a GitHub repository:
https://github.com/aio-libs/aiohttp
Benchmarks
==========
If you are interested in efficiency, the AsyncIO community maintains a
list of benchmarks on the official wiki:
https://github.com/python/asyncio/wiki/Benchmarks

View File

@ -0,0 +1,117 @@
aiohttp-3.8.6.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
aiohttp-3.8.6.dist-info/LICENSE.txt,sha256=n4DQ2311WpQdtFchcsJw7L2PCCuiFd3QlZhZQu2Uqes,588
aiohttp-3.8.6.dist-info/METADATA,sha256=OdVemdf27mXov6yoW0zrhzmxQRlLKtU43RXG0m8Efbk,7695
aiohttp-3.8.6.dist-info/RECORD,,
aiohttp-3.8.6.dist-info/WHEEL,sha256=uAP-ukXX4cQcmS4DJIfTMngbzZ5Fat-TcU2LYkL-U3k,104
aiohttp-3.8.6.dist-info/top_level.txt,sha256=iv-JIaacmTl-hSho3QmphcKnbRRYx1st47yjz_178Ro,8
aiohttp/.hash/_cparser.pxd.hash,sha256=hYa9Vje-oMs2eh_7MfCPOh2QW_1x1yCjcZuc7AmwLd0,121
aiohttp/.hash/_find_header.pxd.hash,sha256=_mbpD6vM-CVCKq3ulUvsOAz5Wdo88wrDzfpOsMQaMNA,125
aiohttp/.hash/_helpers.pyi.hash,sha256=Ew4BZDc2LqFwszgZZUHHrJvw5P8HBhJ700n1Ntg52hE,121
aiohttp/.hash/_helpers.pyx.hash,sha256=5JQ6BlMBE4HnRaCGdkK9_wpL3ZSWpU1gyLYva0Wwx2c,121
aiohttp/.hash/_http_parser.pyx.hash,sha256=IRBIywLdT4-0kqWhb0g0WPjh6Gu10TreFmLI8JQF-L8,125
aiohttp/.hash/_http_writer.pyx.hash,sha256=3Qg3T3D-Ud73elzPHBufK0yEu9tP5jsu6g-aPKQY9gE,125
aiohttp/.hash/_websocket.pyx.hash,sha256=M97f-Yti-4vnE4GNTD1s_DzKs-fG_ww3jle6EUvixnE,123
aiohttp/.hash/hdrs.py.hash,sha256=KpTaDTcWfiQrW2QPA5glgIfw6o5JC1hsAYZHeFMuBnI,116
aiohttp/__init__.py,sha256=kghOjJA6KwR3D2cTMLbgGwLlkzQzPwm11FiWGyWzBRk,6870
aiohttp/__pycache__/__init__.cpython-37.pyc,,
aiohttp/__pycache__/abc.cpython-37.pyc,,
aiohttp/__pycache__/base_protocol.cpython-37.pyc,,
aiohttp/__pycache__/client.cpython-37.pyc,,
aiohttp/__pycache__/client_exceptions.cpython-37.pyc,,
aiohttp/__pycache__/client_proto.cpython-37.pyc,,
aiohttp/__pycache__/client_reqrep.cpython-37.pyc,,
aiohttp/__pycache__/client_ws.cpython-37.pyc,,
aiohttp/__pycache__/connector.cpython-37.pyc,,
aiohttp/__pycache__/cookiejar.cpython-37.pyc,,
aiohttp/__pycache__/formdata.cpython-37.pyc,,
aiohttp/__pycache__/hdrs.cpython-37.pyc,,
aiohttp/__pycache__/helpers.cpython-37.pyc,,
aiohttp/__pycache__/http.cpython-37.pyc,,
aiohttp/__pycache__/http_exceptions.cpython-37.pyc,,
aiohttp/__pycache__/http_parser.cpython-37.pyc,,
aiohttp/__pycache__/http_websocket.cpython-37.pyc,,
aiohttp/__pycache__/http_writer.cpython-37.pyc,,
aiohttp/__pycache__/locks.cpython-37.pyc,,
aiohttp/__pycache__/log.cpython-37.pyc,,
aiohttp/__pycache__/multipart.cpython-37.pyc,,
aiohttp/__pycache__/payload.cpython-37.pyc,,
aiohttp/__pycache__/payload_streamer.cpython-37.pyc,,
aiohttp/__pycache__/pytest_plugin.cpython-37.pyc,,
aiohttp/__pycache__/resolver.cpython-37.pyc,,
aiohttp/__pycache__/streams.cpython-37.pyc,,
aiohttp/__pycache__/tcp_helpers.cpython-37.pyc,,
aiohttp/__pycache__/test_utils.cpython-37.pyc,,
aiohttp/__pycache__/tracing.cpython-37.pyc,,
aiohttp/__pycache__/typedefs.cpython-37.pyc,,
aiohttp/__pycache__/web.cpython-37.pyc,,
aiohttp/__pycache__/web_app.cpython-37.pyc,,
aiohttp/__pycache__/web_exceptions.cpython-37.pyc,,
aiohttp/__pycache__/web_fileresponse.cpython-37.pyc,,
aiohttp/__pycache__/web_log.cpython-37.pyc,,
aiohttp/__pycache__/web_middlewares.cpython-37.pyc,,
aiohttp/__pycache__/web_protocol.cpython-37.pyc,,
aiohttp/__pycache__/web_request.cpython-37.pyc,,
aiohttp/__pycache__/web_response.cpython-37.pyc,,
aiohttp/__pycache__/web_routedef.cpython-37.pyc,,
aiohttp/__pycache__/web_runner.cpython-37.pyc,,
aiohttp/__pycache__/web_server.cpython-37.pyc,,
aiohttp/__pycache__/web_urldispatcher.cpython-37.pyc,,
aiohttp/__pycache__/web_ws.cpython-37.pyc,,
aiohttp/__pycache__/worker.cpython-37.pyc,,
aiohttp/_cparser.pxd,sha256=8jGIg-VJ9p3llwCakUYDsPGxA4HiZe9dmK9Jmtlz-5g,4318
aiohttp/_find_header.pxd,sha256=0GfwFCPN2zxEKTO1_MA5sYq2UfzsG8kcV3aTqvwlz3g,68
aiohttp/_headers.pxi,sha256=n701k28dVPjwRnx5j6LpJhLTfj7dqu2vJt7f0O60Oyg,2007
aiohttp/_helpers.cpython-37m-arm-linux-gnueabihf.so,sha256=4NPiUR371dQX1BwRVLtGkbhvjq2UGLM1f6OA4rjswF8,106032
aiohttp/_helpers.pyi,sha256=ZoKiJSS51PxELhI2cmIr5737YjjZcJt7FbIRO3ym1Ss,202
aiohttp/_helpers.pyx,sha256=XeLbNft5X_4ifi8QB8i6TyrRuayijMSO3IDHeSA89uM,1049
aiohttp/_http_parser.cpython-37m-arm-linux-gnueabihf.so,sha256=BvlsqfKOfQBkzHTj_QWGzW8EFQrwlyGexddUbPw56xM,687336
aiohttp/_http_parser.pyx,sha256=fzKwwVlcGnGVeiGOzo05d-2Rccqtl9-PzYKqgK3fxdI,28058
aiohttp/_http_writer.cpython-37m-arm-linux-gnueabihf.so,sha256=NDoCugEAYbg5FMJSnv5CDGRqPWp9eU0sn6iE4RJMbNA,94692
aiohttp/_http_writer.pyx,sha256=aIHAp8g4ZV5kbGRdmZce-vXjELw2M6fGKyJuOdgYQqw,4575
aiohttp/_websocket.cpython-37m-arm-linux-gnueabihf.so,sha256=uYvMX7eTSGugBQCgmmPMkAOtSsVAO-QZUAfrc2H9F8g,64796
aiohttp/_websocket.pyx,sha256=1XuOSNDCbyDrzF5uMA2isqausSs8l2jWTLDlNDLM9Io,1561
aiohttp/abc.py,sha256=0FhHtbb3W7wRNtJISACN1teP8LZ49553v5Xoh5zNAFQ,5505
aiohttp/base_protocol.py,sha256=5JUyuIGwKf7sFhf0YLAnk36_hkSIxBnP4hN09RdMGGk,2741
aiohttp/client.py,sha256=MasEUwsbJI6OKfPPT7ogmMqqjjye9_6tIrqDJoKEUIc,45872
aiohttp/client_exceptions.py,sha256=tiaUIb2xy3s-O-KTPVL6L_P0rpGQT0rV1dujwwgJKoI,9270
aiohttp/client_proto.py,sha256=c4TAK8CVdycukenCJj7LtlQ3SEj04ilJ3DfmN3kPgeE,8170
aiohttp/client_reqrep.py,sha256=AlEa1SzB6BpMcvfqCkSO2OkjRpThyHlRDpsocGhUQDo,37151
aiohttp/client_ws.py,sha256=Sc0u3S-vZMadtEO6JpbLhVVw7KgtlsgZWHwaSYjkN0I,10516
aiohttp/connector.py,sha256=1itHerlRDWpyCqcJGKvoKijCg3gC0OaI28qFwWor7Go,51367
aiohttp/cookiejar.py,sha256=iJW-DtJuMmOW7I_OdT65U1MRmc1dVQNpNZ0QWI1r89g,13768
aiohttp/formdata.py,sha256=q2gpeiM9NFsl_eSFVxHZ7Qez6RbM8_BujERMkooQkx0,6106
aiohttp/hdrs.py,sha256=owNRw0dgodeDWyobBVLkY88dLbkNoM20czE9xm40oDE,4724
aiohttp/helpers.py,sha256=yS8PJca6UopZBl3jsLlVsV-qHuUKG6Wrga7mzkuf_3s,26527
aiohttp/http.py,sha256=_B20NZc113uNtg0jabY-x4_3RrIpTsqmbRIwMcm-Bco,1800
aiohttp/http_exceptions.py,sha256=2KqKKgLOZiRvWTJO60TQcrYD79taBcck2Q7WoMuiVYo,2715
aiohttp/http_parser.py,sha256=1WlZbVIaxsnBmTbspZKYaIUDrDuxRbqIhIVmZ0LCe9c,35434
aiohttp/http_websocket.py,sha256=X6kzIgu0-wRLU9yQxP4iH-Hv_36uVjTCOmF2HgpZLlk,25299
aiohttp/http_writer.py,sha256=PGQjDjtLCluVuxao1Vef8SN9lJFO8joASSHbHipTGgQ,5933
aiohttp/locks.py,sha256=wRYFo1U82LwBBdqwU24JEPaoTAlKaaJd2FtfDKhkTb4,1136
aiohttp/log.py,sha256=BbNKx9e3VMIm0xYjZI0IcBBoS7wjdeIeSaiJE7-qK2g,325
aiohttp/multipart.py,sha256=gmqFziP4ou8ZuoAOibOjoW7OJOsURzI5gkxoLPARQy8,32313
aiohttp/payload.py,sha256=tx2XE25Auoz22haty49YsuSN8-7ApxObwl9Js2zLlB8,13632
aiohttp/payload_streamer.py,sha256=3WmZ77SQ4dc8aKU6i2ZAb8L7FPdesCSoqRonSVOd_kE,2112
aiohttp/py.typed,sha256=sow9soTwP9T_gEAQSVh7Gb8855h04Nwmhs2We-JRgZM,7
aiohttp/pytest_plugin.py,sha256=4-5LfdrnZIBP2wLp8CjE54eshOolFbBpOTufvp4tUcI,11772
aiohttp/resolver.py,sha256=CASOnXp5oZh_1sCFWzFlD-5x3V49HAXbAJw-5RYjgms,5092
aiohttp/streams.py,sha256=_OTvFQVA8-8GJ120Y95lH-hmLq1QaFNBFdaA49TECIc,20758
aiohttp/tcp_helpers.py,sha256=BSadqVWaBpMFDRWnhaaR941N9MiDZ7bdTrxgCb0CW-M,961
aiohttp/test_utils.py,sha256=MNQb4Zq6rKLLC3PABy5hIjONlsoxd-lc3OirNGHIJS4,21434
aiohttp/tracing.py,sha256=gn_O9btTDB66nQ1wJWT3N2gEsO5kYFSIynnd8cp4YgA,15177
aiohttp/typedefs.py,sha256=oLnG3fxcBEdu4kIzUi0Npcg5kjq01cRkK27VSgjNnmw,1766
aiohttp/web.py,sha256=bAhkE0oeP6eI06ohkBoPu4ZLchctpEz23cVym_JECSg,18081
aiohttp/web_app.py,sha256=QkVmy8pR_oaJ3od2fYfSfjzfZ8oGEPg9FPW_d0r2THo,17170
aiohttp/web_exceptions.py,sha256=T_ghTJB_hnPkoWa3qyeY_GtVbehYQwPCpcCRb-072N0,10098
aiohttp/web_fileresponse.py,sha256=F_xRvYFL2ox4oVNW3WSjwQ6LmVpkkYM8MPxsqiNsfUg,10784
aiohttp/web_log.py,sha256=OH-C5shv59-nXchWX8owfLfToMxVdtj0PuK3uGIGEJQ,7557
aiohttp/web_middlewares.py,sha256=nnllFgxX9GjvkG3YW43jPDH7C03iCfyMBxhYw-OkTI0,4137
aiohttp/web_protocol.py,sha256=EFr0sy29rW7ffRz-tlRlBnHogmlyt6YvaJP6X1Sg3i8,22399
aiohttp/web_request.py,sha256=t0RvF_yOJG6uq9-nZjmwXjfqc9Mvgpc3sXUxC67uGvw,28187
aiohttp/web_response.py,sha256=7WTmyeXY2DrWAhr9HWuxY1SecgxiO_QwRql86PSUS-U,27471
aiohttp/web_routedef.py,sha256=EFk3v1dcFnLimTT5z0JSBO3PShF0w9sIzfK9iJd-LNs,6152
aiohttp/web_runner.py,sha256=EzxH4v1lntydU3W-c6iLgDu5LI7kAyD7sAmkz6W5-9g,11157
aiohttp/web_server.py,sha256=EA1YUxv_4szhpaED1O_VVCUFHNhPUJhl2Cq7W1BK72s,2050
aiohttp/web_urldispatcher.py,sha256=IAvlOBqCPLjasMnYtCwSqbhj-j1JTQRRHFnNvMFd4d4,39483
aiohttp/web_ws.py,sha256=8Qmp_zH-F7t9V4NLRFwfoTBr4oWuo3cZrnYT-i-zBI0,17144
aiohttp/worker.py,sha256=-o-cEhGcUqAG5LhZzO182UTXzAARWwxT0Licd6HHv-w,8755

View File

@ -0,0 +1,5 @@
Wheel-Version: 1.0
Generator: bdist_wheel (0.41.2)
Root-Is-Purelib: false
Tag: cp37-cp37m-linux_armv7l

View File

@ -0,0 +1 @@
aiohttp

View File

@ -0,0 +1 @@
f2318883e549f69de597009a914603b0f1b10381e265ef5d98af499ad973fb98 /home/runner/work/aiohttp/aiohttp/aiohttp/_cparser.pxd

View File

@ -0,0 +1 @@
d067f01423cddb3c442933b5fcc039b18ab651fcec1bc91c577693aafc25cf78 /home/runner/work/aiohttp/aiohttp/aiohttp/_find_header.pxd

View File

@ -0,0 +1 @@
6682a22524b9d4fc442e123672622be7bdfb6238d9709b7b15b2113b7ca6d52b /home/runner/work/aiohttp/aiohttp/aiohttp/_helpers.pyi

View File

@ -0,0 +1 @@
5de2db35fb795ffe227e2f1007c8ba4f2ad1b9aca28cc48edc80c779203cf6e3 /home/runner/work/aiohttp/aiohttp/aiohttp/_helpers.pyx

View File

@ -0,0 +1 @@
7f32b0c1595c1a71957a218ece8d3977ed9171caad97df8fcd82aa80addfc5d2 /home/runner/work/aiohttp/aiohttp/aiohttp/_http_parser.pyx

View File

@ -0,0 +1 @@
6881c0a7c838655e646c645d99971efaf5e310bc3633a7c62b226e39d81842ac /home/runner/work/aiohttp/aiohttp/aiohttp/_http_writer.pyx

View File

@ -0,0 +1 @@
d57b8e48d0c26f20ebcc5e6e300da2b2a6aeb12b3c9768d64cb0e53432ccf48a /home/runner/work/aiohttp/aiohttp/aiohttp/_websocket.pyx

View File

@ -0,0 +1 @@
a30351c34760a1d7835b2a1b0552e463cf1d2db90da0cdb473313dc66e34a031 /home/runner/work/aiohttp/aiohttp/aiohttp/hdrs.py

View File

@ -0,0 +1,216 @@
__version__ = "3.8.6"
from typing import Tuple
from . import hdrs as hdrs
from .client import (
BaseConnector as BaseConnector,
ClientConnectionError as ClientConnectionError,
ClientConnectorCertificateError as ClientConnectorCertificateError,
ClientConnectorError as ClientConnectorError,
ClientConnectorSSLError as ClientConnectorSSLError,
ClientError as ClientError,
ClientHttpProxyError as ClientHttpProxyError,
ClientOSError as ClientOSError,
ClientPayloadError as ClientPayloadError,
ClientProxyConnectionError as ClientProxyConnectionError,
ClientRequest as ClientRequest,
ClientResponse as ClientResponse,
ClientResponseError as ClientResponseError,
ClientSession as ClientSession,
ClientSSLError as ClientSSLError,
ClientTimeout as ClientTimeout,
ClientWebSocketResponse as ClientWebSocketResponse,
ContentTypeError as ContentTypeError,
Fingerprint as Fingerprint,
InvalidURL as InvalidURL,
NamedPipeConnector as NamedPipeConnector,
RequestInfo as RequestInfo,
ServerConnectionError as ServerConnectionError,
ServerDisconnectedError as ServerDisconnectedError,
ServerFingerprintMismatch as ServerFingerprintMismatch,
ServerTimeoutError as ServerTimeoutError,
TCPConnector as TCPConnector,
TooManyRedirects as TooManyRedirects,
UnixConnector as UnixConnector,
WSServerHandshakeError as WSServerHandshakeError,
request as request,
)
from .cookiejar import CookieJar as CookieJar, DummyCookieJar as DummyCookieJar
from .formdata import FormData as FormData
from .helpers import BasicAuth, ChainMapProxy, ETag
from .http import (
HttpVersion as HttpVersion,
HttpVersion10 as HttpVersion10,
HttpVersion11 as HttpVersion11,
WebSocketError as WebSocketError,
WSCloseCode as WSCloseCode,
WSMessage as WSMessage,
WSMsgType as WSMsgType,
)
from .multipart import (
BadContentDispositionHeader as BadContentDispositionHeader,
BadContentDispositionParam as BadContentDispositionParam,
BodyPartReader as BodyPartReader,
MultipartReader as MultipartReader,
MultipartWriter as MultipartWriter,
content_disposition_filename as content_disposition_filename,
parse_content_disposition as parse_content_disposition,
)
from .payload import (
PAYLOAD_REGISTRY as PAYLOAD_REGISTRY,
AsyncIterablePayload as AsyncIterablePayload,
BufferedReaderPayload as BufferedReaderPayload,
BytesIOPayload as BytesIOPayload,
BytesPayload as BytesPayload,
IOBasePayload as IOBasePayload,
JsonPayload as JsonPayload,
Payload as Payload,
StringIOPayload as StringIOPayload,
StringPayload as StringPayload,
TextIOPayload as TextIOPayload,
get_payload as get_payload,
payload_type as payload_type,
)
from .payload_streamer import streamer as streamer
from .resolver import (
AsyncResolver as AsyncResolver,
DefaultResolver as DefaultResolver,
ThreadedResolver as ThreadedResolver,
)
from .streams import (
EMPTY_PAYLOAD as EMPTY_PAYLOAD,
DataQueue as DataQueue,
EofStream as EofStream,
FlowControlDataQueue as FlowControlDataQueue,
StreamReader as StreamReader,
)
from .tracing import (
TraceConfig as TraceConfig,
TraceConnectionCreateEndParams as TraceConnectionCreateEndParams,
TraceConnectionCreateStartParams as TraceConnectionCreateStartParams,
TraceConnectionQueuedEndParams as TraceConnectionQueuedEndParams,
TraceConnectionQueuedStartParams as TraceConnectionQueuedStartParams,
TraceConnectionReuseconnParams as TraceConnectionReuseconnParams,
TraceDnsCacheHitParams as TraceDnsCacheHitParams,
TraceDnsCacheMissParams as TraceDnsCacheMissParams,
TraceDnsResolveHostEndParams as TraceDnsResolveHostEndParams,
TraceDnsResolveHostStartParams as TraceDnsResolveHostStartParams,
TraceRequestChunkSentParams as TraceRequestChunkSentParams,
TraceRequestEndParams as TraceRequestEndParams,
TraceRequestExceptionParams as TraceRequestExceptionParams,
TraceRequestRedirectParams as TraceRequestRedirectParams,
TraceRequestStartParams as TraceRequestStartParams,
TraceResponseChunkReceivedParams as TraceResponseChunkReceivedParams,
)
__all__: Tuple[str, ...] = (
"hdrs",
# client
"BaseConnector",
"ClientConnectionError",
"ClientConnectorCertificateError",
"ClientConnectorError",
"ClientConnectorSSLError",
"ClientError",
"ClientHttpProxyError",
"ClientOSError",
"ClientPayloadError",
"ClientProxyConnectionError",
"ClientResponse",
"ClientRequest",
"ClientResponseError",
"ClientSSLError",
"ClientSession",
"ClientTimeout",
"ClientWebSocketResponse",
"ContentTypeError",
"Fingerprint",
"InvalidURL",
"RequestInfo",
"ServerConnectionError",
"ServerDisconnectedError",
"ServerFingerprintMismatch",
"ServerTimeoutError",
"TCPConnector",
"TooManyRedirects",
"UnixConnector",
"NamedPipeConnector",
"WSServerHandshakeError",
"request",
# cookiejar
"CookieJar",
"DummyCookieJar",
# formdata
"FormData",
# helpers
"BasicAuth",
"ChainMapProxy",
"ETag",
# http
"HttpVersion",
"HttpVersion10",
"HttpVersion11",
"WSMsgType",
"WSCloseCode",
"WSMessage",
"WebSocketError",
# multipart
"BadContentDispositionHeader",
"BadContentDispositionParam",
"BodyPartReader",
"MultipartReader",
"MultipartWriter",
"content_disposition_filename",
"parse_content_disposition",
# payload
"AsyncIterablePayload",
"BufferedReaderPayload",
"BytesIOPayload",
"BytesPayload",
"IOBasePayload",
"JsonPayload",
"PAYLOAD_REGISTRY",
"Payload",
"StringIOPayload",
"StringPayload",
"TextIOPayload",
"get_payload",
"payload_type",
# payload_streamer
"streamer",
# resolver
"AsyncResolver",
"DefaultResolver",
"ThreadedResolver",
# streams
"DataQueue",
"EMPTY_PAYLOAD",
"EofStream",
"FlowControlDataQueue",
"StreamReader",
# tracing
"TraceConfig",
"TraceConnectionCreateEndParams",
"TraceConnectionCreateStartParams",
"TraceConnectionQueuedEndParams",
"TraceConnectionQueuedStartParams",
"TraceConnectionReuseconnParams",
"TraceDnsCacheHitParams",
"TraceDnsCacheMissParams",
"TraceDnsResolveHostEndParams",
"TraceDnsResolveHostStartParams",
"TraceRequestChunkSentParams",
"TraceRequestEndParams",
"TraceRequestExceptionParams",
"TraceRequestRedirectParams",
"TraceRequestStartParams",
"TraceResponseChunkReceivedParams",
)
try:
from .worker import GunicornUVLoopWebWorker, GunicornWebWorker
__all__ += ("GunicornWebWorker", "GunicornUVLoopWebWorker")
except ImportError: # pragma: no cover
pass

Some files were not shown because too many files have changed in this diff Show More