* Added gmtime/localtime/mktime and SYSV timezone globals to timemodule.c.

Added $(SYSDEF) to its build rule in Makefile.
* cgensupport.[ch], modsupport.[ch]: removed some old stuff.  Also
  changed files that still used it...  And made several things static
  that weren't but should have been...  And other minor cleanups...
* listobject.[ch]: add external interfaces {set,get}listslice
* socketmodule.c: fix bugs in new send() argument parsing.
* sunaudiodevmodule.c: added flush() and close().
This commit is contained in:
Guido van Rossum 1993-06-17 12:35:49 +00:00
parent 6a0e2282c3
commit 234f942aef
33 changed files with 299 additions and 124 deletions

View file

@ -29,8 +29,7 @@ typedef char *string;
#define mknewlongobject(x) newintobject(x) #define mknewlongobject(x) newintobject(x)
#define mknewshortobject(x) newintobject((long)x) #define mknewshortobject(x) newintobject((long)x)
#define mknewfloatobject(x) newfloatobject(x) #define mknewfloatobject(x) newfloatobject(x)
#define mknewcharobject(c) mkvalue("c", c)
extern object *mknewcharobject PROTO((int c));
extern int getiobjectarg PROTO((object *args, int nargs, int i, object **p_a)); extern int getiobjectarg PROTO((object *args, int nargs, int i, object **p_a));
extern int getilongarg PROTO((object *args, int nargs, int i, long *p_a)); extern int getilongarg PROTO((object *args, int nargs, int i, long *p_a));

View file

@ -53,6 +53,8 @@ extern object *getlistitem PROTO((object *, int));
extern int setlistitem PROTO((object *, int, object *)); extern int setlistitem PROTO((object *, int, object *));
extern int inslistitem PROTO((object *, int, object *)); extern int inslistitem PROTO((object *, int, object *));
extern int addlistitem PROTO((object *, object *)); extern int addlistitem PROTO((object *, object *));
extern object *getlistslice PROTO((object *, int, int));
extern int setlistslice PROTO((object *, int, int, object *));
extern int sortlist PROTO((object *)); extern int sortlist PROTO((object *));
/* Macro, trading safety for speed */ /* Macro, trading safety for speed */

View file

@ -40,29 +40,8 @@ extern int vgetargs PROTO((object *, char *, va_list));
extern object *mkvalue PROTO((char *, ...)); extern object *mkvalue PROTO((char *, ...));
extern object *vmkvalue PROTO((char *, va_list)); extern object *vmkvalue PROTO((char *, va_list));
/* The following are obsolete -- use getargs directly! */
#define getnoarg(v) getargs(v, "") #define getnoarg(v) getargs(v, "")
#define getintarg(v, a) getargs(v, "i", a) #define getintarg(v, a) getargs(v, "i", a)
#define getintintarg(v, a, b) getargs(v, "(ii)", a, b)
#define getintintintarg(v, a, b, c) getargs(v, "(iii)", a, b, c)
#define getlongarg(v, a) getargs(v, "l", a) #define getlongarg(v, a) getargs(v, "l", a)
#define getlonglongarg(v, a, b) getargs(v, "(ll)", a, b)
#define getlonglongobjectarg(v, a, b, c) getargs(v, "(llO)", a, b, c)
#define getStrarg(v, a) getargs(v, "S", a)
#define getstrarg(v, a) getargs(v, "s", a) #define getstrarg(v, a) getargs(v, "s", a)
#define getstrstrarg(v, a, b) getargs(v, "(ss)", a, b)
#define getStrStrarg(v, a, b) getargs(v, "(SS)", a, b)
#define getstrstrintarg(v, a, b, c) getargs(v, "(ssi)", a, b, c)
#define getStrintarg(v, a, b) getargs(v, "(Si)", a, b)
#define getstrintarg(v, a, b) getargs(v, "(si)", a, b)
#define getintstrarg(v, a, b) getargs(v, "(is)", a, b)
#define getpointarg(v, a) getargs(v, "(ii)", a, (a)+1)
#define get3pointarg(v, a) getargs(v, "((ii)(ii)(ii))", \
a, a+1, a+2, a+3, a+4, a+5)
#define getrectarg(v, a) getargs(v, "((ii)(ii))", a, a+1, a+2, a+3)
#define getrectintarg(v, a) getargs(v, "(((ii)(ii))i)", a, a+1, a+2, a+3, a+4)
#define getpointintarg(v, a) getargs(v, "((ii)i)", a, a+1, a+2)
#define getpointstrarg(v, a, b) getargs(v, "((ii)s)", a, a+1, b)
#define getrectpointarg(v, a) getargs(v, "(((ii)(ii))(ii))", \
a, a+1, a+2, a+3, a+4, a+5)
#define getdoublearg(v, a) getargs(v, "d", a)
#define get2doublearg(v, a, b) getargs(v, "(dd)", a, b)

