01: package kawa.standard;
02:
03: import kawa.lang.*;
04: import gnu.mapping.*;
05: import gnu.expr.*;
06:
07: public class make extends ProcedureN {
08: public int numArgs() {
09: return 0xFFFFF001;
10: } // minimum 1 argument
11:
12: public Object applyN(Object[] args) {
13: int nargs = args.length;
14: if (nargs == 0)
15: throw new WrongArguments(this , nargs);
16: Object arg_0 = args[0];
17: Class clas;
18: if (arg_0 instanceof Class)
19: clas = (Class) arg_0;
20: else if (arg_0 instanceof gnu.bytecode.ClassType)
21: clas = ((gnu.bytecode.ClassType) arg_0).getReflectClass();
22: else
23: clas = null;
24: if (clas == null)
25: throw new WrongType(this , 1, arg_0, "class");
26: Object result;
27: try {
28: result = clas.newInstance();
29: } catch (Exception ex) {
30: throw new WrappedException(ex);
31: }
32: for (int i = 1; i < nargs;) {
33: Keyword key = (Keyword) args[i++];
34: Object arg = args[i++];
35: Record.set1(arg, key.getName(), result);
36: }
37: return result;
38: }
39: }
|