Further simplifications in the interface of the OutputPointer family of Java classes.

FossilOrigin-Name: 962c3e0de2d64ab8a2bcf1a19f9c4224df3d15a41ac9f9b29da685be95c4ef7a
This commit is contained in:
stephan 2023-08-12 15:09:09 +00:00
parent c216df75c6
commit 5b3a754360
5 changed files with 40 additions and 40 deletions

View File

@ -32,9 +32,9 @@ public final class OutputPointer {
private org.sqlite.jni.sqlite3 value;
public sqlite3(){value = null;}
public void clear(){value = null;}
public final org.sqlite.jni.sqlite3 getValue(){return value;}
/** Equivalent to calling getValue() then clear(). */
public final org.sqlite.jni.sqlite3 takeValue(){
public final org.sqlite.jni.sqlite3 get(){return value;}
/** Equivalent to calling get() then clear(). */
public final org.sqlite.jni.sqlite3 take(){
final org.sqlite.jni.sqlite3 v = value;
value = null;
return v;
@ -51,9 +51,9 @@ public final class OutputPointer {
private org.sqlite.jni.sqlite3_stmt value;
public sqlite3_stmt(){value = null;}
public void clear(){value = null;}
public final org.sqlite.jni.sqlite3_stmt getValue(){return value;}
/** Equivalent to calling getValue() then clear(). */
public final org.sqlite.jni.sqlite3_stmt takeValue(){
public final org.sqlite.jni.sqlite3_stmt get(){return value;}
/** Equivalent to calling get() then clear(). */
public final org.sqlite.jni.sqlite3_stmt take(){
final org.sqlite.jni.sqlite3_stmt v = value;
value = null;
return v;
@ -72,8 +72,8 @@ public final class OutputPointer {
public int value;
public Int32(){this(0);}
public Int32(int v){value = v;}
public final int getValue(){return value;}
public final void setValue(int v){value = v;}
public final int get(){return value;}
public final void set(int v){value = v;}
}
/**
@ -88,8 +88,8 @@ public final class OutputPointer {
public long value;
public Int64(){this(0);}
public Int64(long v){value = v;}
public final long getValue(){return value;}
public final void setValue(long v){value = v;}
public final long get(){return value;}
public final void set(long v){value = v;}
}
/**
@ -104,8 +104,8 @@ public final class OutputPointer {
public java.lang.String value;
public String(){this(null);}
public String(java.lang.String v){value = v;}
public final java.lang.String getValue(){return value;}
public final void setValue(java.lang.String v){value = v;}
public final java.lang.String get(){return value;}
public final void set(java.lang.String v){value = v;}
}
/**
@ -120,7 +120,7 @@ public final class OutputPointer {
public byte[] value;
public ByteArray(){this(null);}
public ByteArray(byte[] v){value = v;}
public final byte[] getValue(){return value;}
public final void setValue(byte[] v){value = v;}
public final byte[] get(){return value;}
public final void set(byte[] v){value = v;}
}
}

View File

@ -69,14 +69,14 @@ public class Tester1 {
final OutputPointer.sqlite3 out = new OutputPointer.sqlite3();
int rc = sqlite3_open(":memory:", out);
++metrics.dbOpen;
sqlite3 db = out.takeValue();
sqlite3 db = out.take();
if( 0!=rc ){
final String msg = db.getNativePointer()==0
? sqlite3_errstr(rc)
: sqlite3_errmsg(db);
throw new RuntimeException("Opening db failed: "+msg);
}
affirm( null == out.getValue() );
affirm( null == out.get() );
affirm( 0 != db.getNativePointer() );
rc = sqlite3_busy_timeout(db, 2000);
affirm( 0 == rc );
@ -104,7 +104,7 @@ public class Tester1 {
if(throwOnError) affirm(0 == rc);
else if( 0!=rc ) break;
pos = oTail.value;
stmt = outStmt.takeValue();
stmt = outStmt.take();
if( null == stmt ){
// empty statement was parsed.
continue;
@ -135,8 +135,8 @@ public class Tester1 {
outStmt.clear();
int rc = sqlite3_prepare(db, sql, outStmt);
affirm( 0 == rc );
final sqlite3_stmt rv = outStmt.takeValue();
affirm( null == outStmt.getValue() );
final sqlite3_stmt rv = outStmt.take();
affirm( null == outStmt.get() );
affirm( 0 != rv.getNativePointer() );
return rv;
}
@ -156,7 +156,7 @@ public class Tester1 {
final OutputPointer.sqlite3 out = new OutputPointer.sqlite3();
int rc = sqlite3_open(":memory:", out);
++metrics.dbOpen;
sqlite3 db = out.getValue();
sqlite3 db = out.get();
affirm(0 == rc);
affirm(0 < db.getNativePointer());
sqlite3_db_config(db, SQLITE_DBCONFIG_DEFENSIVE, 1, null)
@ -174,7 +174,7 @@ public class Tester1 {
| SQLITE_OPEN_CREATE, null);
++metrics.dbOpen;
affirm(0 == rc);
sqlite3 db = out.getValue();
sqlite3 db = out.get();
affirm(0 < db.getNativePointer());
sqlite3_close_v2(db);
affirm(0 == db.getNativePointer());
@ -185,7 +185,7 @@ public class Tester1 {
int rc;
rc = sqlite3_prepare(db, "CREATE TABLE t1(a);", outStmt);
affirm(0 == rc);
sqlite3_stmt stmt = outStmt.getValue();
sqlite3_stmt stmt = outStmt.get();
affirm(0 != stmt.getNativePointer());
rc = sqlite3_step(stmt);
affirm(SQLITE_DONE == rc);
@ -208,7 +208,7 @@ public class Tester1 {
if( 0==sqlChunk.length ) break;
rc = sqlite3_prepare_v2(db, sqlChunk, outStmt, oTail);
affirm(0 == rc);
stmt = outStmt.getValue();
stmt = outStmt.get();
pos = oTail.value;
/*outln("SQL tail pos = "+pos+". Chunk = "+
(new String(Arrays.copyOfRange(sqlChunk,0,pos),
@ -232,7 +232,7 @@ public class Tester1 {
rc = sqlite3_prepare_v3(db, "INSERT INTO t2(a) VALUES(1),(2),(3)",
SQLITE_PREPARE_NORMALIZE, outStmt);
affirm(0 == rc);
stmt = outStmt.getValue();
stmt = outStmt.get();
affirm(0 != stmt.getNativePointer());
sqlite3_finalize(stmt);
affirm(0 == stmt.getNativePointer() );
@ -797,13 +797,13 @@ public class Tester1 {
int rc = sqlite3_open(dbName, outDb);
++metrics.dbOpen;
affirm( 0 == rc );
final sqlite3 db1 = outDb.getValue();
final sqlite3 db1 = outDb.get();
execSql(db1, "CREATE TABLE IF NOT EXISTS t(a)");
rc = sqlite3_open(dbName, outDb);
++metrics.dbOpen;
affirm( 0 == rc );
affirm( outDb.getValue() != db1 );
final sqlite3 db2 = outDb.getValue();
affirm( outDb.get() != db1 );
final sqlite3 db2 = outDb.get();
rc = sqlite3_db_config(db1, SQLITE_DBCONFIG_MAINDBNAME, "foo");
affirm( sqlite3_db_filename(db1, "foo").endsWith(dbName) );
@ -826,7 +826,7 @@ public class Tester1 {
affirm(!xDestroyed.value);
rc = sqlite3_prepare_v2(db2, "SELECT * from t", outStmt);
affirm( SQLITE_BUSY == rc);
assert( null == outStmt.getValue() );
assert( null == outStmt.get() );
affirm( 3 == xBusyCalled.value );
sqlite3_close_v2(db1);
affirm(!xDestroyed.value);

View File

@ -368,7 +368,7 @@ public class SQLTester {
if( createIfNeeded ) flags |= SQLITE_OPEN_CREATE;
final OutputPointer.sqlite3 out = new OutputPointer.sqlite3();
int rc = sqlite3_open_v2(name, out, flags, null);
final sqlite3 db = out.takeValue();
final sqlite3 db = out.take();
if( 0==rc && dbInitSql.length() > 0){
//outln("RUNNING DB INIT CODE: ",dbInitSql.toString());
rc = execSql(db, false, ResultBufferMode.NONE,
@ -508,7 +508,7 @@ public class SQLTester {
}
if( 0==sqlChunk.length ) break;
rc = sqlite3_prepare_v2(db, sqlChunk, outStmt, oTail);
/*outln("PREPARE rc ",rc," oTail=",oTail.getValue(),": ",
/*outln("PREPARE rc ",rc," oTail=",oTail.get(),": ",
new String(sqlChunk,StandardCharsets.UTF_8),"\n<EOSQL>");*/
if( 0!=rc ){
if(throwOnError){
@ -519,7 +519,7 @@ public class SQLTester {
break;
}
pos = oTail.value;
stmt = outStmt.takeValue();
stmt = outStmt.take();
if( null == stmt ){
// empty statement was parsed.
continue;

View File

@ -1,5 +1,5 @@
C Tweaks\sand\sdocs\sfor\sthe\sOutputPointer\sfamily\sof\sJava\sclasses.
D 2023-08-12T10:39:26.077
C Further\ssimplifications\sin\sthe\sinterface\sof\sthe\sOutputPointer\sfamily\sof\sJava\sclasses.
D 2023-08-12T15:09:09.163
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@ -249,13 +249,13 @@ F ext/jni/src/org/sqlite/jni/Fts5Function.java 65cde7151e441fee012250a5e03277de7
F ext/jni/src/org/sqlite/jni/Fts5PhraseIter.java 6642beda341c0b1b46af4e2d7f6f9ab03a7aede43277b2c92859176d6bce3be9
F ext/jni/src/org/sqlite/jni/Fts5Tokenizer.java 91489893596b6528c0df5cd7180bd5b55809c26e2b797fb321dfcdbc1298c060
F ext/jni/src/org/sqlite/jni/NativePointerHolder.java 9c5d901cce4f7e57c3d623f4e2476f9f79a8eed6e51b2a603f37866018e040ee
F ext/jni/src/org/sqlite/jni/OutputPointer.java b4aa8137283336dabb4dcbed4b9f133d6cca3abe1babee0b5b0cfe698104f346
F ext/jni/src/org/sqlite/jni/OutputPointer.java b0adc42695f5c6d523f6b537b9eec7b5252581449d32a708aedfe323f6695407
F ext/jni/src/org/sqlite/jni/ProgressHandler.java 6f62053a828a572de809828b1ee495380677e87daa29a1c57a0e2c06b0a131dc
F ext/jni/src/org/sqlite/jni/ResultCode.java 7cdf993f2037ab7bd244c9a34dbaef2ace3beb5da5d7e7fda5c6f67634ceb647
F ext/jni/src/org/sqlite/jni/RollbackHook.java b04c8abcc6ade44a8a57129e33765793f69df0ba909e49ba18d73f4268d92564
F ext/jni/src/org/sqlite/jni/SQLFunction.java 09ce81c1c637e31c3a830d4c859cce95d65f5e02ff45f8bd1985b3479381bc46
F ext/jni/src/org/sqlite/jni/SQLite3Jni.java 18458d7419a9105e4987884f9a51a269a7aee3824abda861f937776a5dfd6b76
F ext/jni/src/org/sqlite/jni/Tester1.java 084694388797bf470dd4ab920082b4ca00f0bbb35ad6c024b7630c864b0dac65
F ext/jni/src/org/sqlite/jni/Tester1.java 07c14a90427529ceba54b5e8344ca03602f5789dc53c4163ce22f92d8c577a11
F ext/jni/src/org/sqlite/jni/TesterFts5.java 59e22dd24af033ea8827d36225a2f3297908fb6af8818ead8850c6c6847557b1
F ext/jni/src/org/sqlite/jni/Tracer.java a5cece9f947b0af27669b8baec300b6dd7ff859c3e6a6e4a1bd8b50f9714775d
F ext/jni/src/org/sqlite/jni/UpdateHook.java e58645a1727f8a9bbe72dc072ec5b40d9f9362cb0aa24acfe93f49ff56a9016d
@ -267,7 +267,7 @@ F ext/jni/src/org/sqlite/jni/sqlite3.java 62b1b81935ccf3393472d17cb883dc5ff39c38
F ext/jni/src/org/sqlite/jni/sqlite3_context.java d26573fc7b309228cb49786e9078597d96232257defa955a3425d10897bca810
F ext/jni/src/org/sqlite/jni/sqlite3_stmt.java 78e6d1b95ac600a9475e9db4623f69449322b0c93d1bd4e1616e76ed547ed9fc
F ext/jni/src/org/sqlite/jni/sqlite3_value.java 3d1d4903e267bc0bc81d57d21f5e85978eff389a1a6ed46726dbe75f85e6914a
F ext/jni/src/org/sqlite/jni/tester/SQLTester.java 26bb7e860174ec0ccc0303ee3626f0b8c8f47eb0bb1fbd37ad02b146794cfc58
F ext/jni/src/org/sqlite/jni/tester/SQLTester.java 1f1286428fab38dfefe328e72b5735f533b19af8dd17712dd3df7e044d21c8b8
F ext/jni/src/org/sqlite/jni/tester/test-script-interpreter.md f9f25126127045d051e918fe59004a1485311c50a13edbf18c79a6ff9160030e
F ext/jni/src/tests/000-000-sanity.test cfe6dc1b950751d6096e3f5695becaadcdaa048bfe9567209d6eb676e693366d
F ext/jni/src/tests/000-001-ignored.test e17e874c6ab3c437f1293d88093cf06286083b65bf162317f91bbfd92f961b70
@ -2091,8 +2091,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P b79477a0af94127b0638a8822de01156bef855a7e167f678809e1c978e1a0c3e
R 12e2b2e0d37bf41e692cbd7292102259
P 265c8fd0d4d425054f6bf7e9cb607ad2e0e46189f16c3014f7fdf9b650085497
R 82a7bb87064debdd63f799e45e3a7aa0
U stephan
Z 1871e1e7678c55928d63894731dc9434
Z 038e6a5cd04ee9dc715f1c7cadd72bf8
# Remove this line to create a well-formed Fossil manifest.

View File

@ -1 +1 @@
265c8fd0d4d425054f6bf7e9cb607ad2e0e46189f16c3014f7fdf9b650085497
962c3e0de2d64ab8a2bcf1a19f9c4224df3d15a41ac9f9b29da685be95c4ef7a