Skip to content

Commit

Permalink
Revert "clean_plugins: remove 'sqlite3'"
Browse files Browse the repository at this point in the history
This reverts commit 155f641.

Conflicts:

	CMakeLists.txt
  • Loading branch information
aristidb committed Sep 19, 2009
1 parent 7be440b commit 59c63c0
Show file tree
Hide file tree
Showing 3 changed files with 571 additions and 0 deletions.
19 changes: 19 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ option(
FORCE_PLUGINS
"Fail configuration if some enabled plugins could not be configured"
OFF)
option(PLUGIN_SQLITE3 "Build SQLite3 plugin" ON)
option(PLUGIN_GMP "Build GMP plugin" ON)
set(
LINE_EDITOR
Expand Down Expand Up @@ -277,6 +278,18 @@ if(LINE_EDITOR STREQUAL "readline")
endif()
endif()

## sqlite3 ##################################################################

if(PLUGIN_SQLITE3)
pkg_check_modules(SQLITE3 sqlite3>=3.4.0)
include_directories(${SQLITE3_INCLUDE_DIRS})
link_directories(${SQLITE3_LIBRARY_DIRS})

if(FORCE_PLUGINS AND NOT SQLITE3_FOUND)
message(SEND_ERROR "SQLite3 plugin required but SQLite3 not found")
endif()
endif()

## GMP ######################################################################

if(PLUGIN_GMP)
Expand Down Expand Up @@ -420,6 +433,12 @@ endif()

## Plugins #################################################################

if(PLUGIN_SQLITE3 AND SQLITE3_FOUND)
set(PLUGINS ${PLUGINS} sqlite3)
set(sqlite3_DEFINITIONS ${SQLITE3_DEFINITIONS})
set(sqlite3_LIBRARIES ${SQLITE3_LIBRARIES})
endif()

if(PLUGIN_GMP AND GMP_FOUND AND GMPXX_FOUND)
set(PLUGINS ${PLUGINS} gmp)
set(gmp_LIBRARIES ${GMPXX_LIBRARY} ${GMP_LIBRARY})
Expand Down
178 changes: 178 additions & 0 deletions src/plugins/sqlite3/sqlite3.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
// vim:ts=2:sw=2:expandtab:autoindent:
// vim: foldmethod=marker:foldmarker={{{,}}}
/*
The MIT License
Copyright (c) 2008, 2009 Aristid Breitkreuz, Ash Berlin, Ruediger Sonderfeld
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/

var SQLite3 = exports.SQLite3;

// generators are easier to write in JS space
SQLite3.Cursor.prototype.__iterator__ = function() {
while (true) {
let row = this.next();
if (row == null)
throw StopIteration;
yield row;
}
};

// SQLite3 {{{
/**
* Opens a handle to the database dsn Will usually be
* a filename, but could also be ":memory:".
*
* @name SQLite3
* @constructor
*
* @param dsn Path to sqlite DB file (or anything else it sqlite3_open
* supports)
*
* @see SQLite3.Cursor
*
* @class SQLite3 Database handle.
*
* ==Example:==
* {{{
* const SQLite3 = require('sqlite3').SQLite3;
* var db = new SQLite3('./my_db.sqlite');
* var c = db.cursor('SELECT * FROM table_1 WHERE id IN (?,?)');
* c.bind([4,6]);
*
* for (let row in c) {
* print(row.toSource());
* }
* }}}
*
*/

// Class properties {{{
/**#@+ @fieldOf SQLite3 */

/**
* SQLite3 version as human readable string
* @name versionStr
* @type string
*/

/**
* SQLite3 version as an integer. For example, SQLite v3.6.12 would have a
* version of 3006012
* @name version
* @type int
*/

/**#@- }}} */

// Class properties {{{
/**#@+ @methodOf SQLite3# */

/**
* Close the database handle. Force the database handle to be closed now,
* instead of when the object gets garbage collected.
* @name close
*/

/**
* Get a cursor to execute the given SQL statement. Bind parameters can be
* passed in as parameters the SQL, or by using [[SQLite3.Cursor#bind]].
* @name cursor
* @function
*
* @param sql SQL to prepare.
* @param bind_arg bind parameters passed to [[SQLite3.Cursor#bind]].
*
* @returns {SQLite3.Cursor} A cursor object
*/

/**#@- }}} */
// }}}

// SQLite3.Cursor {{{
/**
* You cannot construct a cursor object directly, use [[SQLite3#cursor]] to
* create one.
*
* @class Cursor class used to execute statements.
* @name SQLite3.Cursor
*/

// Instance methods {{{
/**#@+ @methodOf SQLite3.Cursor# */

/**
* Bind placeholder values. Accepts either an Array or an Object. SQLite
* bind params are 1 based. However when an array is passed the first bind
* param is pulled from the 0th element of the array, etc.
*
* @name bind
*
* @param binds bind parameters
*/

/**
* Get next row from this cursor. This is the alternative way of getting at
* the results if you don't like the iterator style (or if the JS engine
* doesn't support it).
*
* @returns Next row as an array, or null when end of results reached.
*
* @name SQLite3.Cursor.prototype.next
*/

/**
* Close this cursor. Force it to be closed now, instead of waiting for it to
* get garbage collected.
*
* You don't //have// to call this method, but its probably a good idea to
* call if you know you wont need to use this cursor any more, since garbage
* collection might take a long time to run.
*
* @name SQLite3.Cursor.prototype.close
*/

/**
* Reset the cursor back to the start. This will also clear any errors.
*
* This does not clear any bound parameters.
*
* @name reset
*/
/**#@- }}} */

// Instance properties {{{
/**#@+ @fieldOf SQLite3.Cursor# */

/**
* Iterator support. A generator function that enables you to write
*
* {{{
* for (row in myCursor) { ... }
* }}}
*
* Each row will only be fetched from SQLite as needed as by [[#next]].
*
* @name __iterator__
*/
/**#@- }}} */
// }}}

Loading

0 comments on commit 59c63c0

Please sign in to comment.