Skip to content

Commit 033e1bc

Browse files
committed
make PyBuiltinFunctionSet a subclass of PyBuiltinFunction and break method versions of PyBuiltingFunction sets out into PyBuiltinMethodSet
1 parent f90297c commit 033e1bc

14 files changed

Lines changed: 207 additions & 216 deletions

src/com/ziclix/python/sql/PyConnection.java

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,21 @@
88
*/
99
package com.ziclix.python.sql;
1010

11-
import com.ziclix.python.sql.util.PyArgParser;
11+
import java.sql.Connection;
12+
import java.sql.SQLException;
13+
import java.util.Collections;
14+
import java.util.HashSet;
15+
import java.util.Iterator;
16+
import java.util.Set;
1217
import org.python.core.ClassDictInit;
1318
import org.python.core.Py;
14-
import org.python.core.PyBuiltinFunctionSet;
19+
import org.python.core.PyBuiltinMethodSet;
1520
import org.python.core.PyClass;
1621
import org.python.core.PyInteger;
1722
import org.python.core.PyList;
1823
import org.python.core.PyObject;
1924
import org.python.core.PyString;
20-
21-
import java.sql.Connection;
22-
import java.sql.SQLException;
23-
import java.util.Collections;
24-
import java.util.HashSet;
25-
import java.util.Iterator;
26-
import java.util.Set;
25+
import com.ziclix.python.sql.util.PyArgParser;
2726

2827
/**
2928
* A connection to the database.
@@ -460,9 +459,9 @@ boolean contains(PyStatement statement) {
460459
}
461460
}
462461

463-
class ConnectionFunc extends PyBuiltinFunctionSet {
462+
class ConnectionFunc extends PyBuiltinMethodSet {
464463
ConnectionFunc(String name, int index, int minargs, int maxargs, String doc) {
465-
super(name, index, minargs, maxargs, true, doc);
464+
super(name, index, minargs, maxargs, doc);
466465
}
467466

468467
public PyObject __call__() {
@@ -480,7 +479,7 @@ public PyObject __call__() {
480479
c.rollback();
481480
return Py.None;
482481
default :
483-
throw argCountError(0);
482+
throw info.unexpectedCall(0, false);
484483
}
485484
}
486485

@@ -492,7 +491,7 @@ public PyObject __call__(PyObject arg) {
492491
case 4:
493492
return c.nativesql(arg);
494493
default :
495-
throw argCountError(1);
494+
throw info.unexpectedCall(1, false);
496495
}
497496
}
498497

@@ -502,7 +501,7 @@ public PyObject __call__(PyObject arg1, PyObject arg2, PyObject arg3) {
502501
case 2:
503502
return c.cursor(arg1.__nonzero__(), arg2, arg3);
504503
default :
505-
throw argCountError(3);
504+
throw info.unexpectedCall(3, false);
506505
}
507506
}
508507

@@ -522,7 +521,7 @@ public PyObject __call__(PyObject[] args, String[] keywords) {
522521
return c.cursor(dynamic.__nonzero__(), rstype, rsconcur);
523522

524523
default :
525-
throw argCountError(args.length);
524+
throw info.unexpectedCall(args.length, true);
526525
}
527526
}
528527
}

src/com/ziclix/python/sql/PyCursor.java

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,14 @@
99
*/
1010
package com.ziclix.python.sql;
1111

12-
import com.ziclix.python.sql.util.PyArgParser;
12+
import java.sql.DatabaseMetaData;
13+
import java.sql.SQLException;
14+
import java.sql.SQLWarning;
15+
import java.sql.Statement;
16+
import java.util.List;
1317
import org.python.core.ClassDictInit;
1418
import org.python.core.Py;
15-
import org.python.core.PyBuiltinFunctionSet;
19+
import org.python.core.PyBuiltinMethodSet;
1620
import org.python.core.PyClass;
1721
import org.python.core.PyDictionary;
1822
import org.python.core.PyException;
@@ -21,12 +25,7 @@
2125
import org.python.core.PyObject;
2226
import org.python.core.PyString;
2327
import org.python.core.PyTuple;
24-
25-
import java.sql.DatabaseMetaData;
26-
import java.sql.SQLException;
27-
import java.sql.SQLWarning;
28-
import java.sql.Statement;
29-
import java.util.List;
28+
import com.ziclix.python.sql.util.PyArgParser;
3029