View file

@ -28,6 +28,7 @@ void initall PROTO((void));
int run PROTO((FILE *, char *)); int run PROTO((FILE *, char *));
int run_command PROTO((char *));
int run_script PROTO((FILE *, char *)); int run_script PROTO((FILE *, char *));
int run_tty_1 PROTO((FILE *, char *)); int run_tty_1 PROTO((FILE *, char *));
int run_tty_loop PROTO((FILE *, char *)); int run_tty_loop PROTO((FILE *, char *));

View file

@ -568,7 +568,7 @@ al_openport (self, args)
} }
size = gettuplesize(args); size = gettuplesize(args);
if (size == 2) { if (size == 2) {
if (!getstrstrarg (args, &name, &dir)) if (!getargs (args, "(ss)", &name, &dir))
return NULL; return NULL;
} }
else if (size == 3) { else if (size == 3) {

View file

@ -209,7 +209,7 @@ d_setitem(ap, i, v)
} }
/* Description of types */ /* Description of types */
struct arraydescr descriptors[] = { static struct arraydescr descriptors[] = {
{'c', sizeof(char), c_getitem, c_setitem}, {'c', sizeof(char), c_getitem, c_setitem},
{'b', sizeof(char), b_getitem, b_setitem}, {'b', sizeof(char), b_getitem, b_setitem},
{'h', sizeof(short), h_getitem, h_setitem}, {'h', sizeof(short), h_getitem, h_setitem},

View file

@ -725,12 +725,12 @@ CD_addcallback(self, args)
object *args; object *args;
{ {
int type; int type;
object *funcobject, *funcargobject; object *func, *funcarg;
CheckParser(self); CheckParser(self);
/* XXX - more work here */ /* XXX - more work here */
if (!getargs(args, "(iOO)", &type, &funcobject, &funcargobject)) if (!getargs(args, "(iOO)", &type, &func, &funcarg))
return NULL; return NULL;
if (type < 0 || type >= NCALLBACKS) { if (type < 0 || type >= NCALLBACKS) {
@ -744,11 +744,11 @@ CD_addcallback(self, args)
CDsetcallback(self->ob_cdparser, (CDDATATYPES) type, CD_callback, (void *) self); CDsetcallback(self->ob_cdparser, (CDDATATYPES) type, CD_callback, (void *) self);
#endif #endif
XDECREF(self->ob_cdcallbacks[type].ob_cdcallback); XDECREF(self->ob_cdcallbacks[type].ob_cdcallback);
INCREF(funcobject); INCREF(func);
self->ob_cdcallbacks[type].ob_cdcallback = funcobject; self->ob_cdcallbacks[type].ob_cdcallback = func;
XDECREF(self->ob_cdcallbacks[type].ob_cdcallbackarg); XDECREF(self->ob_cdcallbacks[type].ob_cdcallbackarg);
INCREF(funcargobject); INCREF(funcarg);
self->ob_cdcallbacks[type].ob_cdcallbackarg = funcargobject; self->ob_cdcallbacks[type].ob_cdcallbackarg = funcarg;
INCREF(None); INCREF(None);
return None; return None;

View file

@ -28,17 +28,6 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "cgensupport.h" #include "cgensupport.h"
/* Functions to construct return values */
object *
mknewcharobject(c)
int c;
{
char ch[1];
ch[0] = c;
return newsizedstringobject(ch, 1);
}
/* Functions to extract arguments. /* Functions to extract arguments.
These needs to know the total number of arguments supplied, These needs to know the total number of arguments supplied,
since the argument list is a tuple only of there is more than since the argument list is a tuple only of there is more than

View file

@ -29,8 +29,7 @@ typedef char *string;
#define mknewlongobject(x) newintobject(x) #define mknewlongobject(x) newintobject(x)
#define mknewshortobject(x) newintobject((long)x) #define mknewshortobject(x) newintobject((long)x)
#define mknewfloatobject(x) newfloatobject(x) #define mknewfloatobject(x) newfloatobject(x)
#define mknewcharobject(c) mkvalue("c", c)
extern object *mknewcharobject PROTO((int c));
extern int getiobjectarg PROTO((object *args, int nargs, int i, object **p_a)); extern int getiobjectarg PROTO((object *args, int nargs, int i, object **p_a));
extern int getilongarg PROTO((object *args, int nargs, int i, long *p_a)); extern int getilongarg PROTO((object *args, int nargs, int i, long *p_a));

View file

@ -528,7 +528,7 @@ call_forms_INiINstr (func, obj, args)
char *b; char *b;
int a; int a;
if (!getintstrarg(args, &a, &b)) return NULL; if (!getargs(args, "(is)", &a, &b)) return NULL;
(*func) (obj, a, b); (*func) (obj, a, b);
@ -546,7 +546,7 @@ call_forms_INiINi (func, obj, args)
{ {
int par1, par2; int par1, par2;
if (!getintintarg(args, &par1, &par2)) return NULL; if (!getargs(args, "(ii)", &par1, &par2)) return NULL;
(*func) (obj, par1, par2); (*func) (obj, par1, par2);
@ -1048,7 +1048,7 @@ get_default(g, args)
c = fl_get_default (g->ob_generic); c = fl_get_default (g->ob_generic);
return ((object *) mknewcharobject (c)); /* in cgensupport.c */ return mkvalue("c", c);
} }
static struct methodlist default_methods[] = { static struct methodlist default_methods[] = {
@ -1479,7 +1479,7 @@ form_call_INiINi(func, f, args)
{ {
int a, b; int a, b;
if (!getintintarg(args, &a, &b)) return NULL; if (!getargs(args, "(ii)", &a, &b)) return NULL;
(*func)(f, a, b); (*func)(f, a, b);
@ -2144,7 +2144,7 @@ forms_set_graphics_mode(dummy, args)
{ {
int rgbmode, doublebuf; int rgbmode, doublebuf;
if (!getintintarg(args, &rgbmode, &doublebuf)) if (!getargs(args, "(ii)", &rgbmode, &doublebuf))
return NULL; return NULL;
fl_set_graphics_mode(rgbmode,doublebuf); fl_set_graphics_mode(rgbmode,doublebuf);
INCREF(None); INCREF(None);
@ -2441,7 +2441,7 @@ forms_show_input(f, args)
char *str; char *str;
char *a, *b; char *a, *b;
if (!getstrstrarg(args, &a, &b)) return NULL; if (!getargs(args, "(ss)", &a, &b)) return NULL;
BGN_SAVE BGN_SAVE
str = fl_show_input(a, b); str = fl_show_input(a, b);

View file

@ -68,7 +68,7 @@ fh_scalefont(self, args)
object *args; object *args;
{ {
double size; double size;
if (!getdoublearg(args, &size)) if (!getargs(args, "d", &size))
return NULL; return NULL;
return newfhobject(fmscalefont(self->fh_fh, size)); return newfhobject(fmscalefont(self->fh_fh, size));
} }

View file

@ -162,9 +162,9 @@ imgfile_read(self, args)
return rv; return rv;
} }
IMAGE *glob_image; static IMAGE *glob_image;
long *glob_datap; static long *glob_datap;
int glob_width, glob_z; static int glob_width, glob_z;
static static
xs_get(buf, y) xs_get(buf, y)

View file

@ -33,6 +33,9 @@ extern int errno;
#include "modsupport.h" #include "modsupport.h"
#define getdoublearg(v, a) getargs(v, "d", a)
#define get2doublearg(v, a, b) getargs(v, "(dd)", a, b)
#include <math.h> #include <math.h>
#ifdef i860 #ifdef i860

View file

@ -87,7 +87,7 @@ nis_match (self, args)
int err; int err;
object *res; object *res;
if (!getstrstrarg(args, &key, &map)) if (!getargs(args, "(ss)", &key, &map))
return NULL; return NULL;
if ((err = yp_get_default_domain(&domain)) != 0) if ((err = yp_get_default_domain(&domain)) != 0)
return nis_error(err); return nis_error(err);

View file

@ -166,7 +166,7 @@ posix_2str(args, func)
{ {
char *path1, *path2; char *path1, *path2;
int res; int res;
if (!getstrstrarg(args, &path1, &path2)) if (!getargs(args, "(ss)", &path1, &path2))
return NULL; return NULL;
BGN_SAVE BGN_SAVE
res = (*func)(path1, path2); res = (*func)(path1, path2);
@ -185,7 +185,7 @@ posix_strint(args, func)
char *path; char *path;
int i; int i;
int res; int res;
if (!getstrintarg(args, &path, &i)) if (!getargs(args, "(si)", &path, &i))
return NULL; return NULL;
BGN_SAVE BGN_SAVE
res = (*func)(path, i); res = (*func)(path, i);
@ -691,7 +691,7 @@ posix_kill(self, args)
object *args; object *args;
{ {
int pid, sig; int pid, sig;
if (!getintintarg(args, &pid, &sig)) if (!getargs(args, "(ii)", &pid, &sig))
return NULL; return NULL;
if (kill(pid, sig) == -1) if (kill(pid, sig) == -1)
return posix_error(); return posix_error();
@ -891,7 +891,7 @@ posix_tcsetpgrp(self, args)
/* Functions acting on file descriptors */ /* Functions acting on file descriptors */
object * static object *
posix_open(self, args) posix_open(self, args)
object *self; object *self;
object *args; object *args;
@ -913,7 +913,7 @@ posix_open(self, args)
return newintobject((long)fd); return newintobject((long)fd);
} }
object * static object *
posix_close(self, args) posix_close(self, args)
object *self; object *self;
object *args; object *args;
@ -930,7 +930,7 @@ posix_close(self, args)
return None; return None;
} }
object * static object *
posix_dup(self, args) posix_dup(self, args)
object *self; object *self;
object *args; object *args;
@ -946,7 +946,7 @@ posix_dup(self, args)
return newintobject((long)fd); return newintobject((long)fd);
} }
object * static object *
posix_dup2(self, args) posix_dup2(self, args)
object *self; object *self;
object *args; object *args;
@ -963,7 +963,7 @@ posix_dup2(self, args)
return None; return None;
} }
object * static object *
posix_lseek(self, args) posix_lseek(self, args)
object *self; object *self;
object *args; object *args;
@ -988,7 +988,7 @@ posix_lseek(self, args)
return newintobject(res); return newintobject(res);
} }
object * static object *
posix_read(self, args) posix_read(self, args)
object *self; object *self;
object *args; object *args;
@ -1011,7 +1011,7 @@ posix_read(self, args)
return buffer; return buffer;
} }
object * static object *
posix_write(self, args) posix_write(self, args)
object *self; object *self;
object *args; object *args;
@ -1028,7 +1028,7 @@ posix_write(self, args)
return newintobject((long)size); return newintobject((long)size);
} }
object * static object *
posix_fstat(self, args) posix_fstat(self, args)
object *self; object *self;
object *args; object *args;
@ -1079,7 +1079,7 @@ posix_fdopen(self, args)
} }
#ifndef MSDOS #ifndef MSDOS
object * static object *
posix_pipe(self, args) posix_pipe(self, args)
object *self; object *self;
object *args; object *args;

