RISCOS files by dschwertberger
This commit is contained in:
parent
c92cdf7aa7
commit
228d80736c
|
@ -0,0 +1,46 @@
|
|||
"""A more or less complete user-defined wrapper around dictionary objects."""
|
||||
|
||||
import riscos
|
||||
|
||||
class _Environ:
|
||||
def __init__(self):
|
||||
pass
|
||||
def __repr__(self):
|
||||
return repr(riscos.getenvdict())
|
||||
def __cmp__(self, dict):
|
||||
if isinstance(dict, UserDict):
|
||||
return cmp(riscos.getenvdict(), dict)
|
||||
def __len__(self):
|
||||
return len(riscos.getenvdict())
|
||||
def __getitem__(self, key):
|
||||
ret = riscos.getenv(key)
|
||||
if ret<>None:
|
||||
return ret
|
||||
else:
|
||||
raise KeyError
|
||||
def __setitem__(self, key, item):
|
||||
riscos.setenv(key, item)
|
||||
def __delitem__(self, key):
|
||||
riscos.delenv(key)
|
||||
def clear(self):
|
||||
# too dangerous on RISC OS
|
||||
pass
|
||||
def copy(self):
|
||||
return riscos.getenvdict()
|
||||
def keys(self): return riscos.getenvdict().keys()
|
||||
def items(self): return riscos.getenvdict().items()
|
||||
def values(self): return riscos.getenvdict().values()
|
||||
def has_key(self, key):
|
||||
value = riscos.getenv(key)
|
||||
return value<>None
|
||||
def update(self, dict):
|
||||
for k, v in dict.items():
|
||||
riscos.putenv(k, v)
|
||||
def get(self, key, failobj=None):
|
||||
value = riscos.getenv(key)
|
||||
if value<>None:
|
||||
return value
|
||||
else:
|
||||
return failobj
|
||||
|
||||
environ = _Environ()
|
|
@ -0,0 +1,354 @@
|
|||
# Module 'riscospath' -- common operations on RISC OS pathnames.
|
||||
|
||||
# contributed by Andrew Clover ( andrew@oaktree.co.uk )
|
||||
|
||||
# The "os.path" name is an alias for this module on RISC OS systems;
|
||||
# on other systems (e.g. Mac, Windows), os.path provides the same
|
||||
# operations in a manner specific to that platform, and is an alias
|
||||
# to another module (e.g. macpath, ntpath).
|
||||
|
||||
"""
|
||||
Instead of importing this module directly, import os and refer to this module
|
||||
as os.path.
|
||||
"""
|
||||
|
||||
|
||||
# Imports - make an error-generating swi object if the swi module is not
|
||||
# available (ie. we are not running on RISC OS Python)
|
||||
|
||||
import os, stat, string
|
||||
|
||||
try:
|
||||
import swi
|
||||
except ImportError:
|
||||
class _swi:
|
||||
def swi(*a):
|
||||
raise AttributeError, 'This function only available under RISC OS'
|
||||
block= swi
|
||||
swi= _swi()
|
||||
|
||||
[_false, _true]= range(2)
|
||||
|
||||
_roots= ['$', '&', '%', '@', '\\']
|
||||
|
||||
|
||||
# _allowMOSFSNames
|
||||
# After importing riscospath, set _allowMOSFSNames true if you want the module
|
||||
# to understand the "-SomeFS-" notation left over from the old BBC Master MOS,
|
||||
# as well as the standard "SomeFS:" notation. Set this to be fully backwards
|
||||
# compatible but remember that "-SomeFS-" can also be a perfectly valid file
|
||||
# name so care must be taken when splitting and joining paths.
|
||||
|
||||
_allowMOSFSNames= _false
|
||||
|
||||
|
||||
## Path manipulation, RISC OS stylee.
|
||||
|
||||
def _split(p):
|
||||
"""
|
||||
split filing system name (including special field) and drive specifier from rest
|
||||
of path. This is needed by many riscospath functions.
|
||||
"""
|
||||
dash= _allowMOSFSNames and p[:1]=='-'
|
||||
if dash:
|
||||
q= string.find(p, '-', 1)+1
|
||||
else:
|
||||
if p[:1]==':':
|
||||
q= 0
|
||||
else:
|
||||
q= string.find(p, ':')+1 # q= index of start of non-FS portion of path
|
||||
s= string.find(p, '#')
|
||||
if s==-1 or s>q:
|
||||
s= q # find end of main FS name, not including special field
|
||||
else:
|
||||
for c in p[dash:s]:
|
||||
if c not in string.letters:
|
||||
q= 0
|
||||
break # disallow invalid non-special-field characters in FS name
|
||||
r= q
|
||||
if p[q:q+1]==':':
|
||||
r= string.find(p, '.', q+1)+1
|
||||
if r==0:
|
||||
r= len(p) # find end of drive name (if any) following FS name (if any)
|
||||
return (p[:q], p[q:r], p[r:])
|
||||
|
||||
|
||||
def normcase(p):
|
||||
"""
|
||||
Normalize the case of a pathname. This converts to lowercase as the native RISC
|
||||
OS filesystems are case-insensitive. However, not all filesystems have to be,
|
||||
and there's no simple way to find out what type an FS is argh.
|
||||
"""
|
||||
return string.lower(p)
|
||||
|
||||
|
||||
def isabs(p):
|
||||
"""
|
||||
Return whether a path is absolute. Under RISC OS, a file system specifier does
|
||||
not make a path absolute, but a drive name or number does, and so does using the
|
||||
symbol for root, URD, library, CSD or PSD. This means it is perfectly possible
|
||||
to have an "absolute" URL dependent on the current working directory, and
|
||||
equally you can have a "relative" URL that's on a completely different device to
|
||||
the current one argh.
|
||||
"""
|
||||
(fs, drive, path)= _split(p)
|
||||
return drive!='' or path[:1] in _roots
|
||||
|
||||
|
||||
def join(a, *p):
|
||||
"""
|
||||
Join path elements with the directory separator, replacing the entire path when
|
||||
an absolute or FS-changing path part is found.
|
||||
"""
|
||||
j= a
|
||||
for b in p:
|
||||
(fs, drive, path)= _split(b)
|
||||
if fs!='' or drive!='' or path[:1] in _roots:
|
||||
j= b
|
||||
else:
|
||||
j= j+'.'+b
|
||||
return j
|
||||
|
||||
|
||||
def split(p):
|
||||
"""
|
||||
Split a path in head (everything up to the last '.') and tail (the rest). FS
|
||||
name must still be dealt with separately since special field may contain '.'.
|
||||
"""
|
||||
(fs, drive, path)= _split(p)
|
||||
q= string.rfind(path, '.')
|
||||
if q!=-1:
|
||||
return (fs+drive+path[:q], path[q+1:])
|
||||
return ('', p)
|
||||
|
||||
|
||||
def splitext(p):
|
||||
"""
|
||||
Split a path in root and extension. This assumes the 'using slash for dot and
|
||||
dot for slash with foreign files' convention common in RISC OS is in force.
|
||||
"""
|
||||
(tail, head)= split(p)
|
||||
if '/' in head:
|
||||
q= len(head)-string.rfind(head, '/')
|
||||
return (p[:-q], p[-q:])
|
||||
return (p, '')
|
||||
|
||||
|
||||
def splitdrive(p):
|
||||
"""
|
||||
Split a pathname into a drive specification (including FS name) and the rest of
|
||||
the path. The terminating dot of the drive name is included in the drive
|
||||
specification.
|
||||
"""
|
||||
(fs, drive, path)= _split(p)
|
||||
return (fs+drive, p)
|
||||
|
||||
|
||||
def basename(p):
|
||||
"""
|
||||
Return the tail (basename) part of a path.
|
||||
"""
|
||||
return split(p)[1]
|
||||
|
||||
|
||||
def dirname(p):
|
||||
"""
|
||||
Return the head (dirname) part of a path.
|
||||
"""
|
||||
return split(p)[0]
|
||||
|
||||
|
||||
def commonprefix(ps):
|
||||
"""
|
||||
Return the longest prefix of all list elements. Purely string-based; does not
|
||||
separate any path parts. Why am I in os.path?
|
||||
"""
|
||||
if len(ps)==0:
|
||||
return ''
|
||||
prefix= ps[0]
|
||||
for p in ps[1:]:
|
||||
prefix= prefix[:len(p)]
|
||||
for i in range(len(prefix)):
|
||||
if prefix[i] <> p[i]:
|
||||
prefix= prefix[:i]
|
||||
if i==0:
|
||||
return ''
|
||||
break
|
||||
return prefix
|
||||
|
||||
|
||||
## File access functions. Why are we in os.path?
|
||||
|
||||
def getsize(p):
|
||||
"""
|
||||
Return the size of a file, reported by os.stat().
|
||||
"""
|
||||
st= os.stat(p)
|
||||
return st[stat.ST_SIZE]
|
||||
|
||||
|
||||
def getmtime(p):
|
||||
"""
|
||||
Return the last modification time of a file, reported by os.stat().
|
||||
"""
|
||||
st = os.stat(p)
|
||||
return st[stat.ST_MTIME]
|
||||
|
||||
getatime= getmtime
|
||||
|
||||
|
||||
# RISC OS-specific file access functions
|
||||
|
||||
def exists(p):
|
||||
"""
|
||||
Test whether a path exists.
|
||||
"""
|
||||
return swi.swi('OS_File', '5s;i', p)!=0
|
||||
|
||||
|
||||
def isdir(p):
|
||||
"""
|
||||
Is a path a directory? Includes image files.
|
||||
"""
|
||||
return swi.swi('OS_File', '5s;i', p) in [2, 3]
|
||||
|
||||
|
||||
def isfile(p):
|
||||
"""
|
||||
Test whether a path is a file, including image files.
|
||||
"""
|
||||
return swi.swi('OS_File', '5s;i', p) in [1, 3]
|
||||
|
||||
|
||||
def islink(p):
|
||||
"""
|
||||
RISC OS has no links or mounts.
|
||||
"""
|
||||
return _false
|
||||
|
||||
ismount= islink
|
||||
|
||||
|
||||
# Same-file testing.
|
||||
|
||||
# samefile works on filename comparison since there is no ST_DEV and ST_INO is
|
||||
# not reliably unique (esp. directories). First it has to normalise the
|
||||
# pathnames, which it can do 'properly' using OS_FSControl since samefile can
|
||||
# assume it's running on RISC OS (unlike normpath).
|
||||
|
||||
def samefile(fa, fb):
|
||||
"""
|
||||
Test whether two pathnames reference the same actual file.
|
||||
"""
|
||||
l= 512
|
||||
b= swi.block(l)
|
||||
swi.swi('OS_FSControl', 'isb..i', 37, fa, b, l)
|
||||
fa= b.ctrlstring()
|
||||
swi.swi('OS_FSControl', 'isb..i', 37, fb, b, l)
|
||||
fb= b.ctrlstring()
|
||||
return fa==fb
|
||||
|
||||
|
||||
def sameopenfile(a, b):
|
||||
"""
|
||||
Test whether two open file objects reference the same file.
|
||||
"""
|
||||
return os.fstat(a)[stat.ST_INO]==os.fstat(b)[stat.ST_INO]
|
||||
|
||||
|
||||
## Path canonicalisation
|
||||
|
||||
# 'user directory' is taken as meaning the User Root Directory, which is in
|
||||
# practice never used, for anything.
|
||||
|
||||
def expanduser(p):
|
||||
(fs, drive, path)= _split(p)
|
||||
l= 512
|
||||
b= swi.block(l)
|
||||
|
||||
if path[:1]!='@':
|
||||
return p
|
||||
if fs=='':
|
||||
fsno= swi.swi('OS_Args', '00;i')
|
||||
swi.swi('OS_FSControl', 'iibi', 33, fsno, b, l)
|
||||
fsname= b.ctrlstring()
|
||||
else:
|
||||
if fs[:1]=='-':
|
||||
fsname= fs[1:-1]
|
||||
else:
|
||||
fsname= fs[:-1]
|
||||
fsname= string.split(fsname, '#', 1)[0] # remove special field from fs
|
||||
x= swi.swi('OS_FSControl', 'ib2s.i;.....i', 54, b, fsname, l)
|
||||
if x<l:
|
||||
urd= b.tostring(0, l-x-1)
|
||||
else: # no URD! try CSD
|
||||
x= swi.swi('OS_FSControl', 'ib0s.i;.....i', 54, b, fsname, l)
|
||||
if x<l:
|
||||
urd= b.tostring(0, l-x-1)
|
||||
else: # no CSD! use root
|
||||
urd= '$'
|
||||
return fsname+':'+urd+path[1:]
|
||||
|
||||
# Environment variables are in angle brackets.
|
||||
|
||||
def expandvars(p):
|
||||
"""
|
||||
Expand environment variables using OS_GSTrans.
|
||||
"""
|
||||
l= 512
|
||||
b= swi.block(l)
|
||||
return b.tostring(0, swi.swi('OS_GSTrans', 'sbi;..i', p, b, l))
|
||||
|
||||
|
||||
# Return an absolute path.
|
||||
|
||||
def abspath(p):
|
||||
return normpath(join(os.getcwd(), p))
|
||||
|
||||
|
||||
# Normalize a path. Only special path element under RISC OS is "^" for "..".
|
||||
|
||||
def normpath(p):
|
||||
"""
|
||||
Normalize path, eliminating up-directory ^s.
|
||||
"""
|
||||
(fs, drive, path)= _split(p)
|
||||
rhs= ''
|
||||
ups= 0
|
||||
while path!='':
|
||||
(path, el)= split(path)
|
||||
if el=='^':
|
||||
ups= ups+1
|
||||
else:
|
||||
if ups>0:
|
||||
ups= ups-1
|
||||
else:
|
||||
if rhs=='':
|
||||
rhs= el
|
||||
else:
|
||||
rhs= el+'.'+rhs
|
||||
while ups>0:
|
||||
ups= ups-1
|
||||
rhs= '^.'+rhs
|
||||
return fs+drive+rhs
|
||||
|
||||
|
||||
# Directory tree walk.
|
||||
# Independent of host system. Why am I in os.path?
|
||||
|
||||
def walk(top, func, arg):
|
||||
"""
|
||||
walk(top,func,args) calls func(arg, d, files) for each directory "d" in the tree
|
||||
rooted at "top" (including "top" itself). "files" is a list of all the files and
|
||||
subdirs in directory "d".
|
||||
"""
|
||||
try:
|
||||
names= os.listdir(top)
|
||||
except os.error:
|
||||
return
|
||||
func(arg, top, names)
|
||||
for name in names:
|
||||
name= join(top, name)
|
||||
if isdir(name) and not islink(name):
|
||||
walk(name, func, arg)
|
||||
|
|
@ -0,0 +1,82 @@
|
|||
"""riscos specific module for conversion between pathnames and URLs.
|
||||
Based on macurl2path.
|
||||
Do not import directly, use urllib instead."""
|
||||
|
||||
import string
|
||||
import urllib
|
||||
import os
|
||||
|
||||
def url2pathname(pathname):
|
||||
"Convert /-delimited pathname to mac pathname"
|
||||
#
|
||||
# XXXX The .. handling should be fixed...
|
||||
#
|
||||
tp = urllib.splittype(pathname)[0]
|
||||
if tp and tp <> 'file':
|
||||
raise RuntimeError, 'Cannot convert non-local URL to pathname'
|
||||
components = string.split(pathname, '/')
|
||||
# Remove . and embedded ..
|
||||
i = 0
|
||||
while i < len(components):
|
||||
if components[i] == '.':
|
||||
del components[i]
|
||||
elif components[i] == '..' and i > 0 and \
|
||||
components[i-1] not in ('', '..'):
|
||||
del components[i-1:i+1]
|
||||
i = i-1
|
||||
elif components[i] == '' and i > 0 and components[i-1] <> '':
|
||||
del components[i]
|
||||
else:
|
||||
if components[i]<>'..' and string.find(components[i], '.')<>-1 :
|
||||
components[i] = string.join(string.split(components[i],'.'),'/')
|
||||
i = i+1
|
||||
if not components[0]:
|
||||
# Absolute unix path, don't start with colon
|
||||
return string.join(components[1:], '.')
|
||||
else:
|
||||
# relative unix path, start with colon. First replace
|
||||
# leading .. by empty strings (giving ::file)
|
||||
i = 0
|
||||
while i < len(components) and components[i] == '..':
|
||||
components[i] = '^'
|
||||
i = i + 1
|
||||
return string.join(components, '.')
|
||||
|
||||
def pathname2url(pathname):
|
||||
"convert mac pathname to /-delimited pathname"
|
||||
if '/' in pathname:
|
||||
raise RuntimeError, "Cannot convert pathname containing slashes"
|
||||
components = string.split(pathname, ':')
|
||||
# Replace empty string ('::') by .. (will result in '/../' later)
|
||||
for i in range(1, len(components)):
|
||||
if components[i] == '':
|
||||
components[i] = '..'
|
||||
# Truncate names longer than 31 bytes
|
||||
components = map(lambda x: x[:31], components)
|
||||
|
||||
if os.path.isabs(pathname):
|
||||
return '/' + string.join(components, '/')
|
||||
else:
|
||||
return string.join(components, '/')
|
||||
|
||||
def test():
|
||||
for url in ["index.html",
|
||||
"/SCSI::SCSI4/$/Anwendung/Comm/Apps/!Fresco/Welcome",
|
||||
"../index.html",
|
||||
"bar/index.html",
|
||||
"/foo/bar/index.html",
|
||||
"/foo/bar/",
|
||||
"/"]:
|
||||
print `url`, '->', `url2pathname(url)`
|
||||
for path in ["drive:",
|
||||
"drive:dir:",
|
||||
"drive:dir:file",
|
||||
"drive:file",
|
||||
"file",
|
||||
":file",
|
||||
":dir:",
|
||||
":dir:file"]:
|
||||
print `path`, '->', `pathname2url(path)`
|
||||
|
||||
if __name__ == '__main__':
|
||||
test()
|
|
@ -0,0 +1,418 @@
|
|||
# RISC OS Python
|
||||
LIBSROOT = $.AcornC_C++.Libraries
|
||||
|
||||
# You may need to change some of the following
|
||||
OSLIB = $(LIBSROOT).OSLib
|
||||
CLIB = $(LIBSROOT).clib
|
||||
SOCKLIB = $(LIBSROOT).netlib
|
||||
DLKLIB = $(LIBSROOT).dlk
|
||||
ZLIB = $(LIBSROOT).zlib
|
||||
EXPAT = $(LIBSROOT).expat.lib
|
||||
|
||||
OBJSCAN = $(DLKLIB).objscan
|
||||
MAKEDLK = $(DLKLIB).makedlk
|
||||
|
||||
# change from time to time
|
||||
TARGET=Python21
|
||||
BUILD=10
|
||||
|
||||
|
||||
#
|
||||
# You shouldn't need to change anything below this line
|
||||
#
|
||||
OSLIBS = OSLib:Computer,OSLib:Core,OSLib:User
|
||||
|
||||
DLKFLAG= -DDLK
|
||||
DLKOBJS = $(DLKLIB).o.dlk_load o.linktab
|
||||
|
||||
HEADERS = @,@.^.Include,@.^.Modules,@.^.Objects,@.^.Python,$(CLIB),$(OSLIBS),$(DLKLIB)
|
||||
|
||||
CC = cc -c -j$(HEADERS) $(DLKFLAG) -DRISCOS -DHAVE_CONFIG_H -wad -throwback
|
||||
#-depend !Depend
|
||||
CCEXPAT = cc -c -j$(HEADERS),$(EXPAT) $(DLKFLAG) -DHAVE_EXPAT_H -DRISCOS -DHAVE_CONFIG_H -wad -throwback
|
||||
|
||||
LINK = link
|
||||
LINKFLAGS = -aif -NOUNUSED #-d
|
||||
LOADLIBS = $(CLIB).o.Stubs $(OSLIB).o.OSLib $(DLKOBJS)
|
||||
|
||||
|
||||
.c.o :
|
||||
$(CC) -o $@ $*.c
|
||||
|
||||
|
||||
# code for main Python binary
|
||||
MODULES_STATIC = \
|
||||
@.^.Modules.o.python \
|
||||
@.^.Modules.o.main \
|
||||
Modules.o.config \
|
||||
@.^.Modules.o.getbuildinfo \
|
||||
Modules.o.getpath_riscos \
|
||||
Modules.o.riscosmodule \
|
||||
@.^.Modules.o._sre
|
||||
|
||||
|
||||
# dynamic Modules
|
||||
MODULES_DYNAMIC = \
|
||||
@.^.Lib.array/pyd \
|
||||
@.^.Lib.audioop/pyd \
|
||||
@.^.Lib.binascii/pyd \
|
||||
@.^.Lib.cmath/pyd \
|
||||
@.^.Lib.cPickle/pyd \
|
||||
@.^.Lib.cStringIO/pyd \
|
||||
@.^.Lib.errno/pyd \
|
||||
@.^.Lib.imageop/pyd \
|
||||
@.^.Lib.math/pyd \
|
||||
@.^.Lib.md5/pyd \
|
||||
@.^.Lib.new/pyd \
|
||||
@.^.Lib.operator/pyd \
|
||||
@.^.Lib.parser/pyd \
|
||||
@.^.Lib.pcre/pyd \
|
||||
@.^.Lib.regex/pyd \
|
||||
@.^.Lib.rgbimg/pyd \
|
||||
@.^.Lib.rotor/pyd \
|
||||
@.^.Lib.sha/pyd \
|
||||
@.^.Lib.signal/pyd \
|
||||
@.^.Lib.struct/pyd \
|
||||
@.^.Lib.time/pyd \
|
||||
@.^.Lib._locale/pyd \
|
||||
@.^.Lib.zlib/pyd \
|
||||
@.^.Lib.select/pyd \
|
||||
@.^.Lib._socket/pyd \
|
||||
@.^.Lib._codecs/pyd \
|
||||
@.^.Lib._weakref/pyd \
|
||||
@.^.Lib._testcapi/pyd \
|
||||
@.^.Lib.unicodedata/pyd \
|
||||
@.^.Lib.xreadlines/pyd \
|
||||
@.^.Lib.pyexpat/pyd \
|
||||
@.^.Lib.plat-riscos.drawf/pyd \
|
||||
@.^.Lib.plat-riscos.swi/pyd
|
||||
|
||||
# @.^.Lib.soundex/pyd \
|
||||
# leave strop out? It's no longer in use for string operations
|
||||
# @.^.Lib.mmap/pyd would it make sense? I read about a mmap
|
||||
# implementation for RISC OS recently in usenet news.
|
||||
|
||||
#@.^.Lib.strop/pyd \
|
||||
#@.^.Lib._sre/pyd \
|
||||
|
||||
|
||||
OBJECTS_PYTHON = \
|
||||
@.^.Python.o.traceback \
|
||||
@.^.Python.o.sysmodule \
|
||||
@.^.Python.o.structmember \
|
||||
@.^.Python.o.strdup \
|
||||
@.^.Python.o.sigcheck \
|
||||
@.^.Python.o.pythonrun \
|
||||
@.^.Python.o.pystate \
|
||||
@.^.Python.o.pyfpe \
|
||||
@.^.Python.o.mystrtoul \
|
||||
@.^.Python.o.modsupport \
|
||||
@.^.Python.o.marshal \
|
||||
@.^.Python.o.importdl \
|
||||
@.^.Python.o.import \
|
||||
@.^.Python.o.graminit \
|
||||
@.^.Python.o.getversion \
|
||||
@.^.Python.o.getplatform \
|
||||
@.^.Python.o.getopt \
|
||||
@.^.Python.o.getcopyright \
|
||||
@.^.Python.o.getcompiler \
|
||||
@.^.Python.o.getargs \
|
||||
@.^.Python.o.frozenmain \
|
||||
@.^.Python.o.frozen \
|
||||
@.^.Python.o.errors \
|
||||
@.^.Python.o.compile \
|
||||
@.^.Python.o.ceval \
|
||||
@.^.Python.o.bltinmodule \
|
||||
@.^.Python.o.exceptions \
|
||||
@.^.Python.o.hypot \
|
||||
@.^.Python.o.codecs \
|
||||
@.^.Python.o.symtable
|
||||
# @.^.Python.o.atof @.^.Python.o.strerror
|
||||
|
||||
|
||||
OBJECTS_RISCOS = \
|
||||
@.Python.o.dynload_riscos \
|
||||
@.Python.o.getcwd_riscos \
|
||||
@.Python.o.getmtime_riscos \
|
||||
@.o.unixstuff
|
||||
|
||||
|
||||
OBJECTS_OBJECTS = \
|
||||
@.^.Objects.o.typeobject \
|
||||
@.^.Objects.o.tupleobject \
|
||||
@.^.Objects.o.stringobject \
|
||||
@.^.Objects.o.sliceobject \
|
||||
@.^.Objects.o.rangeobject \
|
||||
@.^.Objects.o.object \
|
||||
@.^.Objects.o.moduleobject \
|
||||
@.^.Objects.o.methodobject \
|
||||
@.^.Objects.o.longobject \
|
||||
@.^.Objects.o.listobject \
|
||||
@.^.Objects.o.intobject \
|
||||
@.^.Objects.o.funcobject \
|
||||
@.^.Objects.o.frameobject \
|
||||
@.^.Objects.o.floatobject \
|
||||
@.^.Objects.o.fileobject \
|
||||
@.^.Objects.o.dictobject \
|
||||
@.^.Objects.o.complexobject \
|
||||
@.^.Objects.o.cobject \
|
||||
@.^.Objects.o.classobject \
|
||||
@.^.Objects.o.cellobject \
|
||||
@.^.Objects.o.bufferobject \
|
||||
@.^.Objects.o.abstract \
|
||||
@.^.Objects.o.unicodectype \
|
||||
@.^.Objects.o.unicodeobject
|
||||
|
||||
|
||||
OBJECTS_PARSER = \
|
||||
@.^.Parser.o.tokenizer \
|
||||
@.^.Parser.o.printgrammar \
|
||||
@.^.Parser.o.parsetok \
|
||||
@.^.Parser.o.parser \
|
||||
@.^.Parser.o.node \
|
||||
@.^.Parser.o.myreadline \
|
||||
@.^.Parser.o.metagrammar \
|
||||
@.^.Parser.o.listnode \
|
||||
@.^.Parser.o.intrcheck \
|
||||
@.^.Parser.o.grammar1 \
|
||||
@.^.Parser.o.grammar \
|
||||
@.^.Parser.o.firstsets \
|
||||
@.^.Parser.o.bitset \
|
||||
@.^.Parser.o.acceler
|
||||
|
||||
SUPPORT_FILES = @.^.!Boot @.^.!Run @.^.!Sprites @.^.!Sprites22 @.^.AddToPath
|
||||
|
||||
OBJECTS = $(OBJECTS_PYTHON) $(OBJECTS_PARSER) $(MODULES_STATIC) $(OBJECTS_OBJECTS) $(OBJECTS_RISCOS)
|
||||
|
||||
|
||||
all: @.^.$(TARGET) $(MODULES_DYNAMIC) $(SUPPORT_FILES)
|
||||
|
||||
@.^.Modules.o.getbuildinfo: @.^.Modules.c.getbuildinfo
|
||||
$(CC) -DBUILD=$(BUILD) -o @.^.Modules.o.getbuildinfo @.^.Modules.c.getbuildinfo
|
||||
|
||||
|
||||
@.^.$(TARGET): $(OBJECTS) o.linktab
|
||||
$(LINK) -o @.^.$(TARGET) $(OBJECTS) $(LOADLIBS)
|
||||
|
||||
|
||||
#########################################################################
|
||||
# Support files
|
||||
@.^.!Boot: support.!Boot
|
||||
copy support.!Boot @.^.!Boot ~C~VF
|
||||
settype @.^.!Boot feb
|
||||
@.^.!Run: support.!Run
|
||||
copy support.!Run @.^.!Run ~C~VF
|
||||
settype @.^.!Run feb
|
||||
@.^.!Sprites: support.!Sprites
|
||||
copy support.!Sprites @.^.!Sprites ~C~VF
|
||||
settype @.^.!Sprites ff9
|
||||
@.^.!Sprites22: support.!Sprites22
|
||||
copy support.!Sprites22 @.^.!Sprites22 ~C~VF
|
||||
settype @.^.!Sprites22 ff9
|
||||
@.^.AddToPath: support.AddToPath
|
||||
copy support.AddToPath @.^.AddToPath ~C~VF
|
||||
settype @.^.AddToPath ffc
|
||||
|
||||
|
||||
#########################################################################
|
||||
# Dynamic Modules
|
||||
#
|
||||
@.^.Lib.array/pyd: @.^.Modules.o.arraymodule s.linktab
|
||||
$(MAKEDLK) -d @.^.Lib.array/pyd -s s.linktab -o @.^.Modules.o.arraymodule -e initarray
|
||||
|
||||
@.^.Lib.audioop/pyd: @.^.Modules.o.audioop # s.linktab
|
||||
$(MAKEDLK) -d @.^.Lib.audioop/pyd -s s.linktab -o @.^.Modules.o.audioop -e initaudioop
|
||||
|
||||
@.^.Lib.binascii/pyd: @.^.Modules.o.binascii s.linktab
|
||||
$(MAKEDLK) -d @.^.Lib.binascii/pyd -s s.linktab -o @.^.Modules.o.binascii -e initbinascii
|
||||
|
||||
@.^.Lib.cmath/pyd: @.^.Modules.o.cmathmodule s.linktab
|
||||
$(MAKEDLK) -d @.^.Lib.cmath/pyd -s s.linktab -o @.^.Modules.o.cmathmodule -e initcmath
|
||||
|
||||
@.^.Lib.cPickle/pyd: @.^.Modules.o.cPickle s.linktab
|
||||
$(MAKEDLK) -d @.^.Lib.cPickle/pyd -s s.linktab -o @.^.Modules.o.cPickle -e initcPickle
|
||||
|
||||
@.^.Lib.cStringIO/pyd: @.^.Modules.o.cStringIO s.linktab
|
||||
$(MAKEDLK) -d @.^.Lib.cStringIO/pyd -s s.linktab -o @.^.Modules.o.cStringIO -e initcStringIO
|
||||
|
||||
@.^.Lib.plat-riscos.drawf/pyd: Modules.o.drawfmodule #s.linktab
|
||||
$(LINK) -aof -o Modules.o.drawflink Modules.o.drawfmodule $(OSLIB).o.OSLIB
|
||||
$(MAKEDLK) -d @.^.Lib.plat-riscos.drawf/pyd -s s.linktab -o Modules.o.drawflink -e initdrawf
|
||||
|
||||
@.^.Lib.errno/pyd: @.^.Modules.o.errnomodule #s.linktab
|
||||
$(MAKEDLK) -d @.^.Lib.errno/pyd -s s.linktab -o @.^.Modules.o.errnomodule -e initerrno
|
||||
|
||||
@.^.Lib.imageop/pyd: @.^.Modules.o.imageop s.linktab
|
||||
$(MAKEDLK) -d @.^.Lib.imageop/pyd -s s.linktab -o @.^.Modules.o.imageop -e initimageop
|
||||
|
||||
@.^.Lib.math/pyd: @.^.Modules.o.mathmodule s.linktab
|
||||
$(MAKEDLK) -d @.^.Lib.math/pyd -s s.linktab -o @.^.Modules.o.mathmodule -e initmath
|
||||
|
||||
@.^.Lib.mmap/pyd: @.^.Modules.o.mmapmodule s.linktab
|
||||
$(MAKEDLK) -d @.^.Lib.mmap/pyd -s s.linktab -o @.^.Modules.o.mmapmodule -e initmmap
|
||||
|
||||
@.^.Lib.md5/pyd: @.^.Modules.o.md5c @.^.Modules.o.md5module s.linktab
|
||||
$(LINK) -aof -o @.^.Modules.o.md5link @.^.Modules.o.md5c @.^.Modules.o.md5module
|
||||
$(MAKEDLK) -d @.^.Lib.md5/pyd -s s.linktab -o @.^.Modules.o.md5link -e initmd5
|
||||
|
||||
@.^.Lib.new/pyd: @.^.Modules.o.newmodule s.linktab
|
||||
$(MAKEDLK) -d @.^.Lib.new/pyd -s s.linktab -o @.^.Modules.o.newmodule -e initnew
|
||||
|
||||
@.^.Lib.operator/pyd: @.^.Modules.o.operator s.linktab
|
||||
$(MAKEDLK) -d @.^.Lib.operator/pyd -s s.linktab -o @.^.Modules.o.operator -e initoperator
|
||||
|
||||
@.^.Lib.parser/pyd: @.^.Modules.o.parsermodule s.linktab
|
||||
$(MAKEDLK) -d @.^.Lib.parser/pyd -s s.linktab -o @.^.Modules.o.parsermodule -e initparser
|
||||
|
||||
@.^.Lib.pcre/pyd: @.^.Modules.o.pcremodule @.^.Modules.o.pypcre s.linktab
|
||||
$(LINK) -aof -o @.^.Modules.o.pcrelink @.^.Modules.o.pcremodule @.^.Modules.o.pypcre
|
||||
$(MAKEDLK) -d @.^.Lib.pcre/pyd -s s.linktab -o @.^.Modules.o.pcrelink -e initpcre
|
||||
|
||||
@.^.Lib.regex/pyd: @.^.Modules.o.regexmodule @.^.Modules.o.regexpr s.linktab
|
||||
$(LINK) -aof -o @.^.Modules.o.regexlink @.^.Modules.o.regexmodule @.^.Modules.o.regexpr
|
||||
$(MAKEDLK) -d @.^.Lib.regex/pyd -s s.linktab -o @.^.Modules.o.regexlink -e initregex
|
||||
|
||||
@.^.Lib.rgbimg/pyd: @.^.Modules.o.rgbimgmodule s.linktab
|
||||
$(MAKEDLK) -d @.^.Lib.rgbimg/pyd -s s.linktab -o @.^.Modules.o.rgbimgmodule -e initrgbimg
|
||||
|
||||
@.^.Lib.rotor/pyd: @.^.Modules.o.rotormodule s.linktab
|
||||
$(MAKEDLK) -d @.^.Lib.rotor/pyd -s s.linktab -o @.^.Modules.o.rotormodule -e initrotor
|
||||
|
||||
@.^.Lib.sha/pyd: @.^.Modules.o.shamodule s.linktab
|
||||
$(MAKEDLK) -d @.^.Lib.sha/pyd -s s.linktab -o @.^.Modules.o.shamodule -e initsha
|
||||
|
||||
@.^.Lib.signal/pyd: @.^.Modules.o.signalmodule s.linktab
|
||||
$(MAKEDLK) -d @.^.Lib.signal/pyd -s s.linktab -o @.^.Modules.o.signalmodule -e initsignal
|
||||
|
||||
#@.^.Lib.soundex/pyd: @.^.Modules.o.soundex s.linktab
|
||||
# $(MAKEDLK) -d @.^.Lib.soundex/pyd -s s.linktab -o @.^.Modules.o.soundex -e initsoundex
|
||||
|
||||
@.^.Lib.strop/pyd: @.^.Modules.o.stropmodule s.linktab
|
||||
$(MAKEDLK) -d @.^.Lib.strop/pyd -s s.linktab -o @.^.Modules.o.stropmodule -e initstrop
|
||||
|
||||
@.^.Lib.struct/pyd: @.^.Modules.o.structmodule s.linktab
|
||||
$(MAKEDLK) -d @.^.Lib.struct/pyd -s s.linktab -o @.^.Modules.o.structmodule -e initstruct
|
||||
|
||||
@.^.Lib.plat-riscos.swi/pyd: Modules.o.swimodule s.linktab
|
||||
$(LINK) -aof -o Modules.o.swilink Modules.o.swimodule $(OSLIB).o.OSLIB
|
||||
$(MAKEDLK) -d @.^.Lib.plat-riscos.swi/pyd -s s.linktab -o Modules.o.swilink -e initswi
|
||||
|
||||
@.^.Lib.time/pyd: @.^.Modules.o.timemodule s.linktab
|
||||
$(MAKEDLK) -d @.^.Lib.time/pyd -s s.linktab -o @.^.Modules.o.timemodule -e inittime
|
||||
|
||||
@.^.Lib._locale/pyd: @.^.Modules.o._localemodule s.linktab
|
||||
$(MAKEDLK) -d @.^.Lib._locale/pyd -s s.linktab -o @.^.Modules.o._localemodule -e init_locale
|
||||
|
||||
@.^.Lib._sre/pyd: @.^.Modules.o._sre s.linktab
|
||||
$(MAKEDLK) -d @.^.Lib._sre/pyd -s s.linktab -o @.^.Modules.o._sre -e init_sre
|
||||
|
||||
@.^.Lib._codecs/pyd: @.^.Modules.o._codecsmodule s.linktab
|
||||
$(MAKEDLK) -d @.^.Lib._codecs/pyd -s s.linktab -o @.^.Modules.o._codecsmodule -e init_codecs
|
||||
|
||||
@.^.Lib._weakref/pyd: @.^.Modules.o._weakref s.linktab
|
||||
$(MAKEDLK) -d @.^.Lib._weakref/pyd -s s.linktab -o @.^.Modules.o._weakref -e init_weakref
|
||||
|
||||
@.^.Lib._testcapi/pyd: @.^.Modules.o._testcapimodule s.linktab
|
||||
$(MAKEDLK) -d @.^.Lib._testcapi/pyd -s s.linktab -o @.^.Modules.o._testcapimodule -e init_testcapi
|
||||
|
||||
@.^.Lib.unicodedata/pyd: @.^.Modules.o.unicodedata s.linktab
|
||||
$(MAKEDLK) -d @.^.Lib.unicodedata/pyd -s s.linktab -o @.^.Modules.o.unicodedata -e initunicodedata
|
||||
|
||||
@.^.Lib.xreadlines/pyd: @.^.Modules.o.xreadlinesmodule s.linktab
|
||||
$(MAKEDLK) -d @.^.Lib.xreadlines/pyd -s s.linktab -o @.^.Modules.o.xreadlinesmodule -e initxreadlines
|
||||
|
||||
|
||||
##@.^.Lib.mmap/pyd: @.^.Modules.o.mmapmodule s.linktab
|
||||
## $(MAKEDLK) -d @.^.Lib.mmap/pyd -s s.linktab -o @.^.Modules.o.mmapmodule -e initmmap
|
||||
|
||||
|
||||
|
||||
############################################################################
|
||||
# Dynamic Modules with other dependencies
|
||||
#
|
||||
@.^.Lib.select/pyd: @.^.Modules.o.selectmodule s.linktab
|
||||
$(LINK) -aof -o @.^.Modules.o.selectlink @.^.Modules.o.selectmodule $(SOCKLIB).o.socklib
|
||||
$(MAKEDLK) -d @.^.Lib.select/pyd -s s.linktab -o @.^.Modules.o.selectlink -e initselect
|
||||
|
||||
@.^.Modules.o.selectmodule: @.^.Modules.c.selectmodule
|
||||
$(CC) -I$(SOCKLIB).include -o $@ @.^.Modules.c.selectmodule
|
||||
|
||||
@.^.Lib._socket/pyd: @.^.Modules.o.socketmodule s.linktab
|
||||
$(LINK) -aof -o @.^.Modules.o._socketlink @.^.Modules.o.socketmodule $(SOCKLIB).o.inetlib $(SOCKLIB).o.unixlib $(SOCKLIB).o.socklib
|
||||
$(MAKEDLK) -d @.^.Lib._socket/pyd -s s.linktab -o @.^.Modules.o._socketlink -e init_socket
|
||||
|
||||
@.^.Modules.o.socketmodule: @.^.Modules.c.socketmodule
|
||||
$(CC) -I$(SOCKLIB).include -o $@ @.^.Modules.c.socketmodule
|
||||
|
||||
|
||||
@.^.Lib.zlib/pyd: @.^.Modules.o.zlibmodule s.linktab
|
||||
$(LINK) -aof -o @.^.Modules.o.zliblink @.^.Modules.o.zlibmodule $(ZLIB).zlib_lib
|
||||
$(MAKEDLK) -d @.^.Lib.zlib/pyd -s s.linktab -o @.^.Modules.o.zliblink -e initzlib
|
||||
|
||||
@.^.Modules.o.zlibmodule: @.^.Modules.c.zlibmodule
|
||||
$(CC) -I$(ZLIB) -o $@ @.^.Modules.c.zlibmodule
|
||||
|
||||
|
||||
@.^.Lib.pyexpat/pyd: @.^.Modules.o.pyexpat s.linktab
|
||||
$(LINK) -aof -o @.^.Modules.o.pyexpatlink @.^.Modules.o.pyexpat $(EXPAT).expat_lib
|
||||
$(MAKEDLK) -d @.^.Lib.pyexpat/pyd -s s.linktab -o @.^.Modules.o.pyexpatlink -e initpyexpat
|
||||
|
||||
@.^.Modules.o.pyexpat: @.^.Modules.c.pyexpat
|
||||
$(CCEXPAT) -o $@ @.^.Modules.c.pyexpat
|
||||
|
||||
|
||||
##########################################################################
|
||||
|
||||
o.linktab: s.linktab
|
||||
ObjAsm s.linktab o.linktab
|
||||
|
||||
s.linktab: $(OBJECTS)
|
||||
$(OBJSCAN) -s s.linktab -o $(OBJECTS) $(clib).o.stubs
|
||||
|
||||
|
||||
clean:
|
||||
create @.^.Objects.o.dummy
|
||||
create @.^.Parser.o.dummy
|
||||
create @.^.Modules.o.dummy
|
||||
create o.dummy
|
||||
create @.^.Python.o.dummy
|
||||
create @.^.Lib.dummy/pyc
|
||||
create @.^.Lib.dummy/pyo
|
||||
create @.^.Lib.plat-riscos.dummy/pyc
|
||||
create @.^.Lib.plat-riscos.dummy/pyo
|
||||
create @.^.Lib.test.dummy/pyc
|
||||
wipe @.^.Modules.o.* ~C ~V
|
||||
wipe @.^.Objects.o.* ~C ~V
|
||||
wipe @.^.Parser.o.* ~C ~V
|
||||
wipe @.^.Python.o.* ~C ~V
|
||||
wipe o.* ~C ~V
|
||||
wipe @.^.Lib.*/pyc ~C~V
|
||||
wipe @.^.Lib.*/pyo ~C~V
|
||||
wipe @.^.Lib.plat-riscos.*/pyc ~C~V
|
||||
wipe @.^.Lib.plat-riscos.*/pyo ~C~V
|
||||
wipe @.^.Lib.test.*/pyc ~C~V
|
||||
|
||||
rebuild: clean
|
||||
create @.^.Lib.dummy/pyd
|
||||
create @.^.$(TARGET)
|
||||
create @.^.Lib.plat-riscos.dummy/pyd
|
||||
create s.linktab
|
||||
create o.linktab
|
||||
wipe @.^.$(TARGET) ~C~V
|
||||
wipe @.^.Lib.*/pyd ~C ~V
|
||||
wipe @.^.Lib.plat-riscos.*/pyd ~C~V
|
||||
wipe s.linktab ~C~V
|
||||
wipe o.linktab ~C~V
|
||||
|
||||
cdirs:
|
||||
cdir @.Modules.o
|
||||
cdir @.Python.o
|
||||
cdir @.s
|
||||
cdir @.o
|
||||
cdir @.^.Python.o
|
||||
cdir @.^.Parser.o
|
||||
cdir @.^.Objects.o
|
||||
cdir @.^.Modules.o
|
||||
|
||||
|
||||
# Dynamic dependencies:
|
|
@ -0,0 +1,68 @@
|
|||
/* -*- C -*- ***********************************************
|
||||
Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam,
|
||||
The Netherlands.
|
||||
|
||||
All Rights Reserved
|
||||
|
||||
Permission to use, copy, modify, and distribute this software and its
|
||||
documentation for any purpose and without fee is hereby granted,
|
||||
provided that the above copyright notice appear in all copies and that
|
||||
both that copyright notice and this permission notice appear in
|
||||
supporting documentation, and that the names of Stichting Mathematisch
|
||||
Centrum or CWI or Corporation for National Research Initiatives or
|
||||
CNRI not be used in advertising or publicity pertaining to
|
||||
distribution of the software without specific, written prior
|
||||
permission.
|
||||
|
||||
While CWI is the initial source for this software, a modified version
|
||||
is made available by the Corporation for National Research Initiatives
|
||||
(CNRI) at the Internet address ftp://ftp.python.org.
|
||||
|
||||
STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH
|
||||
REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH
|
||||
CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
|
||||
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
******************************************************************/
|
||||
|
||||
/* Module configuration */
|
||||
|
||||
/* !!! !!! !!! This file is edited by the makesetup script !!! !!! !!! */
|
||||
|
||||
/* This file contains the table of built-in modules.
|
||||
See init_builtin() in import.c. */
|
||||
|
||||
#include "Python.h"
|
||||
|
||||
|
||||
/* -- ADDMODULE MARKER 1 -- */
|
||||
|
||||
extern void PyMarshal_Init();
|
||||
extern void initimp();
|
||||
extern void initriscos();
|
||||
extern void initswi();
|
||||
|
||||
struct _inittab _PyImport_Inittab[] = {
|
||||
|
||||
{"riscos", initriscos},
|
||||
|
||||
/* -- ADDMODULE MARKER 2 -- */
|
||||
|
||||
/* This module "lives in" with marshal.c */
|
||||
{"marshal", PyMarshal_Init},
|
||||
|
||||
/* This lives it with import.c */
|
||||
{"imp", initimp},
|
||||
|
||||
/* These entries are here for sys.builtin_module_names */
|
||||
{"__main__", NULL},
|
||||
{"__builtin__", NULL},
|
||||
{"sys", NULL},
|
||||
|
||||
/* Sentinel */
|
||||
{0, 0}
|
||||
};
|
|
@ -0,0 +1,664 @@
|
|||
/* drawf DrawFile functions */
|
||||
|
||||
#include "h.os"
|
||||
#include "h.osfile"
|
||||
#include "h.drawfile"
|
||||
#include "Python.h"
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
#define PyDrawF_Check(op) ((op)->ob_type == &PyDrawFType)
|
||||
#define HDRSIZE 40
|
||||
#define GRPHDRSIZE 36
|
||||
#define DRAWTYPE 0xaff
|
||||
#define NEXT(d) ((drawfile_object*)((char*)(d)+(d)->size))
|
||||
|
||||
typedef struct
|
||||
{ PyObject_HEAD
|
||||
drawfile_diagram *drawf;
|
||||
int size; /*length in bytes*/
|
||||
int nobjs; /* no of objects */
|
||||
} PyDrawFObject;
|
||||
|
||||
typedef struct dheader
|
||||
{ char tag [4];
|
||||
int major_version;
|
||||
int minor_version;
|
||||
char source [12];
|
||||
os_box bbox;
|
||||
} dheader;
|
||||
|
||||
static PyObject *DrawFError; /* Exception drawf.error */
|
||||
static os_error *e;
|
||||
static PyTypeObject PyDrawFType;
|
||||
|
||||
static dheader header=
|
||||
{ {'D','r','a','w'},
|
||||
201,0,
|
||||
{'P','y','t','h','o','n',' ',' ',' ',' ',' ',' '},
|
||||
{INT_MAX,INT_MAX,INT_MIN,INT_MIN}
|
||||
};
|
||||
|
||||
static PyObject *drawf_oserror(void)
|
||||
{ PyErr_SetString(DrawFError,e->errmess);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static PyObject *drawf_error(char *s)
|
||||
{ PyErr_SetString(DrawFError,s);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* DrawFile commands */
|
||||
|
||||
static void countobjs(PyDrawFObject *pd)
|
||||
{ int k=0,q;
|
||||
drawfile_diagram *dd=pd->drawf;
|
||||
drawfile_object *d=dd->objects;
|
||||
char *end=(char*)dd+pd->size;
|
||||
pd->nobjs=-1;
|
||||
while((char*)d<end)
|
||||
{ k++;
|
||||
q=d->size;
|
||||
if(q<=0||q&3) return ;
|
||||
d=NEXT(d);
|
||||
}
|
||||
if ((char*)d==end) pd->nobjs=k;
|
||||
}
|
||||
|
||||
static drawfile_object *findobj(PyDrawFObject *pd,int n)
|
||||
{ drawfile_diagram *dd=pd->drawf;
|
||||
drawfile_object *d=dd->objects;
|
||||
for(;n>0;n--) d=NEXT(d);
|
||||
return d;
|
||||
}
|
||||
|
||||
static PyDrawFObject* new(int size)
|
||||
{ PyDrawFObject *b=PyObject_NEW(PyDrawFObject,&PyDrawFType);
|
||||
if(!b) return NULL;
|
||||
size+=HDRSIZE;
|
||||
b->drawf=malloc(size);
|
||||
if(!b->drawf)
|
||||
{ Py_DECREF(b);
|
||||
return (PyDrawFObject*)PyErr_NoMemory();
|
||||
}
|
||||
b->size=size;
|
||||
return b;
|
||||
}
|
||||
|
||||
static void extend(os_box *b,os_box *c)
|
||||
{ if(b->x0>c->x0) b->x0=c->x0;
|
||||
if(b->y0>c->y0) b->y0=c->y0;
|
||||
if(b->x1<c->x1) b->x1=c->x1;
|
||||
if(b->y1<c->y1) b->y1=c->y1;
|
||||
}
|
||||
|
||||
static PyObject *DrawF_New(PyObject *self,PyObject *args)
|
||||
{ PyDrawFObject *b;
|
||||
if(!PyArg_ParseTuple(args,"")) return NULL;
|
||||
b=new(0);
|
||||
if(!b) return NULL;
|
||||
*((dheader*)b->drawf)=header;
|
||||
b->nobjs=0;
|
||||
return (PyObject *)b;
|
||||
}
|
||||
|
||||
static PyObject *DrawF_Load(PyObject *self,PyObject *args)
|
||||
{ int size;
|
||||
char *fname;
|
||||
PyDrawFObject *b;
|
||||
fileswitch_object_type ot;
|
||||
if(!PyArg_ParseTuple(args,"s",&fname)) return NULL;
|
||||
e=xosfile_read_no_path(fname,&ot,0,0,&size,0);
|
||||
if(e) return drawf_oserror();
|
||||
size-=HDRSIZE;
|
||||
if(ot!=osfile_IS_FILE||size<0||size&3) return drawf_error("Bad draw file");
|
||||
b=new(size);
|
||||
if(!b) return NULL;
|
||||
e=xosfile_load_stamped_no_path(fname,(byte*)(b->drawf),0,0,0,0,0);
|
||||
if(e)
|
||||
{ Py_DECREF(b);
|
||||
return drawf_oserror();
|
||||
}
|
||||
countobjs(b);
|
||||
if(b->nobjs>=0) return (PyObject *)b;
|
||||
Py_DECREF(b);
|
||||
return drawf_error("Corrupt draw file");
|
||||
}
|
||||
|
||||
|
||||
static PyObject *DrawF_Save(PyDrawFObject *self,PyObject *arg)
|
||||
{ char *fname;
|
||||
if(!PyArg_ParseTuple(arg,"s",&fname)) return NULL;
|
||||
e=xosfile_save_stamped(fname,DRAWTYPE,
|
||||
(byte*)(self->drawf),(byte*)(self->drawf)+self->size);
|
||||
if (e) return drawf_oserror();
|
||||
Py_INCREF(Py_None);return Py_None;
|
||||
}
|
||||
|
||||
static PyObject *DrawF_Render(PyDrawFObject *self,PyObject *arg)
|
||||
{ int flags,trans,clip,flat;
|
||||
if(!PyArg_ParseTuple(arg,"iiii",&flags,&trans,&clip,&flat)) return NULL;
|
||||
e=xdrawfile_render((drawfile_render_flags)flags,self->drawf,self->size,
|
||||
(os_trfm*)trans,(os_box*)clip,flat);
|
||||
if(e) return drawf_oserror();
|
||||
Py_INCREF(Py_None);return Py_None;
|
||||
}
|
||||
|
||||
static PyObject *DrawF_Path(PyDrawFObject *self,PyObject *arg)
|
||||
{ PyObject *pl;
|
||||
PyObject *dp=0;
|
||||
os_colour fill;
|
||||
os_colour outline;
|
||||
int width,start=0;
|
||||
drawfile_path_style style;
|
||||
int size=40;
|
||||
int n,i,element_count;
|
||||
drawfile_diagram *diag;
|
||||
drawfile_object *dobj;
|
||||
drawfile_path *dpath;
|
||||
draw_path *thepath;
|
||||
draw_line_style line_style;
|
||||
draw_dash_pattern *dash_pattern=0;
|
||||
os_box *box;
|
||||
long *pe;
|
||||
if(!PyArg_ParseTuple(arg,"O!(iiii)|O!i",&PyList_Type,&pl,(int*)&fill,
|
||||
(int*)&outline,&width,(int*)&style,&PyTuple_Type,&dp,&start)) return NULL;
|
||||
if(dp)
|
||||
{ element_count=PyTuple_Size(dp);
|
||||
size+=4*element_count+8;
|
||||
style.flags|=drawfile_PATH_DASHED;
|
||||
}
|
||||
else style.flags&=~drawfile_PATH_DASHED;
|
||||
n=PyList_Size(pl);
|
||||
size+=4*n+8;
|
||||
for(i=0;i<n;i++) if(!PyInt_Check(PyList_GetItem(pl,i))) size+=4;
|
||||
diag=realloc(self->drawf,self->size+size);
|
||||
if(!diag) return PyErr_NoMemory();
|
||||
self->drawf=diag;
|
||||
dobj=(drawfile_object*)((char*)diag+self->size);
|
||||
dobj->type=drawfile_TYPE_PATH;
|
||||
dobj->size=size;
|
||||
dpath=&dobj->data.path;
|
||||
self->size+=size;
|
||||
self->nobjs++;
|
||||
box=&dpath->bbox;
|
||||
dpath->fill=fill;dpath->outline=outline;
|
||||
dpath->width=width;dpath->style=style;
|
||||
pe=(long*)&(dpath->path);
|
||||
if(dp)
|
||||
{ dash_pattern=&(((drawfile_path_with_pattern*)dpath)->pattern);
|
||||
dash_pattern->start=start;
|
||||
dash_pattern->element_count=element_count;
|
||||
for(i=0;i<element_count;i++)
|
||||
{ dash_pattern->elements[i]=(int)PyInt_AsLong(PyTuple_GetItem(dp,i));
|
||||
}
|
||||
pe+=element_count+2;
|
||||
}
|
||||
thepath=(draw_path*)pe;
|
||||
*pe++=draw_MOVE_TO;
|
||||
for(i=0;i<n;i++)
|
||||
{ PyObject *p=PyList_GetItem(pl,i);
|
||||
if(PyInt_Check(p))
|
||||
*pe++=PyInt_AsLong(p);
|
||||
else
|
||||
{
|
||||
*pe++=PyInt_AsLong(PyTuple_GetItem(p,0));
|
||||
*pe++=PyInt_AsLong(PyTuple_GetItem(p,1));
|
||||
}
|
||||
}
|
||||
*pe=draw_END_PATH;
|
||||
line_style.join_style=style.flags&3;
|
||||
line_style.end_cap_style=(style.flags&3)>>2;
|
||||
line_style.start_cap_style=(style.flags&3)>>4;
|
||||
line_style.reserved=0;
|
||||
line_style.mitre_limit=10;
|
||||
line_style.start_cap_width=style.cap_width;
|
||||
line_style.end_cap_width=style.cap_width;
|
||||
line_style.start_cap_length=style.cap_length;
|
||||
line_style.end_cap_length=style.cap_length;
|
||||
e=xdraw_process_path(thepath,0x70000000,0,0,width,&line_style,dash_pattern,
|
||||
(draw_output_path)((char*)box+0x80000000),0);
|
||||
if(e) return drawf_oserror();
|
||||
|
||||
/* draw_process_path seems to have a bug:
|
||||
If the bounding box size is zero, it returns 0x7FFFFFFF, ..., 0x80000000 instead of the
|
||||
correct size. */
|
||||
if (box->x0==0x7FFFFFFF)
|
||||
{
|
||||
/* path has zero extension, so forget it; it would be invisible anyway */
|
||||
self->size-=size;
|
||||
self->nobjs--;
|
||||
diag=realloc(self->drawf,self->size);
|
||||
if(!diag) return PyErr_NoMemory();
|
||||
self->drawf=diag;
|
||||
}
|
||||
else
|
||||
extend(&(diag->bbox),box);
|
||||
Py_INCREF(Py_None);return Py_None;
|
||||
}
|
||||
|
||||
static PyObject *DrawF_Text(PyDrawFObject *self,PyObject *arg)
|
||||
{ os_colour fill,bg_hint;
|
||||
drawfile_text_style style;
|
||||
int xsize,ysize,x,y;
|
||||
int size,len;
|
||||
char *text;
|
||||
drawfile_diagram *diag;
|
||||
drawfile_object *dobj;
|
||||
drawfile_text *dtext;
|
||||
os_box *box;
|
||||
if(!PyArg_ParseTuple(arg,"(ii)s(iiiii)",&x,&y,&text,
|
||||
(int*)&fill,(int*)&bg_hint,(int*)&style,&xsize,&ysize)) return NULL;
|
||||
len=strlen(text);
|
||||
size=((len+4)&(~3))+52;
|
||||
diag=realloc(self->drawf,self->size+size);
|
||||
if(!diag) return PyErr_NoMemory();
|
||||
self->drawf=diag;
|
||||
dobj=(drawfile_object*)((char*)diag+self->size);
|
||||
dobj->type=drawfile_TYPE_TEXT;
|
||||
dobj->size=size;
|
||||
dtext=&dobj->data.text;
|
||||
self->size+=size;
|
||||
self->nobjs++;
|
||||
dtext->fill=fill;
|
||||
dtext->bg_hint=bg_hint;
|
||||
dtext->style=style;
|
||||
dtext->xsize=xsize;
|
||||
dtext->ysize=ysize;
|
||||
dtext->base.x=x;
|
||||
dtext->base.y=y;
|
||||
memset(dtext->text,0,(len+4)&(~3));
|
||||
sprintf(dtext->text,"%s",text);
|
||||
box=&(dtext->bbox);
|
||||
box->x0=x;box->y0=y;box->x1=x+len*xsize;box->y1=y+ysize;
|
||||
extend(&(diag->bbox),box);
|
||||
Py_INCREF(Py_None);return Py_None;
|
||||
}
|
||||
|
||||
static PyObject *DrawF_TText(PyDrawFObject *self,PyObject *arg)
|
||||
{ os_colour fill,bg_hint;
|
||||
drawfile_text_style style;
|
||||
int xsize,ysize,x,y;
|
||||
int t1,t2,t3,t4,t5,t6;
|
||||
int size,len;
|
||||
char *text;
|
||||
drawfile_diagram *diag;
|
||||
drawfile_object *dobj;
|
||||
drawfile_trfm_text *dtext;
|
||||
os_box *box;
|
||||
t1=1<<16;t2=0;
|
||||
t3=0;t4=1<<16;
|
||||
t5=t6=0;
|
||||
if(!PyArg_ParseTuple(arg,"(ii)s(iiiii)|(iiiiii)",&x,&y,&text,
|
||||
(int*)&fill,(int*)&bg_hint,(int*)&style,&xsize,&ysize,&t1,&t2,&t3,&t4,&t5,&t6)) return NULL;
|
||||
len=strlen(text);
|
||||
size=((len+4)&(~3))+52+28;
|
||||
diag=realloc(self->drawf,self->size+size);
|
||||
if(!diag) return PyErr_NoMemory();
|
||||
self->drawf=diag;
|
||||
dobj=(drawfile_object*)((char*)diag+self->size);
|
||||
dobj->type=drawfile_TYPE_TRFM_TEXT;
|
||||
dobj->size=size;
|
||||
dtext=&dobj->data.trfm_text;
|
||||
self->size+=size;
|
||||
self->nobjs++;
|
||||
dtext->trfm.entries[0][0]=t1;
|
||||
dtext->trfm.entries[0][1]=t2;
|
||||
dtext->trfm.entries[1][0]=t3;
|
||||
dtext->trfm.entries[1][1]=t4;
|
||||
dtext->trfm.entries[2][0]=t5;
|
||||
dtext->trfm.entries[2][1]=t6;
|
||||
dtext->flags=0;
|
||||
dtext->fill=fill;
|
||||
dtext->bg_hint=bg_hint;
|
||||
dtext->style=style;
|
||||
dtext->xsize=xsize;
|
||||
dtext->ysize=ysize;
|
||||
dtext->base.x=x;
|
||||
dtext->base.y=y;
|
||||
memset(dtext->text,0,(len+4)&(~3));
|
||||
sprintf(dtext->text,"%s",text);
|
||||
box=&(dtext->bbox);
|
||||
box->x0=x;box->y0=y;box->x1=x+len*xsize;box->y1=y+ysize;
|
||||
extend(&(diag->bbox),box);
|
||||
Py_INCREF(Py_None);return Py_None;
|
||||
}
|
||||
|
||||
static PyObject *DrawF_FontTable(PyDrawFObject *self,PyObject *arg)
|
||||
{ int size=8,n=0;
|
||||
PyObject *d,*key,*value;
|
||||
drawfile_diagram *diag;
|
||||
drawfile_object *dobj;
|
||||
char *dtable;
|
||||
if(!PyArg_ParseTuple(arg,"O!",&PyDict_Type,&d)) return NULL;
|
||||
while(PyDict_Next(d,&n,&key,&value))
|
||||
{ int m=PyString_Size(value);
|
||||
if(m<0||!PyInt_Check(key)) return NULL;
|
||||
size+=m+2;
|
||||
}
|
||||
size=(size+3)&(~3);
|
||||
diag=realloc(self->drawf,self->size+size);
|
||||
if(!diag) return PyErr_NoMemory();
|
||||
self->drawf=diag;
|
||||
dobj=(drawfile_object*)((char*)diag+self->size);
|
||||
dobj->type=drawfile_TYPE_FONT_TABLE;
|
||||
dobj->size=size;
|
||||
dtable=(char*)(&dobj->data.font_table);
|
||||
self->size+=size;
|
||||
self->nobjs++;
|
||||
memset(dtable,0,size-8);
|
||||
n=0;
|
||||
while(PyDict_Next(d,&n,&key,&value))
|
||||
{ int m=PyString_Size(value);
|
||||
*dtable=(char)PyInt_AsLong(key);
|
||||
strcpy(dtable+1,PyString_AsString(value));
|
||||
dtable+=m+2;
|
||||
}
|
||||
Py_INCREF(Py_None);return Py_None;
|
||||
}
|
||||
|
||||
static PyObject *DrawF_Group(PyDrawFObject *self,PyObject *arg)
|
||||
{ int size,n;
|
||||
PyDrawFObject *g;
|
||||
char *name="";
|
||||
drawfile_diagram *diag;
|
||||
drawfile_object *dobj;
|
||||
drawfile_group *dgroup;
|
||||
if(!PyArg_ParseTuple(arg,"O!|s",&PyDrawFType,(PyObject*)&g,&name))
|
||||
return NULL;
|
||||
size=g->size-4;
|
||||
diag=realloc(self->drawf,self->size+size);
|
||||
if(!diag) return PyErr_NoMemory();
|
||||
self->drawf=diag;
|
||||
self->nobjs++;
|
||||
dobj=(drawfile_object*)((char*)diag+self->size);
|
||||
self->size+=size;
|
||||
dobj->type=drawfile_TYPE_GROUP;
|
||||
dobj->size=g->size-4;
|
||||
dgroup=&dobj->data.group;
|
||||
dgroup->bbox=g->drawf->bbox;
|
||||
memset(dgroup->name,' ',12);
|
||||
n=strlen(name);
|
||||
if(n>12) n=12;
|
||||
memcpy(dgroup->name,name,n);
|
||||
memcpy((char*)dgroup->objects,(char*)g->drawf+40,g->size-40);
|
||||
extend(&(diag->bbox),&(dgroup->bbox));
|
||||
Py_INCREF(Py_None);return Py_None;
|
||||
}
|
||||
|
||||
static PyObject *DrawF_Find(PyDrawFObject *self,PyObject *arg)
|
||||
{ int x,y,n=0;
|
||||
int r=-1;
|
||||
drawfile_object *d;
|
||||
if(!PyArg_ParseTuple(arg,"ii|i",&x,&y,&n)) return NULL;
|
||||
if(n<self->nobjs&&n>=0)
|
||||
{ d=findobj(self,n);
|
||||
while(n<self->nobjs)
|
||||
{ if(x>=d->data.text.bbox.x0&&x<=d->data.text.bbox.x1&&
|
||||
y>=d->data.text.bbox.y0&&y<=d->data.text.bbox.y1) { r=n;break;}
|
||||
n++;
|
||||
d=NEXT(d);
|
||||
}
|
||||
}
|
||||
return PyInt_FromLong(r);
|
||||
}
|
||||
|
||||
|
||||
static PyObject *DrawF_Box(PyDrawFObject *self,PyObject *arg)
|
||||
{ int n=-1;
|
||||
os_box *box;
|
||||
if(!PyArg_ParseTuple(arg,"|i",&n)) return NULL;
|
||||
if(n>=self->nobjs|n<0) box=&(self->drawf->bbox);
|
||||
else box=&(findobj(self,n)->data.text.bbox);
|
||||
return Py_BuildValue("iiii",box->x0,box->y0,box->x1,box->y1);
|
||||
}
|
||||
|
||||
static void SetBlock(drawfile_object *d,int size,int type,int offset,int value)
|
||||
{ char *end=(char*)d+size;
|
||||
printf("s%d t%d o%d v%d\n",size,type,offset,value);
|
||||
for(;(char*)d<end;d=NEXT(d))
|
||||
if(d->type==type) ((int*)(d))[offset]=value;
|
||||
else if(d->type==drawfile_TYPE_GROUP)
|
||||
SetBlock((drawfile_object*)&d->data.group.objects,
|
||||
d->size,type,offset,value);
|
||||
printf("SetBlock Done\n");
|
||||
}
|
||||
|
||||
static PyObject *SetWord(PyDrawFObject *self,PyObject *arg,int type,int offset)
|
||||
{ int n=PyTuple_Size(arg);
|
||||
int m,value,q;
|
||||
PyObject *par;
|
||||
drawfile_object *e,*d=self->drawf->objects;
|
||||
if(n==0) return drawf_error("Value Required");
|
||||
par=PyTuple_GetItem(arg,0);
|
||||
if(!PyInt_Check(par))
|
||||
{ PyErr_SetString(PyExc_TypeError,"Int Required");
|
||||
return 0;
|
||||
}
|
||||
value=(int)PyInt_AsLong(par);
|
||||
if(n==1) SetBlock(d,self->size-HDRSIZE,type,offset,value);
|
||||
else
|
||||
{ for(m=1;m<n;m++)
|
||||
{ par=PyTuple_GetItem(arg,m);
|
||||
if(!PyInt_Check(par))
|
||||
{ PyErr_SetString(PyExc_TypeError,"Int Required");
|
||||
return 0;
|
||||
}
|
||||
q=(int)PyInt_AsLong(par);
|
||||
if(q<0||q>=self->nobjs)
|
||||
{ PyErr_SetString(PyExc_ValueError,"Object out of range");
|
||||
return 0;
|
||||
}
|
||||
e=d;
|
||||
for(;q>0;q--) e=NEXT(e);
|
||||
if(e->type==type)
|
||||
{ ((int*)(e))[offset]=value;
|
||||
}
|
||||
else if(e->type==drawfile_TYPE_GROUP)
|
||||
SetBlock((drawfile_object*)&e->data.group.objects,
|
||||
e->size-GRPHDRSIZE,type,offset,value);
|
||||
}
|
||||
}
|
||||
Py_INCREF(Py_None);return Py_None;
|
||||
}
|
||||
|
||||
static PyObject *DrawF_PathFill(PyDrawFObject *self,PyObject *arg)
|
||||
{ return SetWord(self,arg,drawfile_TYPE_PATH,6);
|
||||
}
|
||||
|
||||
static PyObject *DrawF_PathColour(PyDrawFObject *self,PyObject *arg)
|
||||
{ return SetWord(self,arg,drawfile_TYPE_PATH,7);
|
||||
}
|
||||
|
||||
static PyObject *DrawF_TextColour(PyDrawFObject *self,PyObject *arg)
|
||||
{ return SetWord(self,arg,drawfile_TYPE_TEXT,6);
|
||||
}
|
||||
|
||||
static PyObject *DrawF_TextBackground(PyDrawFObject *self,PyObject *arg)
|
||||
{ return SetWord(self,arg,drawfile_TYPE_TEXT,7);
|
||||
}
|
||||
|
||||
static struct PyMethodDef PyDrawF_Methods[]=
|
||||
{
|
||||
{ "render",(PyCFunction)DrawF_Render,1},
|
||||
{ "save",(PyCFunction)DrawF_Save,1},
|
||||
{ "path",(PyCFunction)DrawF_Path,1},
|
||||
{ "text",(PyCFunction)DrawF_Text,1},
|
||||
{ "ttext",(PyCFunction)DrawF_TText,1},
|
||||
{ "fonttable",(PyCFunction)DrawF_FontTable,1},
|
||||
{ "group",(PyCFunction)DrawF_Group,1},
|
||||
{ "find",(PyCFunction)DrawF_Find,1},
|
||||
{ "box",(PyCFunction)DrawF_Box,1},
|
||||
{ "pathfill",(PyCFunction)DrawF_PathFill,1},
|
||||
{ "pathcolour",(PyCFunction)DrawF_PathColour,1},
|
||||
{ "textcolour",(PyCFunction)DrawF_TextColour,1},
|
||||
{ "textbackground",(PyCFunction)DrawF_TextBackground,1},
|
||||
{ NULL,NULL} /* sentinel */
|
||||
};
|
||||
|
||||
static int drawf_len(PyDrawFObject *b)
|
||||
{ return b->nobjs;
|
||||
}
|
||||
|
||||
static PyObject *drawf_concat(PyDrawFObject *b,PyDrawFObject *c)
|
||||
{ int size=b->size+c->size-2*HDRSIZE;
|
||||
PyDrawFObject *p=new(size);
|
||||
drawfile_diagram *dd;
|
||||
drawfile_object *d;
|
||||
int n;
|
||||
if(!p) return NULL;
|
||||
dd=p->drawf;
|
||||
d=(drawfile_object*)((char*)dd+b->size);
|
||||
memcpy((char*)dd,(char*)(b->drawf),b->size);
|
||||
memcpy(d,(char*)(c->drawf)+HDRSIZE,c->size-HDRSIZE);
|
||||
p->nobjs=b->nobjs+c->nobjs;
|
||||
for(n=c->nobjs;n>0;n--)
|
||||
{ extend(&(dd->bbox),&(d->data.path.bbox));
|
||||
d=NEXT(d);
|
||||
}
|
||||
return (PyObject*)p;
|
||||
}
|
||||
|
||||
static PyObject *drawf_repeat(PyDrawFObject *b,int i)
|
||||
{ PyErr_SetString(PyExc_IndexError,"drawf repetition not implemented");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static PyObject *drawf_item(PyDrawFObject *b,int i)
|
||||
{ PyDrawFObject *c;
|
||||
int size;
|
||||
drawfile_diagram *dd;
|
||||
drawfile_object *d;
|
||||
if(i<0||i>=b->nobjs)
|
||||
{ PyErr_SetString(PyExc_IndexError,"drawf index out of range");
|
||||
return NULL;
|
||||
}
|
||||
d=findobj(b,i);
|
||||
size=(char*)findobj(b,i+1)-(char*)d;
|
||||
c=new(size);
|
||||
if(!c) return NULL;
|
||||
dd=c->drawf;
|
||||
*((dheader*)dd)=header;
|
||||
memcpy(dd->objects,d,size);
|
||||
c->nobjs=1;
|
||||
extend(&(dd->bbox),&(d->data.path.bbox));
|
||||
return (PyObject*)c;
|
||||
}
|
||||
|
||||
static PyObject *drawf_slice(PyDrawFObject *b,int i,int j)
|
||||
{ PyDrawFObject *c;
|
||||
int size,n;
|
||||
drawfile_diagram *dd;
|
||||
drawfile_object *d;
|
||||
if(i<0||j>b->nobjs)
|
||||
{ PyErr_SetString(PyExc_IndexError,"drawf index out of range");
|
||||
return NULL;
|
||||
}
|
||||
d=findobj(b,i);
|
||||
size=(char*)findobj(b,j)-(char*)d;
|
||||
c=new(size);
|
||||
if(!c) return NULL;
|
||||
dd=c->drawf;
|
||||
*((dheader*)dd)=header;
|
||||
memcpy(dd->objects,d,size);
|
||||
c->nobjs=j-i;
|
||||
for(n=j-i;n>0;n--)
|
||||
{ extend(&(dd->bbox),&(d->data.path.bbox));
|
||||
d=NEXT(d);
|
||||
}
|
||||
return (PyObject*)c;
|
||||
}
|
||||
|
||||
static int drawf_ass_item(PyDrawFObject *b,int i,PyObject *v)
|
||||
{ PyErr_SetString(PyExc_IndexError,"drawf ass not implemented");
|
||||
return NULL;
|
||||
}
|
||||
/*{ if(i<0||4*i>=b->length)
|
||||
{ PyErr_SetString(PyExc_IndexError,"drawf index out of range");
|
||||
return -1;
|
||||
}
|
||||
if(!PyInt_Check(v))
|
||||
{ PyErr_SetString(PyExc_TypeError,"drawf item must be integer");
|
||||
return -1;
|
||||
}
|
||||
((long*)(b->drawf))[i]=PyInt_AsLong(v);
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
|
||||
static int drawf_ass_slice(PyDrawFObject *b,int i,int j,PyObject *v)
|
||||
{ PyErr_SetString(PyExc_IndexError,"drawf ass_slice not implemented");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static PySequenceMethods drawf_as_sequence=
|
||||
{ (inquiry)drawf_len,
|
||||
(binaryfunc)drawf_concat,
|
||||
(intargfunc)drawf_repeat,
|
||||
(intargfunc)drawf_item,
|
||||
(intintargfunc)drawf_slice,
|
||||
(intobjargproc)drawf_ass_item,
|
||||
(intintobjargproc)drawf_ass_slice,
|
||||
};
|
||||
|
||||
static PyObject *PyDrawF_GetAttr(PyDrawFObject *s,char *name)
|
||||
{
|
||||
if (!strcmp(name, "size")) return PyInt_FromLong((long)s->size);
|
||||
if (!strcmp(name, "start")) return PyInt_FromLong((long)s->drawf);
|
||||
if (!strcmp(name, "__members__"))
|
||||
{ PyObject *list = PyList_New(2);
|
||||
if (list)
|
||||
{ PyList_SetItem(list, 0, PyString_FromString("size"));
|
||||
PyList_SetItem(list, 1, PyString_FromString("start"));
|
||||
if (PyErr_Occurred()) { Py_DECREF(list);list = NULL;}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
return Py_FindMethod(PyDrawF_Methods, (PyObject*) s,name);
|
||||
}
|
||||
|
||||
static void PyDrawF_Dealloc(PyDrawFObject *b)
|
||||
{
|
||||
if (b->drawf)
|
||||
;
|
||||
else
|
||||
PyMem_DEL(b->drawf);
|
||||
PyMem_DEL(b);
|
||||
}
|
||||
|
||||
static PyTypeObject PyDrawFType=
|
||||
{ PyObject_HEAD_INIT(&PyType_Type)
|
||||
0, /*ob_size*/
|
||||
"drawf", /*tp_name*/
|
||||
sizeof(PyDrawFObject), /*tp_size*/
|
||||
0, /*tp_itemsize*/
|
||||
/* methods */
|
||||
(destructor)PyDrawF_Dealloc, /*tp_dealloc*/
|
||||
0, /*tp_print*/
|
||||
(getattrfunc)PyDrawF_GetAttr, /*tp_getattr*/
|
||||
0, /*tp_setattr*/
|
||||
0, /*tp_compare*/
|
||||
0, /*tp_repr*/
|
||||
0, /*tp_as_number*/
|
||||
&drawf_as_sequence, /*tp_as_sequence*/
|
||||
0, /*tp_as_mapping*/
|
||||
0, /*tp_hash*/
|
||||
};
|
||||
|
||||
|
||||
|
||||
static PyMethodDef DrawFMethods[]=
|
||||
{
|
||||
{ "load",DrawF_Load,1},
|
||||
{ "new",DrawF_New,1},
|
||||
{ NULL,NULL} /* Sentinel */
|
||||
};
|
||||
|
||||
void initdrawf()
|
||||
{ PyObject *m, *d;
|
||||
m = Py_InitModule("drawf", DrawFMethods);
|
||||
d = PyModule_GetDict(m);
|
||||
DrawFError=PyString_FromString("drawf.error");
|
||||
PyDict_SetItemString(d,"error",DrawFError);
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
#include "Python.h"
|
||||
#include "osdefs.h"
|
||||
|
||||
static char *prefix,*exec_prefix,*progpath,*module_search_path=0;
|
||||
|
||||
static void
|
||||
calculate_path()
|
||||
{ char *pypath=getenv("Python$Path");
|
||||
if(pypath)
|
||||
{ module_search_path=malloc(strlen(pypath)+1);
|
||||
if (module_search_path) sprintf(module_search_path,"%s",pypath);
|
||||
else
|
||||
{ /* We can't exit, so print a warning and limp along */
|
||||
fprintf(stderr, "Not enough memory for dynamic PYTHONPATH.\n");
|
||||
fprintf(stderr, "Using default static PYTHONPATH.\n");
|
||||
}
|
||||
}
|
||||
if(!module_search_path) module_search_path = "<Python$Dir>.Lib";
|
||||
prefix="";
|
||||
exec_prefix=prefix;
|
||||
progpath="<Python$Dir>";
|
||||
}
|
||||
|
||||
/* External interface */
|
||||
|
||||
char *
|
||||
Py_GetPath()
|
||||
{
|
||||
if (!module_search_path)
|
||||
calculate_path();
|
||||
return module_search_path;
|
||||
}
|
||||
|
||||
char *
|
||||
Py_GetPrefix()
|
||||
{
|
||||
if (!module_search_path)
|
||||
calculate_path();
|
||||
return prefix;
|
||||
}
|
||||
|
||||
char *
|
||||
Py_GetExecPrefix()
|
||||
{
|
||||
if (!module_search_path)
|
||||
calculate_path();
|
||||
return exec_prefix;
|
||||
}
|
||||
|
||||
char *
|
||||
Py_GetProgramFullPath()
|
||||
{
|
||||
if (!module_search_path)
|
||||
calculate_path();
|
||||
return progpath;
|
||||
}
|
|
@ -0,0 +1,283 @@
|
|||
/* RISCOS module implementation */
|
||||
|
||||
#include "h.osfscontrol"
|
||||
#include "h.osgbpb"
|
||||
#include "h.os"
|
||||
#include "h.osfile"
|
||||
|
||||
#include "Python.h"
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
static os_error *e;
|
||||
|
||||
static PyObject *RiscosError; /* Exception riscos.error */
|
||||
|
||||
static PyObject *riscos_oserror(void)
|
||||
{ PyErr_SetString(RiscosError,e->errmess);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static PyObject *riscos_error(char *s) { PyErr_SetString(RiscosError,s);return 0;}
|
||||
|
||||
/* RISCOS file commands */
|
||||
|
||||
static PyObject *riscos_remove(PyObject *self,PyObject *args)
|
||||
{ char *path1;
|
||||
if (!PyArg_Parse(args, "s", &path1)) return NULL;
|
||||
if (remove(path1)) return PyErr_SetFromErrno(RiscosError);
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static PyObject *riscos_rename(PyObject *self,PyObject *args)
|
||||
{ char *path1, *path2;
|
||||
if (!PyArg_Parse(args, "(ss)", &path1, &path2)) return NULL;
|
||||
if (rename(path1,path2)) return PyErr_SetFromErrno(RiscosError);;
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static PyObject *riscos_system(PyObject *self,PyObject *args)
|
||||
{ char *command;
|
||||
if (!PyArg_Parse(args, "s", &command)) return NULL;
|
||||
return PyInt_FromLong(system(command));
|
||||
}
|
||||
|
||||
static PyObject *riscos_chdir(PyObject *self,PyObject *args)
|
||||
{ char *path;
|
||||
if (!PyArg_Parse(args, "s", &path)) return NULL;
|
||||
e=xosfscontrol_dir(path);
|
||||
if(e) return riscos_oserror();
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static PyObject *canon(char *path)
|
||||
{ int len;
|
||||
PyObject *obj;
|
||||
char *buf;
|
||||
e=xosfscontrol_canonicalise_path(path,0,0,0,0,&len);
|
||||
if(e) return riscos_oserror();
|
||||
obj=PyString_FromStringAndSize(NULL,-len);
|
||||
if(obj==NULL) return NULL;
|
||||
buf=PyString_AsString(obj);
|
||||
e=xosfscontrol_canonicalise_path(path,buf,0,0,1-len,&len);
|
||||
if(len!=1) return riscos_error("Error expanding path");
|
||||
if(!e) return obj;
|
||||
Py_DECREF(obj);
|
||||
return riscos_oserror();
|
||||
}
|
||||
|
||||
static PyObject *riscos_getcwd(PyObject *self,PyObject *args)
|
||||
{ if(!PyArg_NoArgs(args)) return NULL;
|
||||
return canon("@");
|
||||
}
|
||||
|
||||
static PyObject *riscos_expand(PyObject *self,PyObject *args)
|
||||
{ char *path;
|
||||
if (!PyArg_Parse(args, "s", &path)) return NULL;
|
||||
return canon(path);
|
||||
}
|
||||
|
||||
static PyObject *riscos_mkdir(PyObject *self,PyObject *args)
|
||||
{ char *path;
|
||||
int mode;
|
||||
if (!PyArg_ParseTuple(args, "s|i", &path, &mode)) return NULL;
|
||||
e=xosfile_create_dir(path,0);
|
||||
if(e) return riscos_oserror();
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static PyObject *riscos_listdir(PyObject *self,PyObject *args)
|
||||
{ char *path,buf[256];
|
||||
PyObject *d, *v;
|
||||
int c=0,count;
|
||||
if (!PyArg_Parse(args, "s", &path)) return NULL;
|
||||
d=PyList_New(0);
|
||||
if(!d) return NULL;
|
||||
for(;;)
|
||||
{ e=xosgbpb_dir_entries(path,(osgbpb_string_list*)buf,
|
||||
1,c,256,0,&count,&c);
|
||||
if(e)
|
||||
{ Py_DECREF(d);return riscos_oserror();
|
||||
}
|
||||
if(count)
|
||||
{ v=PyString_FromString(buf);
|
||||
if(!v) { Py_DECREF(d);return 0;}
|
||||
if(PyList_Append(d,v)) {Py_DECREF(d);Py_DECREF(v);return 0;}
|
||||
}
|
||||
if(c==-1) break;
|
||||
}
|
||||
return d;
|
||||
}
|
||||
|
||||
static PyObject *riscos_stat(PyObject *self,PyObject *args)
|
||||
{ char *path;
|
||||
int ob,len;
|
||||
bits t=0;
|
||||
bits ld,ex,at,ft,mode;
|
||||
if (!PyArg_Parse(args, "s", &path)) return NULL;
|
||||
e=xosfile_read_stamped_no_path(path,&ob,&ld,&ex,&len,&at,&ft);
|
||||
if(e) return riscos_oserror();
|
||||
switch (ob)
|
||||
{ case osfile_IS_FILE:mode=0100000;break; /* OCTAL */
|
||||
case osfile_IS_DIR:mode=040000;break;
|
||||
case osfile_IS_IMAGE:mode=0140000;break;
|
||||
default:return riscos_error("Not found");
|
||||
}
|
||||
if(ft!=-1) t=unixtime(ld,ex);
|
||||
mode|=(at&7)<<6;
|
||||
mode|=((at&112)*9)>>4;
|
||||
return Py_BuildValue("(lllllllllllll)",
|
||||
(long)mode,/*st_mode*/
|
||||
0,/*st_ino*/
|
||||
0,/*st_dev*/
|
||||
0,/*st_nlink*/
|
||||
0,/*st_uid*/
|
||||
0,/*st_gid*/
|
||||
(long)len,/*st_size*/
|
||||
(long)t,/*st_atime*/
|
||||
(long)t,/*st_mtime*/
|
||||
(long)t,/*st_ctime*/
|
||||
(long)ft,/*file type*/
|
||||
(long)at,/*attributes*/
|
||||
(long)ob/*object type*/
|
||||
);
|
||||
}
|
||||
|
||||
static PyObject *riscos_chmod(PyObject *self,PyObject *args)
|
||||
{ char *path;
|
||||
bits mode;
|
||||
bits attr;
|
||||
attr=(mode&0x700)>>8;
|
||||
attr|=(mode&7)<<4;
|
||||
if (!PyArg_Parse(args, "(si)", &path,(int*)&mode)) return NULL;
|
||||
e=xosfile_write_attr(path,attr);
|
||||
if(e) return riscos_oserror();
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static PyObject *riscos_utime(PyObject *self,PyObject *args)
|
||||
{ char *path;
|
||||
int x,y;
|
||||
if (!PyArg_Parse(args, "(s(ii))", &path,&x,&y)) return NULL;
|
||||
e=xosfile_stamp(path);
|
||||
if(e) return riscos_oserror();
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static PyObject *riscos_settype(PyObject *self,PyObject *args)
|
||||
{ char *path,*name;
|
||||
int type;
|
||||
if (!PyArg_Parse(args, "(si)", &path,&type))
|
||||
{ PyErr_Clear();
|
||||
if (!PyArg_Parse(args, "(ss)", &path,&name)) return NULL;
|
||||
e=xosfscontrol_file_type_from_string(name,(bits*)&type);
|
||||
if(e) return riscos_oserror();
|
||||
}
|
||||
e=xosfile_set_type(path,type);
|
||||
if(e) return riscos_oserror();
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static PyObject *riscos_getenv(PyObject *self,PyObject *args)
|
||||
{ char *name,*value;
|
||||
if(!PyArg_Parse(args,"s",&name)) return NULL;
|
||||
value=getenv(name);
|
||||
if(value) return PyString_FromString(value);
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static PyObject *riscos_putenv(PyObject *self,PyObject *args)
|
||||
{ char *name,*value;
|
||||
int len;
|
||||
os_var_type type=os_VARTYPE_LITERAL_STRING;
|
||||
if(!PyArg_ParseTuple(args,"ss|i",&name,&value,&type)) return NULL;
|
||||
if(type!=os_VARTYPE_STRING&&type!=os_VARTYPE_MACRO&&type!=os_VARTYPE_EXPANDED
|
||||
&&type!=os_VARTYPE_LITERAL_STRING)
|
||||
return riscos_error("Bad putenv type");
|
||||
len=strlen(value);
|
||||
if(type!=os_VARTYPE_LITERAL_STRING) len++;
|
||||
/* Other types need null terminator! */
|
||||
e=xos_set_var_val(name,(byte*)value,len,0,type,0,0);
|
||||
if(e) return riscos_oserror();
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static PyObject *riscos_delenv(PyObject *self,PyObject *args)
|
||||
{ char *name;
|
||||
if(!PyArg_Parse(args,"s",&name)) return NULL;
|
||||
e=xos_set_var_val(name,NULL,-1,0,0,0,0);
|
||||
if(e) return riscos_oserror();
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static PyObject *riscos_getenvdict(PyObject *self,PyObject *args)
|
||||
{ PyObject *dict;
|
||||
char value[257];
|
||||
char *which="*";
|
||||
int size;
|
||||
char *context=NULL;
|
||||
if(!PyArg_ParseTuple(args,"|s",&which)) return NULL;
|
||||
dict = PyDict_New();
|
||||
if (!dict) return NULL;
|
||||
/* XXX This part ignores errors */
|
||||
while(!xos_read_var_val(which,value,sizeof(value)-1,(int)context,
|
||||
os_VARTYPE_EXPANDED,&size,(int *)&context,0))
|
||||
{ PyObject *v;
|
||||
value[size]='\0';
|
||||
v = PyString_FromString(value);
|
||||
if (v == NULL) continue;
|
||||
PyDict_SetItemString(dict, context, v);
|
||||
Py_DECREF(v);
|
||||
}
|
||||
return dict;
|
||||
}
|
||||
|
||||
static PyMethodDef riscos_methods[] = {
|
||||
|
||||
{"unlink", riscos_remove},
|
||||
{"remove", riscos_remove},
|
||||
{"rename", riscos_rename},
|
||||
{"system", riscos_system},
|
||||
{"rmdir", riscos_remove},
|
||||
{"chdir", riscos_chdir},
|
||||
{"getcwd", riscos_getcwd},
|
||||
{"expand", riscos_expand},
|
||||
{"mkdir", riscos_mkdir,1},
|
||||
{"listdir", riscos_listdir},
|
||||
{"stat", riscos_stat},
|
||||
{"lstat", riscos_stat},
|
||||
{"chmod", riscos_chmod},
|
||||
{"utime", riscos_utime},
|
||||
{"settype", riscos_settype},
|
||||
{"getenv", riscos_getenv},
|
||||
{"putenv", riscos_putenv},
|
||||
{"delenv", riscos_delenv},
|
||||
{"getenvdict", riscos_getenvdict,1},
|
||||
{NULL, NULL} /* Sentinel */
|
||||
};
|
||||
|
||||
|
||||
|
||||
void
|
||||
initriscos()
|
||||
{
|
||||
PyObject *m, *d;
|
||||
|
||||
m = Py_InitModule("riscos", riscos_methods);
|
||||
d = PyModule_GetDict(m);
|
||||
|
||||
/* Initialize riscos.error exception */
|
||||
RiscosError = PyString_FromString("riscos.error");
|
||||
if (RiscosError == NULL || PyDict_SetItemString(d, "error", RiscosError) != 0)
|
||||
Py_FatalError("can't define riscos.error");
|
||||
}
|
|
@ -0,0 +1,431 @@
|
|||
/* swi
|
||||
|
||||
RISC OS swi functions
|
||||
|
||||
1.00 Chris Stretch
|
||||
|
||||
|
||||
1.01 12 May 1999 Laurence Tratt
|
||||
|
||||
* Changed swi.error to be a class based exception rather than string based
|
||||
* Added swi.ArgError which is generated for errors when the user passes invalid arguments to
|
||||
functions etc
|
||||
* Added "errnum" attribute to swi.error, so one can now check to see what the error number was
|
||||
*/
|
||||
|
||||
#include "h.os"
|
||||
#include "h.kernel"
|
||||
#include "Python.h"
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#define PyBlock_Check(op) ((op)->ob_type == &PyBlockType)
|
||||
|
||||
|
||||
static PyObject *SwiError; /* Exception swi.error */
|
||||
static PyObject *ArgError; /* Exception swi.ArgError */
|
||||
static os_error *e;
|
||||
|
||||
static PyObject *swi_oserror(void)
|
||||
{ PyErr_SetString(SwiError,e->errmess);
|
||||
PyObject_SetAttrString(PyErr_Occurred(), "errnum", PyInt_FromLong(e->errnum));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static PyObject *swi_error(char *s)
|
||||
{ PyErr_SetString(ArgError,s);
|
||||
return 0;
|
||||
}
|
||||
|
||||
typedef struct
|
||||
{ PyObject_HEAD
|
||||
void *block;
|
||||
int length; /*length in bytes*/
|
||||
int heap;
|
||||
} PyBlockObject;
|
||||
|
||||
static PyTypeObject PyBlockType;
|
||||
|
||||
/* block commands */
|
||||
|
||||
static PyObject *PyBlock_New(PyObject *self,PyObject *args)
|
||||
{ int size;
|
||||
PyBlockObject *b;
|
||||
PyObject *init=0;
|
||||
if(!PyArg_ParseTuple(args,"i|O",&size,&init)) return NULL;
|
||||
if(size<1) size=1;
|
||||
b=PyObject_NEW(PyBlockObject,&PyBlockType);
|
||||
if(!b) return NULL;
|
||||
b->block=malloc(4*size);
|
||||
if(!b->block)
|
||||
{ Py_DECREF(b);
|
||||
return PyErr_NoMemory();
|
||||
}
|
||||
b->length=4*size;
|
||||
b->heap=1;
|
||||
if(init)
|
||||
{ if(PyString_Check(init))
|
||||
{ int n=PyString_Size(init);
|
||||
if (n>4*size) n=4*size;
|
||||
memcpy(b->block,PyString_AsString(init),n);
|
||||
memset((char*)b->block+n,0,4*size-n);
|
||||
}
|
||||
else
|
||||
{ int n,k;
|
||||
long *p=(long*)b->block;
|
||||
if(!PyList_Check(init)) goto fail;
|
||||
n=PyList_Size(init);
|
||||
if (n>size) n=size;
|
||||
for(k=0;k<n;k++)
|
||||
{ PyObject *q=PyList_GetItem(init,k);
|
||||
if(!PyInt_Check(q)) goto fail;
|
||||
p[k]=PyInt_AsLong(q);
|
||||
}
|
||||
for(;k<size;k++) p[k]=0;
|
||||
}
|
||||
}
|
||||
return (PyObject *)b;
|
||||
fail:PyErr_SetString(PyExc_TypeError,
|
||||
"block initialiser must be string or list of integers");
|
||||
Py_DECREF(b);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static PyObject *PyRegister(PyObject *self,PyObject *args)
|
||||
{ int size,ptr;
|
||||
PyBlockObject *b;
|
||||
if(!PyArg_ParseTuple(args,"ii",&size,&ptr)) return NULL;
|
||||
if(size<1) size=1;
|
||||
b=PyObject_NEW(PyBlockObject,&PyBlockType);
|
||||
if(!b) return NULL;
|
||||
b->block=(void*)ptr;
|
||||
b->length=4*size;
|
||||
b->heap=0;
|
||||
return (PyObject *)b;
|
||||
}
|
||||
|
||||
static PyObject *PyBlock_ToString(PyBlockObject *self,PyObject *arg)
|
||||
{ int s=0,e=self->length;
|
||||
if(!PyArg_ParseTuple(arg,"|ii",&s,&e)) return NULL;
|
||||
if(s<0||e>self->length||s>e)
|
||||
{ PyErr_SetString(PyExc_IndexError,"block index out of range");
|
||||
return NULL;
|
||||
}
|
||||
return PyString_FromStringAndSize((char*)self->block+s,e-s);
|
||||
}
|
||||
|
||||
static PyObject *PyBlock_NullString(PyBlockObject *self,PyObject *arg)
|
||||
{ int s=0,e=self->length,i;
|
||||
char *p=(char*)self->block;
|
||||
if(!PyArg_ParseTuple(arg,"|ii",&s,&e)) return NULL;
|
||||
if(s<0||e>self->length||s>e)
|
||||
{ PyErr_SetString(PyExc_IndexError,"block index out of range");
|
||||
return NULL;
|
||||
}
|
||||
for(i=s;i<e;i++) if(p[i]==0) break;
|
||||
return PyString_FromStringAndSize((char*)self->block+s,i-s);
|
||||
}
|
||||
|
||||
static PyObject *PyBlock_CtrlString(PyBlockObject *self,PyObject *arg)
|
||||
{ int s=0,e=self->length,i;
|
||||
char *p=(char*)self->block;
|
||||
if(!PyArg_ParseTuple(arg,"|ii",&s,&e)) return NULL;
|
||||
if(s<0||e>self->length||s>e)
|
||||
{ PyErr_SetString(PyExc_IndexError,"block index out of range");
|
||||
return NULL;
|
||||
}
|
||||
for(i=s;i<e;i++) if(p[i]<32) break;
|
||||
return PyString_FromStringAndSize((char*)self->block+s,i-s);
|
||||
}
|
||||
|
||||
static PyObject *PyBlock_PadString(PyBlockObject *self,PyObject *arg)
|
||||
{ int s=0,e=self->length,n,m;
|
||||
char *str;
|
||||
char c;
|
||||
char *p=(char*)self->block;
|
||||
if(!PyArg_ParseTuple(arg,"s#c|ii",&str,&n,&c,&s,&e)) return NULL;
|
||||
if(s<0||e>self->length||s>e)
|
||||
{ PyErr_SetString(PyExc_IndexError,"block index out of range");
|
||||
return NULL;
|
||||
}
|
||||
m=e-s;
|
||||
if(n>m) n=m;
|
||||
memcpy(p+s,str,n);memset(p+s+n,c,m-n);
|
||||
Py_INCREF(Py_None);return Py_None;
|
||||
}
|
||||
|
||||
static PyObject *PyBlock_BitSet(PyBlockObject *self,PyObject *arg)
|
||||
{ int i,x,y;
|
||||
int *p=(int*)self->block;
|
||||
if(!PyArg_ParseTuple(arg,"iii",&i,&x,&y)) return NULL;
|
||||
if(i<0||i>=self->length/4)
|
||||
{ PyErr_SetString(PyExc_IndexError,"block index out of range");
|
||||
return NULL;
|
||||
}
|
||||
p[i]=(p[i]&y)^x;
|
||||
Py_INCREF(Py_None);return Py_None;
|
||||
}
|
||||
|
||||
static PyObject *PyBlock_Resize(PyBlockObject *self,PyObject *arg)
|
||||
{ int n;
|
||||
if(!PyArg_ParseTuple(arg,"i",&n)) return NULL;
|
||||
if(n<1) n=1;
|
||||
if(self->heap)
|
||||
{ void *v=realloc(self->block,4*n);
|
||||
if (!v) return PyErr_NoMemory();
|
||||
self->block=v;
|
||||
}
|
||||
self->length=4*n;
|
||||
Py_INCREF(Py_None);return Py_None;
|
||||
}
|
||||
|
||||
static PyObject *PyBlock_ToFile(PyBlockObject *self,PyObject *arg)
|
||||
{ int s=0,e=self->length/4;
|
||||
PyObject *f;
|
||||
FILE *fp;
|
||||
if(!PyArg_ParseTuple(arg,"O|ii",&f,&s,&e)) return NULL;
|
||||
fp=PyFile_AsFile(f);
|
||||
if (!fp)
|
||||
{ PyErr_SetString(PyExc_TypeError, "arg must be open file");
|
||||
return NULL;
|
||||
}
|
||||
fwrite((int*)(self->block)+s,4,e-s,fp);
|
||||
Py_INCREF(Py_None);return Py_None;
|
||||
}
|
||||
|
||||
static struct PyMethodDef PyBlock_Methods[]=
|
||||
{ { "tostring",(PyCFunction)PyBlock_ToString,1},
|
||||
{ "padstring",(PyCFunction)PyBlock_PadString,1},
|
||||
{ "nullstring",(PyCFunction)PyBlock_NullString,1},
|
||||
{ "ctrlstring",(PyCFunction)PyBlock_CtrlString,1},
|
||||
{ "bitset",(PyCFunction)PyBlock_BitSet,1},
|
||||
{ "resize",(PyCFunction)PyBlock_Resize,1},
|
||||
{ "tofile",(PyCFunction)PyBlock_ToFile,1},
|
||||
{ NULL,NULL} /* sentinel */
|
||||
};
|
||||
|
||||
static int block_len(PyBlockObject *b)
|
||||
{ return b->length/4;
|
||||
}
|
||||
|
||||
static PyObject *block_concat(PyBlockObject *b,PyBlockObject *c)
|
||||
{ PyErr_SetString(PyExc_IndexError,"block concatenation not implemented");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static PyObject *block_repeat(PyBlockObject *b,int i)
|
||||
{ PyErr_SetString(PyExc_IndexError,"block repetition not implemented");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static PyObject *block_item(PyBlockObject *b,int i)
|
||||
{ if(i<0||4*i>=b->length)
|
||||
{ PyErr_SetString(PyExc_IndexError,"block index out of range");
|
||||
return NULL;
|
||||
}
|
||||
return PyInt_FromLong(((long*)(b->block))[i]);
|
||||
}
|
||||
|
||||
static PyObject *block_slice(PyBlockObject *b,int i,int j)
|
||||
{ int n,k;
|
||||
long *p=b->block;
|
||||
PyObject *result;
|
||||
if(j>b->length/4) j=b->length/4;
|
||||
if(i<0||i>j)
|
||||
{ PyErr_SetString(PyExc_IndexError,"block index out of range");
|
||||
return NULL;
|
||||
}
|
||||
n=j-i;
|
||||
result=PyList_New(n);
|
||||
for(k=0;k<n;k++) PyList_SetItem(result,k,PyInt_FromLong(p[i+k]));
|
||||
return result;
|
||||
}
|
||||
|
||||
static int block_ass_item(PyBlockObject *b,int i,PyObject *v)
|
||||
{ if(i<0||i>=b->length/4)
|
||||
{ PyErr_SetString(PyExc_IndexError,"block index out of range");
|
||||
return -1;
|
||||
}
|
||||
if(!PyInt_Check(v))
|
||||
{ PyErr_SetString(PyExc_TypeError,"block item must be integer");
|
||||
return -1;
|
||||
}
|
||||
((long*)(b->block))[i]=PyInt_AsLong(v);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int block_ass_slice(PyBlockObject *b,int i,int j,PyObject *v)
|
||||
{ int n,k;
|
||||
long *p=b->block;
|
||||
if(j>b->length/4) j=b->length/4;
|
||||
if(i<0||i>j)
|
||||
{ PyErr_SetString(PyExc_IndexError,"block index out of range");
|
||||
return -1;
|
||||
}
|
||||
if(!PyList_Check(v)) goto fail;
|
||||
n=PyList_Size(v);
|
||||
if(n>j-i) n=j-i;
|
||||
for(k=0;k<n;k++)
|
||||
{ PyObject *q=PyList_GetItem(v,k);
|
||||
if(!PyInt_Check(q)) goto fail;
|
||||
p[i+k]=PyInt_AsLong(q);
|
||||
}
|
||||
for(;k<j-i;k++) p[i+k]=0;
|
||||
return 0;
|
||||
fail:PyErr_SetString(PyExc_TypeError,"block slice must be integer list");
|
||||
return -1;
|
||||
}
|
||||
|
||||
static PySequenceMethods block_as_sequence=
|
||||
{ (inquiry)block_len, /*sq_length*/
|
||||
(binaryfunc)block_concat, /*sq_concat*/
|
||||
(intargfunc)block_repeat, /*sq_repeat*/
|
||||
(intargfunc)block_item, /*sq_item*/
|
||||
(intintargfunc)block_slice, /*sq_slice*/
|
||||
(intobjargproc)block_ass_item, /*sq_ass_item*/
|
||||
(intintobjargproc)block_ass_slice, /*sq_ass_slice*/
|
||||
};
|
||||
|
||||
static PyObject *PyBlock_GetAttr(PyBlockObject *s,char *name)
|
||||
{
|
||||
if (!strcmp(name, "length")) return PyInt_FromLong((long)s->length);
|
||||
if (!strcmp(name, "start")) return PyInt_FromLong((long)s->block);
|
||||
if (!strcmp(name,"end")) return PyInt_FromLong(((long)(s->block)+s->length));
|
||||
if (!strcmp(name, "__members__"))
|
||||
{ PyObject *list = PyList_New(3);
|
||||
if (list)
|
||||
{ PyList_SetItem(list, 0, PyString_FromString("length"));
|
||||
PyList_SetItem(list, 1, PyString_FromString("start"));
|
||||
PyList_SetItem(list, 2, PyString_FromString("end"));
|
||||
if (PyErr_Occurred()) { Py_DECREF(list);list = NULL;}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
return Py_FindMethod(PyBlock_Methods, (PyObject*) s,name);
|
||||
}
|
||||
|
||||
static void PyBlock_Dealloc(PyBlockObject *b)
|
||||
{
|
||||
if(b->heap) {
|
||||
if (b->heap)
|
||||
;
|
||||
else
|
||||
PyMem_DEL(b->block);
|
||||
}
|
||||
PyMem_DEL(b);
|
||||
}
|
||||
|
||||
static PyTypeObject PyBlockType=
|
||||
{ PyObject_HEAD_INIT(&PyType_Type)
|
||||
0, /*ob_size*/
|
||||
"block", /*tp_name*/
|
||||
sizeof(PyBlockObject), /*tp_size*/
|
||||
0, /*tp_itemsize*/
|
||||
/* methods */
|
||||
(destructor)PyBlock_Dealloc, /*tp_dealloc*/
|
||||
0, /*tp_print*/
|
||||
(getattrfunc)PyBlock_GetAttr, /*tp_getattr*/
|
||||
0, /*tp_setattr*/
|
||||
0, /*tp_compare*/
|
||||
0, /*tp_repr*/
|
||||
0, /*tp_as_number*/
|
||||
&block_as_sequence, /*tp_as_sequence*/
|
||||
0, /*tp_as_mapping*/
|
||||
0, /*tp_hash*/
|
||||
};
|
||||
|
||||
/* swi commands */
|
||||
|
||||
static PyObject *swi_swi(PyObject *self,PyObject *args)
|
||||
{ PyObject *name,*format,*result,*v;
|
||||
int swino,carry,rno=0,j,n;
|
||||
char *swiname,*fmt,*outfmt;
|
||||
_kernel_swi_regs r;
|
||||
PyBlockObject *ao;
|
||||
if(args==NULL||!PyTuple_Check(args)||(n=PyTuple_Size(args))<2)
|
||||
{ PyErr_BadArgument(); return NULL;}
|
||||
name=PyTuple_GetItem(args,0);
|
||||
if(!PyArg_Parse(name,"i",&swino))
|
||||
{ PyErr_Clear();
|
||||
if(!PyArg_Parse(name,"s",&swiname)) return NULL;
|
||||
e=xos_swi_number_from_string(swiname,&swino);
|
||||
if(e) return swi_oserror();
|
||||
}
|
||||
format=PyTuple_GetItem(args,1);
|
||||
if(!PyArg_Parse(format,"s",&fmt)) return NULL;
|
||||
j=2;
|
||||
for(;;fmt++)
|
||||
{ switch(*fmt)
|
||||
{ case '.': rno++;continue;
|
||||
case ';':case 0: goto swicall;
|
||||
case '0':case '1':case '2':case '3':case '4':
|
||||
case '5':case '6':case '7':case '8':case '9':
|
||||
r.r[rno++]=*fmt-'0';continue;
|
||||
case '-':r.r[rno++]=-1;continue;
|
||||
}
|
||||
if(j>=n) return swi_error("Too few arguments");
|
||||
v=PyTuple_GetItem(args,j++);
|
||||
switch(*fmt)
|
||||
{ case 'i':if(!PyArg_Parse(v,"i",&r.r[rno])) return NULL;
|
||||
break;
|
||||
case 's':if(!PyArg_Parse(v,"s",(char**)(&r.r[rno]))) return NULL;
|
||||
break;
|
||||
case 'b':if(!PyArg_Parse(v,"O",(PyObject**)&ao)) return NULL;
|
||||
if(!PyBlock_Check(v)) return swi_error("Not a block");
|
||||
r.r[rno]=(int)(ao->block);
|
||||
break;
|
||||
case 'e':if(!PyArg_Parse(v,"O",(PyObject**)&ao)) return NULL;
|
||||
if(!PyBlock_Check(v)) return swi_error("Not a block");
|
||||
r.r[rno]=(int)(ao->block)+ao->length;
|
||||
break;
|
||||
default:return swi_error("Odd format character");
|
||||
}
|
||||
rno++;
|
||||
}
|
||||
swicall:e=(os_error*)_kernel_swi_c(swino,&r,&r,&carry);
|
||||
if(e) return swi_oserror();
|
||||
if(*fmt==0) { Py_INCREF(Py_None);return Py_None;}
|
||||
n=0;
|
||||
for(outfmt=++fmt;*outfmt;outfmt++) switch(*outfmt)
|
||||
{ case 'i':case 's':case '*':n++;break;
|
||||
case '.':break;
|
||||
default:return swi_error("Odd format character");
|
||||
}
|
||||
if(n==0) { Py_INCREF(Py_None);return Py_None;}
|
||||
if(n!=1)
|
||||
{ result=PyTuple_New(n);
|
||||
if(!result) return NULL;
|
||||
}
|
||||
rno=0;j=0;
|
||||
for(;*fmt;fmt++)
|
||||
{ switch(*fmt)
|
||||
{ case 'i':v=PyInt_FromLong((long)r.r[rno++]); break;
|
||||
case 's':v=PyString_FromString((char*)(r.r[rno++])); break;
|
||||
case '.':rno++; continue;
|
||||
case '*':v=PyInt_FromLong((long)carry); break;
|
||||
}
|
||||
if(!v) goto fail;
|
||||
if(n==1) return v;
|
||||
PyTuple_SetItem(result,j,v);
|
||||
j++;
|
||||
}
|
||||
return result;
|
||||
fail:Py_DECREF(result);return 0;
|
||||
}
|
||||
|
||||
static PyMethodDef SwiMethods[]=
|
||||
{ { "swi",swi_swi,1},
|
||||
{ "block",PyBlock_New,1},
|
||||
{ "register",PyRegister,1},
|
||||
{ NULL,NULL} /* Sentinel */
|
||||
};
|
||||
|
||||
void initswi()
|
||||
{ PyObject *m, *d;
|
||||
m = Py_InitModule("swi", SwiMethods);
|
||||
d = PyModule_GetDict(m);
|
||||
SwiError=PyErr_NewException("swi.error", NULL, NULL);
|
||||
PyDict_SetItemString(d,"error",SwiError);
|
||||
ArgError=PyErr_NewException("swi.ArgError", NULL, NULL);
|
||||
PyDict_SetItemString(d,"ArgError",ArgError);
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
/***********************************************************
|
||||
Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam,
|
||||
The Netherlands.
|
||||
|
||||
All Rights Reserved
|
||||
|
||||
Permission to use, copy, modify, and distribute this software and its
|
||||
documentation for any purpose and without fee is hereby granted,
|
||||
provided that the above copyright notice appear in all copies and that
|
||||
both that copyright notice and this permission notice appear in
|
||||
supporting documentation, and that the names of Stichting Mathematisch
|
||||
Centrum or CWI or Corporation for National Research Initiatives or
|
||||
CNRI not be used in advertising or publicity pertaining to
|
||||
distribution of the software without specific, written prior
|
||||
permission.
|
||||
|
||||
While CWI is the initial source for this software, a modified version
|
||||
is made available by the Corporation for National Research Initiatives
|
||||
(CNRI) at the Internet address ftp://ftp.python.org.
|
||||
|
||||
STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH
|
||||
REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH
|
||||
CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
|
||||
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
******************************************************************/
|
||||
|
||||
/* This module provides the necessary stubs for when dynamic loading is
|
||||
not present. */
|
||||
|
||||
#include "Python.h"
|
||||
#include "importdl.h"
|
||||
|
||||
#include "dlk.h"
|
||||
|
||||
|
||||
const struct filedescr _PyImport_DynLoadFiletab[] = {
|
||||
{"/pyd", "rb", C_EXTENSION},
|
||||
{0, 0}
|
||||
};
|
||||
|
||||
void dynload_init_dummy()
|
||||
{
|
||||
}
|
||||
|
||||
dl_funcptr _PyImport_GetDynLoadFunc(const char *fqname, const char *shortname,
|
||||
char *pathname, FILE *fp)
|
||||
{
|
||||
int err;
|
||||
char errstr[256];
|
||||
|
||||
err = dlk_load(pathname);
|
||||
if (err)
|
||||
{
|
||||
sprintf(errstr, "dlk failure %d", err);
|
||||
PyErr_SetString(PyExc_ImportError, errstr);
|
||||
}
|
||||
return dynload_init_dummy;
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
char *getcwd(char *buf, int size)
|
||||
{
|
||||
buf[0] = '\0';
|
||||
return buf;
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
#include <stdio.h>
|
||||
|
||||
#define __swi
|
||||
#include "osfile.h"
|
||||
|
||||
long PyOS_GetLastModificationTime(char *path, FILE *fp)
|
||||
{
|
||||
int obj;
|
||||
bits load, exec, ftype;
|
||||
|
||||
if (xosfile_read_stamped_no_path(path, &obj, &load, &exec, 0, 0, &ftype)) return -1;
|
||||
if (obj != osfile_IS_FILE) return -1;
|
||||
if (ftype == osfile_TYPE_UNTYPED) return -1;
|
||||
|
||||
load &= 0xFF;
|
||||
load -= 51;
|
||||
if (exec < 1855548004U) load--;
|
||||
exec -= 1855548004U;
|
||||
return exec/100+42949672*load+(95*load)/100;
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
This directory contains files for the RISC OS port of Python.
|
||||
For more information about RISC OS see http://www.riscos.com/ .
|
||||
|
||||
This port is currently being maintained by Dietmar Schwertberger,
|
||||
dietmar@schwertberger.de .
|
||||
|
||||
On http://www.schwertberger.de you may find compiled versions and libraries
|
||||
as well as RISC OS specific documentation and extensions.
|
||||
|
||||
|
||||
==========================================================================
|
||||
Compiling:
|
||||
|
||||
1. Extract Files from archive directory 'Python-...' to a directory named
|
||||
'!Python'.
|
||||
2. Use a tool like Rename to change filenames from '*/[ch]' into '[ch].*'.
|
||||
3. Create missing directories with 'amu cdirs'.
|
||||
4. Build with 'amu'.
|
||||
|
||||
I've only tested Acorn C/C++ 5.06 and amu.
|
||||
|
||||
|
||||
You will also need some additional libraries:
|
||||
|
||||
DLK
|
||||
ftp://ftp.infc.ulst.ac.uk/pub/users/chris/
|
||||
OSLib
|
||||
http://www.mk-net.demon.co.uk/oslib
|
||||
|
||||
zlib (optional)
|
||||
ftp://ftp.freesoftware.com/pub/infozip/zlib/
|
||||
sockets (optional)
|
||||
http://www.mirror.ac.uk/sites/ftp.acorn.co.uk/pub/riscos/releases/networking/tcpip/sockets.arc
|
||||
expat (optional)
|
||||
http://sourceforge.net/projects/expat/
|
||||
(makefile and config.h available from http://www.schwertberger.de/riscos_expat.zip
|
|
@ -0,0 +1,488 @@
|
|||
/* config.h.in. Generated automatically from configure.in by autoheader. */
|
||||
|
||||
/* Define if on AIX 3.
|
||||
System headers sometimes define this.
|
||||
We just want to avoid a redefinition error message. */
|
||||
#ifndef _ALL_SOURCE
|
||||
#undef _ALL_SOURCE
|
||||
#endif
|
||||
|
||||
/* Define if type char is unsigned and you are not using gcc. */
|
||||
#undef __CHAR_UNSIGNED__
|
||||
|
||||
/* Define to empty if the keyword does not work. */
|
||||
#undef const
|
||||
|
||||
/* Define to `int' if <sys/types.h> doesn't define. */
|
||||
#define gid_t int
|
||||
|
||||
/* Define if your struct tm has tm_zone. */
|
||||
#undef HAVE_TM_ZONE
|
||||
|
||||
/* Define if you don't have tm_zone but do have the external array
|
||||
tzname. */
|
||||
#undef HAVE_TZNAME
|
||||
|
||||
/* Define if on MINIX. */
|
||||
#undef _MINIX
|
||||
|
||||
/* Define to `int' if <sys/types.h> doesn't define. */
|
||||
#define mode_t int
|
||||
|
||||
/* Define to `long' if <sys/types.h> doesn't define. */
|
||||
#define off_t long
|
||||
|
||||
/* Define to `int' if <sys/types.h> doesn't define. */
|
||||
#define pid_t int
|
||||
|
||||
/* Define if the system does not provide POSIX.1 features except
|
||||
with this defined. */
|
||||
#undef _POSIX_1_SOURCE
|
||||
|
||||
/* Define if you need to in order for stat and other things to work. */
|
||||
#undef _POSIX_SOURCE
|
||||
|
||||
/* Define as the return type of signal handlers (int or void). */
|
||||
#define RETSIGTYPE void
|
||||
|
||||
/* Define to `unsigned' if <sys/types.h> doesn't define. */
|
||||
#undef size_t
|
||||
|
||||
/* Define if you have the ANSI C header files. */
|
||||
#define STDC_HEADERS 1
|
||||
|
||||
/* Define if you can safely include both <sys/time.h> and <time.h>. */
|
||||
#undef TIME_WITH_SYS_TIME
|
||||
|
||||
/* Define if your <sys/time.h> declares struct tm. */
|
||||
#define TM_IN_SYS_TIME 1
|
||||
|
||||
/* Define to `int' if <sys/types.h> doesn't define. */
|
||||
#define uid_t int
|
||||
|
||||
/* Define if your <unistd.h> contains bad prototypes for exec*()
|
||||
(as it does on SGI IRIX 4.x) */
|
||||
#undef BAD_EXEC_PROTOTYPES
|
||||
|
||||
/* Define if your compiler botches static forward declarations
|
||||
(as it does on SCI ODT 3.0) */
|
||||
#undef BAD_STATIC_FORWARD
|
||||
|
||||
/* Define this if you have BeOS threads */
|
||||
#undef BEOS_THREADS
|
||||
|
||||
/* Define if you have the Mach cthreads package */
|
||||
#undef C_THREADS
|
||||
|
||||
/* Define to `long' if <time.h> doesn't define. */
|
||||
#undef clock_t
|
||||
|
||||
/* Used for BeOS configuration */
|
||||
#undef DL_EXPORT_HEADER
|
||||
#ifdef DL_EXPORT_HEADER
|
||||
#include DL_EXPORT_HEADER
|
||||
#endif
|
||||
|
||||
/* Define if getpgrp() must be called as getpgrp(0). */
|
||||
#undef GETPGRP_HAVE_ARG
|
||||
|
||||
/* Define if gettimeofday() does not have second (timezone) argument
|
||||
This is the case on Motorola V4 (R40V4.2) */
|
||||
#undef GETTIMEOFDAY_NO_TZ
|
||||
|
||||
/* Define this if your time.h defines altzone */
|
||||
#undef HAVE_ALTZONE
|
||||
|
||||
/* Define this if you have some version of gethostbyname_r() */
|
||||
#undef HAVE_GETHOSTBYNAME_R
|
||||
|
||||
/* Define this if you have the 3-arg version of gethostbyname_r() */
|
||||
#undef HAVE_GETHOSTBYNAME_R_3_ARG
|
||||
|
||||
/* Define this if you have the 5-arg version of gethostbyname_r() */
|
||||
#undef HAVE_GETHOSTBYNAME_R_5_ARG
|
||||
|
||||
/* Define this if you have the 6-arg version of gethostbyname_r() */
|
||||
#undef HAVE_GETHOSTBYNAME_R_6_ARG
|
||||
|
||||
/* Define this if you have the type long long */
|
||||
#undef HAVE_LONG_LONG
|
||||
|
||||
/* Define this if you have a K&R style C preprocessor */
|
||||
#undef HAVE_OLD_CPP
|
||||
|
||||
/* Define if your compiler supports function prototypes */
|
||||
#define HAVE_PROTOTYPES 1
|
||||
|
||||
/* Define if your compiler supports variable length function prototypes
|
||||
(e.g. void fprintf(FILE *, char *, ...);) *and* <stdarg.h> */
|
||||
#define HAVE_STDARG_PROTOTYPES 1
|
||||
|
||||
/* Define if malloc(0) returns a NULL pointer */
|
||||
#undef MALLOC_ZERO_RETURNS_NULL
|
||||
|
||||
/* Define if you have POSIX threads */
|
||||
#undef _POSIX_THREADS
|
||||
|
||||
/* Define to force use of thread-safe errno, h_errno, and other functions */
|
||||
#undef _REENTRANT
|
||||
|
||||
/* Define if setpgrp() must be called as setpgrp(0, 0). */
|
||||
#undef SETPGRP_HAVE_ARG
|
||||
|
||||
/* Define to empty if the keyword does not work. */
|
||||
#undef signed
|
||||
|
||||
/* Define if you can safely include both <sys/select.h> and <sys/time.h>
|
||||
(which you can't on SCO ODT 3.0). */
|
||||
#undef SYS_SELECT_WITH_SYS_TIME
|
||||
|
||||
/* Define if a va_list is an array of some kind */
|
||||
#define VA_LIST_IS_ARRAY 1
|
||||
|
||||
/* Define to empty if the keyword does not work. */
|
||||
#undef volatile
|
||||
|
||||
/* Define if you want SIGFPE handled (see Include/pyfpe.h). */
|
||||
#undef WANT_SIGFPE_HANDLER
|
||||
|
||||
/* Define if you want to use SGI (IRIX 4) dynamic linking.
|
||||
This requires the "dl" library by Jack Jansen,
|
||||
ftp://ftp.cwi.nl/pub/dynload/dl-1.6.tar.Z.
|
||||
Don't bother on IRIX 5, it already has dynamic linking using SunOS
|
||||
style shared libraries */
|
||||
#undef WITH_SGI_DL
|
||||
|
||||
/* Define if you want to emulate SGI (IRIX 4) dynamic linking.
|
||||
This is rumoured to work on VAX (Ultrix), Sun3 (SunOS 3.4),
|
||||
Sequent Symmetry (Dynix), and Atari ST.
|
||||
This requires the "dl-dld" library,
|
||||
ftp://ftp.cwi.nl/pub/dynload/dl-dld-1.1.tar.Z,
|
||||
as well as the "GNU dld" library,
|
||||
ftp://ftp.cwi.nl/pub/dynload/dld-3.2.3.tar.Z.
|
||||
Don't bother on SunOS 4 or 5, they already have dynamic linking using
|
||||
shared libraries */
|
||||
#undef WITH_DL_DLD
|
||||
|
||||
/* Define if you want to use the new-style (Openstep, Rhapsody, MacOS)
|
||||
dynamic linker (dyld) instead of the old-style (NextStep) dynamic
|
||||
linker (rld). Dyld is necessary to support frameworks. */
|
||||
#undef WITH_DYLD
|
||||
|
||||
/* Define if you want to compile in rudimentary thread support */
|
||||
#undef WITH_THREAD
|
||||
|
||||
/* Define if you want to produce an OpenStep/Rhapsody framework
|
||||
(shared library plus accessory files). */
|
||||
#undef WITH_NEXT_FRAMEWORK
|
||||
|
||||
/* The number of bytes in an off_t. */
|
||||
#undef SIZEOF_OFF_T
|
||||
|
||||
/* Defined to enable large file support when an off_t is bigger than a long
|
||||
and long long is available and at least as big as an off_t. You may need
|
||||
to add some flags for configuration and compilation to enable this mode.
|
||||
E.g, for Solaris 2.7:
|
||||
CFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64" OPT="-O2 $CFLAGS" \
|
||||
configure
|
||||
*/
|
||||
#undef HAVE_LARGEFILE_SUPPORT
|
||||
|
||||
/* The number of bytes in a time_t. */
|
||||
#define SIZEOF_TIME_T 4
|
||||
|
||||
/* The number of bytes in a int. */
|
||||
#define SIZEOF_INT 4
|
||||
|
||||
/* The number of bytes in a long. */
|
||||
#define SIZEOF_LONG 4
|
||||
|
||||
/* The number of bytes in a long long. */
|
||||
#undef SIZEOF_LONG_LONG
|
||||
|
||||
/* The number of bytes in a void *. */
|
||||
#define SIZEOF_VOID_P 4
|
||||
|
||||
/* Define if you have the alarm function. */
|
||||
#undef HAVE_ALARM
|
||||
|
||||
/* Define if you have the chown function. */
|
||||
#undef HAVE_CHOWN
|
||||
|
||||
/* Define if you have the clock function. */
|
||||
#define HAVE_CLOCK 1
|
||||
|
||||
/* Define if you have the dlopen function. */
|
||||
#undef HAVE_DLOPEN
|
||||
|
||||
/* Define if you have the dup2 function. */
|
||||
#undef HAVE_DUP2
|
||||
|
||||
/* Define if you have the execv function. */
|
||||
#undef HAVE_EXECV
|
||||
|
||||
/* Define if you have the fdatasync function. */
|
||||
#undef HAVE_FDATASYNC
|
||||
|
||||
/* Define if you have the flock function. */
|
||||
#undef HAVE_FLOCK
|
||||
|
||||
/* Define if you have the fork function. */
|
||||
#undef HAVE_FORK
|
||||
|
||||
/* Define if you have the fseek64 function. */
|
||||
#undef HAVE_FSEEK64
|
||||
|
||||
/* Define if you have the fseeko function. */
|
||||
#undef HAVE_FSEEKO
|
||||
|
||||
/* Define if you have the fstatvfs function. */
|
||||
#undef HAVE_FSTATVFS
|
||||
|
||||
/* Define if you have the fsync function. */
|
||||
#undef HAVE_FSYNC
|
||||
|
||||
/* Define if you have the ftell64 function. */
|
||||
#undef HAVE_FTELL64
|
||||
|
||||
/* Define if you have the ftello function. */
|
||||
#undef HAVE_FTELLO
|
||||
|
||||
/* Define if you have the ftime function. */
|
||||
#undef HAVE_FTIME
|
||||
|
||||
/* Define if you have the ftruncate function. */
|
||||
#undef HAVE_FTRUNCATE
|
||||
|
||||
/* Define if you have the getcwd function. */
|
||||
#undef HAVE_GETCWD
|
||||
|
||||
/* Define if you have the getpeername function. */
|
||||
#undef HAVE_GETPEERNAME
|
||||
|
||||
/* Define if you have the getpgrp function. */
|
||||
#undef HAVE_GETPGRP
|
||||
|
||||
/* Define if you have the getpid function. */
|
||||
#undef HAVE_GETPID
|
||||
|
||||
/* Define if you have the getpwent function. */
|
||||
#undef HAVE_GETPWENT
|
||||
|
||||
/* Define if you have the gettimeofday function. */
|
||||
#undef HAVE_GETTIMEOFDAY
|
||||
|
||||
/* Define if you have the getwd function. */
|
||||
#undef HAVE_GETWD
|
||||
|
||||
/* Define if you have the hypot function. */
|
||||
#undef HAVE_HYPOT
|
||||
|
||||
/* Define if you have the kill function. */
|
||||
#undef HAVE_KILL
|
||||
|
||||
/* Define if you have the link function. */
|
||||
#undef HAVE_LINK
|
||||
|
||||
/* Define if you have the lstat function. */
|
||||
#undef HAVE_LSTAT
|
||||
|
||||
/* Define if you have the memmove function. */
|
||||
#define HAVE_MEMMOVE 1
|
||||
|
||||
/* Define if you have the mkfifo function. */
|
||||
#undef HAVE_MKFIFO
|
||||
|
||||
/* Define if you have the mktime function. */
|
||||
#define HAVE_MKTIME 1
|
||||
|
||||
/* Define if you have the nice function. */
|
||||
#undef HAVE_NICE
|
||||
|
||||
/* Define if you have the pause function. */
|
||||
#undef HAVE_PAUSE
|
||||
|
||||
/* Define if you have the plock function. */
|
||||
#undef HAVE_PLOCK
|
||||
|
||||
/* Define if you have the pthread_init function. */
|
||||
#undef HAVE_PTHREAD_INIT
|
||||
|
||||
/* Define if you have the putenv function. */
|
||||
#undef HAVE_PUTENV
|
||||
|
||||
/* Define if you have the readlink function. */
|
||||
#undef HAVE_READLINK
|
||||
|
||||
/* Define if you have the select function. */
|
||||
#undef HAVE_SELECT
|
||||
|
||||
/* Define if you have the setgid function. */
|
||||
#undef HAVE_SETGID
|
||||
|
||||
/* Define if you have the setlocale function. */
|
||||
#undef HAVE_SETLOCALE
|
||||
|
||||
/* Define if you have the setpgid function. */
|
||||
#undef HAVE_SETPGID
|
||||
|
||||
/* Define if you have the setpgrp function. */
|
||||
#undef HAVE_SETPGRP
|
||||
|
||||
/* Define if you have the setsid function. */
|
||||
#undef HAVE_SETSID
|
||||
|
||||
/* Define if you have the setuid function. */
|
||||
#undef HAVE_SETUID
|
||||
|
||||
/* Define if you have the setvbuf function. */
|
||||
#undef HAVE_SETVBUF
|
||||
|
||||
/* Define if you have the sigaction function. */
|
||||
#undef HAVE_SIGACTION
|
||||
|
||||
/* Define if you have the siginterrupt function. */
|
||||
#undef HAVE_SIGINTERRUPT
|
||||
|
||||
/* Define if you have the sigrelse function. */
|
||||
#undef HAVE_SIGRELSE
|
||||
|
||||
/* Define if you have the statvfs function. */
|
||||
#undef HAVE_STATVFS
|
||||
|
||||
/* Define if you have the strdup function. */
|
||||
#undef HAVE_STRDUP
|
||||
|
||||
/* Define if you have the strerror function. */
|
||||
#define HAVE_STRERROR 1
|
||||
|
||||
/* Define if you have the strftime function. */
|
||||
#define HAVE_STRFTIME 1
|
||||
|
||||
/* Define if you have the strptime function. */
|
||||
#undef HAVE_STRPTIME
|
||||
|
||||
/* Define if you have the symlink function. */
|
||||
#undef HAVE_SYMLINK
|
||||
|
||||
/* Define if you have the tcgetpgrp function. */
|
||||
#undef HAVE_TCGETPGRP
|
||||
|
||||
/* Define if you have the tcsetpgrp function. */
|
||||
#undef HAVE_TCSETPGRP
|
||||
|
||||
/* Define if you have the timegm function. */
|
||||
#undef HAVE_TIMEGM
|
||||
|
||||
/* Define if you have the times function. */
|
||||
#undef HAVE_TIMES
|
||||
|
||||
/* Define if you have the truncate function. */
|
||||
#undef HAVE_TRUNCATE
|
||||
|
||||
/* Define if you have the uname function. */
|
||||
#undef HAVE_UNAME
|
||||
|
||||
/* Define if you have the waitpid function. */
|
||||
#undef HAVE_WAITPID
|
||||
|
||||
/* Define if you have the <dirent.h> header file. */
|
||||
#undef HAVE_DIRENT_H
|
||||
|
||||
/* Define if you have the <dlfcn.h> header file. */
|
||||
#undef HAVE_DLFCN_H
|
||||
|
||||
/* Define if you have the <fcntl.h> header file. */
|
||||
#undef HAVE_FCNTL_H
|
||||
|
||||
/* Define if you have the <limits.h> header file. */
|
||||
#define HAVE_LIMITS_H 1
|
||||
|
||||
/* Define if you have the <locale.h> header file. */
|
||||
#define HAVE_LOCALE_H 1
|
||||
|
||||
/* Define if you have the <ncurses.h> header file. */
|
||||
#undef HAVE_NCURSES_H
|
||||
|
||||
/* Define if you have the <ndir.h> header file. */
|
||||
#undef HAVE_NDIR_H
|
||||
|
||||
/* Define if you have the <pthread.h> header file. */
|
||||
#undef HAVE_PTHREAD_H
|
||||
|
||||
/* Define if you have the <signal.h> header file. */
|
||||
#define HAVE_SIGNAL_H 1
|
||||
|
||||
/* Define if you have the <stdarg.h> header file. */
|
||||
#define HAVE_STDARG_H 1
|
||||
|
||||
/* Define if you have the <stddef.h> header file. */
|
||||
#define HAVE_STDDEF_H 1
|
||||
|
||||
/* Define if you have the <stdlib.h> header file. */
|
||||
#define HAVE_STDLIB_H 1
|
||||
|
||||
/* Define if you have the <sys/audioio.h> header file. */
|
||||
#undef HAVE_SYS_AUDIOIO_H
|
||||
|
||||
/* Define if you have the <sys/dir.h> header file. */
|
||||
#undef HAVE_SYS_DIR_H
|
||||
|
||||
/* Define if you have the <sys/file.h> header file. */
|
||||
#undef HAVE_SYS_FILE_H
|
||||
|
||||
/* Define if you have the <sys/lock.h> header file. */
|
||||
#undef HAVE_SYS_LOCK_H
|
||||
|
||||
/* Define if you have the <sys/ndir.h> header file. */
|
||||
#undef HAVE_SYS_NDIR_H
|
||||
|
||||
/* Define if you have the <sys/param.h> header file. */
|
||||
#undef HAVE_SYS_PARAM_H
|
||||
|
||||
/* Define if you have the <sys/select.h> header file. */
|
||||
#undef HAVE_SYS_SELECT_H
|
||||
|
||||
/* Define if you have the <sys/time.h> header file. */
|
||||
#undef HAVE_SYS_TIME_H
|
||||
|
||||
/* Define if you have the <sys/times.h> header file. */
|
||||
#undef HAVE_SYS_TIMES_H
|
||||
|
||||
/* Define if you have the <sys/un.h> header file. */
|
||||
#undef HAVE_SYS_UN_H
|
||||
|
||||
/* Define if you have the <sys/utsname.h> header file. */
|
||||
#undef HAVE_SYS_UTSNAME_H
|
||||
|
||||
/* Define if you have the <sys/wait.h> header file. */
|
||||
#undef HAVE_SYS_WAIT_H
|
||||
|
||||
/* Define if you have the <thread.h> header file. */
|
||||
#undef HAVE_THREAD_H
|
||||
|
||||
/* Define if you have the <unistd.h> header file. */
|
||||
#undef HAVE_UNISTD_H
|
||||
|
||||
/* Define if you have the <utime.h> header file. */
|
||||
#undef HAVE_UTIME_H
|
||||
|
||||
/* Define if you have the dl library (-ldl). */
|
||||
#undef HAVE_LIBDL
|
||||
|
||||
/* Define if you have the dld library (-ldld). */
|
||||
#undef HAVE_LIBDLD
|
||||
|
||||
/* Define if you have the ieee library (-lieee). */
|
||||
#undef HAVE_LIBIEEE
|
||||
|
||||
#define DONT_HAVE_SYS_TYPES_H 1
|
||||
|
||||
#define DONT_HAVE_FSTAT 1
|
||||
#define DONT_HAVE_STAT 1
|
||||
#define DONT_HAVE_SYS_STAT_H 1
|
||||
|
||||
#define PLATFORM "RISCOS"
|
||||
|
||||
#define socklen_t int
|
||||
#define HAVE_DYNAMIC_LOADING
|
|
@ -0,0 +1,62 @@
|
|||
/* Fudge unix isatty and fileno for RISCOS */
|
||||
|
||||
#include "h.unixstuff"
|
||||
#include <math.h>
|
||||
#include "h.osfile"
|
||||
|
||||
int fileno(FILE *f)
|
||||
{ return (int)f;
|
||||
}
|
||||
|
||||
int isatty(int fn)
|
||||
{ return (fn==fileno(stdin));
|
||||
}
|
||||
|
||||
bits unixtime(bits ld,bits ex)
|
||||
{ ld&=0xFF;
|
||||
ld-=51;
|
||||
if(ex<1855548004U) ld--;
|
||||
ex-=1855548004U;
|
||||
return ex/100+42949672*ld+(95*ld)/100;
|
||||
}
|
||||
|
||||
int unlink(char *fname)
|
||||
{ remove(fname);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*#define RET(k) {printf(" %d\n",k);return k;}*/
|
||||
#define RET(k) return k
|
||||
|
||||
int isdir(char *fn)
|
||||
{ int ob;
|
||||
/* printf("isdir %s",fn);*/
|
||||
if(xosfile_read_stamped_no_path(fn,&ob,0,0,0,0,0)) RET(0);
|
||||
switch (ob)
|
||||
{ case osfile_IS_DIR:RET(1);
|
||||
case osfile_IS_IMAGE:RET(1);
|
||||
}
|
||||
RET(0);
|
||||
}
|
||||
|
||||
int isfile(char *fn)
|
||||
{ int ob; /*printf("isfile %s",fn);*/
|
||||
if(xosfile_read_stamped_no_path(fn,&ob,0,0,0,0,0)) RET(0);
|
||||
switch (ob)
|
||||
{ case osfile_IS_FILE:RET(1);
|
||||
case osfile_IS_IMAGE:RET(1);
|
||||
}
|
||||
RET(0);
|
||||
}
|
||||
|
||||
int exists(char *fn)
|
||||
{ int ob; /*printf("exists %s",fn);*/
|
||||
if(xosfile_read_stamped_no_path(fn,&ob,0,0,0,0,0)) RET(0);
|
||||
switch (ob)
|
||||
{ case osfile_IS_FILE:RET(1);
|
||||
case osfile_IS_DIR:RET(1);
|
||||
case osfile_IS_IMAGE:RET(1);
|
||||
}
|
||||
RET(0);
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
/* Fudge unix isatty and fileno for RISCOS */
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int fileno(FILE *f);
|
||||
int isatty(int fn);
|
||||
unsigned int unixtime(unsigned int ld,unsigned int ex);
|
||||
/*long PyOS_GetLastModificationTime(char *name);*/
|
||||
int unlink(char *fname);
|
||||
int isdir(char *fn);
|
||||
int isfile(char *fn);
|
||||
int exists(char *fn);
|
||||
|
Loading…
Reference in New Issue