3130
/**
3231
* These objects represent a database cursor, which is used to manage the
@@ -874,12 +873,12 @@ public static boolean isSeqSeq(PyObject object) {
874873
}
875874
}
876875

877-
class CursorFunc extends PyBuiltinFunctionSet {
876+
class CursorFunc extends PyBuiltinMethodSet {
878877
CursorFunc(String name, int index, int argcount, String doc) {
879-
super(name, index, argcount, argcount, true, doc);
878+
super(name, index, argcount, argcount, doc);
880879
}
881880
CursorFunc(String name, int index, int minargs, int maxargs, String doc) {
882-
super(name, index, minargs, maxargs, true, doc);
881+
super(name, index, minargs, maxargs, doc);
883882
}
884883

885884
public PyObject __call__() {
@@ -897,7 +896,7 @@ public PyObject __call__() {
897896
case 4 :
898897
return cursor.nextset();
899898
default :
900-
throw argCountError(0);
899+
throw info.unexpectedCall(0, false);
901900
}
902901
}
903902

@@ -927,7 +926,7 @@ public PyObject __call__(PyObject arg) {
927926
case 12 :
928927
return cursor.prepare(arg);
929928
default :
930-
throw argCountError(1);
929+
throw info.unexpectedCall(1, false);
931930
}
932931
}
933932

@@ -949,7 +948,7 @@ public PyObject __call__(PyObject arga, PyObject argb) {
949948
cursor.scroll(((PyInteger)arga.__int__()).getValue(), argb.toString());
950949
return Py.None;
951950
default :
952-
throw argCountError(2);
951+
throw info.unexpectedCall(2, false);
953952
}
954953
}
955954

@@ -966,7 +965,7 @@ public PyObject __call__(PyObject arga, PyObject argb, PyObject argc) {
966965
cursor.executemany(arga, argb, argc, Py.None);
967966
return Py.None;
968967
default :
969-
throw argCountError(3);
968+
throw info.unexpectedCall(3, false);
970969
}
971970
}
972971

@@ -994,7 +993,7 @@ public PyObject __call__(PyObject[] args, String[] keywords) {
994993
cursor.executemany(sql, params, bindings, maxrows);
995994
return Py.None;
996995
default :
997-
throw argCountError(args.length);
996+
throw info.unexpectedCall(args.length, true);
998997
}
999998
}
1000999
}

src/com/ziclix/python/sql/PyExtendedCursor.java

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,17 @@
88
*/
99
package com.ziclix.python.sql;
1010

11+
import java.sql.DatabaseMetaData;
12+
import java.sql.SQLException;
13+
import java.util.HashSet;
14+
import java.util.Set;
1115
import org.python.core.Py;
12-
import org.python.core.PyBuiltinFunctionSet;
16+
import org.python.core.PyBuiltinMethodSet;
1317
import org.python.core.PyClass;
1418
import org.python.core.PyList;
1519
import org.python.core.PyObject;
1620
import org.python.core.PyString;
1721

18-
import java.sql.DatabaseMetaData;
19-
import java.sql.SQLException;
20-
import java.util.HashSet;
21-
import java.util.Set;
22-
2322
/**
2423
* A cursor with extensions to the DB API 2.0.
2524
*
@@ -487,14 +486,14 @@ protected String getMetaDataName(PyObject name) {
487486
}
488487
}
489488

490-
class ExtendedCursorFunc extends PyBuiltinFunctionSet {
489+
class ExtendedCursorFunc extends PyBuiltinMethodSet {
491490

492491
ExtendedCursorFunc(String name, int index, int argcount, String doc) {
493-
super(name, index, argcount, argcount, true, doc);
492+
super(name, index, argcount, argcount, doc);
494493
}
495494

496495
ExtendedCursorFunc(String name, int index, int minargs, int maxargs, String doc) {
497-
super(name, index, minargs, maxargs, true, doc);
496+
super(name, index, minargs, maxargs, doc);
498497
}
499498

500499
public PyObject __call__() {
@@ -514,7 +513,7 @@ public PyObject __call__() {
514513
return Py.None;
515514

516515
default :
517-
throw argCountError(0);
516+
throw info.unexpectedCall(0, false);
518517
}
519518
}
520519

@@ -530,7 +529,7 @@ public PyObject __call__(PyObject arga) {
530529
return Py.None;
531530

532531
default :
533-
throw argCountError(1);
532+
throw info.unexpectedCall(1, false);
534533
}
535534
}
536535

@@ -561,7 +560,7 @@ public PyObject __call__(PyObject arga, PyObject argb, PyObject argc) {
561560
return Py.None;
562561

563562
default :
564-
throw argCountError(3);
563+
throw info.unexpectedCall(3, false);
565564
}
566565
}
567566

@@ -582,7 +581,7 @@ public PyObject fancyCall(PyObject[] args) {
582581
return Py.None;
583582

584583
default :
585-
throw argCountError(args.length);
584+
throw info.unexpectedCall(args.length, true);
586585
}
587586
}
588587

@@ -608,7 +607,7 @@ public PyObject __call__(PyObject arg1, PyObject arg2, PyObject arg3, PyObject a
608607
return Py.None;
609608

610609
default :
611-
throw argCountError(4);
610+
throw info.unexpectedCall(4, false);
612611
}
613612
}
614613
}

src/com/ziclix/python/sql/util/BCP.java

Lines changed: 13 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@
88
*/
99
package com.ziclix.python.sql.util;
1010