View file

@ -763,7 +763,9 @@ static typeobject Rotortype = {
}; };
object *rotor_rotor(self, args) static object *
rotor_rotor(self, args)
object *self;
object *args; object *args;
{ {
char *string; char *string;

View file

@ -57,4 +57,4 @@ initsgi()
initmodule("sgi", sgi_methods); initmodule("sgi", sgi_methods);
} }
int dummy; /* $%#@!& dl wants at least a byte of bss */ static int dummy; /* $%#@!& dl wants at least a byte of bss */

View file

@ -744,9 +744,9 @@ sock_send(s, args)
char *buf; char *buf;
int len, n, flags; int len, n, flags;
flags = 0; flags = 0;
if (!getargs(args, "(s#)", &buf, &len)) { if (!getargs(args, "s#", &buf, &len)) {
err_clear(); err_clear();
if (!getargs(args, "s#", &buf, &len, &flags)) if (!getargs(args, "(s#i)", &buf, &len, &flags))
return NULL; return NULL;
} }
BGN_SAVE BGN_SAVE

View file

@ -91,6 +91,15 @@ static type_lock StdwinLock; /* Lock held when interpreter not locked */
#endif #endif
#define getpointarg(v, a) getargs(v, "(ii)", a, (a)+1)
#define get3pointarg(v, a) getargs(v, "((ii)(ii)(ii))", \
a, a+1, a+2, a+3, a+4, a+5)
#define getrectarg(v, a) getargs(v, "((ii)(ii))", a, a+1, a+2, a+3)
#define getrectintarg(v, a) getargs(v, "(((ii)(ii))i)", a, a+1, a+2, a+3, a+4)
#define getpointintarg(v, a) getargs(v, "((ii)i)", a, a+1, a+2)
#define getrectpointarg(v, a) getargs(v, "(((ii)(ii))(ii))", \
a, a+1, a+2, a+3, a+4, a+5)
static object *StdwinError; /* Exception stdwin.error */ static object *StdwinError; /* Exception stdwin.error */
/* Window and menu object types declared here because of forward references */ /* Window and menu object types declared here because of forward references */
@ -1236,7 +1245,7 @@ menu_setitem(self, args)
{ {
int index; int index;
char *text; char *text;
if (!getintstrarg(args, &index, &text)) if (!getargs(args, "(is)", &index, &text))
return NULL; return NULL;
wmenusetitem(self->m_menu, index, text); wmenusetitem(self->m_menu, index, text);
INCREF(None); INCREF(None);
@ -1250,7 +1259,7 @@ menu_enable(self, args)
{ {
int index; int index;
int flag; int flag;
if (!getintintarg(args, &index, &flag)) if (!getargs(args, "(ii)", &index, &flag))
return NULL; return NULL;
wmenuenable(self->m_menu, index, flag); wmenuenable(self->m_menu, index, flag);
INCREF(None); INCREF(None);
@ -1264,7 +1273,7 @@ menu_check(self, args)
{ {
int index; int index;
int flag; int flag;
if (!getintintarg(args, &index, &flag)) if (!getargs(args, "(ii)", &index, &flag))
return NULL; return NULL;
wmenucheck(self->m_menu, index, flag); wmenucheck(self->m_menu, index, flag);
INCREF(None); INCREF(None);
@ -1705,7 +1714,7 @@ window_settitle(wp, args)
object *args; object *args;
{ {
object *title; object *title;
if (!getStrarg(args, &title)) if (!getargs(args, "S", &title))
return NULL; return NULL;
DECREF(wp->w_title); DECREF(wp->w_title);
INCREF(title); INCREF(title);
@ -1930,7 +1939,7 @@ stdwin_open(sw, args)
int tag; int tag;
object *title; object *title;
windowobject *wp; windowobject *wp;
if (!getStrarg(args, &title)) if (!getargs(args, "S", &title))
return NULL; return NULL;
for (tag = 0; tag < MAXNWIN; tag++) { for (tag = 0; tag < MAXNWIN; tag++) {
if (windowlist[tag] == NULL) if (windowlist[tag] == NULL)
@ -2180,7 +2189,7 @@ stdwin_askfile(self, args)
char *prompt, *dflt; char *prompt, *dflt;
int new, ret; int new, ret;
char buf[256]; char buf[256];
if (!getstrstrintarg(args, &prompt, &dflt, &new)) if (!getargs(args, "(ssi)", &prompt, &dflt, &new))
return NULL; return NULL;
strncpy(buf, dflt, sizeof buf); strncpy(buf, dflt, sizeof buf);
buf[sizeof buf - 1] = '\0'; buf[sizeof buf - 1] = '\0';
@ -2201,7 +2210,7 @@ stdwin_askync(self, args)
{ {
char *prompt; char *prompt;
int new, ret; int new, ret;
if (!getstrintarg(args, &prompt, &new)) if (!getargs(args, "(si)", &prompt, &new))
return NULL; return NULL;
BGN_STDWIN BGN_STDWIN
ret = waskync(prompt, new); ret = waskync(prompt, new);
@ -2221,7 +2230,7 @@ stdwin_askstr(self, args)
char *prompt, *dflt; char *prompt, *dflt;
int ret; int ret;
char buf[256]; char buf[256];
if (!getstrstrarg(args, &prompt, &dflt)) if (!getargs(args, "(ss)", &prompt, &dflt))
return NULL; return NULL;
strncpy(buf, dflt, sizeof buf); strncpy(buf, dflt, sizeof buf);
buf[sizeof buf - 1] = '\0'; buf[sizeof buf - 1] = '\0';

View file

@ -28,6 +28,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "modsupport.h" #include "modsupport.h"
#include "structmember.h" #include "structmember.h"
#include <stropts.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <sun/audioio.h> #include <sun/audioio.h>
@ -255,6 +256,38 @@ sad_drain(self, args)
return None; return None;
} }
static object *
sad_flush(self, args)
sadobject *self;
object *args;
{
if ( !getargs(args, "") )
return 0;
if ( ioctl(self->x_fd, I_FLUSH, FLUSHW) < 0 ) {
err_errno(SunAudioError);
return NULL;
}
INCREF(None);
return None;
}
static object *
sad_close(self, args)
sadobject *self;
object *args;
{
if ( !getargs(args, "") )
return 0;
if ( self->x_fd >= 0 ) {
close(self->x_fd);
self->x_fd = -1;
}
INCREF(None);
return None;
}
static struct methodlist sad_methods[] = { static struct methodlist sad_methods[] = {
{ "read", sad_read }, { "read", sad_read },
{ "write", sad_write }, { "write", sad_write },
@ -264,6 +297,8 @@ static struct methodlist sad_methods[] = {
{ "getinfo", sad_getinfo }, { "getinfo", sad_getinfo },
{ "setinfo", sad_setinfo }, { "setinfo", sad_setinfo },
{ "drain", sad_drain }, { "drain", sad_drain },
{ "flush", sad_flush },
{ "close", sad_close },
{NULL, NULL} /* sentinel */ {NULL, NULL} /* sentinel */
}; };

View file

@ -33,7 +33,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
int threads_started = 0; int threads_started = 0;
object *ThreadError; static object *ThreadError;
/* Lock objects */ /* Lock objects */

View file

@ -78,6 +78,26 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <errno.h> #include <errno.h>
#endif #endif
#ifdef SYSV
/* Access timezone stuff */
#ifdef OLDTZ /* ANSI prepends underscore to these */
#define _timezone timezone /* seconds to be added to GMT */
#define _altzone 0 /* _timezone if daylight saving time */
#define _daylight 0 /* if zero, _altzone is not available*/
#define _tzname tzname /* Name of timezone and altzone */
#endif
#ifdef NOALTTZ /* if system doesn't support alt tz */
#undef _daylight
#undef _altzone
#define _daylight 0
#define _altzone 0
#endif
#endif /* SYSV */
/* Forward declarations */
static void floatsleep PROTO((double));
static long millitimer PROTO((void));
/* Time methods */ /* Time methods */
static object * static object *
@ -199,7 +219,6 @@ time_millitimer(self, args)
object *args; object *args;
{ {
long msecs; long msecs;
extern long millitimer();
if (!getnoarg(args)) if (!getnoarg(args))
return NULL; return NULL;
msecs = millitimer(); msecs = millitimer();
@ -225,7 +244,7 @@ time_times(self, args)
err_errno(IOError); err_errno(IOError);
return NULL; return NULL;
} }
return mkvalue("dddd", return mkvalue("(dddd)",
(double)t.tms_utime / HZ, (double)t.tms_utime / HZ,
(double)t.tms_stime / HZ, (double)t.tms_stime / HZ,
(double)t.tms_cutime / HZ, (double)t.tms_cutime / HZ,
@ -235,6 +254,71 @@ time_times(self, args)
#endif #endif
static object *
time_convert(when, function)
time_t when;
struct tm * (*function) PROTO((time_t *));
{
struct tm *p = function(&when);
return mkvalue("(iiiiiiiii)",
p->tm_year + 1900,
p->tm_mon + 1, /* Want January == 1 */
p->tm_mday,
p->tm_hour,
p->tm_min,
p->tm_sec,
(p->tm_wday + 6) % 7, /* Want Monday == 0 */
p->tm_yday,
p->tm_isdst);
}
static object *
time_gmtime(self, args)
object *self;
object *args;
{
double when;
if (!getargs(args, "d", &when))
return NULL;
return time_convert((time_t)when, gmtime);
}
static object *
time_localtime(self, args)
object *self;
object *args;
{
double when;
if (!getargs(args, "d", &when))
return NULL;
return time_convert((time_t)when, localtime);
}
/* Some very old systems may not have mktime(). Comment it out then! */
static object *
time_mktime(self, args)
object *self;
object *args;
{
struct tm buf;
if (!getargs(args, "(iiiiiiiii)",
&buf.tm_year,
&buf.tm_mon,
&buf.tm_mday,
&buf.tm_hour,
&buf.tm_min,
&buf.tm_sec,
&buf.tm_wday,
&buf.tm_yday,
&buf.tm_isdst))
return NULL;
if (buf.tm_year >= 1900)
buf.tm_year -= 1900;
buf.tm_mon--;
return newintobject((long)mktime(&buf));
}
static struct methodlist time_methods[] = { static struct methodlist time_methods[] = {
#ifdef DO_MILLI #ifdef DO_MILLI
{"millisleep", time_millisleep}, {"millisleep", time_millisleep},
@ -245,6 +329,9 @@ static struct methodlist time_methods[] = {
#endif #endif
{"sleep", time_sleep}, {"sleep", time_sleep},
{"time", time_time}, {"time", time_time},
{"gmtime", time_gmtime},
{"localtime", time_localtime},
{"mktime", time_mktime},
{NULL, NULL} /* sentinel */ {NULL, NULL} /* sentinel */
}; };
@ -252,7 +339,40 @@ static struct methodlist time_methods[] = {
void void
inittime() inittime()
{ {
initmodule("time", time_methods); object *m, *d;
m = initmodule("time", time_methods);
d = getmoduledict(m);
#ifdef SYSV
tzset();
dictinsert(d, "timezone", newintobject((long)_timezone));
dictinsert(d, "altzone", newintobject((long)_altzone));
dictinsert(d, "daylight", newintobject((long)_daylight));
dictinsert(d, "tzname", mkvalue("(zz)", _tzname[0], _tzname[1]));
#else /* !SYSV */
{
#define YEAR ((time_t)((365 * 24 + 6) * 3600))
time_t t;
struct tm *p;
long winterzone, summerzone;
char wintername[10], summername[10];
t = (time((time_t *)0) / YEAR) * YEAR;
p = localtime(&t);
winterzone = -p->tm_gmtoff;
strncpy(wintername, p->tm_zone ? p->tm_zone : " ", 9);
wintername[9] = '\0';
t += YEAR/2;
p = localtime(&t);
summerzone = -p->tm_gmtoff;
strncpy(summername, p->tm_zone ? p->tm_zone : " ", 9);
summername[9] = '\0';
dictinsert(d, "timezone", newintobject(winterzone));
dictinsert(d, "altzone", newintobject(summerzone));
dictinsert(d, "daylight",
newintobject((long)(winterzone != summerzone)));
dictinsert(d, "tzname",
mkvalue("(zz)", wintername, summername));
}
#endif /* !SYSV */
} }
@ -274,6 +394,7 @@ sleep(secs)
} }
#endif #endif
static void
floatsleep(secs) floatsleep(secs)
double secs; double secs;
{ {
@ -286,7 +407,7 @@ floatsleep(secs)
} }
} }
long static long
millitimer() millitimer()
{ {
return MacTicks * 50 / 3; /* MacTicks * 1000 / 60 */ return MacTicks * 50 / 3; /* MacTicks * 1000 / 60 */
@ -299,7 +420,7 @@ millitimer()
#ifdef BSD_TIME #ifdef BSD_TIME
long static long
millitimer() millitimer()
{ {
struct timeval t; struct timeval t;
@ -309,6 +430,7 @@ millitimer()
return t.tv_sec*1000 + t.tv_usec/1000; return t.tv_sec*1000 + t.tv_usec/1000;
} }
static void
floatsleep(secs) floatsleep(secs)
double secs; double secs;
{ {
@ -325,6 +447,7 @@ floatsleep(secs)
#else /* !BSD_TIME */ #else /* !BSD_TIME */
static void
floatsleep(secs) floatsleep(secs)
double secs; double secs;
{ {
@ -342,13 +465,14 @@ floatsleep(secs)
#define CLOCKS_PER_SEC 55 /* 54.945 msec per tick (18.2 HZ clock) */ #define CLOCKS_PER_SEC 55 /* 54.945 msec per tick (18.2 HZ clock) */
#endif #endif
static void
floatsleep(secs) floatsleep(secs)
double secs; double secs;
{ {
delay(long(secs/1000.0)); delay(long(secs/1000.0));
} }
long static long
millitimer() millitimer()
{ {
clock_t ticks; clock_t ticks;

View file

@ -24,6 +24,13 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
/* Access object implementation */ /* Access object implementation */
/* XXX TO DO LIST
- need a "super user" mechanism for debugger etc.
- __init__ and __del__ (and all other similar methods)
should be usable even when private, not ignored
- "from foo import bar" should check access of bar
*/
#include "allobjects.h" #include "allobjects.h"
#include "structmember.h" #include "structmember.h"

View file

@ -328,7 +328,7 @@ file_read(f, args)
< 0: strip trailing '\n', raise EOFError if EOF reached immediately < 0: strip trailing '\n', raise EOFError if EOF reached immediately
*/ */
object * static object *
getline(f, n) getline(f, n)
fileobject *f; fileobject *f;
int n; int n;

View file

@ -70,7 +70,7 @@ newfloatobject(fval)
return (object *) op; return (object *) op;
} }
void static void
float_dealloc(op) float_dealloc(op)
object *op; object *op;
{ {
@ -329,7 +329,7 @@ float_nonzero(v)
return v->ob_fval != 0.0; return v->ob_fval != 0.0;
} }
int static int
float_coerce(pv, pw) float_coerce(pv, pw)
object **pv; object **pv;
object **pw; object **pw;

View file

@ -207,7 +207,7 @@ list_print(op, fp, flags)
return 0; return 0;
} }
object * static object *
list_repr(v) list_repr(v)
listobject *v; listobject *v;
{ {
@ -291,6 +291,18 @@ list_slice(a, ilow, ihigh)
return (object *)np; return (object *)np;
} }
object *
getlistslice(a, ilow, ihigh)
object *a;
int ilow, ihigh;
{
if (!is_listobject(a)) {
err_badcall();
return NULL;
}
return list_slice((listobject *)a, ilow, ihigh);
}
static object * static object *
list_concat(a, bb) list_concat(a, bb)
listobject *a; listobject *a;
@ -422,6 +434,19 @@ list_ass_slice(a, ilow, ihigh, v)
#undef b #undef b
} }
int
setlistslice(a, ilow, ihigh, v)
object *a;
int ilow, ihigh;
object *v;
{
if (!is_listobject(a)) {
err_badcall();
return NULL;
}
return list_ass_slice((listobject *)a, ilow, ihigh, v);
}
static int static int
list_ass_item(a, i, v) list_ass_item(a, i, v)
listobject *a; listobject *a;

View file

@ -261,7 +261,7 @@ divrem1(a, n, prem)
If base is 8 or 16, add the proper prefix '0' or '0x'. If base is 8 or 16, add the proper prefix '0' or '0x'.
External linkage: used in bltinmodule.c by hex() and oct(). */ External linkage: used in bltinmodule.c by hex() and oct(). */
object * static object *
long_format(aa, base) long_format(aa, base)
object *aa; object *aa;
int base; int base;
@ -1275,7 +1275,7 @@ long_or(a, b)
return long_bitwise(a, '|', b); return long_bitwise(a, '|', b);
} }
int static int
long_coerce(pv, pw) long_coerce(pv, pw)
object **pv; object **pv;
object **pw; object **pw;

View file

@ -60,7 +60,7 @@ newstringobject(str)
return (object *) op; return (object *) op;
} }
void static void
string_dealloc(op) string_dealloc(op)
object *op; object *op;
{ {
@ -676,6 +676,8 @@ formatstring(format, args)
"unsupported format character"); "unsupported format character");
goto error; goto error;
} }
/* XXX There's a bug somewhere here so that
XXX '%4d'%-1 yields '- 1' ... */
if (sign) { if (sign) {
if (*buf == '-' || *buf == '+') { if (*buf == '-' || *buf == '+') {
sign = *buf++; sign = *buf++;

View file

@ -136,7 +136,7 @@ tupleprint(op, fp, flags)
return 0; return 0;
} }
object * static object *
tuplerepr(v) tuplerepr(v)
tupleobject *v; tupleobject *v;
{ {

View file

@ -28,7 +28,6 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "node.h" #include "node.h"
#include "graminit.h" #include "graminit.h"
#include "errcode.h"
#include "sysmodule.h" #include "sysmodule.h"
#include "bltinmodule.h" #include "bltinmodule.h"
#include "import.h" #include "import.h"

View file

@ -1964,6 +1964,8 @@ not(v)
INCREF(w); INCREF(w);
return w; return w;
} }
/* External interface to call any callable object. The arg may be NULL. */ /* External interface to call any callable object. The arg may be NULL. */
object * object *

View file

@ -28,17 +28,6 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "cgensupport.h" #include "cgensupport.h"
/* Functions to construct return values */
object *
mknewcharobject(c)
int c;
{
char ch[1];
ch[0] = c;
return newsizedstringobject(ch, 1);
}
/* Functions to extract arguments. /* Functions to extract arguments.
These needs to know the total number of arguments supplied, These needs to know the total number of arguments supplied,
since the argument list is a tuple only of there is more than since the argument list is a tuple only of there is more than

View file

@ -393,26 +393,35 @@ static state states_22[3] = {
static arc arcs_23_0[1] = { static arc arcs_23_0[1] = {
{51, 1}, {51, 1},
}; };
static arc arcs_23_1[1] = { static arc arcs_23_1[2] = {
{13, 2}, {22, 2},
{13, 3},
}; };
static arc arcs_23_2[2] = { static arc arcs_23_2[1] = {
{21, 1}, {15, 4},
{15, 3},
}; };
static arc arcs_23_3[1] = { static arc arcs_23_3[2] = {
{52, 4}, {21, 5},
{15, 4},
}; };
static arc arcs_23_4[2] = { static arc arcs_23_4[1] = {
{21, 3}, {52, 6},
{0, 4},
}; };
static state states_23[5] = { static arc arcs_23_5[1] = {
{13, 3},
};
static arc arcs_23_6[2] = {
{21, 4},
{0, 6},
};
static state states_23[7] = {
{1, arcs_23_0}, {1, arcs_23_0},
{1, arcs_23_1}, {2, arcs_23_1},
{2, arcs_23_2}, {1, arcs_23_2},
{1, arcs_23_3}, {2, arcs_23_3},
{2, arcs_23_4}, {1, arcs_23_4},
{1, arcs_23_5},
{2, arcs_23_6},
}; };
static arc arcs_24_0[1] = { static arc arcs_24_0[1] = {
{13, 1}, {13, 1},
@ -1057,7 +1066,7 @@ static dfa dfas[51] = {
"\000\000\000\000\000\000\003\000\000\000\000\000\000\000\000"}, "\000\000\000\000\000\000\003\000\000\000\000\000\000\000\000"},
{278, "global_stmt", 0, 3, states_22, {278, "global_stmt", 0, 3, states_22,
"\000\000\000\000\000\000\004\000\000\000\000\000\000\000\000"}, "\000\000\000\000\000\000\004\000\000\000\000\000\000\000\000"},
{279, "access_stmt", 0, 5, states_23, {279, "access_stmt", 0, 7, states_23,
"\000\000\000\000\000\000\010\000\000\000\000\000\000\000\000"}, "\000\000\000\000\000\000\010\000\000\000\000\000\000\000\000"},
{280, "accesstype", 0, 2, states_24, {280, "accesstype", 0, 2, states_24,
"\000\040\000\000\000\000\000\000\000\000\000\000\000\000\000"}, "\000\040\000\000\000\000\000\000\000\000\000\000\000\000\000"},