; Remove etags test files whose copyright is incompatible

This commit is contained in:
Eli Zaretskii 2015-05-14 18:35:13 +03:00
parent 2958e5237c
commit 17bbb94dca
19 changed files with 192 additions and 23264 deletions

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -4,21 +4,21 @@ CSRC=$(addprefix ./c-src/,abbrev.c .//c.c torture.c getopt.h etags.c\
exit.c exit.strange_suffix sysdep.h tab.c dostorture.c\
emacs/src/gmalloc.c emacs/src/regex.h emacs/src/keyboard.c emacs/src/lisp.h\
machsyscalls.c machsyscalls.h fail.c a/b/b.c) ../etags/c-src/h.h
CPSRC=$(addprefix ./cp-src/,c.C abstract.C abstract.H cfront.H burton.cpp burton.cpp\
functions.cpp MDiagArray2.h Pctest.h Range.h\
CPSRC=$(addprefix ./cp-src/,c.C burton.cpp burton.cpp\
functions.cpp MDiagArray2.h Range.h\
screen.cpp screen.hpp conway.cpp conway.hpp clheir.cpp.gz clheir.hpp.gz fail.C)
ELSRC=$(addprefix ./el-src/,TAGTEST.EL emacs/lisp/progmodes/etags.el)
ERLSRC=$(addprefix ./erl-src/,gs_dialog.erl lines.erl lists.erl)
ERLSRC=$(addprefix ./erl-src/,gs_dialog.erl)
FORTHSRC=$(addprefix ./forth-src/,test-forth.fth)
FSRC=$(addprefix ./f-src/,entry.for entry.strange_suffix entry.strange)
HTMLSRC=$(addprefix ./html-src/,softwarelibero.html index.shtml algrthms.html software.html)
JAVASRC=$(addprefix ./java-src/,AWTEMul.java KeyEve.java SMan.java SysCol.java TG.java)
#JAVASRC=$(addprefix ./java-src/, )
LUASRC=$(addprefix ./lua-src/,allegro.lua)
MAKESRC=$(addprefix ./make-src/,Makefile)
OBJCSRC=$(addprefix ./objc-src/,Subprocess.h Subprocess.m PackInsp.h PackInsp.m)
OBJCPPSRC=$(addprefix ./objcpp-src/,SimpleCalc.H SimpleCalc.M)
PASSRC=$(addprefix ./pas-src/,common.pas)
PERLSRC=$(addprefix ./perl-src/,htlmify-cystic yagrip.pl kai-test.pl mirror.pl)
PERLSRC=$(addprefix ./perl-src/,htlmify-cystic yagrip.pl kai-test.pl)
PHPSRC=$(addprefix ./php-src/,lce_functions.php ptest.php sendmail.php)
PSSRC=$(addprefix ./ps-src/,rfc1245.ps)
PROLSRC=$(addprefix ./prol-src/,ordsets.prolog natded.prolog)

View file

@ -1,99 +0,0 @@
// -*- c++ -*-
//
// $Id: Pctest.h,v 1.14 2000/01/19 17:14:42 bmah Exp $
//
// Pctest.h
// Bruce A. Mah <bmah@ca.sandia.gov>
//
// This work was first produced by an employee of Sandia National
// Laboratories under a contract with the U.S. Department of Energy.
// Sandia National Laboratories dedicates whatever right, title or
// interest it may have in this software to the public. Although no
// license from Sandia is needed to copy and use this software,
// copying and using the software might infringe the rights of
// others. This software is provided as-is. SANDIA DISCLAIMS ANY
// WARRANTY OF ANY KIND, EXPRESS OR IMPLIED.
//
// Header for virtual base class of tests. A particular protocol (e.g.
// IPv4, IPv6) will override the methods of this base class
// with protocol-specific implementations.
//
//
#ifndef PCTEST_H
#define PCTEST_H
#include <stdio.h>
#if STDC_HEADERS
#include <stdlib.h>
#include <string.h>
#endif /* STDC_HEADERS */
#if HAVE_UNISTD_H
#include <sys/types.h>
#endif /* HAVE_UNISTD_H */
#include <sys/socket.h>
#include <sys/time.h>
#include "pc.h"
// #include "TestRecord.h"
class TestRecord;
// Action codes. ICMPv4 and ICMPv6 have different values for their type
// and code fields. The Pctest abstracts these differences.
typedef enum {
PctestActionValid, // store valid measurement (e.g. ICMP
// time exceeded)
PctestActionValidLasthop, // store valid measurement, this is last hop
// (e.g. ICMP port unreachable)
PctestActionFiltered, // packets filtered, give up (e.g.
// ICMP prohibited)
PctestActionAbort // huh? we haven't a clue
} PctestActionType;
class Pctest {
public:
Pctest() {
initialized = 0;
TimeSyscall(syscallTime);
IF_DEBUG(3, fprintf(stderr, "syscallTime.tv_usec = %ld\n", syscallTime.tv_usec));
}
virtual ~Pctest() { };
// Get gettimeofday() system call overhead.
virtual void TimeSyscall(struct timeval &diff);
// Get random payload buffer
virtual char *GeneratePayload(int size);
// Set target host for our tests (resolve if necessary)
virtual int SetTargetName(char *target) = 0;
// Get target host name and address
virtual char *GetTargetName() { return targetName; };
virtual char *GetPrintableAddress() = 0;
virtual char *GetPrintableAddress(void *a) = 0;
virtual char *GetName(void *a) = 0;
virtual char *GetAddressFamily() = 0;
// Perform a test and return statistics
virtual int Test(TestRecord &tr) = 0;
virtual PctestActionType GetAction(TestRecord &tr) = 0;
virtual PctestActionType GetAction(TestRecord *tr) {
return this->GetAction(*tr);
};
virtual int GetMinSize() = 0;
protected:
int initialized; // initialization flag
char *targetName; // target hostname
struct timeval syscallTime; // estimated overhead for gettimeofday()
};
#endif /* PCTEST_H */

File diff suppressed because it is too large Load diff

View file

@ -1,993 +0,0 @@
/*****************************************************************************
Copyright (c) 1992 Consorzio Pisa Ricerche.
Authors: Caneve Maurizio, Salvatori Elena
This software was produced under the ESPRIT/LOTOSPHERE
project. All rights reserved.
*****************************************************************************/
/* */
/* @(#)abstract.h 4.31 2/1/93 */
/* */
#ifndef abstract_hh
#define abstract_hh
#include <tree.h>
#include <adatat.h>
class SignatureSorts;
class ID_Place: public Tree_Node
{
char *str;
char RBubble;
friend class Gl_Identifier;
public:
ID_Place();
void SetIdent(char *);
void SetPosition(Coord, Coord);
void SetDimensions(void);
void SetVisible(char);
void SetFather(Tree_Node *);
void ClearID(void);
virtual ~ID_Place();
/* inline functions */
char *GetIdent() {return(str);};
void SetRBubble(char r) { RBubble = r; };
char GetRBubble(void) { return(RBubble); };
}; /* end of class ID_Place */
class ID_List: public Tree_Node
{
ID_Place *elem;
ID_List *next;
friend class Gl_Id_List;
friend class Oper;
public:
ID_List(ID_Place *, ID_List *);
void SetPosition(Coord, Coord);
void SetDimensions(void);
void SetFather(Tree_Node *);
ID_Place *GetElem();
void HideMe(void);
void SetCollapsed(char);
void SetRBubble(char);
void BuildSigSorts(char, SignatureSorts **, char, Oper *);
void SetVisible(char);
void SetAlignement(char);
void ClearIDs(void);
int GetCardinality(int);
}; /* end of class ID_List */
class Id_Decl: public Tree_Node
{
ID_List *id_list;
ID_Place *sort_id;
friend class Gl_Id_Decl;
public:
Id_Decl(ID_List *, ID_Place *);
void SetPosition(Coord, Coord);
void SetDimensions(void);
void SetFather(Tree_Node *);
void SetCollapsed(char);
}; /* end of class Id_Decl */
class Id_Decl_List: public Tree_Node
{
Id_Decl *elem;
Id_Decl_List *next;
friend class Gl_Id_Decl_List;
public:
Id_Decl_List(Id_Decl *, Id_Decl_List *);
void SetPosition(Coord, Coord);
void SetDimensions(void);
void SetFather(Tree_Node *);
void SetCollapsed(char);
}; /* end of class Id_Decl_List */
class Comment: public Tree_Node
{
char *comm;
friend class Gl_Comment;
public:
Comment();
Comment(Tree_Node*, Coord , Coord);
void SetComment(char *);
void SetPosition(Coord, Coord);
void SetDimensions(void);
void SetFather(Tree_Node *);
virtual ~Comment();
}; /* end of class Comment */
class Comment_List: public Tree_Node
{
Comment *elem;
Comment_List *next;
public:
Comment_List(Comment *, Comment_List *);
void SetPosition(Coord, Coord);
void SetDimensions(void);
void SetFather(Tree_Node *);
}; /* end of class Comment_List */
class Value_Expr: public Tree_Node
{
friend class Gl_Value_Expr;
public:
Value_Expr();
void SetPosition(Coord, Coord);
void SetDimensions(void);
void SetFather(Tree_Node *);
}; /* end of class Value_Expr */
class Value_Expr_List: public Tree_Node
{
Tree_Node *elem;
Value_Expr_List *next;
friend class Gl_Value_Expr_List;
public:
Value_Expr_List(Tree_Node *, Value_Expr_List *);
void SetPosition(Coord, Coord);
void SetDimensions(void);
void SetFather(Tree_Node *);
void SetCollapsed(char);
}; /* end of class Value_Expr_List */
class Exit_Entry: public Tree_Node
{
friend class Gl_Exit_Entry;
public:
Exit_Entry();
void SetPosition(Coord, Coord);
void SetDimensions(void);
void SetFather(Tree_Node *);
}; /* end of class Exit_Entry */
class Exit_Entry_List: public Tree_Node
{
Tree_Node *elem;
Exit_Entry_List *next;
friend class Gl_Exit_Entry_List;
public:
Exit_Entry_List(Tree_Node *, Exit_Entry_List *);
void SetPosition(Coord, Coord);
void SetDimensions(void);
void SetFather(Tree_Node *);
void SetCollapsed(char);
}; /* end of class Exit_Entry_List */
class Exper_Off: public Tree_Node
{
public:
Exper_Off();
void SetPosition(Coord, Coord);
void SetDimensions(void);
void SetFather(Tree_Node *);
}; /* end of class Exper_Off */
class Exper_Off_List: public Tree_Node
{
Exper_Off *elem;
Exper_Off_List *next;
friend class Gl_Exper_Off_List;
public:
Exper_Off_List(Exper_Off *, Exper_Off_List *);
void SetPosition(Coord, Coord);
void SetDimensions(void);
void SetFather(Tree_Node *);
void SetCollapsed(char);
}; /* end of class Exper_Off_List */
class Gate_Decl: public Tree_Node
{
ID_List *gate_id_list1;
ID_List *gate_id_list2;
friend class Gl_Gate_Decl;
public:
Gate_Decl(ID_List *, ID_List *);
void SetPosition(Coord, Coord);
void SetDimensions(void);
void SetFather(Tree_Node *);
void SetCollapsed(char);
}; /* end of class Gate_Decl */
class Gate_Decl_List: public Tree_Node
{
Gate_Decl *elem;
Gate_Decl_List *next;
friend class Gl_Gate_Decl_List;
public:
Gate_Decl_List(Gate_Decl *, Gate_Decl_List *);
void SetPosition(Coord, Coord);
void SetDimensions(void);
void SetFather(Tree_Node *);
void SetCollapsed(char);
}; /* end of class Gate_Decl_List */
class Ident_Eq: public Tree_Node
{
Id_Decl *iddecl;
Value_Expr *expr;
friend class Gl_Ident_Eq;
public:
Ident_Eq(Id_Decl *, Value_Expr *);
void SetPosition(Coord, Coord);
void SetDimensions(void);
void SetFather(Tree_Node *);
void SetCollapsed(char);
}; /* end of class Ident_Eq */
class Ident_Eq_List: public Tree_Node
{
Ident_Eq *elem;
Ident_Eq_List *next;
friend class Gl_Ident_Eq_List;
public:
Ident_Eq_List(Ident_Eq *, Ident_Eq_List *);
void SetPosition(Coord, Coord);
void SetDimensions(void);
void SetFather(Tree_Node *);
void SetCollapsed(char);
}; /* end of class Ident_Eq_List */
class Half_Container: public Tree_Node
{
ID_List *gate_list;
friend class Gl_Half_Container;
public:
Half_Container(ID_List *);
void SetPosition(Coord, Coord);
void SetDimensions(void);
void SetFather(Tree_Node *);
void SetCollapsed(char);
}; /* end of class Half_Container */
/* */
/* Process Definitions */
/* */
class Specification: public Tree_Node
{
class Definition;
Comment_List *com_list;
ID_Place *ident;
ID_List *gate_list;
Id_Decl_List *id_decl_list;
Comment_List *com_list1;
Tree_Node *func;
Data_List *dt_list;
Definition *def;
Coord yl1,yl2,yl3;
Coord MaxX, MaxY;
friend class Gl_Specification;
public:
Specification(Comment_List *, ID_Place *, ID_List *, Id_Decl_List *,
Comment_List *, Definition *, Tree_Node *, Data_List *);
void SetPosition(Coord, Coord);
void SetDimensions(void);
void SetFather(Tree_Node *);
void SetPath(int&, int&);
Coord GetMaxX();
Coord GetMaxY();
}; /* end of class Specification */
class Process: public Tree_Node
{
Comment_List *com_list;
ID_Place *ident;
ID_List *gate_list;
Id_Decl_List *id_decl_list;
Definition *def;
Tree_Node *func;
char nesting;
Coord yl1,yl2,yl3,ypath;
Coord MaxX, MaxY;
friend class Gl_Process;
public:
Process(Comment_List *, ID_Place *, ID_List *,Id_Decl_List *, Definition *, Tree_Node *);
void SetPosition(Coord, Coord);
void SetDimensions(void);
void SetFather(Tree_Node *);
void SetPath(char *, char, int&, int&);
void NewBex(Tree_Node *);
Coord GetMaxY();
Coord GetMaxX();
/* inline functions */
char GetNesting() {return(nesting);};
}; /* end of class Process */
class Proc_List: public Tree_Node
{
Process *elem;
Proc_List *next;
public:
Proc_List(Process *, Proc_List *);
void SetPosition(Coord, Coord);
void SetDimensions(void);
void SetFather(Tree_Node *);
void SetPath(char *, char, int&, int&);
char *GetPath();
}; /* end of class Proc_List */
class Definition: public Tree_Node
{
Tree_Node *bex;
Proc_List *process_list;
Data_List *data_list;
char path[PATH_LENGHT];
public:
Definition(Tree_Node *, Proc_List *, Data_List *);
void SetPosition(Coord, Coord);
void SetDimensions(void);
void SetFather(Tree_Node *);
void SetPath(char *, char, int&, int&);
/* inline functions */
char *GetPath() { return(path);};
}; /* end of class Definition */
/* */
/* Functionalities */
/* */
class Exit: public Tree_Node
{
ID_List *sort_list;
friend class Gl_Exit;
public:
Exit(ID_List *);
void SetPosition(Coord, Coord, Coord, Coord);
void SetDimensions(void);
void SetFather(Tree_Node *);
}; /*end of class Exit */
class NoExit: public Tree_Node
{
friend class Gl_NoExit;
public:
NoExit();
void SetPosition(Coord, Coord);
void SetDimensions(void);
void SetFather(Tree_Node *);
}; /*end of class NoExit */
/* */
/* Value Expressions */
/* */
class Value: public Tree_Node
{
ID_Place *ident;
ID_Place *sort_id;
friend class Gl_Value;
public:
Value(ID_Place *, ID_Place *);
void SetPosition(Coord, Coord);
void SetDimensions(void);
void SetFather(Tree_Node *);
void SetCollapsed(char);
}; /* end of class Value */
class Term: public Tree_Node
{
ID_Place *op_ident;
Value_Expr_List *expr_list;
ID_Place *sort_id;
friend class Gl_Term;
public:
Term(ID_Place *, Value_Expr_List *, ID_Place *);
void SetPosition(Coord, Coord);
void SetDimensions(void);
void SetFather(Tree_Node *);
void SetCollapsed(char);
}; /* end of class Term */
class Equality: public Tree_Node
{
Tree_Node *express1;
Tree_Node *express2;
friend class Gl_Equality;
public:
Equality();
Equality(Tree_Node *, Tree_Node *);
void SetPosition(Coord, Coord);
void SetDimensions(void);
void SetFather(Tree_Node *);
void SetCollapsed(char);
}; /* end of class Equality */
class Sort_Id_Exit: public Tree_Node
{
ID_Place *sort_id;
friend class Gl_Sort_Id_Exit;
public:
Sort_Id_Exit(ID_Place *);
void SetPosition(Coord, Coord);
void SetDimensions(void);
void SetFather(Tree_Node *);
void SetCollapsed(char);
}; /* end of class Sort_id_Exit */
/* */
/* Guard Options */
/* */
class NoGuard: public Tree_Node
{
friend class Gl_NoGuard;
public:
NoGuard();
void SetPosition(Coord, Coord);
void SetDimensions(void);
void SetFather(Tree_Node *);
}; /* end of class NoGuard */
class Guard: public Tree_Node
{
Equality *equality;
friend class Gl_Guard;
public:
Guard(Equality *);
void SetPosition(Coord, Coord);
void SetDimensions(void);
void SetFather(Tree_Node *);
void SetCollapsed(char);
}; /* end of class Guard */
/* */
/* Experiment Offers */
/* */
class NoExperiment: public Tree_Node
{
friend class Gl_NoExperiment;
public:
NoExperiment();
void SetPosition(Coord, Coord);
void SetDimensions(void);
void SetFather(Tree_Node *);
}; /* end of class NoExperiment */
class Experiment: public Tree_Node
{
Exper_Off_List *exp_offer_list;
Tree_Node *guard_option;
friend class Gl_Experiment;
public:
Experiment(Exper_Off_List *, Tree_Node *);
void SetPosition(Coord, Coord);
void SetDimensions(void);
void SetFather(Tree_Node *);
void SetTextual(char, char = FALSE);
void SetCollapsed(char);
/* inline functions */
Tree_Node *GetGuard(void) { return(guard_option); };
}; /* end of class Experiment */
class Exclam: public Tree_Node
{
Tree_Node *value_exp;
friend class Gl_Exclam;
public:
Exclam(Tree_Node *);
void SetPosition(Coord, Coord);
void SetDimensions(void);
void SetFather(Tree_Node *);
void SetCollapsed(char);
}; /* end of class Exclam */
class Query: public Tree_Node
{
Id_Decl *id_decl;
friend class Gl_Query;
public:
Query(Id_Decl *);
void SetPosition(Coord, Coord);
void SetDimensions(void);
void SetFather(Tree_Node *);
void SetCollapsed(char);
}; /* end of class Query */
/* */
/* Action Denotations */
/* */
class Internal: public Tree_Node
{
friend class Gl_Internal;
public:
Internal();
void SetPosition(Coord, Coord);
void SetDimensions(void);
void SetFather(Tree_Node *);
}; /* end of class Internal */
class Communication: public Tree_Node
{
ID_Place *gate_identifier;
Tree_Node *experiment_option;
Coord xl, yl;
int hr;
friend class Gl_Communication;
public:
Communication(ID_Place *, Tree_Node *);
void SetPosition(Coord, Coord);
void SetDimensions(void);
void SetFather(Tree_Node *);
void SetTextual(char, char = FALSE);
void SetCollapsed(char);
}; /* end of class Communication */
/* */
/* Parallel Operators */
/* */
class Gen_Paral: public Tree_Node
{
ID_List *gate_id_list;
Coord Xclose;
char border;
friend class Gl_Gen_Paral;
public:
Gen_Paral(ID_List *);
void SetPosition(Coord, Coord);
void SetDimensions(void);
void SetFather(Tree_Node *);
void SetCollapsed(char);
/* inline functions */
void HideGate() { ((ID_List *)gate_id_list)->HideMe(); };
}; /* end of class Gen_Paral */
class Interl: public Tree_Node
{
friend class Gl_Interl;
public:
Interl();
void SetPosition(Coord, Coord);
void SetDimensions(void);
void SetFather(Tree_Node *);
}; /* end of class Interl */
class Syncr: public Tree_Node
{
friend class Gl_Syncr;
public:
Syncr();
void SetPosition(Coord, Coord);
void SetDimensions(void);
void SetFather(Tree_Node *);
}; /* end of class Syncr */
/* */
/* Bejhviour Expressions */
/* */
class Action_Pref: public Tree_Node
{
Tree_Node *action_den;
Tree_Node *bex;
char havebox;
char border;
friend class Gl_Action_Pref;
public:
Action_Pref(Tree_Node *, Tree_Node *);
void SetPosition(Coord, Coord);
void SetDimensions(void);
void SetFather(Tree_Node *);
void SetTextual(char, char = FALSE);
void SetCollapsed(char);
}; /* end of class Action_Pref */
class Enable: public Tree_Node
{
Tree_Node *bex1, *bex2;
ID_List *gate_id_list;
Coord xl, yl1, xl2, yl2, xid, yid, Yclose;
char havebox;
char border;
friend class Gl_Enable;
public:
Enable(Tree_Node *, ID_List *, Tree_Node *);
void SetPosition(Coord, Coord);
void SetDimensions(void);
void SetFather(Tree_Node *);
void SetTextual(char, char = FALSE);
int Get_Textual_H(void);
int Get_Textual_W(void);
void SetTerminalPos(void);
void SetCollapsed(char);
}; /* end of class Enable */
class Disable: public Tree_Node
{
Tree_Node *bex1, *bex2;
Coord xl, yl, yl2;
char havebox;
char border;
friend class Gl_Disable;
public:
Disable(Tree_Node *, Tree_Node *);
void SetPosition(Coord, Coord);
void SetDimensions(void);
void SetFather(Tree_Node *);
void SetTextual(char, char = FALSE);
int Get_Textual_H(void);
int Get_Textual_W(void);
void SetTerminalPos(void);
void SetCollapsed(char);
}; /* end of class Disable */
class Choice: public Tree_Node
{
Tree_Node *bex1, *bex2;
Coord xl, yl, yl1;
char havebox;
int delta;
char border;
friend class Gl_Choice;
public:
Choice(Tree_Node *, Tree_Node *);
void SetPosition(Coord, Coord);
void SetDimensions(void);
void SetFather(Tree_Node *);
void SetTextual(char, char = FALSE);
void SetCollapsed(char);
int Get_Textual_H(void);
int Get_Textual_W(void);
void SetTerminalPos(void);
void ChangeH(int);
void ChangeW(int);
}; /* end of class Choice */
class Stop: public Tree_Node
{
char havebox;
char border;
friend class Gl_Stop;
public:
Stop();
void SetPosition(Coord, Coord);
void SetDimensions(void);
void SetFather(Tree_Node *);
void SetTextual(char, char = FALSE);
void SetCollapsed(char);
}; /* end of class Stop */
class Exit_Bex: public Tree_Node
{
Exit_Entry_List *entry_list;
Coord Xopen, Xclose;
char havebox;
char border;
friend class Gl_Exit_Bex;
public:
Exit_Bex(Exit_Entry_List *);
void SetPosition(Coord, Coord);
void SetDimensions(void);
void SetFather(Tree_Node *);
void SetTextual(char, char = FALSE);
void SetCollapsed(char);
}; /*end of class Exit_Bex */
class Hide: public Tree_Node
{
ID_List *gate_list;
Tree_Node *bex;
char border;
Coord yl;
friend class Gl_Hide;
public:
Hide(ID_List *, Tree_Node *);
void SetPosition(Coord, Coord);
void SetDimensions(void);
void SetFather(Tree_Node *);
void SetTextual(char, char = FALSE);
void SetCollapsed(char);
}; /* end of class Hide */
class Guarded: public Tree_Node
{
Equality *equality;
Tree_Node *bex;
Coord Xclose;
char border;
friend class Gl_Guarded;
public:
Guarded(Equality *, Tree_Node *);
void SetPosition(Coord, Coord);
void SetDimensions(void);
void SetFather(Tree_Node *);
void SetTextual(char, char = FALSE);
void SetCollapsed(char);
}; /* end of class Guarded */
class Proc_Inst: public Tree_Node
{
ID_List *gate_list;
ID_Place *ident;
Value_Expr_List *value_expr_list;
Coord yp, yl1, Xopen, Xclose;
int hp;
char border;
friend class Gl_Proc_Inst;
public:
Proc_Inst(ID_Place *, ID_List *, Value_Expr_List *);
void SetPosition(Coord, Coord);
void SetDimensions(void);
void SetFather(Tree_Node *);
void SetTextual(char, char = FALSE);
void SetCollapsed(char);
}; /* end of class Proc_inst */
class Parallel: public Tree_Node
{
Tree_Node *bex1, *bex2, *oper;
Coord xl, yl, yl1;
char havebox;
int delta;
char border;
friend class Gl_Parallel;
public:
Parallel(Tree_Node *, Tree_Node *, Tree_Node *);
void SetPosition(Coord, Coord);
void SetDimensions(void);
void SetFather(Tree_Node *);
void SetTextual(char, char = FALSE);
int Get_Textual_W(void);
int Get_Textual_H(void);
void SetTerminalPos(void);
void SetCollapsed(char);
/* inline functions */
char GetOperType(void) { return(oper->GetType());};
}; /* end of class Parallel */
class Local_Def: public Tree_Node
{
Ident_Eq_List *equa_list;
Tree_Node *bex;
Coord yl;
char border;
friend class Gl_Local_Def;
public:
Local_Def(Ident_Eq_List *, Tree_Node *);
void SetPosition(Coord, Coord);
void SetDimensions(void);
void SetFather(Tree_Node *);
void SetTextual(char, char = FALSE);
void SetCollapsed(char);
}; /* end of class Local_Def */
class Par: public Tree_Node
{
Gate_Decl_List *gate_decl_list;
Tree_Node *oper, *bex;
Coord xl, yl;
char border;
friend class Gl_Par;
public:
Par(Gate_Decl_List *, Tree_Node *, Tree_Node *);
void SetPosition(Coord, Coord);
void SetDimensions(void);
void SetFather(Tree_Node *);
void SetTextual(char, char = FALSE);
void SetCollapsed(char);
}; /* end of class Par */
class Sum_Gate: public Tree_Node
{
Gate_Decl_List *gate_decl_list;
Tree_Node *bex;
Coord xl, yl, Xch, Ych, Xclose, Yclose;
char border;
friend class Gl_Sum_Gate;
public:
Sum_Gate(Gate_Decl_List *, Tree_Node *);
void SetPosition(Coord, Coord);
void SetDimensions(void);
void SetFather(Tree_Node *);
void SetTextual(char, char = FALSE);
void SetTerminalPos(void);
void SetCollapsed(char);
}; /* end of class Sum_Gate */
class Sum_Ident: public Tree_Node
{
Id_Decl_List *ident_decl_list;
Tree_Node *bex;
Coord xl, yl, Xch, Ych, Xclose, Yclose;
char border;
friend class Gl_Sum_Ident;
public:
Sum_Ident(Id_Decl_List *, Tree_Node *);
void SetPosition(Coord, Coord);
void SetDimensions(void);
void SetFather(Tree_Node *);
void SetTextual(char, char = FALSE);
void SetTerminalPos(void);
void SetCollapsed(char);
}; /* end of class Sum_Ident */
#endif

View file

@ -1,836 +0,0 @@
/*ident "@(#)cfront:src/cfront.h 1.13" */
/***********************************************************************
C++ source for cfront, the C++ compiler front-end
written in the computer science research center of Bell Labs
Copyright (c) 1984 AT&T, Inc. All Rights Reserved
THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T, INC.
When reading cfront code please remember that C++ was not available
when it was originally written. Out of necessity cfront is written
in a style that takes advantage of only few of C++'s features.
cfront.h:
Here is all the class definitions for cfront, and most of the externs
***********************************************************************/
/* WARNING:
This program relies on non-initialized class members being ZERO.
This will be true as long as they are allocated using the "new" operator
*/
#include "token.h"
#include "typedef.h"
extern bit old_fct_accepted; /* if set:
old style function definitions are legal,
implicit declarations are legal
*/
extern bit fct_void; /* if set:
int f(); ... f(1); gives a warning per file
undeclared(); gives a warning per file
if not:
int f(); ... f(1); is an error
undeclared(); is an error (currently only a warning)
*/
#ifndef GRAM
extern char* prog_name; // compiler name and version
extern int inline_restr; // inline expansion restrictions
extern bit emode; // print_mode error
#endif
extern Pname name_free; // free lists
extern Pexpr expr_free;
extern Pstmt stmt_free;
/* "spy" counters: */
extern int Nspy;
extern int Nfile, Nline, Ntoken, Nname, Nfree_store, Nalloc, Nfree;
extern int Nn, Nbt, Nt, Ne, Ns, Nstr, Nc, Nl;
extern int NFn, NFtn, NFpv, NFbt, NFf, NFs, NFc, NFe, NFl;
extern TOK lex();
extern Pname syn();
extern void init_print(); // stage initializers
extern void init_lex();
extern void int_syn();
extern void ext(int);
extern char* make_name(TOK);
struct loc // a source file location
{
short file; // index into file_name[], or zero
short line;
#ifndef GRAM
void put(FILE*);
void putline();
#endif
};
extern Loc curloc;
extern int curr_file;
struct ea { // fudge portable printf-like formatting for error()
union {
void* p;
int i;
};
ea(void* pp) { p = pp; }
ea(int ii) { i = ii; }
ea() {}
ea(int i) { x; }
};
extern ea* ea0;
overload error;
int error(const char*, ea& = *ea0, ea& = *ea0, ea& = *ea0, ea& = *ea0);
int error(loc*, const char*, ea& = *ea0, ea& = *ea0, ea& = *ea0, ea& = *ea0);
int error(int, const char*, ea& = *ea0, ea& = *ea0, ea& = *ea0, ea& = *ea0);
int error(int, loc*, const char*, ea& = *ea0, ea& = *ea0, ea& = *ea0, ea& = *ea0);
#ifndef GRAM
extern int error_count;
extern bit debug;
extern int vtbl_opt;
extern FILE* out_file;
extern FILE* in_file;
extern char scan_started;
extern bit warn;
#endif
extern int br_level;
extern int bl_level;
extern Ptable ktbl; // keywords and typedef names
extern Ptable gtbl; // global names
extern char* oper_name(TOK);
extern Pclass ccl;
extern Pbase defa_type;
extern Pbase moe_type;
#ifndef GRAM
extern Pstmt Cstmt; // current statement, or 0
extern Pname Cdcl; // name currently being declared, or 0
extern void put_dcl_context();
extern Ptable any_tbl; // table of undefined struct members
extern Pbase any_type;
#endif
extern Pbase int_type;
extern Pbase char_type;
extern Pbase short_type;
extern Pbase long_type;
extern Pbase uint_type;
extern Pbase float_type;
extern Pbase double_type;
extern Pbase void_type;
#ifndef GRAM
extern Pbase uchar_type;
extern Pbase ushort_type;
extern Pbase ulong_type;
extern Ptype Pchar_type;
extern Ptype Pint_type;
extern Ptype Pfctvec_type;
extern Ptype Pfctchar_type;
extern Ptype Pvoid_type;
extern Pbase zero_type;
extern int byte_offset;
extern int bit_offset;
extern int max_align;
extern int stack_size;
extern int enum_count;
extern int const_save;
#endif
extern Pexpr dummy; /* the empty expression */
extern Pexpr zero;
extern Pexpr one;
extern Pname sta_name; /* qualifier for unary :: */
#define DEL(p) if (p && (p->permanent==0)) p->del()
#define PERM(p) p->permanent=1
#define UNPERM(p) p->permanent=0
struct node {
TOK base;
TOK n_key; /* for names in table: class */
bit permanent;
};
#ifndef GRAM
extern Pclass Ebase, Epriv; /* lookc return values */
#endif
struct table : node {
/* a table is a node only to give it a "base" for debugging */
char init_stat; /* ==0 if block(s) of table not simplified,
==1 if simplified but had no initializers,
==2 if simplified and had initializers.
*/
short size;
short hashsize;
short free_slot; /* next free slot in entries */
Pname* entries;
short* hashtbl;
Pstmt real_block; /* the last block the user wrote,
not one of the ones cfront created
*/
Ptable next; /* table for enclosing scope */
Pname t_name; /* name of the table */
table(short, Ptable, Pname);
Pname look(char*, TOK);
Pname insert(Pname, TOK);
#ifndef GRAM
void grow(int);
void set_scope(Ptable t) { next = t; };
void set_name(Pname n) { t_name = n; };
Pname get_mem(int);
int max() { return free_slot-1; };
void dcl_print(TOK,TOK);
Pname lookc(char*, TOK);
Pexpr find_name(Pname, bit, Pexpr);
void del();
#endif
};
#ifndef GRAM
extern bit Nold;
extern bit vec_const, fct_const;
#endif
extern void restore();
extern void set_scope(Pname);
extern Plist modified_tn;
extern Pbase start_cl(TOK, Pname, Pname);
extern void end_cl();
extern Pbase end_enum(Pname, Pname);
/************ types : basic types, aggregates, declarators ************/
#ifndef GRAM
extern bit new_type;
extern Pname cl_obj_vec;
extern Pname eobj;
#endif
#define DEFINED 01 /* definition fed through ?::dcl() */
#define SIMPLIFIED 02 /* in ?::simpl() */
#define DEF_SEEN 04 /* definition seen, but not processed */
/* used for class members in norm.c */
#define IN_ERROR 010
struct type : node {
bit defined; /* flags DEF_SEEN, DEFINED, SIMPLIFIED, IN_ERROR
not used systematically yet
*/
char* signature(char*);
#ifndef GRAM
void print();
void dcl_print(Pname);
void base_print();
void del();
Pname is_cl_obj(); /* sets cl_obj_vec */
int is_ref();
void dcl(Ptable);
int tsizeof();
bit tconst();
TOK set_const(bit);
int align();
TOK kind(TOK,TOK);
TOK integral(TOK oo) { return kind(oo,I); };
TOK numeric(TOK oo) { return kind(oo,N); };
TOK num_ptr(TOK oo) { return kind(oo,P); };
bit vec_type();
bit check(Ptype, TOK);
Ptype deref();
Pptr addrof();
#endif
};
struct enumdef : type { /* ENUM */
bit e_body;
short no_of_enumerators;
Pname mem;
enumdef(Pname n) { base=ENUM; mem=n; };
#ifndef GRAM
void print();
void dcl_print(Pname);
void dcl(Pname, Ptable);
void simpl();
#endif
};
struct classdef : type { /* CLASS */
bit pubbase;
bit c_body; /* print definition only once */
TOK csu; /* CLASS, STRUCT, UNION, or ANON */
char obj_align;
char bit_ass; // 1 if no member has operator=()
char virt_count; /* number of virtual functions
incl. virtuals in base classes */
Pname clbase; // base class
char* string; /* name of class */
Pname mem_list;
Ptable memtbl;
int obj_size;
int real_size; /* obj_size - alignment waste */
Plist friend_list;
Pname pubdef;
Plist tn_list; // list of member names hiding type names
Pclass in_class; /* enclosing class, or 0 */
Ptype this_type;
Pname* virt_init; /* vector of jump table initializers */
Pname itor; /* constructor X(X&) */
Pname conv; /* operator T() chain */
classdef(TOK);
TOK is_simple() { return (csu==CLASS)?0:csu; };
#ifndef GRAM
void print();
void dcl_print(Pname);
void simpl();
void print_members();
void dcl(Pname, Ptable);
bit has_friend(Pname);
bit baseof(Pname);
bit baseof(Pclass);
Pname has_oper(TOK);
Pname has_ctor() { return memtbl->look("_ctor",0); }
Pname has_dtor() { return memtbl->look("_dtor",0); }
Pname has_itor() { return itor; }
Pname has_ictor();
#endif
};
struct basetype : type
/* ZTYPE CHAR SHORT INT LONG FLOAT DOUBLE
FIELD EOBJ COBJ TYPE ANY
*/
/* used for gathering all the attributes
for a list of declarators
ZTYPE is the (generic) type of ZERO
ANY is the generic type of an undeclared name
*/
{
bit b_unsigned;
bit b_const;
bit b_typedef;
bit b_inline;
bit b_virtual;
bit b_short;
bit b_long;
char b_bits; /* number of bits in field */
char b_offset; // bit offset of field
TOK b_sto; /* AUTO STATIC EXTERN REGISTER 0 */
Pname b_name; /* name of non-basic type */
Ptable b_table; /* memtbl for b_name, or 0 */
Pexpr b_field; /* field size expression for a field */
Pname b_xname; /* extra name */
Ptype b_fieldtype;
basetype(TOK, Pname);
Pbase type_adj(TOK);
Pbase base_adj(Pbase);
Pbase name_adj(Pname);
Pname aggr();
void normalize();
#ifndef GRAM
Pbase check(Pname);
void dcl_print();
Pbase arit_conv(Pbase);
#endif
};
struct fct : type // FCT
{
TOK nargs;
TOK nargs_known; // KNOWN, ELLIPSIS, or 0
char f_virtual; // 1+index in virtual table, or 0
char f_inline; // 1 if inline, 2 if being expanded, else 0
Ptype returns;
Pname argtype;
Ptype s_returns;
Pname f_this;
Pclass memof; // member of class memof
Pblock body;
Pname f_init; // base/member initializers
// null name => base class init;
// ids => member classes (with ctors)
Pexpr b_init; // base class initializer
// ctor call after fct.dcl()
// int frame_size;
Pexpr f_expr; // body expanded into an expression
Pexpr last_expanded;
Pname f_result; // extra second argument of type X&
fct(Ptype, Pname, TOK);
void argdcl(Pname,Pname);
#ifndef GRAM
Ptype normalize(Ptype);
void dcl_print();
void dcl(Pname);
Pexpr base_init(Pname, Pexpr, Ptable);
Pexpr mem_init(Pname, Pexpr, Ptable);
bit declared() { return nargs_known; };
void simpl();
Pexpr expand(Pname,Ptable,Pexpr);
#endif
};
struct name_list {
Pname f;
Plist l;
name_list(Pname ff, Plist ll) { f=ff; l=ll; };
};
#ifndef GRAM
struct gen : type { // OVERLOAD
Plist fct_list;
char* string;
gen(char*);
Pname add(Pname, int);
Pname find(Pfct, bit);
};
#endif
struct pvtyp : type {
Ptype typ;
};
struct vec : pvtyp // VEC
// typ [ dim ]
{
Pexpr dim;
int size;
vec(Ptype t, Pexpr e) { Nt++; base=VEC; typ=t; dim=e; };
#ifndef GRAM
Ptype normalize(Ptype);
#endif
};
struct ptr : pvtyp // PTR, RPTR i.e. reference
{
Pclass memof; // pointer to member of memof: memof::*
bit rdo; // "*const"
ptr(TOK b, Ptype t, bit r = 0) { Nt++; base=b; typ=t; rdo=r; };
#ifndef GRAM
Ptype normalize(Ptype);
#endif
};
#ifndef GRAM
inline Pptr type::addrof() { return new ptr(PTR,this,0); }
extern bit vrp_equiv;
#endif
/****************************** constants ********************************/
/* STRING ZERO ICON FCON CCON ID */
/* IVAL FVAL LVAL */
/***************************** expressions ********************************/
#ifndef GRAM
extern Pexpr next_elem();
extern void new_list(Pexpr);
extern void list_check(Pname, Ptype, Pexpr);
extern Pexpr ref_init(Pptr,Pexpr,Ptable);
extern Pexpr class_init(Pexpr,Ptype,Pexpr,Ptable);
extern Pexpr check_cond(Pexpr, TOK, Ptable);
#endif
struct expr : node /* PLUS, MINUS, etc. */
/* IMPORTANT: all expressions are of sizeof(expr) */
/* DEREF => *e1 (e2==0) OR e1[e2]
UMINUS => -e2
INCR (e1==0) => ++e2
INCR (e2==0) => e1++
CM => e1 , e2
ILIST => LC e1 RC (an initializer list)
a Pexpr may denote a name
*/
{
union {
Ptype tp;
int syn_class;
};
union {
Pexpr e1;
char* string;
int i1;
};
union {
Pexpr e2;
Pexpr n_initializer;
char* string2;
};
union { /* used by the derived classes */
Ptype tp2;
Pname fct_name;
Pexpr cond;
Pname mem;
Ptype as_type;
Ptable n_table;
Pin il;
};
expr(TOK, Pexpr, Pexpr);
~expr();
#ifndef GRAM
void del();
void print();
Pexpr typ(Ptable);
int eval();
int lval(TOK);
Ptype fct_call(Ptable);
Pexpr address();
Pexpr contents();
void simpl();
Pexpr expand();
bit not_simple();
Pexpr try_to_overload(Ptable);
Pexpr docast(Ptable);
Pexpr dovalue(Ptable);
Pexpr donew(Ptable);
void simpl_new();
void simpl_delete();
#endif
};
struct texpr : expr { // NEW CAST VALUE
texpr(TOK bb, Ptype tt, Pexpr ee) : (bb,ee,0) {this=0; tp2=tt;}
};
struct ival : expr { // NEW CAST VALUE
ival(int ii) : (IVAL,0,0) {this=0; i1 = ii;}
};
struct call : expr { // CALL
call(Pexpr aa, Pexpr bb) : (CALL,aa,bb) { this=0; }
#ifndef GRAM
void simpl();
Pexpr expand(Ptable);
#endif
};
struct qexpr : expr { // QUEST cond ? e1 : e2
qexpr(Pexpr ee, Pexpr ee1, Pexpr ee2) : (QUEST,ee1,ee2) { this=0; cond=ee; }
};
struct ref : expr { // REF DOT e1->mem OR e1.mem
ref(TOK ba, Pexpr a, Pname b) : (ba,a,0) { this=0; mem=b; }
};
struct text_expr : expr { // TEXT
text_expr(char* a, char* b) : (TEXT,0,0) { string=a; string2=b; }
};
/************************* names (are expressions) ****************************/
struct name : expr { // NAME TNAME and the keywords in the ktbl
TOK n_oper; // name of operator or 0
TOK n_sto; // EXTERN STATIC AUTO REGISTER ENUM 0
TOK n_stclass; // STATIC AUTO REGISTER 0
TOK n_scope; // EXTERN STATIC FCT ARG PUBLIC 0
unsigned char n_union; // 0 or union index
bit n_evaluated; // 0 or n_val holds the value
bit n_xref; // argument of type X(X&)
unsigned char lex_level;
TOK n_protect; // PROTECTED (<=>n_scope==0) or 0
short n_addr_taken;
short n_used;
short n_assigned_to;
Loc where;
int n_val; // the value of n_initializer
// also used as the argument number
// for inline arguments
int n_offset; // byte offset in frame or struct
Pname n_list;
Pname n_tbl_list;
union {
Pname n_qualifier; // name of containing class
Ptable n_realscope; /* for labels (always entered in
function table) the table for the
actual scope in which label occurred.
*/
};
name(char* =0);
~name();
Pname normalize(Pbase, Pblock, bit);
Pname tdef();
Pname tname(TOK);
void hide();
void unhide() { n_key=0; n_list=0; };
#ifndef GRAM
Pname dcl(Ptable,TOK);
int no_of_names();
void use() { n_used++; };
void assign();
void take_addr() { n_addr_taken++; };
void check_oper(Pname);
void simpl();
void del();
void print();
void dcl_print(TOK);
void field_align();
Pname dofct(Ptable,TOK);
#endif
};
#ifndef GRAM
extern int friend_in_class;
#endif
/******************** statements *********************************/
struct stmt : node { /* BREAK CONTINUE DEFAULT */
/* IMPORTANT: all statement nodes have sizeof(stmt) */
Pstmt s;
Pstmt s_list;
Loc where;
union {
Pname d;
Pexpr e2;
Pstmt has_default;
int case_value;
Ptype ret_tp;
};
union {
Pexpr e;
bit own_tbl;
Pstmt s2;
};
Ptable memtbl;
union {
Pstmt for_init;
Pstmt else_stmt;
Pstmt case_list;
bit empty;
};
stmt(TOK, loc, Pstmt);
~stmt();
#ifndef GRAM
void del();
void print();
void dcl();
void reached();
Pstmt simpl();
Pstmt expand();
Pstmt copy();
#endif
};
#ifndef GRAM
extern char* Neval;
extern Pname dcl_temp(Ptable, Pname);
extern char* temp(char*, char*, char*);
extern Ptable scope;
extern Ptable expand_tbl;
extern Pname expand_fn;
#endif
struct estmt : stmt /* SM WHILE DO SWITCH RETURN CASE */
/* SM (e!=0) => e;
in particular assignments and function calls
SM (e==0) => ; (the null statement)
CASE => case e : s ;
*/
{
estmt(TOK t, loc ll, Pexpr ee, Pstmt ss) : (t,ll,ss) { this=0; e=ee; }
};
struct ifstmt : stmt /* IF */
// else_stme==0 => if (e) s
// else_stmt!=0 => if (e) s else else_stmt
{
ifstmt(loc ll, Pexpr ee, Pstmt ss1, Pstmt ss2)
: (IF,ll,ss1) { this=0; e=ee; else_stmt=ss2; };
};
struct lstmt : stmt /* LABEL GOTO */
/*
d : s
goto d
*/
{
lstmt(TOK bb, loc ll, Pname nn, Pstmt ss) : (bb,ll,ss) { this=0; d=nn; }
};
struct forstmt : stmt { // FOR
forstmt(loc ll, Pstmt fss, Pexpr ee1, Pexpr ee2, Pstmt ss)
: (FOR,ll,ss) { this=0; for_init=fss; e=ee1; e2=ee2; }
};
struct block : stmt { // BLOCK { d s }
block(loc ll, Pname nn, Pstmt ss) : (BLOCK,ll,ss) { this=0; d=nn; }
#ifndef GRAM
void dcl(Ptable);
Pstmt simpl();
#endif
};
#ifndef GRAM
struct pair : public stmt { // PAIR
pair(loc ll, Pstmt a, Pstmt b) : (PAIR,ll,a) { this=0; s2 = b; }
};
#endif
struct nlist {
Pname head;
Pname tail;
nlist(Pname);
void add(Pname n) { tail->n_list = n; tail = n; };
void add_list(Pname);
};
extern Pname name_unlist(nlist*);
struct slist {
Pstmt head;
Pstmt tail;
slist(Pstmt s) { Nl++; head = tail = s; };
void add(Pstmt s) { tail->s_list = s; tail = s; };
};
extern Pstmt stmt_unlist(slist*);
struct elist {
Pexpr head;
Pexpr tail;
elist(Pexpr e) { Nl++; head = tail = e; };
void add(Pexpr e) { tail->e2 = e; tail = e; };
};
extern Pexpr expr_unlist(elist*);
#ifndef GRAM
extern class dcl_context * cc;
struct dcl_context {
Pname c_this; /* current fct's "this" */
Ptype tot; /* type of "this" or 0 */
Pname not; /* name of "this"'s class or 0 */
Pclass cot; /* the definition of "this"'s class */
Ptable ftbl; /* current fct's symbol table */
Pname nof; /* current fct's name */
void stack() { cc++; *cc = *(cc-1); };
void unstack() { cc--; };
};
#define MAXCONT 20
extern dcl_context ccvec[MAXCONT];
#endif
extern void yyerror(char*);
extern TOK back;
#ifndef GRAM
extern char* line_format;
extern Plist isf_list;
extern Pstmt st_ilist;
extern Pstmt st_dlist;
extern Ptable sti_tbl;
extern Ptable std_tbl;
Pexpr try_to_coerce(Ptype, Pexpr, char*, Ptable);
extern bit can_coerce(Ptype, Ptype);
extern Ptype np_promote(TOK, TOK, TOK, Ptype, Ptype, TOK);
extern void new_key(char*, TOK, TOK);
extern Pname dcl_list;
extern int over_call(Pname, Pexpr);
extern Pname Nover;
extern Pname Ntncheck;
extern Pname Ncoerce;
extern Nover_coerce;
const MIA = 8;
struct iline {
Pname fct_name; /* fct called */
Pin i_next;
Ptable i_table;
Pname local[MIA]; /* local variable for arguments */
Pexpr arg[MIA]; /* actual arguments for call */
Ptype tp[MIA]; /* type of formal arguments */
};
extern Pexpr curr_expr;
extern Pin curr_icall;
#define FUDGE111 111
extern Pstmt curr_loop;
extern Pblock curr_block;
extern Pstmt curr_switch;
extern bit arg_err_suppress;
extern loc last_line;
extern no_of_undcl;
extern no_of_badcall;
extern Pname undcl, badcall;
extern int strlen(const char*);
extern char* strcpy(char*, const char*);
extern int str_to_int(const char*);
extern int c_strlen(const char* s);
#endif
extern int strcmp(const char*, const char*);
#ifndef GRAM
extern Pname vec_new_fct;
extern Pname vec_del_fct;
extern int Nstd; // standard coercion used (derived* =>base* or int=>long or ...)
extern int stcount; // number of names generated using make_name()
extern Pname find_hidden(Pname);
Pexpr replace_temp(Pexpr,Pexpr);
void make_res(Pfct);
Pexpr ptr_init(Pptr,Pexpr,Ptable);
#endif
extern bit fake_sizeof; // suppress error message for ``int v[];''
extern TOK lalex();
#ifdef DEBUG
extern fprintf(FILE*, char* ...);
#define DB(a) fprintf a
#else
#define DB(a) /**/
#endif
/* end */

View file

@ -1,297 +0,0 @@
%%% The contents of this file are subject to the Erlang Public License,
%%% Version 1.0, (the "License"); you may not use this file except in
%%% compliance with the License. You may obtain a copy of the License at
%%% http://www.erlang.org/license/EPL1_0.txt
%%%
%%% Software distributed under the License is distributed on an "AS IS"
%%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
%%% the License for the specific language governing rights and limitations
%%% under the License.
%%%
%%% The Original Code is lines-1.0.
%%%
%%% The Initial Developer of the Original Code is Ericsson Telecom
%%% AB. Portions created by Ericsson are Copyright (C), 1998, Ericsson
%%% Telecom AB. All Rights Reserved.
%%%
%%% Contributor(s): ______________________________________.
%%%----------------------------------------------------------------------
%%% #0. BASIC INFORMATION
%%%----------------------------------------------------------------------
%%% File: lines.erl
%%% Author : Ulf Wiger <ulf.wiger@ericsson.com>
%%% Description : Efficient array of lines (e.g. for text editor)
%%%
%%% Modules used : lists
%%%
%%%----------------------------------------------------------------------
%%% Efficient array of lines (e.g. for text editor)
%%% allows for append, as well as insert, replace, delete in any position
%%% with reasonable access times.
%%% Rough benchmarking indicates (on a 440MHz Ultra):
%%%
%%% NoOfLines Append (uSec) Read (uSec) Delete (uSec)
%%% 100 9 7 7
%%% 1,000 14 10 11
%%% 10,000 22 13 15
%%% 100,000 30 16 18
%%%
%%% Comment on the benchmark: The times for Append and Delete are mean
%%% times for "growing file" and "shrinking file", that is, starting from
%%% an empty array and inserting 100,000 lines took ca 3 seconds; deleting
%%% them took ca 1.8 seconds. The Read test involved accessing all lines
%%% in the full array and calculating the mean time.
%%%
%%% The array doesn't care what goes into each position. In other words,
%%% it can be used for any datatype -- not just lines of text.
%%%----------------------------------------------------------------------
-module(lines).
-vsn('1.0').
-date('00-03-13').
-author('ulf.wiger@ericsson.com').
-export([new/0,
count/1,
nth/2,
append/2,
replace/3,
insert/3,
insert_after/3,
delete/2,
convert_to_list/1,
convert_from_list/1]).
-define(BREAK, 10). % how many lines to store in each leaf
-define(dbg(Fmt, Args), ok=io:format("~p: " ++ Fmt, [?LINE|Args])).
%% new() -> line_array()
%%
%% Creates a new line array.
%%
new() ->
{0, []}.
%% line_count(line_array()) -> integer()
%%
%% Returns the number of lines stored in the array
%%
count({N, _}) ->
N.
%% nth(LineNo : integer(), Array : line_array()) -> line()
%%
%% Returns the line in position LineNo
%%
nth(L, _) when L < 1 ->
exit({out_of_range, L});
nth(L, {LMax, _}) when L > LMax ->
exit({out_of_range, L});
nth(L, {LMax, List}) when list(List) ->
lists:nth(L, List);
nth(L, {LMax, {Left = {LL, _}, Right}}) when L > LL ->
nth(L-LL, Right);
nth(L, {_, {Left, _}}) ->
nth(L, Left).
%% append(Line : line(), Array : line_array()) -> line_array().
%%
%% Appends Line to the end of Array.
%% e.g. append(x, [1,2,3,4]) -> [1,2,3,4,x].
%% Returns the modified array.
%%
append(Line, {L, List}) when list(List), L < ?BREAK ->
{L+1, List ++ [Line]};
append(Line, {L, List}) when list(List) ->
{L+1, {{L, List}, {1, [Line]}}};
append(Line, {L, {Left = {LL1, L1}, Right}}) ->
NewRight = append(Line, Right),
balance_left(L+1, Left, NewRight).
%% replace(LineNo : integer(), Array : line_array(), NewLine : line()) ->
%% line_array().
%%
%% Replaces the line in position LineNo with NewLine.
%% e.g. replace(3, [1,2,3,4], x) -> [1,2,x,4].
%% Returns the modified array.
%%
replace(Lno, _, _) when Lno < 1 ->
exit({out_of_range, Lno});
replace(Lno, {L, _}, NewLine) when Lno > L ->
exit({out_of_range, Lno});
replace(Lno, {L, List}, NewLine) when list(List) ->
{L, replace_nth(Lno, List, NewLine)};
replace(Lno, {L, {Left={LL1, L1}, Right={LL2, L2}}}, NewLine) when Lno > LL1 ->
NewRight = replace(Lno-LL1, Right, NewLine),
{L, Left, NewRight};
replace(Lno, {L, {Left={LL1,L1}, Right={LL2,L2}}}, NewLine) ->
NewLeft = replace(Lno, Left, NewLine),
{L, NewLeft, Right}.
%% insert(LineNo : integer(), Array : line_array(), NewLine) -> line_array().
%%
%% Inserts NewLine *before* the line in position LineNo.
%% e.g. insert(3, [1,2,3,4], x) -> [1,2,x,3,4].
%% Returns the modified array.
%%
insert(Lno, _, _) when Lno < 1 ->
exit({out_of_range, Lno});
insert(Lno, {L, _}, NewLine) when Lno > L ->
exit({out_of_range, Lno});
insert(Lno, {L, List}, NewLine) when list(List) ->
if L < ?BREAK ->
{L+1, insert_nth(Lno, List, NewLine)};
true ->
NewList = insert_nth(Lno, List, NewLine),
{L1, L2} = split_at(?BREAK, NewList),
NewL = L+1,
{NewL, {{?BREAK, L1}, {NewL-?BREAK, L2}}}
end;
insert(Lno, {L, {Left={LL,_}, Right}}, NewLine) when Lno > LL ->
NewRight = insert(Lno-LL, Right, NewLine),
balance_left(L+1, Left, NewRight);
insert(Lno, {L, {Left, Right}}, NewLine) ->
NewLeft = insert(Lno, Left, NewLine),
balance_right(L+1, NewLeft, Right).
%% insert_after(LineNo : integer(), Array : line_array(), NewLine) ->
%% line_array().
%%
%% Inserts NewLine *after* the line in position LineNo.
%% e.g. insert(3, [1,2,3,4], x) -> [1,2,3,x,4].
%% Returns the modified array.
%%
insert_after(Lno, _, _) when Lno < 1 ->
exit({out_of_range, Lno});
insert_after(Lno, {L, _}, NewLine) when Lno > L ->
exit({out_of_range, Lno});
insert_after(Lno, {L, List}, NewLine) when list(List) ->
if L < ?BREAK ->
{L+1, insert_after_nth(Lno, List, NewLine)};
true ->
NewList = insert_after_nth(Lno, List, NewLine),
{L1, L2} = split_at(?BREAK, NewList),
NewL = L+1,
{NewL, {{?BREAK, L1}, {NewL-?BREAK, L2}}}
end;
insert_after(Lno, {L, {Left={LL,_}, Right}}, NewLine) when Lno > LL ->
NewRight = insert_after(Lno-LL, Right, NewLine),
balance_left(L+1, Left, NewRight);
insert_after(Lno, {L, {Left, Right}}, NewLine) ->
NewLeft = insert_after(Lno, Left, NewLine),
balance_right(L+1, NewLeft, Right).
%% delete(LineNo : integer(), Array : line_array()) -> line_array().
%%
%% Deletes the line in position LineNo.
%% e.g. delete(3, [1,2,3,4]) -> [1,2,4].
%% Returns the modified array.
%%
delete(Lno, _) when Lno < 1 ->
exit({out_of_range, Lno});
delete(Lno, {N_Tot, _}) when Lno > N_Tot ->
exit({out_of_range, Lno});
delete(Lno, {N, List}) when list(List) ->
{N-1, delete_nth(Lno, List)};
delete(Lno, {N, {Left = {N_Left, _}, Right}}) when Lno > N_Left ->
case delete(Lno-N_Left, Right) of
{0, _} ->
case N-1 of N_Left -> ok end, % Assert
Left;
NewRight ->
balance_right(N-1, Left, NewRight)
end;
delete(Lno, {N, {Left, Right = {N_Right,_}}}) ->
case delete(Lno, Left) of
{0, _} ->
case N-1 of N_Right -> ok end, % Assert
Right;
NewLeft ->
balance_left(N-1, NewLeft, Right)
end.
convert_to_list({_, List}) when list(List) ->
List;
convert_to_list({L, {Left, Right}}) ->
convert_to_list(Left) ++ convert_to_list(Right).
convert_from_list(L) when list(L) ->
lists:foldl(fun(Ln, Lsx) ->
append(Ln, Lsx)
end, new(), L).
%%% ===========================================================
%%% internal functions
%%% ===========================================================
replace_nth(1, [H|T], X) ->
[X|T];
replace_nth(N, [H|T], X) ->
[H|replace_nth(N-1, T, X)].
insert_nth(1, L, X) ->
[X|L];
insert_nth(N, [H|T], X) ->
[H|insert_nth(N-1, T, X)].
insert_after_nth(1, [H|T], X) ->
[H,X|T];
insert_after_nth(N, [H|T], X) ->
[H|insert_after_nth(N-1, T, X)].
delete_nth(1, [H|T]) ->
T;
delete_nth(N, [H|T]) ->
[H|delete_nth(N-1, T)].
%% split_at(Pos, List) -> {List1, List2}
%% split List into two after position Pos (List1 includes List[Pos])
%%
split_at(Pos, L) ->
split_at(Pos, L, []).
split_at(0, L, Acc) ->
{lists:reverse(Acc), L};
split_at(Pos, [H|T], Acc) ->
split_at(Pos-1, T, [H|Acc]).
%% Balancing functions
%% Since we know whether we inserted/deleted in the right or left subtree,
%% we have explicit balancing functions for each case.
%% We rebalance if the number of elements in one sub-subtree exceeds the
%% sum of elements in the others.
balance_left(N_Tot,
Left = {N_Left, _},
Right = {N_Right, {RLeft = {N_RLeft, _},
RRight = {N_RRight, _}}}) ->
NewN_Left = N_Left + N_RLeft,
if N_RRight > NewN_Left ->
NewLeft = {NewN_Left, {Left, RLeft}},
NewRight = RRight,
{N_Tot, {NewLeft, NewRight}};
true ->
{N_Tot, {Left, Right}}
end;
balance_left(N_Tot, Left, Right) ->
{N_Tot, {Left, Right}}.
balance_right(N_Tot,
Left = {N_Left, {LLeft = {N_LLeft, _},
LRight = {N_LRight, _}}},
Right = {N_Right, _}) ->
NewN_Right = N_Right + N_LRight,
if N_LLeft > NewN_Right ->
NewLeft = LLeft,
NewRight = {NewN_Right, {LRight, Right}},
{N_Tot, {NewLeft, NewRight}};
true ->
{N_Tot, {Left, Right}}
end;
balance_right(N_Tot, Left, Right) ->
{N_Tot, {Left, Right}}.

Binary file not shown.

View file

@ -1,658 +0,0 @@
/*
* @(#)AWTEventMulticaster.java 1.10 97/01/23
*
* Copyright (c) 1996 Sun Microsystems, Inc. All Rights Reserved.
*
* This software is the confidential and proprietary information of Sun
* Microsystems, Inc. ("Confidential Information"). You shall not
* disclose such Confidential Information and shall use it only in
* accordance with the terms of the license agreement you entered into
* with Sun.
*
* SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
* SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
* IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
* SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
* THIS SOFTWARE OR ITS DERIVATIVES.
*
* CopyrightVersion 1.1_beta
*
*/
package java.awt;
import java.awt.event.*;
import java.util.EventListener;
import java.io.Serializable;
import java.io.ObjectOutputStream;
import java.io.IOException;
/**
* A class which implements efficient multi-cast event dispatching
* for the AWT events defined in the java.awt.event package. This
* class will manage the structure of a chain of event listeners
* and dispatch events to those listeners.
*
* An example of how this class could be used to implement a new
* component which fires "action" events:
*
* <pre><code>
* public myComponent extends Component {
* ActionListener actionListener = null;
*
* public void addActionListener(ActionListener l) {
* actionListener = AWTEventMulticaster.add(actionListener, l);
* }
* public void removeActionListener(ActionListener l) {
* actionListener = AWTEventMulticaster.remove(actionListener, l);
* }
* public void processEvent(AWTEvent e) {
* // when event occurs which causes "action" semantic
* if (actionListener != null) {
* actionListener.actionPerformed(new ActionEvent());
* }
* }
* </code></pre>
*
* @version 1.10, 23 Jan 1997
* @author John Rose
* @author Amy Fowler
*/
public class AWTEventMulticaster implements
ComponentListener, ContainerListener, FocusListener, KeyListener,
MouseListener, MouseMotionListener, WindowListener,
ActionListener, ItemListener, AdjustmentListener,
TextListener {
protected EventListener a, b;
/**
* Creates an event multicaster instance which chains listener-a
* with listener-b.
* @param a listener-a
* @param b listener-b
*/
protected AWTEventMulticaster(EventListener a, EventListener b) {
this.a = a; this.b = b;
}
/**
* Removes a listener from this multicaster and returns the
* resulting multicast listener.
* @param oldl the listener to be removed
*/
protected EventListener remove(EventListener oldl) {
if (oldl == a) return b;
if (oldl == b) return a;
EventListener a2 = removeInternal(a, oldl);
EventListener b2 = removeInternal(b, oldl);
if (a2 == a && b2 == b) {
return this; // it's not here
}
return addInternal(a2, b2);
}
/**
* Handles the componentResized event by invoking the
* componentResized methods on listener-a and listener-b.
* @param e the component event
*/
public void componentResized(ComponentEvent e) {
((ComponentListener)a).componentResized(e);
((ComponentListener)b).componentResized(e);
}
/**
* Handles the componentMoved event by invoking the
* componentMoved methods on listener-a and listener-b.
* @param e the component event
*/
public void componentMoved(ComponentEvent e) {
((ComponentListener)a).componentMoved(e);
((ComponentListener)b).componentMoved(e);
}
/**
* Handles the componentShown event by invoking the
* componentShown methods on listener-a and listener-b.
* @param e the component event
*/
public void componentShown(ComponentEvent e) {
((ComponentListener)a).componentShown(e);
((ComponentListener)b).componentShown(e);
}
/**
* Handles the componentHidden event by invoking the
* componentHidden methods on listener-a and listener-b.
* @param e the component event
*/
public void componentHidden(ComponentEvent e) {
((ComponentListener)a).componentHidden(e);
((ComponentListener)b).componentHidden(e);
}
/**
* Handles the componentAdded container event by invoking the
* componentAdded methods on listener-a and listener-b.
* @param e the component event
*/
public void componentAdded(ContainerEvent e) {
((ContainerListener)a).componentAdded(e);
((ContainerListener)b).componentAdded(e);
}
/**
* Handles the componentRemoved container event by invoking the
* componentRemoved methods on listener-a and listener-b.
* @param e the component event
*/
public void componentRemoved(ContainerEvent e) {
((ContainerListener)a).componentRemoved(e);
((ContainerListener)b).componentRemoved(e);
}
/**
* Handles the focusGained event by invoking the
* focusGained methods on listener-a and listener-b.
* @param e the focus event
*/
public void focusGained(FocusEvent e) {
((FocusListener)a).focusGained(e);
((FocusListener)b).focusGained(e);
}
/**
* Handles the focusLost event by invoking the
* focusLost methods on listener-a and listener-b.
* @param e the focus event
*/
public void focusLost(FocusEvent e) {
((FocusListener)a).focusLost(e);
((FocusListener)b).focusLost(e);
}
/**
* Handles the keyTyped event by invoking the
* keyTyped methods on listener-a and listener-b.
* @param e the key event
*/
public void keyTyped(KeyEvent e) {
((KeyListener)a).keyTyped(e);
((KeyListener)b).keyTyped(e);
}
/**
* Handles the keyPressed event by invoking the
* keyPressed methods on listener-a and listener-b.
* @param e the key event
*/
public void keyPressed(KeyEvent e) {
((KeyListener)a).keyPressed(e);
((KeyListener)b).keyPressed(e);
}
/**
* Handles the keyReleased event by invoking the
* keyReleased methods on listener-a and listener-b.
* @param e the key event
*/
public void keyReleased(KeyEvent e) {
((KeyListener)a).keyReleased(e);
((KeyListener)b).keyReleased(e);
}
/**
* Handles the mouseClicked event by invoking the
* mouseClicked methods on listener-a and listener-b.
* @param e the mouse event
*/
public void mouseClicked(MouseEvent e) {
((MouseListener)a).mouseClicked(e);
((MouseListener)b).mouseClicked(e);
}
/**
* Handles the mousePressed event by invoking the
* mousePressed methods on listener-a and listener-b.
* @param e the mouse event
*/
public void mousePressed(MouseEvent e) {
((MouseListener)a).mousePressed(e);
((MouseListener)b).mousePressed(e);
}
/**
* Handles the mouseReleased event by invoking the
* mouseReleased methods on listener-a and listener-b.
* @param e the mouse event
*/
public void mouseReleased(MouseEvent e) {
((MouseListener)a).mouseReleased(e);
((MouseListener)b).mouseReleased(e);
}
/**
* Handles the mouseEntered event by invoking the
* mouseEntered methods on listener-a and listener-b.
* @param e the mouse event
*/
public void mouseEntered(MouseEvent e) {
((MouseListener)a).mouseEntered(e);
((MouseListener)b).mouseEntered(e);
}
/**
* Handles the mouseExited event by invoking the
* mouseExited methods on listener-a and listener-b.
* @param e the mouse event
*/
public void mouseExited(MouseEvent e) {
((MouseListener)a).mouseExited(e);
((MouseListener)b).mouseExited(e);
}
/**
* Handles the mouseDragged event by invoking the
* mouseDragged methods on listener-a and listener-b.
* @param e the mouse event
*/
public void mouseDragged(MouseEvent e) {
((MouseMotionListener)a).mouseDragged(e);
((MouseMotionListener)b).mouseDragged(e);
}
/**
* Handles the mouseMoved event by invoking the
* mouseMoved methods on listener-a and listener-b.
* @param e the mouse event
*/
public void mouseMoved(MouseEvent e) {
((MouseMotionListener)a).mouseMoved(e);
((MouseMotionListener)b).mouseMoved(e);
}
/**
* Handles the windowOpened event by invoking the
* windowOpened methods on listener-a and listener-b.
* @param e the window event
*/
public void windowOpened(WindowEvent e) {
((WindowListener)a).windowOpened(e);
((WindowListener)b).windowOpened(e);
}
/**
* Handles the windowClosing event by invoking the
* windowClosing methods on listener-a and listener-b.
* @param e the window event
*/
public void windowClosing(WindowEvent e) {
((WindowListener)a).windowClosing(e);
((WindowListener)b).windowClosing(e);
}
/**
* Handles the windowClosed event by invoking the
* windowClosed methods on listener-a and listener-b.
* @param e the window event
*/
public void windowClosed(WindowEvent e) {
((WindowListener)a).windowClosed(e);
((WindowListener)b).windowClosed(e);
}
/**
* Handles the windowIconified event by invoking the
* windowIconified methods on listener-a and listener-b.
* @param e the window event
*/
public void windowIconified(WindowEvent e) {
((WindowListener)a).windowIconified(e);
((WindowListener)b).windowIconified(e);
}
/**
* Handles the windowDeiconfied event by invoking the
* windowDeiconified methods on listener-a and listener-b.
* @param e the window event
*/
public void windowDeiconified(WindowEvent e) {
((WindowListener)a).windowDeiconified(e);
((WindowListener)b).windowDeiconified(e);
}
/**
* Handles the windowActivated event by invoking the
* windowActivated methods on listener-a and listener-b.
* @param e the window event
*/
public void windowActivated(WindowEvent e) {
((WindowListener)a).windowActivated(e);
((WindowListener)b).windowActivated(e);
}
/**
* Handles the windowDeactivated event by invoking the
* windowDeactivated methods on listener-a and listener-b.
* @param e the window event
*/
public void windowDeactivated(WindowEvent e) {
((WindowListener)a).windowDeactivated(e);
((WindowListener)b).windowDeactivated(e);
}
/**
* Handles the actionPerformed event by invoking the
* actionPerformed methods on listener-a and listener-b.
* @param e the action event
*/
public void actionPerformed(ActionEvent e) {
((ActionListener)a).actionPerformed(e);
((ActionListener)b).actionPerformed(e);
}
/**
* Handles the itemStateChanged event by invoking the
* itemStateChanged methods on listener-a and listener-b.
* @param e the item event
*/
public void itemStateChanged(ItemEvent e) {
((ItemListener)a).itemStateChanged(e);
((ItemListener)b).itemStateChanged(e);
}
/**
* Handles the adjustmentValueChanged event by invoking the
* adjustmentValueChanged methods on listener-a and listener-b.
* @param e the adjustment event
*/
public void adjustmentValueChanged(AdjustmentEvent e) {
((AdjustmentListener)a).adjustmentValueChanged(e);
((AdjustmentListener)b).adjustmentValueChanged(e);
}
public void textValueChanged(TextEvent e) {
((TextListener)a).textValueChanged(e);
((TextListener)b).textValueChanged(e);
}
/**
* Adds component-listener-a with component-listener-b and
* returns the resulting multicast listener.
* @param a component-listener-a
* @param b component-listener-b
*/
public static ComponentListener add(ComponentListener a, ComponentListener b) {
return (ComponentListener)addInternal(a, b);
}
/**
* Adds container-listener-a with container-listener-b and
* returns the resulting multicast listener.
* @param a container-listener-a
* @param b container-listener-b
*/
public static ContainerListener add(ContainerListener a, ContainerListener b) {
return (ContainerListener)addInternal(a, b);
}
/**
* Adds focus-listener-a with focus-listener-b and
* returns the resulting multicast listener.
* @param a focus-listener-a
* @param b focus-listener-b
*/
public static FocusListener add(FocusListener a, FocusListener b) {
return (FocusListener)addInternal(a, b);
}
/**
* Adds key-listener-a with key-listener-b and
* returns the resulting multicast listener.
* @param a key-listener-a
* @param b key-listener-b
*/
public static KeyListener add(KeyListener a, KeyListener b) {
return (KeyListener)addInternal(a, b);
}
/**
* Adds mouse-listener-a with mouse-listener-b and
* returns the resulting multicast listener.
* @param a mouse-listener-a
* @param b mouse-listener-b
*/
public static MouseListener add(MouseListener a, MouseListener b) {
return (MouseListener)addInternal(a, b);
}
/**
* Adds mouse-motion-listener-a with mouse-motion-listener-b and
* returns the resulting multicast listener.
* @param a mouse-motion-listener-a
* @param b mouse-motion-listener-b
*/
public static MouseMotionListener add(MouseMotionListener a, MouseMotionListener b) {
return (MouseMotionListener)addInternal(a, b);
}
/**
* Adds window-listener-a with window-listener-b and
* returns the resulting multicast listener.
* @param a window-listener-a
* @param b window-listener-b
*/
public static WindowListener add(WindowListener a, WindowListener b) {
return (WindowListener)addInternal(a, b);
}
/**
* Adds action-listener-a with action-listener-b and
* returns the resulting multicast listener.
* @param a action-listener-a
* @param b action-listener-b
*/
public static ActionListener add(ActionListener a, ActionListener b) {
return (ActionListener)addInternal(a, b);
}
/**
* Adds item-listener-a with item-listener-b and
* returns the resulting multicast listener.
* @param a item-listener-a
* @param b item-listener-b
*/
public static ItemListener add(ItemListener a, ItemListener b) {
return (ItemListener)addInternal(a, b);
}
/**
* Adds adjustment-listener-a with adjustment-listener-b and
* returns the resulting multicast listener.
* @param a adjustment-listener-a
* @param b adjustment-listener-b
*/
public static AdjustmentListener add(AdjustmentListener a, AdjustmentListener b) {
return (AdjustmentListener)addInternal(a, b);
}
public static TextListener add(TextListener a, TextListener b) {
return (TextListener)addInternal(a, b);
}
/**
* Removes the old component-listener from component-listener-l and
* returns the resulting multicast listener.
* @param l component-listener-l
* @param oldl the component-listener being removed
*/
public static ComponentListener remove(ComponentListener l, ComponentListener oldl) {
return (ComponentListener) removeInternal(l, oldl);
}
/**
* Removes the old container-listener from container-listener-l and
* returns the resulting multicast listener.
* @param l container-listener-l
* @param oldl the container-listener being removed
*/
public static ContainerListener remove(ContainerListener l, ContainerListener oldl) {
return (ContainerListener) removeInternal(l, oldl);
}
/**
* Removes the old focus-listener from focus-listener-l and
* returns the resulting multicast listener.
* @param l focus-listener-l
* @param oldl the focus-listener being removed
*/
public static FocusListener remove(FocusListener l, FocusListener oldl) {
return (FocusListener) removeInternal(l, oldl);
}
/**
* Removes the old key-listener from key-listener-l and
* returns the resulting multicast listener.
* @param l key-listener-l
* @param oldl the key-listener being removed
*/
public static KeyListener remove(KeyListener l, KeyListener oldl) {
return (KeyListener) removeInternal(l, oldl);
}
/**
* Removes the old mouse-listener from mouse-listener-l and
* returns the resulting multicast listener.
* @param l mouse-listener-l
* @param oldl the mouse-listener being removed
*/
public static MouseListener remove(MouseListener l, MouseListener oldl) {
return (MouseListener) removeInternal(l, oldl);
}
/**
* Removes the old mouse-motion-listener from mouse-motion-listener-l
* and returns the resulting multicast listener.
* @param l mouse-motion-listener-l
* @param oldl the mouse-motion-listener being removed
*/
public static MouseMotionListener remove(MouseMotionListener l, MouseMotionListener oldl) {
return (MouseMotionListener) removeInternal(l, oldl);
}
/**
* Removes the old window-listener from window-listener-l and
* returns the resulting multicast listener.
* @param l window-listener-l
* @param oldl the window-listener being removed
*/
public static WindowListener remove(WindowListener l, WindowListener oldl) {
return (WindowListener) removeInternal(l, oldl);
}
/**
* Removes the old action-listener from action-listener-l and
* returns the resulting multicast listener.
* @param l action-listener-l
* @param oldl the action-listener being removed
*/
public static ActionListener remove(ActionListener l, ActionListener oldl) {
return (ActionListener) removeInternal(l, oldl);
}
/**
* Removes the old item-listener from item-listener-l and
* returns the resulting multicast listener.
* @param l item-listener-l
* @param oldl the item-listener being removed
*/
public static ItemListener remove(ItemListener l, ItemListener oldl) {
return (ItemListener) removeInternal(l, oldl);
}
/**
* Removes the old adjustment-listener from adjustment-listener-l and
* returns the resulting multicast listener.
* @param l adjustment-listener-l
* @param oldl the adjustment-listener being removed
*/
public static AdjustmentListener remove(AdjustmentListener l, AdjustmentListener oldl) {
return (AdjustmentListener) removeInternal(l, oldl);
}
public static TextListener remove(TextListener l, TextListener oldl) {
return (TextListener) removeInternal(l, oldl);
}
/**
* Returns the resulting multicast listener from adding listener-a
* and listener-b together.
* If listener-a is null, it returns listener-b;
* If listener-b is null, it returns listener-a
* If neither are null, then it creates and returns
* a new AWTEventMulticaster instance which chains a with b.
* @param a event listener-a
* @param b event listener-b
*/
protected static EventListener addInternal(EventListener a, EventListener b) {
if (a == null) return b;
if (b == null) return a;
return new AWTEventMulticaster(a, b);
}
/**
* Returns the resulting multicast listener after removing the
* old listener from listener-l.
* If listener-l equals the old listener OR listener-l is null,
* returns null.
* Else if listener-l is an instance of AWTEventMulticaster,
* then it removes the old listener from it.
* Else, returns listener l.
* @param l the listener being removed from
* @param oldl the listener being removed
*/
protected static EventListener removeInternal(EventListener l, EventListener oldl) {
if (l == oldl || l == null) {
return null;
} else if (l instanceof AWTEventMulticaster) {
return ((AWTEventMulticaster)l).remove(oldl);
} else {
return l; // it's not here
}
}
/* Serialization support.
*/
protected void saveInternal(ObjectOutputStream s, String k) throws IOException {
if (a instanceof AWTEventMulticaster) {
((AWTEventMulticaster)a).saveInternal(s, k);
}
else if (a instanceof Serializable) {
s.writeObject(k);
s.writeObject(a);
}
if (b instanceof AWTEventMulticaster) {
((AWTEventMulticaster)b).saveInternal(s, k);
}
else if (b instanceof Serializable) {
s.writeObject(k);
s.writeObject(b);
}
}
static void save(ObjectOutputStream s, String k, EventListener l) throws IOException {
if (l == null) {
return;
}
else if (l instanceof AWTEventMulticaster) {
((AWTEventMulticaster)l).saveInternal(s, k);
}
else if (l instanceof Serializable) {
s.writeObject(k);
s.writeObject(l);
}
}
}

View file

@ -1,440 +0,0 @@
/*
* @(#)KeyEvent.java 1.20 97/01/30
*
* Copyright (c) 1995, 1996 Sun Microsystems, Inc. All Rights Reserved.
*
* This software is the confidential and proprietary information of Sun
* Microsystems, Inc. ("Confidential Information"). You shall not
* disclose such Confidential Information and shall use it only in
* accordance with the terms of the license agreement you entered into
* with Sun.
*
* SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
* SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
* IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
* SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
* THIS SOFTWARE OR ITS DERIVATIVES.
*
* CopyrightVersion 1.1_beta
*
*/
package java.awt.event;
import java.awt.Event;
import java.awt.Component;
import java.awt.Toolkit;
/**
* The component-level keyboard event.
*
* @version 1.20 30 Jan 1997
* @author Carl Quinn
* @author Amy Fowler
*/
public class KeyEvent extends InputEvent {
/**
* Marks the first integer id for the range of key event ids.
*/
public static final int KEY_FIRST = 400;
/**
* Marks the last integer id for the range of key event ids.
*/
public static final int KEY_LAST = 402;
/**
* The key typed event type. This type is generated by a combination
* of a key press followed by a key release.
*/
public static final int KEY_TYPED = KEY_FIRST;
/**
* The key pressed event type.
*/
public static final int KEY_PRESSED = 1 + KEY_FIRST; //Event.KEY_PRESS
/**
* The key released event type.
*/
public static final int KEY_RELEASED = 2 + KEY_FIRST; //Event.KEY_RELEASE
/**
* Virtual key codes. These codes report which keyboard key has
* been pressed, rather than any character generated by one or more
* keys being pressed.
*
* For example, pressing the Shift key will cause a KEY_PRESSED event
* with a VK_SHIFT keyCode, while pressing the 'a' key will result in
* a VK_A keyCode. After the 'a' key is released, a KEY_RELEASED event
* will be fired with VK_A, followed by a KEY_TYPED event with a keyChar
* value of 'A'. Key combinations which do not result in characters,
* such as action keys like F1, will not generate KEY_TYPED events.
*
* Note: not all keyboards or systems are capable of generating all
* virtual key codes. No attempt is made in Java to artificially
* generate these keys.
*
* WARNING: aside from those keys where are defined by the Java language
* (VK_ENTER, VK_BACK_SPACE, and VK_TAB), do not rely on the values of these
* constants. Sun reserves the right to change these values as needed
* to accomodate a wider range of keyboards in the future.
*/
public static final int VK_ENTER = '\n';
public static final int VK_BACK_SPACE = '\b';
public static final int VK_TAB = '\t';
public static final int VK_CANCEL = 0x03;
public static final int VK_CLEAR = 0x0C;
public static final int VK_SHIFT = 0x10;
public static final int VK_CONTROL = 0x11;
public static final int VK_ALT = 0x12;
public static final int VK_PAUSE = 0x13;
public static final int VK_CAPS_LOCK = 0x14;
public static final int VK_ESCAPE = 0x1B;
public static final int VK_SPACE = 0x20;
public static final int VK_PAGE_UP = 0x21;
public static final int VK_PAGE_DOWN = 0x22;
public static final int VK_END = 0x23;
public static final int VK_HOME = 0x24;
public static final int VK_LEFT = 0x25;
public static final int VK_UP = 0x26;
public static final int VK_RIGHT = 0x27;
public static final int VK_DOWN = 0x28;
public static final int VK_COMMA = 0x2C;
public static final int VK_PERIOD = 0x2E;
public static final int VK_SLASH = 0x2F;
/** VK_0 thru VK_9 are the same as ASCII '0' thru '9' (0x30 - 0x39) */
public static final int VK_0 = 0x30;
public static final int VK_1 = 0x31;
public static final int VK_2 = 0x32;
public static final int VK_3 = 0x33;
public static final int VK_4 = 0x34;
public static final int VK_5 = 0x35;
public static final int VK_6 = 0x36;
public static final int VK_7 = 0x37;
public static final int VK_8 = 0x38;
public static final int VK_9 = 0x39;
public static final int VK_SEMICOLON = 0x3B;
public static final int VK_EQUALS = 0x3D;
/** VK_A thru VK_Z are the same as ASCII 'A' thru 'Z' (0x41 - 0x5A) */
public static final int VK_A = 0x41;
public static final int VK_B = 0x42;
public static final int VK_C = 0x43;
public static final int VK_D = 0x44;
public static final int VK_E = 0x45;
public static final int VK_F = 0x46;
public static final int VK_G = 0x47;
public static final int VK_H = 0x48;
public static final int VK_I = 0x49;
public static final int VK_J = 0x4A;
public static final int VK_K = 0x4B;
public static final int VK_L = 0x4C;
public static final int VK_M = 0x4D;
public static final int VK_N = 0x4E;
public static final int VK_O = 0x4F;
public static final int VK_P = 0x50;
public static final int VK_Q = 0x51;
public static final int VK_R = 0x52;
public static final int VK_S = 0x53;
public static final int VK_T = 0x54;
public static final int VK_U = 0x55;
public static final int VK_V = 0x56;
public static final int VK_W = 0x57;
public static final int VK_X = 0x58;
public static final int VK_Y = 0x59;
public static final int VK_Z = 0x5A;
public static final int VK_OPEN_BRACKET = 0x5B;
public static final int VK_BACK_SLASH = 0x5C;
public static final int VK_CLOSE_BRACKET = 0x5D;
public static final int VK_NUMPAD0 = 0x60;
public static final int VK_NUMPAD1 = 0x61;
public static final int VK_NUMPAD2 = 0x62;
public static final int VK_NUMPAD3 = 0x63;
public static final int VK_NUMPAD4 = 0x64;
public static final int VK_NUMPAD5 = 0x65;
public static final int VK_NUMPAD6 = 0x66;
public static final int VK_NUMPAD7 = 0x67;
public static final int VK_NUMPAD8 = 0x68;
public static final int VK_NUMPAD9 = 0x69;
public static final int VK_MULTIPLY = 0x6A;
public static final int VK_ADD = 0x6B;
public static final int VK_SEPARATER = 0x6C;
public static final int VK_SUBTRACT = 0x6D;
public static final int VK_DECIMAL = 0x6E;
public static final int VK_DIVIDE = 0x6F;
public static final int VK_F1 = 0x70;
public static final int VK_F2 = 0x71;
public static final int VK_F3 = 0x72;
public static final int VK_F4 = 0x73;
public static final int VK_F5 = 0x74;
public static final int VK_F6 = 0x75;
public static final int VK_F7 = 0x76;
public static final int VK_F8 = 0x77;
public static final int VK_F9 = 0x78;
public static final int VK_F10 = 0x79;
public static final int VK_F11 = 0x7A;
public static final int VK_F12 = 0x7B;
public static final int VK_DELETE = 0x7F; /* ASCII DEL */
public static final int VK_NUM_LOCK = 0x90;
public static final int VK_SCROLL_LOCK = 0x91;
public static final int VK_PRINTSCREEN = 0x9A;
public static final int VK_INSERT = 0x9B;
public static final int VK_HELP = 0x9C;
public static final int VK_META = 0x9D;
public static final int VK_BACK_QUOTE = 0xC0;
public static final int VK_QUOTE = 0xDE;
/** for Asian Keyboard */
public static final int VK_FINAL = 0x18;
public static final int VK_CONVERT = 0x1C;
public static final int VK_NONCONVERT = 0x1D;
public static final int VK_ACCEPT = 0x1E;
public static final int VK_MODECHANGE = 0x1F;
public static final int VK_KANA = 0x15;
public static final int VK_KANJI = 0x19;
/**
* KEY_TYPED events do not have a defined keyCode.
*/
public static final int VK_UNDEFINED = 0x0;
/**
* KEY_PRESSED and KEY_RELEASED events which do not map to a
* valid Unicode character do not have a defined keyChar.
*/
public static final char CHAR_UNDEFINED = 0x0;
int keyCode;
char keyChar;
/*
* JDK 1.1 serialVersionUID
*/
private static final long serialVersionUID = -2352130953028126954L;
/**
* Constructs a KeyEvent object with the specified source component,
* type, modifiers, and key.
* @param source the object where the event originated
* @id the event type
* @when the time the event occurred
* @modifiers the modifier keys down during event
* @keyCode the integer code representing the key of the event
* @keyChar the Unicode character generated by this event, or NUL
*/
public KeyEvent(Component source, int id, long when, int modifiers,
int keyCode, char keyChar) {
super(source, id, when, modifiers);
if (id == KEY_TYPED && keyChar == CHAR_UNDEFINED) {
throw new IllegalArgumentException("invalid keyChar");
}
if (id == KEY_TYPED && keyCode != VK_UNDEFINED) {
throw new IllegalArgumentException("invalid keyCode");
}
this.keyCode = keyCode;
this.keyChar = keyChar;
}
/*
* @deprecated, as of JDK1.1 - Do NOT USE; will be removed in 1.1.1.
*/
public KeyEvent(Component source, int id, long when, int modifiers,
int keyCode) {
this(source, id, when, modifiers, keyCode, (char)keyCode);
}
/**
* Returns the integer key-code associated with the key in this event.
* For KEY_TYPED events, keyCode is VK_UNDEFINED.
*/
public int getKeyCode() {
return keyCode;
}
public void setKeyCode(int keyCode) {
this.keyCode = keyCode;
}
public void setKeyChar(char keyChar) {
this.keyChar = keyChar;
}
public void setModifiers(int modifiers) {
this.modifiers = modifiers;
}
/**
* Returns the character associated with the key in this event.
* If no valid Unicode character exists for this key event, keyChar
* is CHAR_UNDEFINED.
*/
public char getKeyChar() {
return keyChar;
}
/**
* Returns a String describing the keyCode, such as "HOME", "F1" or "A".
* These strings can be localized by changing the awt.properties file.
*/
public static String getKeyText(int keyCode) {
if (keyCode >= VK_0 && keyCode <= VK_9 ||
keyCode >= VK_A && keyCode <= VK_Z) {
return String.valueOf((char)keyCode);
}
// Check for other ASCII keyCodes.
int index = ",./;=[\\]".indexOf(keyCode);
if (index >= 0) {
return String.valueOf((char)keyCode);
}
switch(keyCode) {
case VK_ENTER: return Toolkit.getProperty("AWT.enter", "Enter");
case VK_BACK_SPACE: return Toolkit.getProperty("AWT.backSpace", "Backspace");
case VK_TAB: return Toolkit.getProperty("AWT.tab", "Tab");
case VK_CANCEL: return Toolkit.getProperty("AWT.cancel", "Cancel");
case VK_CLEAR: return Toolkit.getProperty("AWT.clear", "Clear");
case VK_SHIFT: return Toolkit.getProperty("AWT.shift", "Shift");
case VK_CONTROL: return Toolkit.getProperty("AWT.control", "Control");
case VK_ALT: return Toolkit.getProperty("AWT.alt", "Alt");
case VK_PAUSE: return Toolkit.getProperty("AWT.pause", "Pause");
case VK_CAPS_LOCK: return Toolkit.getProperty("AWT.capsLock", "Caps Lock");
case VK_ESCAPE: return Toolkit.getProperty("AWT.escape", "Escape");
case VK_SPACE: return Toolkit.getProperty("AWT.space", "Space");
case VK_PAGE_UP: return Toolkit.getProperty("AWT.pgup", "Page Up");
case VK_PAGE_DOWN: return Toolkit.getProperty("AWT.pgdn", "Page Down");
case VK_END: return Toolkit.getProperty("AWT.end", "End");
case VK_HOME: return Toolkit.getProperty("AWT.home", "Home");
case VK_LEFT: return Toolkit.getProperty("AWT.left", "Left");
case VK_UP: return Toolkit.getProperty("AWT.up", "Up");
case VK_RIGHT: return Toolkit.getProperty("AWT.right", "Right");
case VK_DOWN: return Toolkit.getProperty("AWT.down", "Down");
case VK_MULTIPLY: return Toolkit.getProperty("AWT.multiply", "NumPad *");
case VK_ADD: return Toolkit.getProperty("AWT.add", "NumPad +");
case VK_SEPARATER: return Toolkit.getProperty("AWT.separater", "NumPad ,");
case VK_SUBTRACT: return Toolkit.getProperty("AWT.subtract", "NumPad -");
case VK_DECIMAL: return Toolkit.getProperty("AWT.decimal", "NumPad .");
case VK_DIVIDE: return Toolkit.getProperty("AWT.divide", "NumPad /");
case VK_F1: return Toolkit.getProperty("AWT.f1", "F1");
case VK_F2: return Toolkit.getProperty("AWT.f2", "F2");
case VK_F3: return Toolkit.getProperty("AWT.f3", "F3");
case VK_F4: return Toolkit.getProperty("AWT.f4", "F4");
case VK_F5: return Toolkit.getProperty("AWT.f5", "F5");
case VK_F6: return Toolkit.getProperty("AWT.f6", "F6");
case VK_F7: return Toolkit.getProperty("AWT.f7", "F7");
case VK_F8: return Toolkit.getProperty("AWT.f8", "F8");
case VK_F9: return Toolkit.getProperty("AWT.f9", "F9");
case VK_F10: return Toolkit.getProperty("AWT.f10", "F10");
case VK_F11: return Toolkit.getProperty("AWT.f11", "F11");
case VK_F12: return Toolkit.getProperty("AWT.f12", "F12");
case VK_DELETE: return Toolkit.getProperty("AWT.delete", "Delete");
case VK_NUM_LOCK: return Toolkit.getProperty("AWT.numLock", "Num Lock");
case VK_SCROLL_LOCK: return Toolkit.getProperty("AWT.scrollLock", "Scroll Lock");
case VK_PRINTSCREEN: return Toolkit.getProperty("AWT.printScreen", "Print Screen");
case VK_INSERT: return Toolkit.getProperty("AWT.insert", "Insert");
case VK_HELP: return Toolkit.getProperty("AWT.help", "Help");
case VK_META: return Toolkit.getProperty("AWT.meta", "Meta");
case VK_BACK_QUOTE: return Toolkit.getProperty("AWT.backQuote", "Back Quote");
case VK_QUOTE: return Toolkit.getProperty("AWT.quote", "Quote");
case VK_FINAL: return Toolkit.getProperty("AWT.final", "Final");
case VK_CONVERT: return Toolkit.getProperty("AWT.convert", "Convert");
case VK_NONCONVERT: return Toolkit.getProperty("AWT.noconvert", "No Convert");
case VK_ACCEPT: return Toolkit.getProperty("AWT.accept", "Accept");
case VK_MODECHANGE: return Toolkit.getProperty("AWT.modechange", "Mode Change");
case VK_KANA: return Toolkit.getProperty("AWT.kana", "Kana");
case VK_KANJI: return Toolkit.getProperty("AWT.kanji", "Kanji");
}
if (keyCode >= VK_NUMPAD0 && keyCode <= VK_NUMPAD9) {
String numpad = Toolkit.getProperty("AWT.numpad", "NumPad");
char c = (char)(keyCode - VK_NUMPAD0 + '0');
return numpad + "-" + c;
}
String unknown = Toolkit.getProperty("AWT.unknown", "Unknown keyCode");
return unknown + ": 0x" + Integer.toString(keyCode, 16);
}
/**
* Returns a String describing the modifier key(s), such as "Shift",
* or "Ctrl+Shift". These strings can be localized by changing the
* awt.properties file.
*/
public static String getKeyModifiersText(int modifiers) {
StringBuffer buf = new StringBuffer();
if ((modifiers & Event.META_MASK) != 0) {
buf.append(Toolkit.getProperty("AWT.meta", "Meta"));
buf.append("+");
}
if ((modifiers & Event.CTRL_MASK) != 0) {
buf.append(Toolkit.getProperty("AWT.control", "Ctrl"));
buf.append("+");
}
if ((modifiers & Event.META_MASK) != 0) {
buf.append(Toolkit.getProperty("AWT.alt", "Alt"));
buf.append("+");
}
if ((modifiers & Event.SHIFT_MASK) != 0) {
buf.append(Toolkit.getProperty("AWT.shift", "Shift"));
buf.append("+");
}
if (buf.length() > 0) {
buf.setLength(buf.length()-1); // remove trailing '+'
}
return buf.toString();
}
/** Returns whether or not the key in this event is an "action" key.
*/
public boolean isActionKey() {
return (keyChar == CHAR_UNDEFINED);
}
public String paramString() {
String typeStr;
switch(id) {
case KEY_PRESSED:
typeStr = "KEY_PRESSED";
break;
case KEY_RELEASED:
typeStr = "KEY_RELEASED";
break;
case KEY_TYPED:
typeStr = "KEY_TYPED";
break;
default:
typeStr = "unknown type";
}
String str = typeStr + ",keyCode=" + keyCode;
if (isActionKey() || keyCode == VK_ENTER || keyCode == VK_BACK_SPACE ||
keyCode == VK_TAB || keyCode == VK_ESCAPE || keyCode == VK_DELETE ||
(keyCode >= VK_NUMPAD0 && keyCode <= VK_NUMPAD9)) {
str += "," + getKeyText(keyCode);
} else if (keyChar == '\n' || keyChar == '\b' ||
keyChar == '\t' || keyChar == VK_ESCAPE || keyChar == VK_DELETE) {
str += "," + getKeyText(keyChar);
} else {
str += ",keyChar='" + keyChar + "'";
}
if (modifiers > 0) {
str += ",modifiers=" + getKeyModifiersText(modifiers);
}
return str;
}
}

View file

@ -1,848 +0,0 @@
/*
* @(#)SecurityManager.java 1.46 97/01/27
*
* Copyright (c) 1995, 1996 Sun Microsystems, Inc. All Rights Reserved.
*
* This software is the confidential and proprietary information of Sun
* Microsystems, Inc. ("Confidential Information"). You shall not
* disclose such Confidential Information and shall use it only in
* accordance with the terms of the license agreement you entered into
* with Sun.
*
* SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
* SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
* IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
* SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
* THIS SOFTWARE OR ITS DERIVATIVES.
*
* CopyrightVersion 1.1_beta
*
*/
package java.lang;
import java.io.FileDescriptor;
import java.util.Hashtable;
import java.net.InetAddress;
import java.lang.reflect.Member;
/**
* The security manager is an abstract class that allows
* applications to implement a security policy. It allows an
* application to determine, before performing a possibly unsafe or
* sensitive operation, what the operation is and whether the
* operation is being performed by a class created via a class loader
* rather than installed locally. Classes loaded via a class loader
* (especially if they have been downloaded over a network) may be
* less trustworthy than classes from files installed locally. The
* application can allow or disallow the operation.
* <p>
* The <code>SecurityManager</code> class contains many methods with
* names that begin with the word <code>check</code>. These methods
* are called by various methods in the Java libraries before those
* methods perform certain potentially sensitive operations. The
* invocation of such a check method typically looks like this:
* <p><blockquote><pre>
* SecurityManager security = System.getSecurityManager();
* if (security != null) {
* security.check</code><i>XXX</i><code>(argument, &nbsp;.&nbsp;.&nbsp;.&nbsp;);
* }
* </pre></blockquote>
* <p>
* The security manager is thereby given an opportunity to prevent
* completion of the operation by throwing an exception. A security
* manager routine simply returns if the operation is permitted, but
* throws a <code>SecurityException</code> if the operation is not
* permitted. The only exception to this convention is
* <code>checkTopLevelWindow</code>, which returns a
* <code>boolean</code> value.
* <p>
* The current security manager is set by the
* <code>setSecurityManager</code> method in class
* <code>System</code>. The current security manager is obtained
* by the <code>getSecurityManager</code> method.
* <p>
* The default implementation of each of the
* <code>check</code><i>XXX</i> methods is to assume that the caller
* does <i>not</i> have permission to perform the requested operation.
*
* @author Arthur van Hoff
* @version 1.46, 27 Jan 1997
* @see java.lang.ClassLoader
* @see java.lang.SecurityException
* @see java.lang.SecurityManager#checkTopLevelWindow(java.lang.Object)
* @see java.lang.System#getSecurityManager()
* @see java.lang.System#setSecurityManager(java.lang.SecurityManager)
* @since JDK1.0
*/
public abstract
class SecurityManager {
/**
* This field is <code>true</code> if there is a security check in
* progress; <code>false</code> otherwise.
*
* @since JDK1.0
*/
protected boolean inCheck;
// Have we been initialized. Effective against finalizer attacks.
private boolean initialized = false;
/**
* Tests if there is a security check in progress.
*
* @return the value of the <code>inCheck</code> field. This field should
* contain <code>true</code> if a security check is in progress;
* <code>false</code> otherwise.
* @see java.lang.SecurityManager#inCheck
* @since JDK1.0
*/
public boolean getInCheck() {
return inCheck;
}
/**
* Constructs a new <code>SecurityManager</code>. An application is
* not allowed to create a new security manager if there is already a
* current security manager.
*
* @exception SecurityException if a security manager already exists.
* @see java.lang.System#getSecurityManager()
* @since JDK1.0
*/
protected SecurityManager() {
// checkCreateSecurityManager(); ? REMIND
initialized = true;
}
/**
* Returns the current execution stack as an array of classes.
* <p>
* The length of the array is the number of methods on the execution
* stack. The element at index <code>0</code> is the class of the
* currently executing method, the element at index <code>1</code> is
* the class of that method's caller, and so on.
*
* @return the execution stack.
* @since JDK1.0
*/
protected native Class[] getClassContext();
/**
* Returns an object describing the most recent class loader executing
* on the stack.
*
* @return the class loader of the most recent occurrence on the stack
* of a method from a class defined using a class loader;
* returns <code>null</code> if there is no occurrence on the
* stack of a method from a class defined using a class loader.
* @since JDK1.0
*/
protected native ClassLoader currentClassLoader();
/**
* Returns the current Class with a ClassLoader on the execution stack.
*
* @since JDK1.1
*/
protected Class currentLoadedClass() {
return currentLoadedClass0();
}
/**
* Returns the stack depth of the specified class.
*
* @param name the fully qualified name of the class to search for.
* @return the depth on the stack frame of the first occurrence of a
* method from a class with the specified name;
* <code>-1</code> if such a frame cannot be found.
* @since JDK1.0
*/
protected native int classDepth(String name);
/**
* Returns the stack depth of the most recently executing method
* from a class defined using a class loader.
*
* @return the depth on the stack frame of the most recent occurrence of a
* method from a class defined using a class loader; returns
* <code>-1</code> if there is no occurrence of a method from
* a class defined using a class loader.
* @since JDK1.0
*/
protected native int classLoaderDepth();
/**
* Tests if the specified String is in this Class.
*
* @param name the fully qualified name of the class.
* @return <code>true</code> if a method from a class with the specified
* name is on the execution stack; <code>false</code> otherwise.
* @since JDK1.0
*/
protected boolean inClass(String name) {
return classDepth(name) >= 0;
}
/**
* Tests if the current ClassLoader is equal to
* <code>null</code>.
*
* @return <code>true</code> if a method from a class defined using a
* class loader is on the execution stack.
* @since JDK1.0
*/
protected boolean inClassLoader() {
return currentClassLoader() != null;
}
/**
* Creates an object that encapsulates the current execution
* environment. The result of this method is used by the
* three-argument <code>checkConnect</code> method and by the
* two-argument <code>checkRead</code> method.
* <p>
* These methods are needed because a trusted method may be called
* on to read a file or open a socket on behalf of another method.
* The trusted method needs to determine if the other (possibly
* untrusted) method would be allowed to perform the operation on its
* own.
*
* @return an implementation-dependent object that encapsulates
* sufficient information about the current execution environment
* to perform some security checks later.
* @see java.lang.SecurityManager#checkConnect(java.lang.String,
* int, java.lang.Object)
* @see java.lang.SecurityManager#checkRead(java.lang.String,
* java.lang.Object)
* @since JDK1.0
*/
public Object getSecurityContext() {
return null;
}
/**
* Throws a <code>SecurityException</code> if the
* calling thread is not allowed to create a new class loader.
* <p>
* The <code>checkCreateClassLoader</code> method for class
* <code>SecurityManager</code> always throws a
* <code>SecurityException</code>.
*
* @exception SecurityException if the caller does not have permission
* to create a new class loader.
* @see java.lang.ClassLoader#ClassLoader()
* @since JDK1.0
*/
public void checkCreateClassLoader() {
throw new SecurityException();
}
/**
* Throws a <code>SecurityException</code> if the
* calling thread is not allowed to modify the thread argument.
* <p>
* This method is invoked for the current security manager by the
* <code>stop</code>, <code>suspend</code>, <code>resume</code>,
* <code>setPriority</code>, <code>setName</code>, and
* <code>setDaemon</code> methods of class <code>Thread</code>.
* <p>
* The <code>checkAccess</code> method for class
* <code>SecurityManager</code> always throws a
* <code>SecurityException</code>.
*
* @param g the thread to be checked.
* @exception SecurityException if the caller does not have permission
* to modify the thread.
* @see java.lang.System#getSecurityManager()
* @see java.lang.Thread#resume()
* @see java.lang.Thread#setDaemon(boolean)
* @see java.lang.Thread#setName(java.lang.String)
* @see java.lang.Thread#setPriority(int)
* @see java.lang.Thread#stop()
* @see java.lang.Thread#suspend()
* @since JDK1.0
*/
public void checkAccess(Thread g) {
throw new SecurityException();
}
/**
* Throws a <code>SecurityException</code> if the
* calling thread is not allowed to modify the thread group argument.
* <p>
* This method is invoked for the current security manager when a
* new child thread or child thread group is created, and by the
* <code>setDaemon</code>, <code>setMaxPriority</code>,
* <code>stop</code>, <code>suspend</code>, <code>resume</code>, and
* <code>destroy</code> methods of class <code>ThreadGroup</code>.
* <p>
* The <code>checkAccess</code> method for class
* <code>SecurityManager</code> always throws a
* <code>SecurityException</code>.
*
* @param g the thread group to be checked.
* @exception SecurityException if the caller does not have permission
* to modify the thread group.
* @see java.lang.System#getSecurityManager()
* @see java.lang.ThreadGroup#destroy()
* @see java.lang.ThreadGroup#resume()
* @see java.lang.ThreadGroup#setDaemon(boolean)
* @see java.lang.ThreadGroup#setMaxPriority(int)
* @see java.lang.ThreadGroup#stop()
* @see java.lang.ThreadGroup#suspend()
* @since JDK1.0
*/
public void checkAccess(ThreadGroup g) {
throw new SecurityException();
}
/**
* Throws a <code>SecurityException</code> if the
* calling thread is not allowed to cause the Java Virtual Machine to
* halt with the specified status code.
* <p>
* This method is invoked for the current security manager by the
* <code>exit</code> method of class <code>Runtime</code>. A status
* of <code>0</code> indicates success; other values indicate various
* errors.
* <p>
* The <code>checkExit</code> method for class
* <code>SecurityManager</code> always throws a
* <code>SecurityException</code>.
*
* @param status the exit status.
* @exception SecurityException if the caller does not have permission
* to halt the Java Virtual Machine with the specified status.
* @see java.lang.Runtime#exit(int)
* @see java.lang.System#getSecurityManager()
* @since JDK1.0
*/
public void checkExit(int status) {
throw new SecurityException();
}
/**
* Throws a <code>SecurityException</code> if the
* calling thread is not allowed to create a subprocss.
* <p>
* This method is invoked for the current security manager by the
* <code>exec</code> methods of class <code>Runtime</code>.
* <p>
* The <code>checkExec</code> method for class
* <code>SecurityManager</code> always throws a
* <code>SecurityException</code>.
*
* @param cmd the specified system command.
* @exception SecurityException if the caller does not have permission
* to create a subprocess.
* @see java.lang.Runtime#exec(java.lang.String)
* @see java.lang.Runtime#exec(java.lang.String, java.lang.String[])
* @see java.lang.Runtime#exec(java.lang.String[])
* @see java.lang.Runtime#exec(java.lang.String[],
* java.lang.String[])
* @see java.lang.System#getSecurityManager()
* @since JDK1.0
*/
public void checkExec(String cmd) {
throw new SecurityException();
}
/**
* Throws a <code>SecurityException</code> if the
* calling thread is not allowed to dynamic link the library code
* specified by the string argument file. The argument is either a
* simple library name or a complete filename.
* <p>
* This method is invoked for the current security manager by
* methods <code>load</code> and <code>loadLibrary</code> of class
* <code>Runtime</code>.
* <p>
* The <code>checkLink</code> method for class
* <code>SecurityManager</code> always throws a
* <code>SecurityException</code>.
*
* @param lib the name of the library.
* @exception SecurityException if the caller does not have permission
* to dynamically link the library.
* @see java.lang.Runtime#load(java.lang.String)
* @see java.lang.Runtime#loadLibrary(java.lang.String)
* @see java.lang.System#getSecurityManager()
* @since JDK1.0
*/
public void checkLink(String lib) {
throw new SecurityException();
}
/**
* Throws a <code>SecurityException</code> if the
* calling thread is not allowed to read from the specified file
* descriptor.
* <p>
* The <code>checkRead</code> method for class
* <code>SecurityManager</code> always throws a
* <code>SecurityException</code>.
*
* @param fd the system-dependent file descriptor.
* @exception SecurityException if the caller does not have permission
* to access the specified file descriptor.
* @see java.io.FileDescriptor
* @since JDK1.0
*/
public void checkRead(FileDescriptor fd) {
throw new SecurityException();
}
/**
* Throws a <code>SecurityException</code> if the
* calling thread is not allowed to read the file specified by the
* string argument.
* <p>
* The <code>checkRead</code> method for class
* <code>SecurityManager</code> always throws a
* <code>SecurityException</code>.
*
* @param file the system-dependent file name.
* @exception SecurityException if the caller does not have permission
* to access the specified file.
* @since JDK1.0
*/
public void checkRead(String file) {
throw new SecurityException();
}
/**
* Throws a <code>SecurityException</code> if the
* specified security context is not allowed to read the file
* specified by the string argument. The context must be a security
* context returned by a previous call to
* <code>getSecurityContext</code>.
* <p>
* The <code>checkRead</code> method for class
* <code>SecurityManager</code> always throws a
* <code>SecurityException</code>.
*
* @param file the system-dependent filename.
* @param context a system-dependent security context.
* @exception SecurityException if the specified security context does
* not have permission to read the specified file.
* @see java.lang.SecurityManager#getSecurityContext()
* @since JDK1.0
*/
public void checkRead(String file, Object context) {
throw new SecurityException();
}
/**
* Throws a <code>SecurityException</code> if the
* calling thread is not allowed to write to the specified file
* descriptor.
* <p>
* The <code>checkWrite</code> method for class
* <code>SecurityManager</code> always throws a
* <code>SecurityException</code>.
*
* @param fd the system-dependent file descriptor.
* @exception SecurityException if the caller does not have permission
* to access the specified file descriptor.
* @see java.io.FileDescriptor
* @since JDK1.0
*/
public void checkWrite(FileDescriptor fd) {
throw new SecurityException();
}
/**
* Throws a <code>SecurityException</code> if the
* calling thread is not allowed to write to the file specified by
* the string argument.
* <p>
* The <code>checkWrite</code> method for class
* <code>SecurityManager</code> always throws a
* <code>SecurityException</code>.
*
* @param file the system-dependent filename.
* @exception SecurityException if the caller does not have permission
* to access the specified file.
* @since JDK1.0
*/
public void checkWrite(String file) {
throw new SecurityException();
}
/**
* Throws a <code>SecurityException</code> if the
* calling thread is not allowed to delete the specified file.
* <p>
* This method is invoked for the current security manager by the
* <code>delete</code> method of class <code>File</code>.
* <p>
* The <code>checkDelete</code> method for class
* <code>SecurityManager</code> always throws a
* <code>SecurityException</code>.
*
* @param file the system-dependent filename.
* @exception SecurityException if the caller does not have permission
* to delete the file.
* @see java.io.File#delete()
* @see java.lang.System#getSecurityManager()
* @since JDK1.0
*/
public void checkDelete(String file) {
throw new SecurityException();
}
/**
* Throws a <code>SecurityException</code> if the
* calling thread is not allowed to open a socket connection to the
* specified host and port number.
* <p>
* A port number of <code>-1</code> indicates that the calling
* method is attempting to determine the IP address of the specified
* host name.
* <p>
* The <code>checkConnect</code> method for class
* <code>SecurityManager</code> always throws a
* <code>SecurityException</code>.
*
* @param host the host name port to connect to.
* @param port the protocol port to connect to.
* @exception SecurityException if the caller does not have permission
* to open a socket connection to the specified
* <code>host</code> and <code>port</code>.
* @since JDK1.0
*/
public void checkConnect(String host, int port) {
throw new SecurityException();
}
/**
* Throws a <code>SecurityException</code> if the
* specified security context is not allowed to open a socket
* connection to the specified host and port number.
* <p>
* A port number of <code>-1</code> indicates that the calling
* method is attempting to determine the IP address of the specified
* host name.
* <p>
* The <code>checkConnect</code> method for class
* <code>SecurityManager</code> always throws a
* <code>SecurityException</code>.
*
* @param host the host name port to connect to.
* @param port the protocol port to connect to.
* @param context a system-dependent security context.
* @exception SecurityException if the specified security context does
* not have permission to open a socket connection to the
* specified <code>host</code> and <code>port</code>.
* @see java.lang.SecurityManager#getSecurityContext()
* @since JDK1.0
*/
public void checkConnect(String host, int port, Object context) {
throw new SecurityException();
}
/**
* Throws a <code>SecurityException</code> if the
* calling thread is not allowed to wait for a connection request on
* the specified local port number.
* <p>
* The <code>checkListen</code> method for class
* <code>SecurityManager</code> always throws a
* <code>SecurityException</code>.
*
* @param port the local port.
* @exception SecurityException if the caller does not have permission
* to listen on the specified port.
* @since JDK1.0
*/
public void checkListen(int port) {
throw new SecurityException();
}
/**
* Throws a <code>SecurityException</code> if the
* calling thread is not permitted to accept a socket connection from
* the specified host and port number.
* <p>
* This method is invoked for the current security manager by the
* <code>accept</code> method of class <code>ServerSocket</code>.
* <p>
* The <code>checkAccept</code> method for class
* <code>SecurityManager</code> always throws a
* <code>SecurityException</code>.
*
* @param host the host name of the socket connection.
* @param port the port number of the socket connection.
* @exception SecurityException if the caller does not have permission
* to accept the connection.
* @see java.lang.System#getSecurityManager()
* @see java.net.ServerSocket#accept()
* @since JDK1.0
*/
public void checkAccept(String host, int port) {
throw new SecurityException();
}
/**
* Tests if current execution context is allowed to use
* (join/leave/send/receive) IP multicast.
*
* @param multicast Internet group address to be used.
* @exception SecurityException if a security error has occurred.
* @since JDK1.1
*/
public void checkMulticast(InetAddress maddr) {
throw new SecurityException();
}
/**
* Tests to see if current execution context is allowed to use
* (join/leave/send/receive) IP multicast.
*
* @param multicast Internet group address to be used.
* @param ttl value in use, if it is multicast send.
* @exception SecurityException if a security error has occurred.
* @since JDK1.1
*/
public void checkMulticast(InetAddress maddr, byte ttl) {
throw new SecurityException();
}
/**
* Throws a <code>SecurityException</code> if the
* calling thread is not allowed to access or modify the system
* properties.
* <p>
* This method is used by the <code>getProperties</code> and
* <code>setProperties</code> methods of class <code>System</code>.
* <p>
* The <code>checkPropertiesAccess</code> method for class
* <code>SecurityManager</code> always throws a
* <code>SecurityException</code>.
*
* @exception SecurityException if the caller does not have permission
* to access or modify the system properties.
* @see java.lang.System#getProperties()
* @see java.lang.System#setProperties(java.util.Properties)
* @since JDK1.0
*/
public void checkPropertiesAccess() {
throw new SecurityException();
}
/**
* Throws a <code>SecurityException</code> if the
* calling thread is not allowed to access the system property with
* the specified <code>key</code> name.
* <p>
* This method is used by the <code>getProperty</code> method of
* class <code>System</code>.
* <p>
* The <code>checkPropertiesAccess</code> method for class
* <code>SecurityManager</code> always throws a
* <code>SecurityException</code>.
*
* @param key a system property key.
* @exception SecurityException if the caller does not have permission
* to access the specified system property.
* @see java.lang.System#getProperty(java.lang.String)
* @since JDK1.0
*/
public void checkPropertyAccess(String key) {
throw new SecurityException();
}
/**
* Returns <code>false</code> if the calling
* thread is not trusted to bring up the top-level window indicated
* by the <code>window</code> argument. In this case, the caller can
* still decide to show the window, but the window should include
* some sort of visual warning. If the method returns
* <code>true</code>, then the window can be shown without any
* special restrictions.
* <p>
* See class <code>Window</code> for more information on trusted and
* untrusted windows.
* <p>
* The <code>checkSetFactory</code> method for class
* <code>SecurityManager</code> always returns <code>false</code>.
*
* @param window the new window that is being created.
* @return <code>true</code> if the caller is trusted to put up
* top-level windows; <code>false</code> otherwise.
* @exception SecurityException if creation is disallowed entirely.
* @see java.awt.Window
* @since JDK1.0
*/
public boolean checkTopLevelWindow(Object window) {
return false;
}
/**
* Tests if a client can initiate a print job request.
*
* @since JDK1.1
*/
public void checkPrintJobAccess() {
throw new SecurityException();
}
/**
* Tests if a client can get access to the system clipboard.
*
* @since JDK1.1
*/
public void checkSystemClipboardAccess() {
throw new SecurityException();
}
/**
* Tests if a client can get access to the AWT event queue.
*
* @since JDK1.1
*/
public void checkAwtEventQueueAccess() {
throw new SecurityException();
}
/**
* Throws a <code>SecurityException</code> if the
* calling thread is not allowed to access the package specified by
* the argument.
* <p>
* This method is used by the <code>loadClass</code> method of class
* loaders.
* <p>
* The <code>checkPackageAccess</code> method for class
* <code>SecurityManager</code> always throws a
* <code>SecurityException</code>.
*
* @param pkg the package name.
* @exception SecurityException if the caller does not have permission
* to access the specified package.
* @see java.lang.ClassLoader#loadClass(java.lang.String, boolean)
* @since JDK1.0
*/
public void checkPackageAccess(String pkg) {
throw new SecurityException();
}
/**
* Throws a <code>SecurityException</code> if the
* calling thread is not allowed to define classes in the package
* specified by the argument.
* <p>
* This method is used by the <code>loadClass</code> method of some
* class loaders.
* <p>
* The <code>checkPackageDefinition</code> method for class
* <code>SecurityManager</code> always throws a
* <code>SecurityException</code>.
*
* @param pkg the package name.
* @exception SecurityException if the caller does not have permission
* to define classes in the specified package.
* @see java.lang.ClassLoader#loadClass(java.lang.String, boolean)
* @since JDK1.0
*/
public void checkPackageDefinition(String pkg) {
throw new SecurityException();
}
/**
* Throws a <code>SecurityException</code> if the
* calling thread is not allowed to set the socket factory used by
* <code>ServerSocket</code> or <code>Socket</code>, or the stream
* handler factory used by <code>URL</code>.
* <p>
* The <code>checkSetFactory</code> method for class
* <code>SecurityManager</code> always throws a
* <code>SecurityException</code>.
*
* @exception SecurityException if the caller does not have permission
* to specify a socket factory or a stream handler factory.
* @see java.net.ServerSocket#setSocketFactory(
* java.net.SocketImplFactory)
* @see java.net.Socket#setSocketImplFactory(
* java.net.SocketImplFactory)
* @see java.net.URL#setURLStreamHandlerFactory(
* java.net.URLStreamHandlerFactory)
* @since JDK1.0
*/
public void checkSetFactory() {
throw new SecurityException();
}
/**
* Tests if a client is allowed to access members. If access is
* denied, throw a SecurityException.
* The default policy is to deny all accesses.
*
* @since JDK1.1
*/
public void checkMemberAccess(Class clazz, int which) {
throw new SecurityException();
}
/**
* Tests access to certain operations for a security API
* action.
*
* @since JDK1.1
*/
public void checkSecurityAccess(String action) {
throw new SecurityException();
}
private native Class currentLoadedClass0();
/**
* Returns the thread group into which to instantiate any new
* thread being created at the time this is being called.
* By default, it returns the thread group of the current
* thread. This should be overriden by specific security
* manager to return the appropriate thread group.
*
* @since JDK1.1
*/
public ThreadGroup getThreadGroup() {
return Thread.currentThread().getThreadGroup();
}
}
class NullSecurityManager extends SecurityManager {
public void checkCreateClassLoader() { }
public void checkAccess(Thread g) { }
public void checkAccess(ThreadGroup g) { }
public void checkExit(int status) { }
public void checkExec(String cmd) { }
public void checkLink(String lib) { }
public void checkRead(FileDescriptor fd) { }
public void checkRead(String file) { }
public void checkRead(String file, Object context) { }
public void checkWrite(FileDescriptor fd) { }
public void checkWrite(String file) { }
public void checkDelete(String file) { }
public void checkConnect(String host, int port) { }
public void checkConnect(String host, int port, Object context) { }
public void checkListen(int port) { }
public void checkAccept(String host, int port) { }
public void checkMulticast(InetAddress maddr) { }
public void checkMulticast(InetAddress maddr, byte ttl) { }
public void checkPropertiesAccess() { }
public void checkPropertyAccess(String key) { }
public void checkPropertyAccess(String key, String def) { }
public boolean checkTopLevelWindow(Object window) { return true; }
public void checkPrintJobAccess() { }
public void checkSystemClipboardAccess() { }
public void checkAwtEventQueueAccess() { }
public void checkPackageAccess(String pkg) { }
public void checkPackageDefinition(String pkg) { }
public void checkSetFactory() { }
public void checkMemberAccess(Class clazz, int which) { }
public void checkSecurityAccess(String provider) { }
}

View file

@ -1,381 +0,0 @@
/*
* @(#)SystemColor.java 1.5 97/01/27
*
* Copyright (c) 1995, 1996 Sun Microsystems, Inc. All Rights Reserved.
*
* This software is the confidential and proprietary information of Sun
* Microsystems, Inc. ("Confidential Information"). You shall not
* disclose such Confidential Information and shall use it only in
* accordance with the terms of the license agreement you entered into
* with Sun.
*
* SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
* SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
* IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
* SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
* THIS SOFTWARE OR ITS DERIVATIVES.
*
* CopyrightVersion 1.1_beta
*
*/
package java.awt;
/**
* A class to encapsulate symbolic colors representing the color
* of GUI objects on a system. For systems which support the dynamic
* update of the system colors (when the user changes the colors)
* the actual RGB values of these symbolic colors will also change
* dynamically. In order to compare the "current" RGB value of a SystemColor
* object with a non-symbolic Color object, getRGB() should be used
* rather than equals().
*
* @version 1.5, 27 Jan 1997
* @author Carl Quinn
* @author Amy Fowler
*/
public final class SystemColor extends Color implements java.io.Serializable {
/**
* The array index for the desktop background color.
*/
public final static int DESKTOP = 0;
/**
* The array index for the active caption background color.
*/
public final static int ACTIVE_CAPTION = 1;
/**
* The array index for the action caption text color.
*/
public final static int ACTIVE_CAPTION_TEXT = 2;
/**
* The array index for the active caption border color.
*/
public final static int ACTIVE_CAPTION_BORDER = 3;
/**
* The array index for the inactive caption background color.
*/
public final static int INACTIVE_CAPTION = 4;
/**
* The array index for the inactive caption text color.
*/
public final static int INACTIVE_CAPTION_TEXT = 5;
/**
* The array index for the inactive caption border color.
*/
public final static int INACTIVE_CAPTION_BORDER = 6;
/**
* The array index for the window background color.
*/
public final static int WINDOW = 7;
/**
* The array index for the window border color.
*/
public final static int WINDOW_BORDER = 8;
/**
* The array index for the window text color.
*/
public final static int WINDOW_TEXT = 9;
/**
* The array index for the menu background color.
*/
public final static int MENU = 10;
/**
* The array index for the menu text color.
*/
public final static int MENU_TEXT = 11;
/**
* The array index for the text background color.
*/
public final static int TEXT = 12;
/**
* The array index for the text text color.
*/
public final static int TEXT_TEXT = 13;
/**
* The array index for the text highlight color.
*/
public final static int TEXT_HIGHLIGHT = 14;
/**
* The array index for the text highlight text color.
*/
public final static int TEXT_HIGHLIGHT_TEXT = 15;
/**
* The array index for the text inactive text color.
*/
public final static int TEXT_INACTIVE_TEXT = 16;
/**
* The array index for the control background color.
*/
public final static int CONTROL = 17;
/**
* The array index for the control text color.
*/
public final static int CONTROL_TEXT = 18;
/**
* The array index for the control highlight color.
*/
public final static int CONTROL_HIGHLIGHT = 19;
/**
* The array index for the control light highlight color.
*/
public final static int CONTROL_LT_HIGHLIGHT = 20;
/**
* The array index for the control shadow color.
*/
public final static int CONTROL_SHADOW = 21;
/**
* The array index for the control dark shadow color.
*/
public final static int CONTROL_DK_SHADOW = 22;
/**
* The array index for the scrollbar background color.
*/
public final static int SCROLLBAR = 23;
/**
* The array index for the info background color.
*/
public final static int INFO = 24;
/**
* The array index for the info text color.
*/
public final static int INFO_TEXT = 25;
/**
* The number of system colors in the array.
*/
public final static int NUM_COLORS = 26;
/**
* The color of the desktop background.
*/
public final static SystemColor desktop = new SystemColor((byte)DESKTOP);
/**
* The background color for captions in window borders.
*/
public final static SystemColor activeCaption = new SystemColor((byte)ACTIVE_CAPTION);
/**
* The text color for captions in window borders.
*/
public final static SystemColor activeCaptionText = new SystemColor((byte)ACTIVE_CAPTION_TEXT);
/**
* The border color for captions in window borders.
*/
public final static SystemColor activeCaptionBorder = new SystemColor((byte)ACTIVE_CAPTION_BORDER);
/**
* The background color for inactive captions in window borders.
*/
public final static SystemColor inactiveCaption = new SystemColor((byte)INACTIVE_CAPTION);
/**
* The text color for inactive captions in window borders.
*/
public final static SystemColor inactiveCaptionText = new SystemColor((byte)INACTIVE_CAPTION_TEXT);
/**
* The border color for inactive captios in window borders.
*/
public final static SystemColor inactiveCaptionBorder = new SystemColor((byte)INACTIVE_CAPTION_BORDER);
/**
* The background color for windows.
*/
public final static SystemColor window = new SystemColor((byte)WINDOW);
/**
* The border color for windows.
*/
public final static SystemColor windowBorder = new SystemColor((byte)WINDOW_BORDER);
/**
* The text color for windows.
*/
public final static SystemColor windowText = new SystemColor((byte)WINDOW_TEXT);
/**
* The background color for menus.
*/
public final static SystemColor menu = new SystemColor((byte)MENU);
/**
* The text color for menus.
*/
public final static SystemColor menuText = new SystemColor((byte)MENU_TEXT);
/**
* The background color for text components.
*/
public final static SystemColor text = new SystemColor((byte)TEXT);
/**
* The text color for text components.
*/
public final static SystemColor textText = new SystemColor((byte)TEXT_TEXT);
/**
* The background color for highlighted text.
*/
public final static SystemColor textHighlight = new SystemColor((byte)TEXT_HIGHLIGHT);
/**
* The text color for highlighted text.
*/
public final static SystemColor textHighlightText = new SystemColor((byte)TEXT_HIGHLIGHT_TEXT);
/**
* The text color for inactive text.
*/
public final static SystemColor textInactiveText = new SystemColor((byte)TEXT_INACTIVE_TEXT);
/**
* The background color for control objects.
*/
public final static SystemColor control = new SystemColor((byte)CONTROL);
/**
* The text color for control objects.
*/
public final static SystemColor controlText = new SystemColor((byte)CONTROL_TEXT);
/**
* The light highlight color for control objects.
*/
public final static SystemColor controlHighlight = new SystemColor((byte)CONTROL_HIGHLIGHT);
/**
* The regular highlight color for control objects.
*/
public final static SystemColor controlLtHighlight = new SystemColor((byte)CONTROL_LT_HIGHLIGHT);
/**
* The regular shadow color for control objects.
*/
public final static SystemColor controlShadow = new SystemColor((byte)CONTROL_SHADOW);
/**
* The dark shadow color for control objects.
*/
public final static SystemColor controlDkShadow = new SystemColor((byte)CONTROL_DK_SHADOW);
/**
* The background color for scrollbars.
*/
public final static SystemColor scrollbar = new SystemColor((byte)SCROLLBAR);
/**
* The background color for info(help) text.
*/
public final static SystemColor info = new SystemColor((byte)INFO);
/**
* The text color for info(help) text.
*/
public final static SystemColor infoText = new SystemColor((byte)INFO_TEXT);
/*
* System colors with default initial values, overwritten by toolkit if
* system values differ and are available.
*/
private static int[] systemColors = {
0xFF005C5C, // desktop = new Color(0,92,92);
0xFF000080, // activeCaption = new Color(0,0,128);
0xFFFFFFFF, // activeCaptionText = Color.white;
0xFFC0C0C0, // activeCaptionBorder = Color.lightGray;
0xFF808080, // inactiveCaption = Color.gray;
0xFFC0C0C0, // inactiveCaptionText = Color.lightGray;
0xFFC0C0C0, // inactiveCaptionBorder = Color.lightGray;
0xFFFFFFFF, // window = Color.white;
0xFF000000, // windowBorder = Color.black;
0xFF000000, // windowText = Color.black;
0xFFC0C0C0, // menu = Color.lightGray;
0xFF000000, // menuText = Color.black;
0xFFC0C0C0, // text = Color.lightGray;
0xFF000000, // textText = Color.black;
0xFF000080, // textHighlight = new Color(0,0,128);
0xFFFFFFFF, // textHighlightText = Color.white;
0xFF808080, // textInactiveText = Color.gray;
0xFFC0C0C0, // control = Color.lightGray;
0xFF000000, // controlText = Color.black;
0xFFFFFFFF, // controlHighlight = Color.white;
0xFFE0E0E0, // controlLtHighlight = new Color(224,224,224);
0xFF808080, // controlShadow = Color.gray;
0xFF000000, // controlDkShadow = Color.black;
0xFFE0E0E0, // scrollbar = new Color(224,224,224);
0xFFE0E000, // info = new Color(224,224,0);
0xFF000000, // infoText = Color.black;
};
/*
* JDK 1.1 serialVersionUID
*/
private static final long serialVersionUID = 4503142729533789064L;
static {
updateSystemColors();
}
/**
* called from <init> & toolkit to update the above systemColors cache
*/
private static void updateSystemColors() {
Toolkit.getDefaultToolkit().loadSystemColors(systemColors);
}
/**
* Create a symbolic color that represents an indexed entry into system
* color cache. Used by above static system colors.
*/
private SystemColor(byte index) {
super(0, 0, 0);
value = index;
}
/**
* Gets the "current" RGB value representing the symbolic color.
* (Bits 24-31 are 0xff, 16-23 are red, 8-15 are green, 0-7 are blue).
* @see java.awt.image.ColorModel#getRGBdefault
* @see #getRed
* @see #getGreen
* @see #getBlue
*/
public int getRGB() {
return systemColors[value];
}
/**
* Returns the String representation of this Color's values.
*/
public String toString() {
return getClass().getName() + "[i=" + (value) + "]";
}
}

View file

@ -1,840 +0,0 @@
/*
* @(#)ThreadGroup.java 1.31 97/01/20
*
* Copyright (c) 1995, 1996 Sun Microsystems, Inc. All Rights Reserved.
*
* This software is the confidential and proprietary information of Sun
* Microsystems, Inc. ("Confidential Information"). You shall not
* disclose such Confidential Information and shall use it only in
* accordance with the terms of the license agreement you entered into
* with Sun.
*
* SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
* SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
* IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
* SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
* THIS SOFTWARE OR ITS DERIVATIVES.
*
* CopyrightVersion 1.1_beta
*
*/
package java.lang;
import java.io.PrintStream;
import sun.misc.VM;
/**
* A thread group represents a set of threads. In addition, a thread
* group can also include other thread groups. The thread groups form
* a tree in which every thread group except the initial thread group
* has a parent.
* <p>
* A thread is allowed to access information about its own thread
* group, but not to access information about its thread group's
* parent thread group or any other thread groups.
*
* @author unascribed
* @version 1.31, 20 Jan 1997
* @since JDK1.0
*/
/* The locking strategy for this code is to try to lock only one level of the
* tree wherever possible, but otherwise to lock from the bottom up.
* That is, from child thread groups to parents.
* This has the advantage of limiting the number of locks that need to be held
* and in particular avoids having to grab the lock for the root thread group,
* (or a global lock) which would be a source of contention on a
* multi-processor system with many thread groups.
* This policy often leads to taking a snapshot of the state of a thread group
* and working off of that snapshot, rather than holding the thread group locked
* while we work on the children.
*/
public
class ThreadGroup {
ThreadGroup parent;
String name;
int maxPriority;
boolean destroyed;
boolean daemon;
boolean vmAllowSuspension;
int nthreads;
Thread threads[];
int ngroups;
ThreadGroup groups[];
/**
* Creates an empty Thread group that is not in any Thread group.
* This method is used to create the system Thread group.
*/
private ThreadGroup() { // called from C code
this.name = "system";
this.maxPriority = Thread.MAX_PRIORITY;
}
/**
* Constructs a new thread group. The parent of this new group is
* the thread group of the currently running thread.
*
* @param name the name of the new thread group.
* @since JDK1.0
*/
public ThreadGroup(String name) {
this(Thread.currentThread().getThreadGroup(), name);
}
/**
* Creates a new thread group. The parent of this new group is the
* specified thread group.
* <p>
* The <code>checkAccess</code> method of the parent thread group is
* called with no arguments; this may result in a security exception.
*
* @param parent the parent thread group.
* @param name the name of the new thread group.
* @exception NullPointerException if the thread group argument is
* <code>null</code>.
* @exception SecurityException if the current thread cannot create a
* thread in the specified thread group.
* @see java.lang.SecurityException
* @see java.lang.ThreadGroup#checkAccess()
* @since JDK1.0
*/
public ThreadGroup(ThreadGroup parent, String name) {
if (parent == null) {
throw new NullPointerException();
}
parent.checkAccess();
this.name = name;
this.maxPriority = parent.maxPriority;
this.daemon = parent.daemon;
this.vmAllowSuspension = parent.vmAllowSuspension;
this.parent = parent;
parent.add(this);
}
/**
* Returns the name of this thread group.
*
* @return the name of this thread group.
* @since JDK1.0
*/
public final String getName() {
return name;
}
/**
* Returns the parent of this thread group.
*
* @return the parent of this thread group. The top-level thread group
* is the only thread group whose parent is <code>null</code>.
* @since JDK1.0
*/
public final ThreadGroup getParent() {
return parent;
}
/**
* Returns the maximum priority of this thread group. Threads that are
* part of this group cannot have a higher priority than the maximum
* priority.
*
* @return the maximum priority that a thread in this thread group
* can have.
* @since JDK1.0
*/
public final int getMaxPriority() {
return maxPriority;
}
/**
* Tests if this thread group is a daemon thread group. A
* daemon thread group is automatically destroyed when its last
* thread is stopped or its last thread group is destroyed.
*
* @return <code>true</code> if this thread group is a daemon thread group;
* <code>false</code> otherwise.
* @since JDK1.0
*/
public final boolean isDaemon() {
return daemon;
}
/**
* Tests if this thread group has not been destroyed.
*
* @since JDK1.1
*/
public synchronized boolean isDestroyed() {
return destroyed;
}
/**
* Changes the daemon status of this thread group.
* <p>
* First, the <code>checkAccess</code> method of this thread group is
* called with no arguments; this may result in a security exception.
* <p>
* A daemon thread group is automatically destroyed when its last
* thread is stopped or its last thread group is destroyed.
*
* @param daemon if <code>true</code>, marks this thread group as
* a daemon thread group; otherwise, marks this
* thread group as normal.
* @exception SecurityException if the current thread cannot modify
* this thread.
* @see java.lang.SecurityException
* @see java.lang.ThreadGroup#checkAccess()
* @since JDK1.0
*/
public final void setDaemon(boolean daemon) {
checkAccess();
this.daemon = daemon;
}
/**
* Sets the maximum priority of the group.
* <p>
* First, the <code>checkAccess</code> method of this thread group is
* called with no arguments; this may result in a security exception.
* <p>
* Threads in the thread group that already have a higher priority
* are not affected.
*
* @param pri the new priority of the thread group.
* @exception SecurityException if the current thread cannot modify
* this thread group.
* @see java.lang.SecurityException
* @see java.lang.ThreadGroup#checkAccess()
* @since JDK1.0
*/
public final void setMaxPriority(int pri) {
int ngroupsSnapshot;
ThreadGroup[] groupsSnapshot;
synchronized (this) {
checkAccess();
if (pri < Thread.MIN_PRIORITY) {
maxPriority = Thread.MIN_PRIORITY;
} else if (pri < maxPriority) {
maxPriority = pri;
}
ngroupsSnapshot = ngroups;
if (groups != null) {
groupsSnapshot = new ThreadGroup[ngroupsSnapshot];
System.arraycopy(groups, 0, groupsSnapshot, 0, ngroupsSnapshot);
} else {
groupsSnapshot = null;
}
}
for (int i = 0 ; i < ngroupsSnapshot ; i++) {
groupsSnapshot[i].setMaxPriority(pri);
}
}
/**
* Tests if this thread group is either the thread group
* argument or one of its ancestor thread groups.
*
* @param g a thread group.
* @return <code>true</code> if this thread group is the thread group
* argument or one of its ancestor thread groups;
* <code>false</code> otherwise.
* @since JDK1.0
*/
public final boolean parentOf(ThreadGroup g) {
for (; g != null ; g = g.parent) {
if (g == this) {
return true;
}
}
return false;
}
/**
* Determines if the currently running thread has permission to
* modify this thread group.
* <p>
* If there is a security manager, its <code>checkAccess</code> method
* is called with this thread group as its argument. This may result
* in throwing a <code>SecurityException</code>.
*
* @exception SecurityException if the current thread is not allowed to
* access this thread group.
* @see java.lang.SecurityManager#checkAccess(java.lang.ThreadGroup)
* @since JDK1.0
*/
public final void checkAccess() {
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkAccess(this);
}
}
/**
* Returns an estimate of the number of active threads in this
* thread group.
*
* @return the number of active threads in this thread group and in any
* other thread group that has this thread group as an ancestor.
* @since JDK1.0
*/
public int activeCount() {
int result;
// Snapshot sub-group data so we don't hold this lock
// while our children are computing.
int ngroupsSnapshot;
ThreadGroup[] groupsSnapshot;
synchronized (this) {
if (destroyed) {
return 0;
}
result = nthreads;
ngroupsSnapshot = ngroups;
if (groups != null) {
groupsSnapshot = new ThreadGroup[ngroupsSnapshot];
System.arraycopy(groups, 0, groupsSnapshot, 0, ngroupsSnapshot);
} else {
groupsSnapshot = null;
}
}
for (int i = 0 ; i < ngroupsSnapshot ; i++) {
result += groupsSnapshot[i].activeCount();
}
return result;
}
/**
* Copies into the specified array every active thread in this
* thread group and its subgroups.
* <p>
* An application should use the <code>activeCount</code> method to
* get an estimate of how big the array should be. If the array is
* too short to hold all the threads, the extra threads are silently
* ignored.
*
* @param list an array into which to place the list of threads.
* @return the number of threads put into the array.
* @see java.lang.ThreadGroup#activeCount()
* @since JDK1.0
*/
public int enumerate(Thread list[]) {
return enumerate(list, 0, true);
}
/**
* Copies into the specified array every active thread in this
* thread group. If the <code>recurse</code> flag is
* <code>true</code>, references to every active thread in this
* thread's subgroups are also included. If the array is too short to
* hold all the threads, the extra threads are silently ignored.
* <p>
* An application should use the <code>activeCount</code> method to
* get an estimate of how big the array should be.
*
* @param list an array into which to place the list of threads.
* @param recurse a flag indicating whether also to include threads
* in thread groups that are subgroups of this
* thread group.
* @return the number of threads placed into the array.
* @see java.lang.ThreadGroup#activeCount()
* @since JDK1.0
*/
public int enumerate(Thread list[], boolean recurse) {
return enumerate(list, 0, recurse);
}
private int enumerate(Thread list[], int n, boolean recurse) {
int ngroupsSnapshot = 0;
ThreadGroup[] groupsSnapshot = null;
synchronized (this) {
if (destroyed) {
return 0;
}
int nt = nthreads;
if (nt > list.length - n) {
nt = list.length - n;
}
if (nt > 0) {
System.arraycopy(threads, 0, list, n, nt);
n += nt;
}
if (recurse) {
ngroupsSnapshot = ngroups;
if (groups != null) {
groupsSnapshot = new ThreadGroup[ngroupsSnapshot];
System.arraycopy(groups, 0, groupsSnapshot, 0, ngroupsSnapshot);
} else {
groupsSnapshot = null;
}
}
}
if (recurse) {
for (int i = 0 ; i < ngroupsSnapshot ; i++) {
n = groupsSnapshot[i].enumerate(list, n, true);
}
}
return n;
}
/**
* Returns an estimate of the number of active groups in this
* thread group.
*
* @return the number of active thread groups with this thread group as
* an ancestor.
* @since JDK1.0
*/
public int activeGroupCount() {
int ngroupsSnapshot;
ThreadGroup[] groupsSnapshot;
synchronized (this) {
if (destroyed) {
return 0;
}
ngroupsSnapshot = ngroups;
if (groups != null) {
groupsSnapshot = new ThreadGroup[ngroupsSnapshot];
System.arraycopy(groups, 0, groupsSnapshot, 0, ngroupsSnapshot);
} else {
groupsSnapshot = null;
}
}
int n = ngroupsSnapshot;
for (int i = 0 ; i < ngroupsSnapshot ; i++) {
n += groupsSnapshot[i].activeGroupCount();
}
return n;
}
/**
* Copies into the specified array references to every active
* subgroup in this thread group.
* <p>
* An application should use the <code>activeGroupCount</code>
* method to get an estimate of how big the array should be. If the
* array is too short to hold all the thread groups, the extra thread
* groups are silently ignored.
*
* @param list an array into which to place the list of thread groups.
* @return the number of thread groups put into the array.
* @see java.lang.ThreadGroup#activeGroupCount()
* @since JDK1.0
*/
public int enumerate(ThreadGroup list[]) {
return enumerate(list, 0, true);
}
/**
* Copies into the specified array references to every active
* subgroup in this thread group. If the <code>recurse</code> flag is
* <code>true</code>, references to all active subgroups of the
* subgroups and so forth are also included.
* <p>
* An application should use the <code>activeGroupCount</code>
* method to get an estimate of how big the array should be.
*
* @param list an array into which to place the list of threads.
* @param recurse a flag indicating whether to recursively enumerate
* all included thread groups.
* @return the number of thread groups put into the array.
* @see java.lang.ThreadGroup#activeGroupCount()
* @since JDK1.0
*/
public int enumerate(ThreadGroup list[], boolean recurse) {
return enumerate(list, 0, recurse);
}
private int enumerate(ThreadGroup list[], int n, boolean recurse) {
int ngroupsSnapshot = 0;
ThreadGroup[] groupsSnapshot = null;
synchronized (this) {
if (destroyed) {
return 0;
}
int ng = ngroups;
if (ng > list.length - n) {
ng = list.length - n;
}
if (ng > 0) {
System.arraycopy(groups, 0, list, n, ng);
n += ng;
}
if (recurse) {
ngroupsSnapshot = ngroups;
if (groups != null) {
groupsSnapshot = new ThreadGroup[ngroupsSnapshot];
System.arraycopy(groups, 0, groupsSnapshot, 0, ngroupsSnapshot);
} else {
groupsSnapshot = null;
}
}
}
if (recurse) {
for (int i = 0 ; i < ngroupsSnapshot ; i++) {
n = groupsSnapshot[i].enumerate(list, n, true);
}
}
return n;
}
/**
* Stops all processes in this thread group.
* <p>
* First, the <code>checkAccess</code> method of this thread group is
* called with no arguments; this may result in a security exception.
* <p>
* This method then calls the <code>stop</code> method on all the
* threads in this thread group and in all of its subgroups.
*
* @exception SecurityException if the current thread is not allowed
* to access this thread group or any of the threads in
* the thread group.
* @see java.lang.SecurityException
* @see java.lang.Thread#stop()
* @see java.lang.ThreadGroup#checkAccess()
* @since JDK1.0
*/
public final void stop() {
int ngroupsSnapshot;
ThreadGroup[] groupsSnapshot;
synchronized (this) {
checkAccess();
for (int i = 0 ; i < nthreads ; i++) {
threads[i].stop();
}
ngroupsSnapshot = ngroups;
if (groups != null) {
groupsSnapshot = new ThreadGroup[ngroupsSnapshot];
System.arraycopy(groups, 0, groupsSnapshot, 0, ngroupsSnapshot);
} else {
groupsSnapshot = null;
}
}
for (int i = 0 ; i < ngroupsSnapshot ; i++) {
groupsSnapshot[i].stop();
}
}
/**
* Suspends all processes in this thread group.
* <p>
* First, the <code>checkAccess</code> method of this thread group is
* called with no arguments; this may result in a security exception.
* <p>
* This method then calls the <code>suspend</code> method on all the
* threads in this thread group and in all of its subgroups.
*
* @exception SecurityException if the current thread is not allowed
* to access this thread group or any of the threads in
* the thread group.
* @see java.lang.SecurityException
* @see java.lang.Thread#suspend()
* @see java.lang.ThreadGroup#checkAccess()
* @since JDK1.0
*/
public final void suspend() {
int ngroupsSnapshot;
ThreadGroup[] groupsSnapshot;
synchronized (this) {
checkAccess();
for (int i = 0 ; i < nthreads ; i++) {
threads[i].suspend();
}
ngroupsSnapshot = ngroups;
if (groups != null) {
groupsSnapshot = new ThreadGroup[ngroupsSnapshot];
System.arraycopy(groups, 0, groupsSnapshot, 0, ngroupsSnapshot);
} else {
groupsSnapshot = null;
}
}
for (int i = 0 ; i < ngroupsSnapshot ; i++) {
groupsSnapshot[i].suspend();
}
}
/**
* Resumes all processes in this thread group.
* <p>
* First, the <code>checkAccess</code> method of this thread group is
* called with no arguments; this may result in a security exception.
* <p>
* This method then calls the <code>resume</code> method on all the
* threads in this thread group and in all of its sub groups.
*
* @exception SecurityException if the current thread is not allowed to
* access this thread group or any of the threads in the
* thread group.
* @see java.lang.SecurityException
* @see java.lang.Thread#resume()
* @see java.lang.ThreadGroup#checkAccess()
* @since JDK1.0
*/
public final void resume() {
int ngroupsSnapshot;
ThreadGroup[] groupsSnapshot;
synchronized (this) {
checkAccess();
for (int i = 0 ; i < nthreads ; i++) {
threads[i].resume();
}
ngroupsSnapshot = ngroups;
if (groups != null) {
groupsSnapshot = new ThreadGroup[ngroupsSnapshot];
System.arraycopy(groups, 0, groupsSnapshot, 0, ngroupsSnapshot);
} else {
groupsSnapshot = null;
}
}
for (int i = 0 ; i < ngroupsSnapshot ; i++) {
groupsSnapshot[i].resume();
}
}
/**
* Destroys this thread group and all of its subgroups. This thread
* group must be empty, indicating that all threads that had been in
* this thread group have since stopped.
*
* @exception IllegalThreadStateException if the thread group is not
* empty or if the thread group has already been destroyed.
* @exception SecurityException if the current thread cannot modify this
* thread group.
* @since JDK1.0
*/
public final void destroy() {
int ngroupsSnapshot;
ThreadGroup[] groupsSnapshot;
synchronized (this) {
checkAccess();
if (destroyed || (nthreads > 0)) {
throw new IllegalThreadStateException();
}
ngroupsSnapshot = ngroups;
if (groups != null) {
groupsSnapshot = new ThreadGroup[ngroupsSnapshot];
System.arraycopy(groups, 0, groupsSnapshot, 0, ngroupsSnapshot);
} else {
groupsSnapshot = null;
}
if (parent != null) {
destroyed = true;
ngroups = 0;
groups = null;
nthreads = 0;
threads = null;
}
}
for (int i = 0 ; i < ngroupsSnapshot ; i += 1) {
groupsSnapshot[i].destroy();
}
if (parent != null) {
parent.remove(this);
}
}
/**
* Adds the specified Thread group to this group.
* @param g the specified Thread group to be added
* @exception IllegalThreadStateException If the Thread group has been destroyed.
*/
private final void add(ThreadGroup g){
synchronized (this) {
if (destroyed) {
throw new IllegalThreadStateException();
}
if (groups == null) {
groups = new ThreadGroup[4];
} else if (ngroups == groups.length) {
ThreadGroup newgroups[] = new ThreadGroup[ngroups * 2];
System.arraycopy(groups, 0, newgroups, 0, ngroups);
groups = newgroups;
}
groups[ngroups] = g;
// This is done last so it doesn't matter in case the
// thread is killed
ngroups++;
}
}
/**
* Removes the specified Thread group from this group.
* @param g the Thread group to be removed
* @return if this Thread has already been destroyed.
*/
private void remove(ThreadGroup g) {
synchronized (this) {
if (destroyed) {
return;
}
for (int i = 0 ; i < ngroups ; i++) {
if (groups[i] == g) {
ngroups -= 1;
System.arraycopy(groups, i + 1, groups, i, ngroups - i);
// Zap dangling reference to the dead group so that
// the garbage collector will collect it.
groups[ngroups] = null;
break;
}
}
if (nthreads == 0) {
notifyAll();
}
if (daemon && (nthreads == 0) && (ngroups == 0)) {
destroy();
}
}
}
/**
* Adds the specified Thread to this group.
* @param t the Thread to be added
* @exception IllegalThreadStateException If the Thread group has been destroyed.
*/
void add(Thread t) {
synchronized (this) {
if (destroyed) {
throw new IllegalThreadStateException();
}
if (threads == null) {
threads = new Thread[4];
} else if (nthreads == threads.length) {
Thread newthreads[] = new Thread[nthreads * 2];
System.arraycopy(threads, 0, newthreads, 0, nthreads);
threads = newthreads;
}
threads[nthreads] = t;
// This is done last so it doesn't matter in case the
// thread is killed
nthreads++;
}
}
/**
* Removes the specified Thread from this group.
* @param t the Thread to be removed
* @return if the Thread has already been destroyed.
*/
void remove(Thread t) {
synchronized (this) {
if (destroyed) {
return;
}
for (int i = 0 ; i < nthreads ; i++) {
if (threads[i] == t) {
System.arraycopy(threads, i + 1, threads, i, --nthreads - i);
// Zap dangling reference to the dead thread so that
// the garbage collector will collect it.
threads[nthreads] = null;
break;
}
}
if (nthreads == 0) {
notifyAll();
}
if (daemon && (nthreads == 0) && (ngroups == 0)) {
destroy();
}
}
}
/**
* Prints information about this thread group to the standard
* output. This method is useful only for debugging.
*
* @since JDK1.0
*/
public void list() {
list(System.out, 0);
}
void list(PrintStream out, int indent) {
int ngroupsSnapshot;
ThreadGroup[] groupsSnapshot;
synchronized (this) {
for (int j = 0 ; j < indent ; j++) {
out.print(" ");
}
out.println(this);
indent += 4;
for (int i = 0 ; i < nthreads ; i++) {
for (int j = 0 ; j < indent ; j++) {
out.print(" ");
}
out.println(threads[i]);
}
ngroupsSnapshot = ngroups;
if (groups != null) {
groupsSnapshot = new ThreadGroup[ngroupsSnapshot];
System.arraycopy(groups, 0, groupsSnapshot, 0, ngroupsSnapshot);
} else {
groupsSnapshot = null;
}
}
for (int i = 0 ; i < ngroupsSnapshot ; i++) {
groupsSnapshot[i].list(out, indent);
}
}
/**
* Called by the Java Virtual Machine when a thread in this
* thread group stops because of an uncaught exception.
* <p>
* The <code>uncaughtException</code> method of
* <code>ThreadGroup</code> does the following:
* <ul>
* <li>If this thread group has a parent thread group, the
* <code>uncaughtException</code> method of that parent is called
* with the same two arguments.
* <li>Otherwise, this method determines if the <code>Throwable</code>
* argument is an instance of <code>ThreadDeath</code>. If so, nothing
* special is done. Otherwise, the <code>Throwable</code>'s
* <code>printStackTrace</code> method is called to print a stack
* backtrace to the standard error stream.
* </ul>
* <p>
* Applications can override this method in subclasses of
* <code>ThreadGroup</code> to provide alternative handling of
* uncaught exceptions.
*
* @param t the thread that is about to exit.
* @param e the uncaught exception.
* @see java.lang.System#err
* @see java.lang.ThreadDeath
* @see java.lang.Throwable#printStackTrace(java.io.PrintStream)
* @since JDK1.0
*/
public void uncaughtException(Thread t, Throwable e) {
if (parent != null) {
parent.uncaughtException(t, e);
} else if (!(e instanceof ThreadDeath)) {
e.printStackTrace(System.err);
}
}
/**
* Used by VM to control lowmem implicit suspension.
*
* @since JDK1.1
*/
public boolean allowThreadSuspension(boolean b) {
this.vmAllowSuspension = b;
if (!b) {
VM.unsuspendSomeThreads();
}
return true;
}
/**
* Returns a string representation of this Thread group.
*
* @return a string representation of this thread group.
* @since JDK1.0
*/
public String toString() {
return getClass().getName() + "[name=" + getName() + ",maxpri=" + maxPriority + "]";
}
}

File diff suppressed because it is too large Load diff