* Makefile: added IMGFILE; moved some stuff around.

* flmodule.c: added some missing functions; changed readonly flags of
  some data members based upon FORMS documentation.
* listobject.c: fixed int/long arg lint bug (bites PC compilers).
* several: removed redundant print methods (repr is good enough).
* posixmodule.c: added (still experimental) process group functions.
This commit is contained in:
Guido van Rossum 1992-09-17 17:54:56 +00:00
parent c2670a000b
commit 7066dd75c5
11 changed files with 126 additions and 142 deletions

View file

@ -315,11 +315,11 @@ static struct memberlist generic_memberlist[] = {
{"focus", T_INT, OFF(focus), RO}, {"focus", T_INT, OFF(focus), RO},
{"belowmouse", T_INT, OFF(belowmouse),RO}, {"belowmouse", T_INT, OFF(belowmouse),RO},
{"frozen", T_INT, OFF(frozen), RO}, {"frozen", T_INT, OFF(frozen), RO},
{"active", T_INT, OFF(active), RO}, {"active", T_INT, OFF(active)},
{"input", T_INT, OFF(input), RO}, {"input", T_INT, OFF(input)},
{"visible", T_INT, OFF(visible), RO}, {"visible", T_INT, OFF(visible), RO},
{"radio", T_INT, OFF(radio), RO}, {"radio", T_INT, OFF(radio)},
{"automatic", T_INT, OFF(automatic), RO}, {"automatic", T_INT, OFF(automatic)},
{NULL} /* Sentinel */ {NULL} /* Sentinel */
}; };
@ -1827,6 +1827,22 @@ form_find_last(f, args)
return forms_find_first_or_last(fl_find_last, f, args); return forms_find_first_or_last(fl_find_last, f, args);
} }
static object *
form_set_object_focus(f, args)
formobject *f;
object *args;
{
genericobject *g;
if (args == NULL || !is_genericobject(args)) {
err_badarg();
return NULL;
}
g = (genericobject *)args;
fl_set_object_focus(f->ob_form, g->ob_generic);
INCREF(None);
return None;
}
static struct methodlist form_methods[] = { static struct methodlist form_methods[] = {
/* adm */ /* adm */
{"show_form", form_show_form}, {"show_form", form_show_form},
@ -1844,6 +1860,7 @@ static struct methodlist form_methods[] = {
{"end_group", form_end_group}, {"end_group", form_end_group},
{"find_first", form_find_first}, {"find_first", form_find_first},
{"find_last", form_find_last}, {"find_last", form_find_last},
{"set_object_focus", form_set_object_focus},
/* basic objects */ /* basic objects */
{"add_button", form_add_button}, {"add_button", form_add_button},
@ -1886,11 +1903,11 @@ static struct memberlist form_memberlist[] = {
{"window", T_LONG, OFF(window), RO}, {"window", T_LONG, OFF(window), RO},
{"w", T_FLOAT, OFF(w)}, {"w", T_FLOAT, OFF(w)},
{"h", T_FLOAT, OFF(h)}, {"h", T_FLOAT, OFF(h)},
{"x", T_FLOAT, OFF(x)}, {"x", T_FLOAT, OFF(x), RO},
{"y", T_FLOAT, OFF(y)}, {"y", T_FLOAT, OFF(y), RO},
{"deactivated", T_INT, OFF(deactivated)}, {"deactivated", T_INT, OFF(deactivated)},
{"visible", T_INT, OFF(visible)}, {"visible", T_INT, OFF(visible), RO},
{"frozen", T_INT, OFF(frozen)}, {"frozen", T_INT, OFF(frozen), RO},
{"doublebuf", T_INT, OFF(doublebuf)}, {"doublebuf", T_INT, OFF(doublebuf)},
{NULL} /* Sentinel */ {NULL} /* Sentinel */
}; };
@ -2045,7 +2062,7 @@ forms_do_or_check_forms(dummy, args, func)
int dev; int dev;
short val; short val;
if (my_event_callback == NULL) if (my_event_callback == NULL)
return newintobject(-1); return newintobject(-1L);
dev = fl_qread(&val); dev = fl_qread(&val);
arg = newtupleobject(2); arg = newtupleobject(2);
if (arg == NULL) if (arg == NULL)
@ -2100,6 +2117,22 @@ forms_check_forms(dummy, args)
return forms_do_or_check_forms(dummy, args, fl_check_forms); return forms_do_or_check_forms(dummy, args, fl_check_forms);
} }
static object *
forms_do_only_forms(dummy, args)
object *dummy;
object *args;
{
return forms_do_or_check_forms(dummy, args, fl_do_only_forms);
}
static object *
forms_check_only_forms(dummy, args)
object *dummy;
object *args;
{
return forms_do_or_check_forms(dummy, args, fl_check_only_forms);
}
#ifdef UNUSED #ifdef UNUSED
static object * static object *
fl_call(func, args) fl_call(func, args)
@ -2134,14 +2167,42 @@ forms_get_rgbmode(dummy, args)
object *dummy; object *dummy;
object *args; object *args;
{ {
extern fl_rgbmode; extern int fl_rgbmode;
if (args != NULL) { if (args != NULL) {
err_badarg(); err_badarg();
return NULL; return NULL;
} }
return newintobject(fl_rgbmode); return newintobject((long)fl_rgbmode);
} }
static object *
forms_show_errors(dummy, args)
object *dummy;
object *args;
{
int show;
if (!getargs(args, "i", &show))
return NULL;
fl_show_errors(show);
INCREF(None);
return None;
}
static object *
forms_set_font_name(dummy, args)
object *dummy;
object *args;
{
int numb;
char *name;
if (!getargs(args, "(is)", &numb, &name))
return NULL;
fl_set_font_name(numb, name);
INCREF(None);
return None;
}
#endif /* !FL_V15 */ #endif /* !FL_V15 */
@ -2355,7 +2416,7 @@ forms_show_choice(f, args)
char *m1, *m2, *m3, *b1, *b2, *b3; char *m1, *m2, *m3, *b1, *b2, *b3;
int nb; int nb;
char *format; char *format;
int rv; long rv;
if (args == NULL || !is_tupleobject(args)) { if (args == NULL || !is_tupleobject(args)) {
err_badarg(); err_badarg();
@ -2526,6 +2587,8 @@ static struct methodlist forms_methods[] = {
#ifndef FL_V15 #ifndef FL_V15
{"set_graphics_mode", forms_set_graphics_mode}, {"set_graphics_mode", forms_set_graphics_mode},
{"get_rgbmode", forms_get_rgbmode}, {"get_rgbmode", forms_get_rgbmode},
{"show_errors", forms_show_errors},
{"set_font_name", forms_set_font_name},
#endif /* !FL_V15 */ #endif /* !FL_V15 */
{NULL, NULL} /* sentinel */ {NULL, NULL} /* sentinel */
}; };

View file

@ -819,7 +819,7 @@ posix_times(self, args)
errno = 0; errno = 0;
c = times(&t); c = times(&t);
if (c == (clock_t) -1) { if (c == (clock_t) -1) {
err_errno(IOError); err_errno(PosixError);
return NULL; return NULL;
} }
tuple = newtupleobject(4); tuple = newtupleobject(4);
@ -847,8 +847,10 @@ posix_setsid(self, args)
{ {
if (!getnoarg(args)) if (!getnoarg(args))
return NULL; return NULL;
if (setsid() < 0) if (setsid() < 0) {
err_errno(PosixError); err_errno(PosixError);
return NULL;
}
INCREF(None); INCREF(None);
return None; return None;
} }
@ -861,12 +863,46 @@ posix_setpgid(self, args)
int pid, pgrp; int pid, pgrp;
if (!getargs(args, "(ii)", &pid, &pgrp)) if (!getargs(args, "(ii)", &pid, &pgrp))
return NULL; return NULL;
if (setpgid(pid, pgrp) < 0) if (setpgid(pid, pgrp) < 0) {
err_errno(PosixError); err_errno(PosixError);
return NULL;
}
INCREF(None); INCREF(None);
return None; return None;
} }
static object *
posix_tcgetpgrp(self, args)
object *self;
object *args;
{
int fd, pgid;
if (!getargs(args, "i", &fd))
return NULL;
pgid = tcgetpgrp(fd);
if (pgid < 0) {
err_errno(PosixError);
return NULL;
}
return newintobject((long)pgid);
}
static object *
posix_tcsetpgrp(self, args)
object *self;
object *args;
{
int fd, pgid;
if (!getargs(args, "(ii)", &fd, &pgid))
return NULL;
if (tcsetpgrp(fd, pgid) < 0) {
err_errno(PosixError);
return NULL;
}
INCREF(None);
return None;
}
#endif /* DO_PG */ #endif /* DO_PG */
@ -919,6 +955,8 @@ static struct methodlist posix_methods[] = {
#ifdef DO_PG #ifdef DO_PG
{"setsid", posix_setsid}, {"setsid", posix_setsid},
{"setpgid", posix_setpgid}, {"setpgid", posix_setpgid},
{"tcgetpgrp", posix_tcgetpgrp},
{"tcsetpgrp", posix_tcsetpgrp},
#endif #endif
{NULL, NULL} /* Sentinel */ {NULL, NULL} /* Sentinel */

View file

@ -1311,18 +1311,6 @@ window_dealloc(wp)
free((char *)wp); free((char *)wp);
} }
static int
window_print(wp, fp, flags)
windowobject *wp;
FILE *fp;
int flags;
{
fprintf(fp, "<%s window titled '%s'>",
wp->w_win == NULL ? "closed" : "open",
getstringvalue(wp->w_title));
return 0;
}
static object * static object *
window_close(wp, args) window_close(wp, args)
windowobject *wp; windowobject *wp;
@ -1684,7 +1672,7 @@ typeobject Windowtype = {
0, /*tp_itemsize*/ 0, /*tp_itemsize*/
/* methods */ /* methods */
window_dealloc, /*tp_dealloc*/ window_dealloc, /*tp_dealloc*/
window_print, /*tp_print*/ 0, /*tp_print*/
window_getattr, /*tp_getattr*/ window_getattr, /*tp_getattr*/
window_setattr, /*tp_setattr*/ window_setattr, /*tp_setattr*/
0, /*tp_compare*/ 0, /*tp_compare*/

View file

@ -261,30 +261,6 @@ instance_setattr(inst, name, v)
return dictinsert(inst->in_attr, name, v); return dictinsert(inst->in_attr, name, v);
} }
int
instance_print(inst, fp, flags)
instanceobject *inst;
FILE *fp;
int flags;
{
object *func, *repr;
int ret;
func = instance_getattr(inst, "__repr__");
if (func == NULL) {
err_clear();
fprintf(fp, "<instance object at %lx>", (long)inst);
return 0;
}
repr = call_object(func, (object *)NULL);
DECREF(func);
if (repr == NULL)
return -1;
ret = printobject(repr, fp, flags | PRINT_RAW);
DECREF(repr);
return ret;
}
object * object *
instance_repr(inst) instance_repr(inst)
instanceobject *inst; instanceobject *inst;
@ -753,7 +729,7 @@ typeobject Instancetype = {
sizeof(instanceobject), sizeof(instanceobject),
0, 0,
instance_dealloc, /*tp_dealloc*/ instance_dealloc, /*tp_dealloc*/
instance_print, /*tp_print*/ 0, /*tp_print*/
instance_getattr, /*tp_getattr*/ instance_getattr, /*tp_getattr*/
instance_setattr, /*tp_setattr*/ instance_setattr, /*tp_setattr*/
instance_compare, /*tp_compare*/ instance_compare, /*tp_compare*/

View file

@ -132,29 +132,11 @@ file_dealloc(f)
free((char *)f); free((char *)f);
} }
static int
file_print(f, fp, flags)
fileobject *f;
FILE *fp;
int flags;
{
fprintf(fp, "<%s file ", f->f_fp == NULL ? "closed" : "open");
if (printobject(f->f_name, fp, flags) != 0)
return -1;
fprintf(fp, ", mode ");
if (printobject(f->f_mode, fp, flags) != 0)
return -1;
fprintf(fp, ">");
return 0;
}
static object * static object *
file_repr(f) file_repr(f)
fileobject *f; fileobject *f;
{ {
char buf[300]; char buf[300];
/* XXX This differs from file_print if the filename contains
quotes or other funny characters. */
sprintf(buf, "<%s file '%.256s', mode '%.10s'>", sprintf(buf, "<%s file '%.256s', mode '%.10s'>",
f->f_fp == NULL ? "closed" : "open", f->f_fp == NULL ? "closed" : "open",
getstringvalue(f->f_name), getstringvalue(f->f_name),
@ -535,7 +517,7 @@ typeobject Filetype = {
sizeof(fileobject), sizeof(fileobject),
0, 0,
file_dealloc, /*tp_dealloc*/ file_dealloc, /*tp_dealloc*/
file_print, /*tp_print*/ 0, /*tp_print*/
file_getattr, /*tp_getattr*/ file_getattr, /*tp_getattr*/
0, /*tp_setattr*/ 0, /*tp_setattr*/
0, /*tp_compare*/ 0, /*tp_compare*/

View file

@ -600,7 +600,7 @@ listindex(self, args)
} }
for (i = 0; i < self->ob_size; i++) { for (i = 0; i < self->ob_size; i++) {
if (cmpobject(self->ob_item[i], args) == 0) if (cmpobject(self->ob_item[i], args) == 0)
return newintobject(i); return newintobject((long)i);
} }
err_setstr(ValueError, "list.index(x): x not in list"); err_setstr(ValueError, "list.index(x): x not in list");
return NULL; return NULL;

View file

@ -581,21 +581,6 @@ long_dealloc(v)
DEL(v); DEL(v);
} }
/* ARGSUSED */
static int
long_print(v, fp, flags)
object *v;
FILE *fp;
int flags; /* Not used but required by interface */
{
stringobject *str = (stringobject *) long_format(v, 10);
if (str == NULL)
return -1;
fprintf(fp, "%s", GETSTRINGVALUE(str));
DECREF(str);
return 0;
}
static object * static object *
long_repr(v) long_repr(v)
object *v; object *v;
@ -1347,7 +1332,7 @@ typeobject Longtype = {
sizeof(longobject) - sizeof(digit), sizeof(longobject) - sizeof(digit),
sizeof(digit), sizeof(digit),
long_dealloc, /*tp_dealloc*/ long_dealloc, /*tp_dealloc*/
long_print, /*tp_print*/ 0, /*tp_print*/
0, /*tp_getattr*/ 0, /*tp_getattr*/
0, /*tp_setattr*/ 0, /*tp_setattr*/
(int (*) FPROTO((object *, object *))) (int (*) FPROTO((object *, object *)))

View file

@ -99,21 +99,6 @@ meth_dealloc(m)
free((char *)m); free((char *)m);
} }
/* ARGSUSED */
static int
meth_print(m, fp, flags)
methodobject *m;
FILE *fp;
int flags; /* Not used but required by interface */
{
if (m->m_self == NULL)
fprintf(fp, "<built-in function '%s'>", m->m_name);
else
fprintf(fp, "<built-in method '%s' of some %s object>",
m->m_name, m->m_self->ob_type->tp_name);
return 0;
}
static object * static object *
meth_repr(m) meth_repr(m)
methodobject *m; methodobject *m;
@ -131,11 +116,11 @@ meth_repr(m)
typeobject Methodtype = { typeobject Methodtype = {
OB_HEAD_INIT(&Typetype) OB_HEAD_INIT(&Typetype)
0, 0,
"method", "builtin_function_or_method",
sizeof(methodobject), sizeof(methodobject),
0, 0,
meth_dealloc, /*tp_dealloc*/ meth_dealloc, /*tp_dealloc*/
meth_print, /*tp_print*/ 0, /*tp_print*/
0, /*tp_getattr*/ 0, /*tp_getattr*/
0, /*tp_setattr*/ 0, /*tp_setattr*/
0, /*tp_compare*/ 0, /*tp_compare*/

View file

@ -83,17 +83,6 @@ module_dealloc(m)
free((char *)m); free((char *)m);
} }
/* ARGSUSED */
static int
module_print(m, fp, flags)
moduleobject *m;
FILE *fp;
int flags; /* Not used but required by interface */
{
fprintf(fp, "<module '%s'>", getstringvalue(m->md_name));
return 0;
}
static object * static object *
module_repr(m) module_repr(m)
moduleobject *m; moduleobject *m;
@ -153,7 +142,7 @@ typeobject Moduletype = {
sizeof(moduleobject), /*tp_size*/ sizeof(moduleobject), /*tp_size*/
0, /*tp_itemsize*/ 0, /*tp_itemsize*/
module_dealloc, /*tp_dealloc*/ module_dealloc, /*tp_dealloc*/
module_print, /*tp_print*/ 0, /*tp_print*/
module_getattr, /*tp_getattr*/ module_getattr, /*tp_getattr*/
module_setattr, /*tp_setattr*/ module_setattr, /*tp_setattr*/
0, /*tp_compare*/ 0, /*tp_compare*/

View file

@ -206,17 +206,6 @@ There is (and should be!) no way to create other objects of this type,
so there is exactly one (which is indestructible, by the way). so there is exactly one (which is indestructible, by the way).
*/ */
/* ARGSUSED */
static int
none_print(op, fp, flags)
object *op;
FILE *fp;
int flags;
{
fprintf(fp, "None");
return 0;
}
/* ARGSUSED */ /* ARGSUSED */
static object * static object *
none_repr(op) none_repr(op)
@ -232,7 +221,7 @@ static typeobject Notype = {
0, 0,
0, 0,
0, /*tp_dealloc*/ /*never called*/ 0, /*tp_dealloc*/ /*never called*/
none_print, /*tp_print*/ 0, /*tp_print*/
0, /*tp_getattr*/ 0, /*tp_getattr*/
0, /*tp_setattr*/ 0, /*tp_setattr*/
0, /*tp_compare*/ 0, /*tp_compare*/

View file

@ -28,17 +28,6 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
/* Type object implementation */ /* Type object implementation */
/* ARGSUSED */
static int
type_print(v, fp, flags)
typeobject *v;
FILE *fp;
int flags;
{
fprintf(fp, "<type '%s'>", v->tp_name);
return 0;
}
static object * static object *
type_repr(v) type_repr(v)
typeobject *v; typeobject *v;
@ -55,7 +44,7 @@ typeobject Typetype = {
sizeof(typeobject), /* Basic object size */ sizeof(typeobject), /* Basic object size */
0, /* Item size for varobject */ 0, /* Item size for varobject */
0, /*tp_dealloc*/ 0, /*tp_dealloc*/
type_print, /*tp_print*/ 0, /*tp_print*/
0, /*tp_getattr*/ 0, /*tp_getattr*/
0, /*tp_setattr*/ 0, /*tp_setattr*/
0, /*tp_compare*/ 0, /*tp_compare*/