11-
import com.ziclix.python.sql.PyConnection;
12-
import com.ziclix.python.sql.pipe.Pipe;
13-
import com.ziclix.python.sql.pipe.db.DBSink;
14-
import com.ziclix.python.sql.pipe.db.DBSource;
15-
import com.ziclix.python.sql.zxJDBC;
1611
import org.python.core.ClassDictInit;
1712
import org.python.core.Py;
18-
import org.python.core.PyBuiltinFunctionSet;
13+
import org.python.core.PyBuiltinMethodSet;
1914
import org.python.core.PyClass;
2015
import org.python.core.PyList;
2116
import org.python.core.PyObject;
2217
import org.python.core.PyString;
18+
import com.ziclix.python.sql.PyConnection;
19+
import com.ziclix.python.sql.zxJDBC;
20+
import com.ziclix.python.sql.pipe.Pipe;
21+
import com.ziclix.python.sql.pipe.db.DBSink;
22+
import com.ziclix.python.sql.pipe.db.DBSource;
2323

2424
/**
2525
* A class to perform efficient Bulk CoPy of database tables.
@@ -204,40 +204,19 @@ protected PyObject bcp(String fromTable, String where, PyObject params, PyObject
204204
}
205205

206206
/**
207-
* Class BCPFunc
208-
*
209-
* @author
210207
* @author last modified by $Author$
211208
* @version $Revision$
212-
* @date $today.date$
213209
* @date last modified on $Date$
214210
* @copyright 2001 brian zimmer
215211
*/
216-
class BCPFunc extends PyBuiltinFunctionSet {
212+
class BCPFunc extends PyBuiltinMethodSet {
217213

218-
/**
219-
* Constructor BCPFunc
220-
*
221-
* @param name
222-
* @param index
223-
* @param argcount
224-
* @param doc
225-
*/
226214
BCPFunc(String name, int index, int argcount, String doc) {
227-
super(name, index, argcount, argcount, true, doc);
215+
super(name, index, argcount, argcount, doc);
228216
}
229217

230-
/**
231-
* Constructor BCPFunc
232-
*
233-
* @param name
234-
* @param index
235-
* @param minargs
236-
* @param maxargs
237-
* @param doc
238-
*/
239218
BCPFunc(String name, int index, int minargs, int maxargs, String doc) {
240-
super(name, index, minargs, maxargs, true, doc);
219+
super(name, index, minargs, maxargs, doc);
241220
}
242221

243222
/**
@@ -264,7 +243,7 @@ public PyObject __call__(PyObject arg) {
264243
return count;
265244

266245
default :
267-
throw argCountError(1);
246+
throw info.unexpectedCall(1, false);
268247
}
269248
}
270249

@@ -287,7 +266,7 @@ public PyObject __call__(PyObject arga, PyObject argb) {
287266
return count;
288267

289268
default :
290-
throw argCountError(2);
269+
throw info.unexpectedCall(2, false);
291270
}
292271
}
293272

@@ -310,7 +289,7 @@ public PyObject __call__(PyObject arga, PyObject argb, PyObject argc) {
310289
return count;
311290

312291
default :
313-
throw argCountError(3);
292+
throw info.unexpectedCall(3, false);
314293
}
315294
}
316295

@@ -361,7 +340,7 @@ public PyObject __call__(PyObject[] args, String[] keywords) {
361340
return count;
362341

363342
default :
364-
throw argCountError(3);
343+
throw info.unexpectedCall(3, false);
365344
}
366345
}
367346
}

0 commit comments

Comments
 (0)