Merge mozilla-central to tracemonkey.
Merge mozilla-central to tracemonkey.
--- a/browser/components/safebrowsing/content/test/browser_bug415846.js
+++ b/browser/components/safebrowsing/content/test/browser_bug415846.js
@@ -2,27 +2,27 @@
menu items.
Mac makes this astonishingly painful to test since their help menu is special magic,
but we can at least test it on the other platforms.*/
var menu;
function test() {
waitForExplicitFinish();
-
+
gBrowser.selectedTab = gBrowser.addTab();
// Navigate to a normal site
- gBrowser.addEventListener("load", testNormal, false);
+ gBrowser.addEventListener("DOMContentLoaded", testNormal, false);
content.location = "http://example.com/";
}
function testNormal() {
- gBrowser.removeEventListener("load", testNormal, false);
-
+ gBrowser.removeEventListener("DOMContentLoaded", testNormal, false);
+
// open the menu, to force it to update
menu = document.getElementById("menu_HelpPopup");
ok(menu, "Help menu should exist!");
menu.addEventListener("popupshown", testNormal_PopupListener, false);
menu.openPopup(null, "", 0, 0, false, null);
}
@@ -33,17 +33,17 @@ function testNormal_PopupListener() {
var errorMenu = document.getElementById("menu_HelpPopup_reportPhishingErrortoolmenu");
is(reportMenu.hidden, false, "Report phishing menu should be visible on normal sites");
is(errorMenu.hidden, true, "Report error menu item should be hidden on normal sites");
menu.hidePopup();
// Now launch the phishing test. Can't use onload here because error pages don't
// fire normal load events.
content.location = "http://www.mozilla.com/firefox/its-a-trap.html";
- window.setTimeout(testPhishing, 2000);
+ setTimeout(testPhishing, 2000);
}
function testPhishing() {
menu.addEventListener("popupshown", testPhishing_PopupListener, false);
menu.openPopup(null, "", 0, 0, false, null);
}
function testPhishing_PopupListener() {
--- a/browser/components/sessionstore/test/browser/browser_394759.js
+++ b/browser/components/sessionstore/test/browser/browser_394759.js
@@ -68,18 +68,18 @@ function test() {
// make sure that the next closed window will increase getClosedWindowCount
let max_windows_undo = gPrefService.getIntPref("browser.sessionstore.max_windows_undo");
gPrefService.setIntPref("browser.sessionstore.max_windows_undo", max_windows_undo + 1);
let closedWindowCount = ss.getClosedWindowCount();
let newWin = openDialog(location, "", "chrome,all,dialog=no", testURL);
newWin.addEventListener("load", function(aEvent) {
- newWin.gBrowser.addEventListener("load", function(aEvent) {
- newWin.gBrowser.removeEventListener("load", arguments.callee, true);
+ newWin.gBrowser.selectedBrowser.addEventListener("load", function(aEvent) {
+ newWin.gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
executeSoon(function() {
newWin.gBrowser.addTab().linkedBrowser.stop();
executeSoon(function() {
// mark the window with some unique data to be restored later on
ss.setWindowValue(newWin, uniqueKey, uniqueValue);
let textbox = newWin.content.document.getElementById("textbox");
textbox.wrappedJSObject.value = uniqueText;
@@ -96,18 +96,18 @@ function test() {
let newWin2 = ss.undoCloseWindow(0);
ok(newWin2 instanceof ChromeWindow,
"undoCloseWindow actually returned a window");
is(ss.getClosedWindowCount(), closedWindowCount,
"The reopened window was removed from Recently Closed Windows");
newWin2.addEventListener("load", function(aEvent) {
- newWin2.gBrowser.addEventListener("SSTabRestored", function(aEvent) {
- newWin2.gBrowser.removeEventListener("SSTabRestored", arguments.callee, true);
+ newWin2.gBrowser.tabContainer.addEventListener("SSTabRestored", function(aEvent) {
+ newWin2.gBrowser.tabContainer.removeEventListener("SSTabRestored", arguments.callee, true);
is(newWin2.gBrowser.tabContainer.childNodes.length, 2,
"The window correctly restored 2 tabs");
is(newWin2.gBrowser.currentURI.spec, testURL,
"The window correctly restored the URL");
let textbox = newWin2.content.document.getElementById("textbox");
is(textbox.wrappedJSObject.value, uniqueText,
@@ -152,18 +152,18 @@ function test() {
}
// hack to force window to be considered a popup (toolbar=no didn't work)
let winData = windowsToOpen.shift();
let settings = "chrome,dialog=no," +
(winData.isPopup ? "all=no" : "all");
let url = "http://window" + windowsToOpen.length + ".example.com";
let win = openDialog(location, "", settings, url);
win.addEventListener("load", function(aEvent) {
- win.gBrowser.addEventListener("load", function(aEvent) {
- win.gBrowser.removeEventListener("load", arguments.callee, true);
+ win.gBrowser.selectedBrowser.addEventListener("DOMContentLoaded", function(aEvent) {
+ win.gBrowser.selectedBrowser.removeEventListener("DOMContentLoaded", arguments.callee, true);
// the window _should_ have state with a tab of url, but it doesn't
// always happend before window.close(). addTab ensure we don't treat
// this window as a stateless window
win.gBrowser.addTab();
executeSoon(function() {
win.close();
executeSoon(function() {
--- a/browser/fuel/test/browser_Browser.js
+++ b/browser/fuel/test/browser_Browser.js
@@ -44,21 +44,21 @@ function test() {
// need to wait for the url's to be refreshed during the load
function afterOpen(event) {
gPageB.events.removeListener("load", delayAfterOpen);
// check actuals
is(gPageA.uri.spec, "chrome://mochikit/content/browser/browser/fuel/test/ContentA.html", "Checking 'BrowserTab.uri' after opening");
is(gPageB.uri.spec, "chrome://mochikit/content/browser/browser/fuel/test/ContentB.html", "Checking 'BrowserTab.uri' after opening");
+ // check event
+ is(gTabOpenCount, 2, "Checking event handler for tab open");
// check cached values from TabOpen event
is(gPageA.uri.spec, gTabOpenPageA.uri.spec, "Checking first browser tab open is equal to page A");
is(gPageB.uri.spec, gTabOpenPageB.uri.spec, "Checking second browser tab open is equal to page B");
- // check event
- is(gTabOpenCount, 2, "Checking event handler for tab open");
// test document access
var test1 = gPageA.document.getElementById("test1");
ok(test1, "Checking existence of element in content DOM");
is(test1.innerHTML, "A", "Checking content of element in content DOM");
// test moving tab
is(gTabMoveCount, 0, "Checking initial tab move count");
--- a/build/automation.py.in
+++ b/build/automation.py.in
@@ -46,16 +46,19 @@ import re
import select
import shutil
import signal
import subprocess
import sys
import threading
import tempfile
+_DEFAULT_WEB_SERVER = "127.0.0.1"
+_DEFAULT_HTTP_PORT = 8888
+_DEFAULT_SSL_PORT = 4443
#expand _DIST_BIN = __XPC_BIN_PATH__
#expand _IS_WIN32 = len("__WIN32__") != 0
#expand _IS_MAC = __IS_MAC__ != 0
#expand _IS_LINUX = __IS_LINUX__ != 0
#ifdef IS_CYGWIN
#expand _IS_CYGWIN = __IS_CYGWIN__ == 1
#else
@@ -124,30 +127,33 @@ class Automation(object):
CRASHREPORTER = _CRASHREPORTER
SCRIPT_DIR = os.path.abspath(os.path.realpath(os.path.dirname(sys.argv[0])))
sys.path.insert(0, SCRIPT_DIR)
automationutils = __import__('automationutils')
# timeout, in seconds
DEFAULT_TIMEOUT = 60.0
+ DEFAULT_WEB_SERVER = _DEFAULT_WEB_SERVER
+ DEFAULT_HTTP_PORT = _DEFAULT_HTTP_PORT
+ DEFAULT_SSL_PORT = _DEFAULT_SSL_PORT
log = logging.getLogger()
def __init__(self):
# We use the logging system here primarily because it'll handle multiple
# threads, which is needed to process the output of the server and application
# processes simultaneously.
handler = logging.StreamHandler(sys.stdout)
self.log.setLevel(logging.INFO)
self.log.addHandler(handler)
- def setServerInfo(self, server = "mochi.test", httpPort = 8888, sslPort = 4443):
- self.webServer = server
+ def setServerInfo(self, webServer = _DEFAULT_WEB_SERVER, httpPort = _DEFAULT_HTTP_PORT, sslPort = _DEFAULT_SSL_PORT):
+ self.webServer = webServer
self.httpPort = httpPort
self.sslPort = sslPort
@property
def __all__(self):
return [
"UNIXISH",
"IS_WIN32",
@@ -311,17 +317,17 @@ user_pref("capability.principal.codebase
part = """
user_pref("capability.principal.codebase.p%(i)d.granted",
"UniversalXPConnect UniversalBrowserRead UniversalBrowserWrite \
UniversalPreferencesRead UniversalPreferencesWrite \
UniversalFileRead");
user_pref("capability.principal.codebase.p%(i)d.id", "%(origin)s");
user_pref("capability.principal.codebase.p%(i)d.subjectName", "");
""" % { "i": i,
- "origin": (l.scheme + "://" + l.host + ":" + l.port) }
+ "origin": (l.scheme + "://" + l.host + ":" + str(l.port)) }
prefs.append(part)
# We need to proxy every server but the primary one.
origins = ["'%s://%s:%s'" % (l.scheme, l.host, l.port)
for l in filter(lambda l: "primary" not in l.options, locations)]
origins = ", ".join(origins)
pacURL = """data:text/plain,
@@ -343,21 +349,24 @@ function FindProxyForURL(url, host)
if (isHttp) matches[3] = '80';
if (isHttps) matches[3] = '443';
}
var origin = matches[1] + '://' + matches[2] + ':' + matches[3];
if (origins.indexOf(origin) < 0)
return 'DIRECT';
if (isHttp)
- return 'PROXY 127.0.0.1:8888';
+ return 'PROXY %(remote)s:%(httpport)s';
if (isHttps)
- return 'PROXY 127.0.0.1:4443';
+ return 'PROXY %(remote)s:%(sslport)s';
return 'DIRECT';
-}""" % { "origins": origins }
+}""" % { "origins": origins,
+ "remote": self.webServer,
+ "httpport":self.httpPort,
+ "sslport": self.sslPort }
pacURL = "".join(pacURL.splitlines())
part += """
user_pref("network.proxy.type", 2);
user_pref("network.proxy.autoconfig_url", "%(pacURL)s");
user_pref("camino.use_system_proxy_settings", false); // Camino-only, harmless to others
""" % {"pacURL": pacURL}
@@ -393,38 +402,38 @@ user_pref("camino.use_system_proxy_setti
pwfile.close()
# Create head of the ssltunnel configuration file
sslTunnelConfigPath = os.path.join(profileDir, "ssltunnel.cfg")
sslTunnelConfig = open(sslTunnelConfigPath, "w")
sslTunnelConfig.write("httpproxy:1\n")
sslTunnelConfig.write("certdbdir:%s\n" % certPath)
- sslTunnelConfig.write("forward:127.0.0.1:8888\n")
- sslTunnelConfig.write("listen:*:4443:pgo server certificate\n")
+ sslTunnelConfig.write("forward:127.0.0.1:%s\n" % self.httpPort)
+ sslTunnelConfig.write("listen:*:%s:pgo server certificate\n" % self.sslPort)
# Configure automatic certificate and bind custom certificates, client authentication
locations = self.readLocations()
locations.pop(0)
for loc in locations:
if loc.scheme == "https" and "nocert" not in loc.options:
customCertRE = re.compile("^cert=(?P<nickname>[0-9a-zA-Z_ ]+)")
clientAuthRE = re.compile("^clientauth=(?P<clientauth>[a-z]+)")
for option in loc.options:
match = customCertRE.match(option)
if match:
customcert = match.group("nickname");
- sslTunnelConfig.write("listen:%s:%s:4443:%s\n" %
- (loc.host, loc.port, customcert))
+ sslTunnelConfig.write("listen:%s:%s:%s:%s\n" %
+ (loc.host, loc.port, self.sslPort, customcert))
match = clientAuthRE.match(option)
if match:
clientauth = match.group("clientauth");
- sslTunnelConfig.write("clientauth:%s:%s:4443:%s\n" %
- (loc.host, loc.port, clientauth))
+ sslTunnelConfig.write("clientauth:%s:%s:%s:%s\n" %
+ (loc.host, loc.port, self.sslPort, clientauth))
sslTunnelConfig.close()
# Pre-create the certification database for the profile
env = self.environment(xrePath = xrePath)
certutil = os.path.join(utilityPath, "certutil" + self.BIN_SUFFIX)
pk12util = os.path.join(utilityPath, "pk12util" + self.BIN_SUFFIX)
--- a/db/mork/src/morkFile.cpp
+++ b/db/mork/src/morkFile.cpp
@@ -55,24 +55,16 @@
#include "morkFile.h"
#endif
#ifdef MORK_WIN
#include "io.h"
#include <windows.h>
#endif
-// #define MORK_CONFIG_USE_ORKINFILE 1
-
-#ifdef MORK_CONFIG_USE_ORKINFILE
-#ifndef _ORKINFILE_
-#include "orkinFile.h"
-#endif
-#endif /*MORK_CONFIG_USE_ORKINFILE*/
-
//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
// ````` ````` ````` ````` `````
// { ===== begin morkNode interface =====
/*public virtual*/ void
morkFile::CloseMorkNode(morkEnv* ev) // CloseFile() only if open
@@ -146,29 +138,16 @@ morkFile::CloseFile(morkEnv* ev) // call
}
else
ev->NilPointerError();
}
// } ===== end morkNode methods =====
// ````` ````` ````` ````` `````
-nsIMdbFile*
-morkFile::AcquireFileHandle(morkEnv* ev)
-{
- nsIMdbFile* outFile = 0;
-
-#ifdef MORK_CONFIG_USE_ORKINFILE
- return this;
-#endif /*MORK_CONFIG_USE_ORKINFILE*/
- MORK_USED_1(ev);
-
- return outFile;
-}
-
/*static*/ morkFile*
morkFile::OpenOldFile(morkEnv* ev, nsIMdbHeap* ioHeap,
const char* inFilePath, mork_bool inFrozen)
// Choose some subclass of morkFile to instantiate, in order to read
// (and write if not frozen) the file known by inFilePath. The file
// returned should be open and ready for use, and presumably positioned
// at the first byte position of the file. The exact manner in which
// files must be opened is considered a subclass specific detail, and
--- a/db/mork/src/morkFile.h
+++ b/db/mork/src/morkFile.h
@@ -131,18 +131,16 @@ public: // public static standard file c
// (and write if not frozen) the file known by inFilePath. The file
// returned should be created and ready for use, and presumably positioned
// at the first byte position of the file. The exact manner in which
// files must be opened is considered a subclass specific detail, and
// other portions or Mork source code don't want to know how it's done.
public: // non-poly morkFile methods
- nsIMdbFile* AcquireFileHandle(morkEnv* ev); // mObject_Handle
-
mork_bool FileFrozen() const { return mFile_Frozen == 'F'; }
mork_bool FileDoTrace() const { return mFile_DoTrace == 'T'; }
mork_bool FileIoOpen() const { return mFile_IoOpen == 'O'; }
mork_bool FileActive() const { return mFile_Active == 'A'; }
void SetFileFrozen(mork_bool b) { mFile_Frozen = (mork_u1) ((b)? 'F' : 0); }
void SetFileDoTrace(mork_bool b) { mFile_DoTrace = (mork_u1) ((b)? 'T' : 0); }
void SetFileIoOpen(mork_bool b) { mFile_IoOpen = (mork_u1) ((b)? 'O' : 0); }
--- a/db/mork/src/morkRowCellCursor.cpp
+++ b/db/mork/src/morkRowCellCursor.cpp
@@ -54,20 +54,16 @@
#ifndef _MORKCURSOR_
#include "morkCursor.h"
#endif
#ifndef _MORKROWCELLCURSOR_
#include "morkRowCellCursor.h"
#endif
-#ifndef _ORKINROWCELLCURSOR_
-#include "orkinRowCellCursor.h"
-#endif
-
#ifndef _MORKSTORE_
#include "morkStore.h"
#endif
#ifndef _MORKROWOBJECT_
#include "morkRowObject.h"
#endif
--- a/db/mork/src/morkSearchRowCursor.cpp
+++ b/db/mork/src/morkSearchRowCursor.cpp
@@ -58,32 +58,24 @@
#ifndef _MORKSEARCHROWCURSOR_
#include "morkSearchRowCursor.h"
#endif
#ifndef _MORKUNIQROWCURSOR_
#include "morkUniqRowCursor.h"
#endif
-#ifndef _ORKINTABLEROWCURSOR_
-#include "orkinTableRowCursor.h"
-#endif
-
#ifndef _MORKSTORE_
#include "morkStore.h"
#endif
#ifndef _MORKTABLE_
#include "morkTable.h"
#endif
-#ifndef _MORKSORTING_
-#include "morkSorting.h"
-#endif
-
#ifndef _MORKROW_
#include "morkRow.h"
#endif
//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
// ````` ````` ````` ````` `````
// { ===== begin morkNode interface =====
deleted file mode 100644
--- a/db/mork/src/morkSorting.cpp
+++ /dev/null
@@ -1,373 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (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.mozilla.org/MPL/
- *
- * 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 mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1999
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef _MDB_
-#include "mdb.h"
-#endif
-
-#ifndef _MORK_
-#include "mork.h"
-#endif
-
-#ifndef _MORKNODE_
-#include "morkNode.h"
-#endif
-
-#ifndef _MORKMAP_
-#include "morkMap.h"
-#endif
-
-#ifndef _MORKENV_
-#include "morkEnv.h"
-#endif
-
-#ifndef _MORKTABLE_
-#include "morkTable.h"
-#endif
-
-#ifndef _MORKSTORE_
-#include "morkStore.h"
-#endif
-
-#ifndef _MORKROWSPACE_
-#include "morkRowSpace.h"
-#endif
-
-#ifndef _MORKARRAY_
-#include "morkArray.h"
-#endif
-
-#ifndef _MORKROW_
-#include "morkRow.h"
-#endif
-
-#ifndef _ORKINSORTING_
-#include "orkinSorting.h"
-#endif
-
-#ifndef _MORKTABLEROWCURSOR_
-#include "morkTableRowCursor.h"
-#endif
-
-#ifndef _MORKSORTING_
-#include "morkSorting.h"
-#endif
-
-#ifndef _MORKQUICKSORT_
-#include "morkQuickSort.h"
-#endif
-
-//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
-
-// ````` ````` ````` ````` `````
-// { ===== begin morkNode interface =====
-
-/*public virtual*/ void
-morkSorting::CloseMorkNode(morkEnv* ev) /*i*/ // CloseSorting() only if open
-{
- if ( this->IsOpenNode() )
- {
- this->MarkClosing();
- this->CloseSorting(ev);
- this->MarkShut();
- }
-}
-
-/*public virtual*/
-morkSorting::~morkSorting() /*i*/ // assert CloseSorting() executed earlier
-{
- MORK_ASSERT(this->IsShutNode());
- MORK_ASSERT(mSorting_Table==0);
-}
-
-#define morkSorting_kExtraSlots 2 /* space for two more rows */
-
-/*public non-poly*/
-morkSorting::morkSorting(morkEnv* ev, const morkUsage& inUsage,
- nsIMdbHeap* ioNodeHeap, morkTable* ioTable,
- nsIMdbCompare* ioCompare,
- nsIMdbHeap* ioSlotHeap, mork_column inCol)
-: morkObject(ev, inUsage, ioNodeHeap, morkColor_kNone, (morkHandle*) 0)
-, mSorting_Table( 0 )
-
-, mSorting_Compare( 0 )
-
-, mSorting_RowArray(ev, morkUsage::kMember, (nsIMdbHeap*) 0,
- ioTable->GetRowCount() + morkSorting_kExtraSlots, ioSlotHeap)
-
-, mSorting_Col( inCol )
-{
- if ( ev->Good() )
- {
- if ( ioTable && ioSlotHeap && ioCompare )
- {
- if ( inCol )
- {
- nsIMdbCompare_SlotStrongCompare(ioCompare, ev, &mSorting_Compare);
- morkTable::SlotWeakTable(ioTable, ev, &mSorting_Table);
- if ( ev->Good() )
- {
- mNode_Derived = morkDerived_kSorting;
- }
- }
- else
- this->ZeroColError(ev);
- }
- else
- ev->NilPointerError();
- }
-}
-
-/*public non-poly*/ void
-morkSorting::CloseSorting(morkEnv* ev) /*i*/ // called by CloseMorkNode();
-{
- if ( this )
- {
- if ( this->IsNode() )
- {
- nsIMdbCompare_SlotStrongCompare((nsIMdbCompare*) 0, ev,
- &mSorting_Compare);
- morkTable::SlotWeakTable((morkTable*) 0, ev, &mSorting_Table);
- mSorting_RowArray.CloseMorkNode(ev);
- mSorting_Col = 0;
- this->MarkShut();
- }
- else
- this->NonNodeError(ev);
- }
- else
- ev->NilPointerError();
-}
-
-// } ===== end morkNode methods =====
-// ````` ````` ````` ````` `````
-
-/*static*/ void
-morkSorting::NonSortingTypeError(morkEnv* ev)
-{
- ev->NewError("non morkSorting");
-}
-
-/*static*/ void
-morkSorting::NonSortingTypeWarning(morkEnv* ev)
-{
- ev->NewWarning("non morkSorting");
-}
-
-/*static*/ void
-morkSorting::NilTableError(morkEnv* ev)
-{
- ev->NewError("nil mSorting_Table");
-}
-
-/*static*/ void
-morkSorting::NilCompareError(morkEnv* ev)
-{
- ev->NewError("nil mSorting_Compare");
-}
-
-/*static*/ void
-morkSorting::ZeroColError(morkEnv* ev)
-{
- ev->NewError("zero mSorting_Col");
-}
-
-nsIMdbSorting*
-morkSorting::AcquireSortingHandle(morkEnv* ev)
-{
- nsIMdbSorting* outSorting = 0;
- orkinSorting* s = (orkinSorting*) mObject_Handle;
- if ( s ) // have an old handle?
- s->AddStrongRef(ev->AsMdbEnv());
- else // need new handle?
- {
- s = orkinSorting::MakeSorting(ev, this);
- mObject_Handle = s;
- }
- if ( s )
- outSorting = s;
- return outSorting;
-}
-
-
-class morkSortClosure {
-public:
-
- morkEnv* mSortClosure_Env;
- morkSorting* mSortClosure_Sorting;
-
-public:
- morkSortClosure(morkEnv* ev, morkSorting* ioSorting);
-};
-
-morkSortClosure::morkSortClosure(morkEnv* ev, morkSorting* ioSorting)
- : mSortClosure_Env(ev), mSortClosure_Sorting(ioSorting)
-{
-}
-
-static mdb_order morkRow_Order(const morkRow* inA, const morkRow* inB,
- morkSortClosure* ioClosure)
-{
- return 0;
-}
-
-void morkSorting::sort_rows(morkEnv* ev)
-{
- morkTable* table = mSorting_Table;
- if ( table )
- {
- morkArray* tra = &table->mTable_RowArray;
- mork_count count = mSorting_RowArray.mArray_Fill;
- if ( this->is_seed_stale() || count != tra->mArray_Fill )
- count = this->copy_table_row_array(ev);
-
- if ( ev->Good() )
- {
- void** slots = mSorting_RowArray.mArray_Slots;
- morkSortClosure closure(ev, this);
-
- morkQuickSort((mork_u1*) slots, count, sizeof(morkRow*),
- (mdbAny_Order) morkRow_Order, &closure);
- }
- }
- else
- this->NilTableError(ev);
-}
-
-mork_count morkSorting::copy_table_row_array(morkEnv* ev)
-{
- morkArray* tra = &mSorting_Table->mTable_RowArray;
- mork_bool bigEnough = mSorting_RowArray.mArray_Size > tra->mArray_Fill;
- if ( !bigEnough )
- bigEnough = mSorting_RowArray.Grow(ev, tra->mArray_Fill);
-
- if ( ev->Good() && bigEnough )
- {
- mSorting_RowArray.mArray_Fill = tra->mArray_Fill;
- morkRow** src = (morkRow**) tra->mArray_Slots;
- morkRow** dst = (morkRow**) mSorting_RowArray.mArray_Slots;
- morkRow** end = dst + tra->mArray_Fill;
-
- while ( dst < end )
- *dst++ = *src++;
-
- this->sync_with_table_seed();
- }
-
- return mSorting_RowArray.mArray_Fill;
-}
-
-mork_pos
-morkSorting::ArrayHasOid(morkEnv* ev, const mdbOid* inOid)
-{
- MORK_USED_1(ev);
- mork_count count = mSorting_RowArray.mArray_Fill;
- mork_pos pos = -1;
- while ( ++pos < (mork_pos)count )
- {
- morkRow* row = (morkRow*) mSorting_RowArray.At(pos);
- MORK_ASSERT(row);
- if ( row && row->EqualOid(inOid) )
- {
- return pos;
- }
- }
- return -1;
-}
-
-mork_bool
-morkSorting::AddRow(morkEnv* ev, morkRow* ioRow)
-{
- MORK_USED_1(ioRow);
- return ev->Good();
-}
-
-mork_bool
-morkSorting::CutRow(morkEnv* ev, morkRow* ioRow)
-{
- MORK_USED_1(ioRow);
- return ev->Good();
-}
-
-
-mork_bool
-morkSorting::CutAllRows(morkEnv* ev)
-{
- return ev->Good();
-}
-
-morkSortingRowCursor*
-morkSorting::NewSortingRowCursor(morkEnv* ev, mork_pos inRowPos)
-{
- morkSortingRowCursor* outCursor = 0;
- if ( ev->Good() )
- {
-// nsIMdbHeap* heap = mSorting_Table->mTable_Store->mPort_Heap;
-// morkSortingRowCursor* cursor = 0;
-
- // $$$$$
- // morkSortingRowCursor* cursor = new(*heap, ev)
- // morkSortingRowCursor(ev, morkUsage::kHeap, heap, this, inRowPos);
- // if ( cursor )
- // {
- // if ( ev->Good() )
- // outCursor = cursor;
- // else
- // cursor->CutStrongRef(ev);
- // }
- }
- return outCursor;
-}
-
-
-//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
-
-
-morkSortingMap::~morkSortingMap()
-{
-}
-
-morkSortingMap::morkSortingMap(morkEnv* ev, const morkUsage& inUsage,
- nsIMdbHeap* ioHeap, nsIMdbHeap* ioSlotHeap)
- : morkNodeMap(ev, inUsage, ioHeap, ioSlotHeap)
-{
- if ( ev->Good() )
- mNode_Derived = morkDerived_kSortingMap;
-}
-
-
-//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
deleted file mode 100644
--- a/db/mork/src/morkSorting.h
+++ /dev/null
@@ -1,256 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (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.mozilla.org/MPL/
- *
- * 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 mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1999
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef _MORKSORTING_
-#define _MORKSORTING_ 1
-
-#ifndef _MORK_
-#include "mork.h"
-#endif
-
-#ifndef _MORKNODE_
-#include "morkNode.h"
-#endif
-
-#ifndef _MORKDEQUE_
-#include "morkDeque.h"
-#endif
-
-#ifndef _MORKOBJECT_
-#include "morkObject.h"
-#endif
-
-#ifndef _MORKARRAY_
-#include "morkArray.h"
-#endif
-
-#ifndef _MORKROWMAP_
-#include "morkRowMap.h"
-#endif
-
-#ifndef _MORKNODEMAP_
-#include "morkNodeMap.h"
-#endif
-
-#ifndef _MORKTABLE_
-#include "morkTable.h"
-#endif
-
-//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
-
-class nsIMdbSorting;
-#define morkDerived_kSorting /*i*/ 0x536F /* ascii 'So' */
-
-class morkSorting : public morkObject {
-
- // NOTE the morkLink base is for morkRowSpace::mRowSpace_SortingsByPriority
-
-// public: // slots inherited from morkObject (meant to inform only)
- // nsIMdbHeap* mNode_Heap;
-
- // mork_base mNode_Base; // must equal morkBase_kNode
- // mork_derived mNode_Derived; // depends on specific node subclass
-
- // mork_access mNode_Access; // kOpen, kClosing, kShut, or kDead
- // mork_usage mNode_Usage; // kHeap, kStack, kMember, kGlobal, kNone
- // mork_able mNode_Mutable; // can this node be modified?
- // mork_load mNode_Load; // is this node clean or dirty?
-
- // mork_uses mNode_Uses; // refcount for strong refs
- // mork_refs mNode_Refs; // refcount for strong refs + weak refs
-
- // mork_color mBead_Color; // ID for this bead
- // morkHandle* mObject_Handle; // weak ref to handle for this object
-
-public: // state is public because the entire Mork system is private
-
- morkTable* mSorting_Table; // weak ref to table
-
- nsIMdbCompare* mSorting_Compare;
-
- morkArray mSorting_RowArray; // array of morkRow pointers
-
- mork_column mSorting_Col; // column that gets sorted
-
-public: // sorting dirty handling more than morkNode::SetNodeDirty() etc.
-
- void SetSortingDirty() { this->SetNodeDirty(); }
-
- mork_bool IsSortingClean() const { return this->IsNodeClean(); }
- mork_bool IsSortingDirty() const { return this->IsNodeDirty(); }
-
-public: // morkNode memory management operators
- void* operator new(size_t inSize, nsIMdbHeap& ioHeap, morkEnv* ev) CPP_THROW_NEW
- { return morkNode::MakeNew(inSize, ioHeap, ev); }
-
-
-// { ===== begin morkNode interface =====
-public: // morkNode virtual methods
- virtual void CloseMorkNode(morkEnv* ev); // CloseSorting() if open
- virtual ~morkSorting(); // assert that close executed earlier
-
-public: // morkSorting construction & destruction
- morkSorting(morkEnv* ev, const morkUsage& inUsage,
- nsIMdbHeap* ioNodeHeap, morkTable* ioTable,
- nsIMdbCompare* ioCompare,
- nsIMdbHeap* ioSlotHeap, mork_column inCol);
- void CloseSorting(morkEnv* ev); // called by CloseMorkNode();
-
-private: // copying is not allowed
- morkSorting(const morkSorting& other);
- morkSorting& operator=(const morkSorting& other);
-
-public: // dynamic type identification
- mork_bool IsSorting() const
- { return IsNode() && mNode_Derived == morkDerived_kSorting; }
-// } ===== end morkNode methods =====
-
-public: // errors
- static void NonSortingTypeError(morkEnv* ev);
- static void NonSortingTypeWarning(morkEnv* ev);
- static void ZeroColError(morkEnv* ev);
- static void NilTableError(morkEnv* ev);
- static void NilCompareError(morkEnv* ev);
-
-public: // utilities
-
- void sort_rows(morkEnv* ev);
- mork_count copy_table_row_array(morkEnv* ev);
-
-public: // other sorting methods
-
- mork_seed SortingSeed() const { return mSorting_RowArray.mArray_Seed; }
-
- morkRow* SafeRowAt(morkEnv* ev, mork_pos inPos)
- { return (morkRow*) mSorting_RowArray.SafeAt(ev, inPos); }
-
- nsIMdbSorting* AcquireSortingHandle(morkEnv* ev); // mObject_Handle
-
- mork_count GetRowCount() const { return mSorting_RowArray.mArray_Fill; }
- mork_pos ArrayHasOid(morkEnv* ev, const mdbOid* inOid);
-
- morkSortingRowCursor* NewSortingRowCursor(morkEnv* ev, mork_pos inRowPos);
-
- mork_bool AddRow(morkEnv* ev, morkRow* ioRow);
-
- mork_bool CutRow(morkEnv* ev, morkRow* ioRow);
-
- mork_bool CutAllRows(morkEnv* ev);
-
-protected: // table seed sync management
-
- mork_bool is_seed_stale() const
- { return mSorting_RowArray.mArray_Seed != mSorting_Table->TableSeed(); }
-
- void sync_with_table_seed()
- { mSorting_RowArray.mArray_Seed = mSorting_Table->TableSeed(); }
-
-public: // typesafe refcounting inlines calling inherited morkNode methods
- static void SlotWeakSorting(morkSorting* me,
- morkEnv* ev, morkSorting** ioSlot)
- { morkNode::SlotWeakNode((morkNode*) me, ev, (morkNode**) ioSlot); }
-
- static void SlotStrongSorting(morkSorting* me,
- morkEnv* ev, morkSorting** ioSlot)
- { morkNode::SlotStrongNode((morkNode*) me, ev, (morkNode**) ioSlot); }
-};
-
-//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
-
-#define morkDerived_kSortingMap /*i*/ 0x734D /* ascii 'sM' */
-
-/*| morkSortingMap: maps mork_column -> morkSorting
-|*/
-class morkSortingMap : public morkNodeMap { // for mapping cols to sortings
-
-public:
-
- virtual ~morkSortingMap();
- morkSortingMap(morkEnv* ev, const morkUsage& inUsage,
- nsIMdbHeap* ioHeap, nsIMdbHeap* ioSlotHeap);
-
-public: // other map methods
-
- mork_bool AddSorting(morkEnv* ev, morkSorting* ioSorting)
- { return this->AddNode(ev, ioSorting->mSorting_Col, ioSorting); }
- // the AddSorting() boolean return equals ev->Good().
-
- mork_bool CutSorting(morkEnv* ev, mork_column inCol)
- { return this->CutNode(ev, inCol); }
- // The CutSorting() boolean return indicates whether removal happened.
-
- morkSorting* GetSorting(morkEnv* ev, mork_column inCol)
- { return (morkSorting*) this->GetNode(ev, inCol); }
- // Note the returned table does NOT have an increase in refcount for this.
-
- mork_num CutAllSortings(morkEnv* ev)
- { return this->CutAllNodes(ev); }
- // CutAllSortings() releases all the referenced table values.
-};
-
-class morkSortingMapIter: public morkMapIter{ // typesafe wrapper class
-
-public:
- morkSortingMapIter(morkEnv* ev, morkSortingMap* ioMap)
- : morkMapIter(ev, ioMap) { }
-
- morkSortingMapIter( ) : morkMapIter() { }
- void InitSortingMapIter(morkEnv* ev, morkSortingMap* ioMap)
- { this->InitMapIter(ev, ioMap); }
-
- mork_change*
- FirstSorting(morkEnv* ev, mork_column* outCol, morkSorting** outSorting)
- { return this->First(ev, outCol, outSorting); }
-
- mork_change*
- NextSorting(morkEnv* ev, mork_column* outCol, morkSorting** outSorting)
- { return this->Next(ev, outCol, outSorting); }
-
- mork_change*
- HereSorting(morkEnv* ev, mork_column* outCol, morkSorting** outSorting)
- { return this->Here(ev, outCol, outSorting); }
-
- // cutting while iterating hash map might dirty the parent table:
- mork_change*
- CutHereSorting(morkEnv* ev, mork_column* outCol, morkSorting** outSorting)
- { return this->CutHere(ev, outCol, outSorting); }
-};
-
-
-//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
-
-#endif /* _MORKSORTING_ */
deleted file mode 100644
--- a/db/mork/src/morkSortingRowCursor.cpp
+++ /dev/null
@@ -1,236 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (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.mozilla.org/MPL/
- *
- * 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 mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1999
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef _MDB_
-#include "mdb.h"
-#endif
-
-#ifndef _MORK_
-#include "mork.h"
-#endif
-
-#ifndef _MORKNODE_
-#include "morkNode.h"
-#endif
-
-#ifndef _MORKENV_
-#include "morkEnv.h"
-#endif
-
-#ifndef _MORKCURSOR_
-#include "morkCursor.h"
-#endif
-
-#ifndef _MORKSORTINGROWCURSOR_
-#include "morkSortingRowCursor.h"
-#endif
-
-#ifndef _ORKINTABLEROWCURSOR_
-#include "orkinTableRowCursor.h"
-#endif
-
-#ifndef _MORKSTORE_
-#include "morkStore.h"
-#endif
-
-#ifndef _MORKTABLE_
-#include "morkTable.h"
-#endif
-
-#ifndef _MORKSORTING_
-#include "morkSorting.h"
-#endif
-
-#ifndef _MORKROW_
-#include "morkRow.h"
-#endif
-
-//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
-
-// ````` ````` ````` ````` `````
-// { ===== begin morkNode interface =====
-
-/*public virtual*/ void
-morkSortingRowCursor::CloseMorkNode(morkEnv* ev) // CloseSortingRowCursor() only if open
-{
- if ( this->IsOpenNode() )
- {
- this->MarkClosing();
- this->CloseSortingRowCursor(ev);
- this->MarkShut();
- }
-}
-
-/*public virtual*/
-morkSortingRowCursor::~morkSortingRowCursor() // CloseSortingRowCursor() executed earlier
-{
- MORK_ASSERT(this->IsShutNode());
-}
-
-/*public non-poly*/
-morkSortingRowCursor::morkSortingRowCursor(morkEnv* ev,
- const morkUsage& inUsage,
- nsIMdbHeap* ioHeap, morkTable* ioTable, mork_pos inRowPos,
- morkSorting* ioSorting)
-: morkTableRowCursor(ev, inUsage, ioHeap, ioTable, inRowPos)
-, mSortingRowCursor_Sorting( 0 )
-{
- if ( ev->Good() )
- {
- if ( ioSorting )
- {
- morkSorting::SlotWeakSorting(ioSorting, ev, &mSortingRowCursor_Sorting);
- if ( ev->Good() )
- {
- // mNode_Derived = morkDerived_kTableRowCursor;
- // mNode_Derived must stay equal to kTableRowCursor
- }
- }
- else
- ev->NilPointerError();
- }
-}
-
-/*public non-poly*/ void
-morkSortingRowCursor::CloseSortingRowCursor(morkEnv* ev)
-{
- if ( this )
- {
- if ( this->IsNode() )
- {
- mCursor_Pos = -1;
- mCursor_Seed = 0;
- morkSorting::SlotWeakSorting((morkSorting*) 0, ev, &mSortingRowCursor_Sorting);
- this->CloseTableRowCursor(ev);
- this->MarkShut();
- }
- else
- this->NonNodeError(ev);
- }
- else
- ev->NilPointerError();
-}
-
-// } ===== end morkNode methods =====
-// ````` ````` ````` ````` `````
-
-/*static*/ void
-morkSortingRowCursor::NonSortingRowCursorTypeError(morkEnv* ev)
-{
- ev->NewError("non morkSortingRowCursor");
-}
-
-orkinTableRowCursor*
-morkSortingRowCursor::AcquireUniqueRowCursorHandle(morkEnv* ev)
-{
- return this->AcquireTableRowCursorHandle(ev);
-}
-
-mork_bool
-morkSortingRowCursor::CanHaveDupRowMembers(morkEnv* ev)
-{
- return morkBool_kFalse; // false is correct
-}
-
-mork_count
-morkSortingRowCursor::GetMemberCount(morkEnv* ev)
-{
- morkTable* table = mTableRowCursor_Table;
- if ( table )
- return table->mTable_RowArray.mArray_Fill;
- else
- return 0;
-
- // morkSorting* sorting = mSortingRowCursor_Sorting;
- // if ( sorting )
- // return sorting->mSorting_RowArray.mArray_Fill;
- // else
- // return 0;
-}
-
-morkRow*
-morkSortingRowCursor::NextRow(morkEnv* ev, mdbOid* outOid, mdb_pos* outPos)
-{
- morkRow* outRow = 0;
- mork_pos pos = -1;
-
- morkSorting* sorting = mSortingRowCursor_Sorting;
- if ( sorting )
- {
- if ( sorting->IsOpenNode() )
- {
- morkArray* array = &sorting->mSorting_RowArray;
- pos = mCursor_Pos;
- if ( pos < 0 )
- pos = 0;
- else
- ++pos;
-
- if ( pos < (mork_pos)(array->mArray_Fill))
- {
- mCursor_Pos = pos; // update for next time
- morkRow* row = (morkRow*) array->At(pos);
- if ( row )
- {
- if ( row->IsRow() )
- {
- outRow = row;
- *outOid = row->mRow_Oid;
- }
- else
- row->NonRowTypeError(ev);
- }
- else
- ev->NilPointerError();
- }
- else
- {
- outOid->mOid_Scope = 0;
- outOid->mOid_Id = morkId_kMinusOne;
- }
- }
- else
- sorting->NonOpenNodeError(ev);
- }
- else
- ev->NilPointerError();
-
- *outPos = pos;
- return outRow;
-}
-
-//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
deleted file mode 100644
--- a/db/mork/src/morkSortingRowCursor.h
+++ /dev/null
@@ -1,137 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (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.mozilla.org/MPL/
- *
- * 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 mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1999
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef _MORKSORTINGROWCURSOR_
-#define _MORKSORTINGROWCURSOR_ 1
-
-#ifndef _MORK_
-#include "mork.h"
-#endif
-
-#ifndef _MORKCURSOR_
-#include "morkCursor.h"
-#endif
-
-#ifndef _MORKSORTINGROWCURSOR_
-#include "morkSortingRowCursor.h"
-#endif
-
-#ifndef _MORKTABLEROWCURSOR_
-#include "morkTableRowCursor.h"
-#endif
-
-#ifndef _MORKMAP_
-#include "morkMap.h"
-#endif
-
-//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
-
-class orkinSortingRowCursor;
-// define morkDerived_kSortingRowCursor /*i*/ 0x7343 /* ascii 'sC' */
-
-class morkSortingRowCursor : public morkTableRowCursor { // row iterator
-
-// public: // slots inherited from morkObject (meant to inform only)
- // nsIMdbHeap* mNode_Heap;
- // mork_able mNode_Mutable; // can this node be modified?
- // mork_load mNode_Load; // is this node clean or dirty?
- // mork_base mNode_Base; // must equal morkBase_kNode
- // mork_derived mNode_Derived; // depends on specific node subclass
- // mork_access mNode_Access; // kOpen, kClosing, kShut, or kDead
- // mork_usage mNode_Usage; // kHeap, kStack, kMember, kGlobal, kNone
- // mork_uses mNode_Uses; // refcount for strong refs
- // mork_refs mNode_Refs; // refcount for strong refs + weak refs
-
- // morkFactory* mObject_Factory; // weak ref to suite factory
-
- // mork_seed mCursor_Seed;
- // mork_pos mCursor_Pos;
- // mork_bool mCursor_DoFailOnSeedOutOfSync;
- // mork_u1 mCursor_Pad[ 3 ]; // explicitly pad to u4 alignment
-
- // morkTable* mTableRowCursor_Table; // weak ref to table
-
-public: // state is public because the entire Mork system is private
-
- morkSorting* mSortingRowCursor_Sorting; // weak ref to sorting
-
-// { ===== begin morkNode interface =====
-public: // morkNode virtual methods
- virtual void CloseMorkNode(morkEnv* ev); // CloseSortingRowCursor()
- virtual ~morkSortingRowCursor(); // assert that close executed earlier
-
-public: // morkSortingRowCursor construction & destruction
- morkSortingRowCursor(morkEnv* ev, const morkUsage& inUsage,
- nsIMdbHeap* ioHeap, morkTable* ioTable, mork_pos inRowPos,
- morkSorting* ioSorting);
- void CloseSortingRowCursor(morkEnv* ev); // called by CloseMorkNode();
-
-private: // copying is not allowed
- morkSortingRowCursor(const morkSortingRowCursor& other);
- morkSortingRowCursor& operator=(const morkSortingRowCursor& other);
-
-public: // dynamic type identification
- // mork_bool IsSortingRowCursor() const
- // { return IsNode() && mNode_Derived == morkDerived_kSortingRowCursor; }
-// } ===== end morkNode methods =====
-
-public: // typing
- static void NonSortingRowCursorTypeError(morkEnv* ev);
-
-public: // other table row cursor methods
-
- virtual mork_bool CanHaveDupRowMembers(morkEnv* ev);
- virtual mork_count GetMemberCount(morkEnv* ev);
-
- virtual orkinTableRowCursor* AcquireUniqueRowCursorHandle(morkEnv* ev);
-
- // virtual mdb_pos NextRowOid(morkEnv* ev, mdbOid* outOid);
- virtual morkRow* NextRow(morkEnv* ev, mdbOid* outOid, mdb_pos* outPos);
-
-public: // typesafe refcounting inlines calling inherited morkNode methods
- static void SlotWeakSortingRowCursor(morkSortingRowCursor* me,
- morkEnv* ev, morkSortingRowCursor** ioSlot)
- { morkNode::SlotWeakNode((morkNode*) me, ev, (morkNode**) ioSlot); }
-
- static void SlotStrongSortingRowCursor(morkSortingRowCursor* me,
- morkEnv* ev, morkSortingRowCursor** ioSlot)
- { morkNode::SlotStrongNode((morkNode*) me, ev, (morkNode**) ioSlot); }
-};
-
-//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
-
-#endif /* _MORKSORTINGROWCURSOR_ */
--- a/db/mork/src/morkTableRowCursor.cpp
+++ b/db/mork/src/morkTableRowCursor.cpp
@@ -55,20 +55,16 @@
#ifndef _MORKCURSOR_
#include "morkCursor.h"
#endif
#ifndef _MORKTABLEROWCURSOR_
#include "morkTableRowCursor.h"
#endif
-#ifndef _ORKINTABLEROWCURSOR_
-#include "orkinTableRowCursor.h"
-#endif
-
#ifndef _MORKSTORE_
#include "morkStore.h"
#endif
#ifndef _MORKTABLE_
#include "morkTable.h"
#endif
--- a/db/mork/src/morkThumb.cpp
+++ b/db/mork/src/morkThumb.cpp
@@ -50,20 +50,16 @@
#ifndef _MORKENV_
#include "morkEnv.h"
#endif
#ifndef _MORKTHUMB_
#include "morkThumb.h"
#endif
-#ifndef _ORKINTHUMB_
-#include "orkinThumb.h"
-#endif
-
#ifndef _MORKSTORE_
#include "morkStore.h"
#endif
// #ifndef _MORKFILE_
// #include "morkFile.h"
// #endif
deleted file mode 100644
--- a/db/mork/src/orkinCell.cpp
+++ /dev/null
@@ -1,746 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (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.mozilla.org/MPL/
- *
- * 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 mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1999
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef _MDB_
-#include "mdb.h"
-#endif
-
-#ifndef _MORK_
-#include "mork.h"
-#endif
-
-#ifndef _MORKNODE_
-#include "morkNode.h"
-#endif
-
-#ifndef _MORKHANDLE_
-#include "morkHandle.h"
-#endif
-
-#ifndef _MORKCELL_
-#include "morkCell.h"
-#endif
-
-#ifndef _MORKCELLOBJECT_
-#include "morkCellObject.h"
-#endif
-
-#ifndef _MORKROWOBJECT_
-#include "morkRowObject.h"
-#endif
-
-#ifndef _ORKINCELL_
-#include "orkinCell.h"
-#endif
-
-#ifndef _MORKENV_
-#include "morkEnv.h"
-#endif
-
-#ifndef _MORKPOOL_
-#include "morkPool.h"
-#endif
-
-#ifndef _MORKROW_
-#include "morkRow.h"
-#endif
-
-#ifndef _MORKATOM_
-#include "morkAtom.h"
-#endif
-
-#ifndef _MORKSPACE_
-#include "morkSpace.h"
-#endif
-
-#ifndef _MORKROWSPACE_
-#include "morkRowSpace.h"
-#endif
-
-#ifndef _MORKSTORE_
-#include "morkStore.h"
-#endif
-
-//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
-
-/* public virtual*/
-orkinCell:: ~orkinCell() // morkHandle destructor does everything
-{
-}
-
-/*protected non-poly construction*/
-orkinCell::orkinCell(morkEnv* ev, // morkUsage is morkUsage_kPool
- morkHandleFace* ioFace, // must not be nil, cookie for this handle
- morkCellObject* ioObject) // must not be nil, the object for this handle
-: morkHandle(ev, ioFace, ioObject, morkMagic_kCell)
-{
- // do not modify mNode_Derived; leave it equal to morkDerived_kHandle
-}
-
-
-/*static */ orkinCell*
-orkinCell::MakeCell(morkEnv* ev, morkCellObject* ioObject)
-{
- mork_bool isEnv = ev->IsEnv();
- MORK_ASSERT(isEnv);
- if ( isEnv )
- {
- morkHandleFace* face = ev->NewHandle(sizeof(orkinCell));
- if ( face )
- return new(face) orkinCell(ev, face, ioObject);
- else
- ev->OutOfMemoryError();
- }
-
- return (orkinCell*) 0;
-}
-
-// ResyncWithRow() moved to the morkCellObject class:
-// mork_bool
-// orkinCell::ResyncWithRow(morkEnv* ev)
-// {
-// morkCellObject* cellObj = (morkCellObject*) mHandle_Object;
-// morkRow* row = cellObj->mCellObject_Row;
-// mork_pos pos = 0;
-// morkCell* cell = row->GetCell(ev, cellObj->mCellObject_Col, &pos);
-// if ( cell )
-// {
-// cellObj->mCellObject_Pos = pos;
-// cellObj->mCellObject_Cell = cell;
-// cellObj->mCellObject_RowSeed = row->mRow_Seed;
-// }
-// else
-// {
-// cellObj->mCellObject_Cell = 0;
-// cellObj->MissingRowColumnError(ev);
-// }
-// return ev->Good();
-// }
-
-morkEnv*
-orkinCell::CanUseCell(nsIMdbEnv* mev, mork_bool inMutable,
- mdb_err* outErr, morkCell** outCell) const
-{
- morkEnv* outEnv = 0;
- morkCell* cell = 0;
- morkEnv* ev = morkEnv::FromMdbEnv(mev);
- if ( ev )
- {
- morkCellObject* cellObj = (morkCellObject*)
- this->GetGoodHandleObject(ev, inMutable, morkMagic_kCell,
- /*inClosedOkay*/ morkBool_kFalse);
- if ( cellObj )
- {
- if ( cellObj->IsCellObject() )
- {
- if ( cellObj->IsMutable() || !inMutable )
- {
- morkRowObject* rowObj = cellObj->mCellObject_RowObject;
- if ( rowObj )
- {
- morkRow* row = cellObj->mCellObject_Row;
- if ( row )
- {
- if ( rowObj->mRowObject_Row == row )
- {
- mork_u2 oldSeed = cellObj->mCellObject_RowSeed;
- if ( row->mRow_Seed == oldSeed || cellObj->ResyncWithRow(ev) )
- {
- cell = cellObj->mCellObject_Cell;
- if ( cell )
- {
- outEnv = ev;
- }
- else
- cellObj->NilCellError(ev);
- }
- }
- else
- cellObj->WrongRowObjectRowError(ev);
- }
- else
- cellObj->NilRowError(ev);
- }
- else
- cellObj->NilRowObjectError(ev);
- }
- else
- cellObj->NonMutableNodeError(ev);
- }
- else
- cellObj->NonCellObjectTypeError(ev);
- }
- *outErr = ev->AsErr();
- }
- MORK_ASSERT(outEnv);
- *outCell = cell;
-
- return outEnv;
-}
-
-// { ===== begin nsIMdbISupports methods =====
-NS_IMPL_QUERY_INTERFACE0(orkinCell)
-
-/*virtual*/ nsrefcnt
-orkinCell::AddRef() // add strong ref with no
-{
- morkEnv* ev = mHandle_Env;
- if ( ev && ev->IsEnv() )
- return this->Handle_AddStrongRef(ev->AsMdbEnv());
- else
- return morkEnv_kNonEnvTypeError;
-}
-
-/*virtual*/ nsrefcnt
-orkinCell::Release() // cut strong ref
-{
- morkEnv* ev = mHandle_Env;
- if ( ev && ev->IsEnv() )
- return this->Handle_CutStrongRef(ev->AsMdbEnv());
- else
- return morkEnv_kNonEnvTypeError;
-}
-// } ===== end nsIMdbISupports methods =====
-
-// { ===== begin nsIMdbObject methods =====
-
-// { ----- begin attribute methods -----
-/*virtual*/ mdb_err
-orkinCell::IsFrozenMdbObject(nsIMdbEnv* mev, mdb_bool* outIsReadonly)
-{
- return this->Handle_IsFrozenMdbObject(mev, outIsReadonly);
-}
-// same as nsIMdbPort::GetIsPortReadonly() when this object is inside a port.
-// } ----- end attribute methods -----
-
-// { ----- begin factory methods -----
-/*virtual*/ mdb_err
-orkinCell::GetMdbFactory(nsIMdbEnv* mev, nsIMdbFactory** acqFactory)
-{
- return this->Handle_GetMdbFactory(mev, acqFactory);
-}
-// } ----- end factory methods -----
-
-// { ----- begin ref counting for well-behaved cyclic graphs -----
-/*virtual*/ mdb_err
-orkinCell::GetWeakRefCount(nsIMdbEnv* mev, // weak refs
- mdb_count* outCount)
-{
- return this->Handle_GetWeakRefCount(mev, outCount);
-}
-/*virtual*/ mdb_err
-orkinCell::GetStrongRefCount(nsIMdbEnv* mev, // strong refs
- mdb_count* outCount)
-{
- return this->Handle_GetStrongRefCount(mev, outCount);
-}
-
-/*virtual*/ mdb_err
-orkinCell::AddWeakRef(nsIMdbEnv* mev)
-{
- return this->Handle_AddWeakRef(mev);
-}
-/*virtual*/ mdb_err
-orkinCell::AddStrongRef(nsIMdbEnv* mev)
-{
- return this->Handle_AddStrongRef(mev);
-}
-
-/*virtual*/ mdb_err
-orkinCell::CutWeakRef(nsIMdbEnv* mev)
-{
- return this->Handle_CutWeakRef(mev);
-}
-/*virtual*/ mdb_err
-orkinCell::CutStrongRef(nsIMdbEnv* mev)
-{
- return this->Handle_CutStrongRef(mev);
-}
-
-/*virtual*/ mdb_err
-orkinCell::CloseMdbObject(nsIMdbEnv* mev)
-{
- return this->Handle_CloseMdbObject(mev);
-}
-
-/*virtual*/ mdb_err
-orkinCell::IsOpenMdbObject(nsIMdbEnv* mev, mdb_bool* outOpen)
-{
- return this->Handle_IsOpenMdbObject(mev, outOpen);
-}
-// } ----- end ref counting -----
-
-// } ===== end nsIMdbObject methods =====
-
-// { ===== begin nsIMdbBlob methods =====
-
-// { ----- begin attribute methods -----
-/*virtual*/ mdb_err
-orkinCell::SetBlob(nsIMdbEnv* mev,
- nsIMdbBlob* ioBlob)
-{
- MORK_USED_1(ioBlob);
- mdb_err outErr = 0;
- morkCell* cell = 0;
- morkEnv* ev = this->CanUseCell(mev, /*inMutable*/ morkBool_kTrue,
- &outErr, &cell);
- if ( ev )
- {
- // remember row->MaybeDirtySpaceStoreAndRow();
-
- ev->StubMethodOnlyError();
- outErr = ev->AsErr();
- }
-
- return outErr;
-} // reads inBlob slots
-// when inBlob is in the same suite, this might be fastest cell-to-cell
-
-/*virtual*/ mdb_err
-orkinCell::ClearBlob( // make empty (so content has zero length)
- nsIMdbEnv* mev)
-{
- mdb_err outErr = 0;
- morkCell* cell = 0;
- morkEnv* ev = this->CanUseCell(mev, /*inMutable*/ morkBool_kTrue,
- &outErr, &cell);
- if ( ev )
- {
- // remember row->MaybeDirtySpaceStoreAndRow();
-
- ev->StubMethodOnlyError();
- outErr = ev->AsErr();
- }
-
- return outErr;
-}
-// clearing a yarn is like SetYarn() with empty yarn instance content
-
-/*virtual*/ mdb_err
-orkinCell::GetBlobFill(nsIMdbEnv* mev,
- mdb_fill* outFill)
-// Same value that would be put into mYarn_Fill, if one called GetYarn()
-// with a yarn instance that had mYarn_Buf==nil and mYarn_Size==0.
-{
- mdb_err outErr = 0;
- mdb_fill fill = 0;
- morkCell* cell = 0;
- morkEnv* ev = this->CanUseCell(mev, /*inMutable*/ morkBool_kTrue,
- &outErr, &cell);
- if ( ev )
- {
- ev->StubMethodOnlyError();
- outErr = ev->AsErr();
- }
- if ( outFill )
- *outFill = fill;
-
- return outErr;
-} // size of blob
-
-/*virtual*/ mdb_err
-orkinCell::SetYarn(nsIMdbEnv* mev,
- const mdbYarn* inYarn)
-{
- mdb_err outErr = 0;
- morkCell* cell = 0;
- morkEnv* ev = this->CanUseCell(mev, /*inMutable*/ morkBool_kTrue,
- &outErr, &cell);
- if ( ev )
- {
- morkCellObject* cellObj = (morkCellObject*) mHandle_Object;
- morkRow* row = cellObj->mCellObject_Row;
- if ( row )
- {
- morkStore* store = row->GetRowSpaceStore(ev);
- if ( store )
- {
- cell->SetYarn(ev, inYarn, store);
- if ( row->IsRowClean() && store->mStore_CanDirty )
- row->MaybeDirtySpaceStoreAndRow();
- }
- }
- else
- ev->NilPointerError();
-
- outErr = ev->AsErr();
- }
-
- return outErr;
-} // reads from yarn slots
-// make this text object contain content from the yarn's buffer
-
-/*virtual*/ mdb_err
-orkinCell::GetYarn(nsIMdbEnv* mev,
- mdbYarn* outYarn)
-{
- mdb_err outErr = 0;
- morkCell* cell = 0;
- morkEnv* ev = this->CanUseCell(mev, /*inMutable*/ morkBool_kTrue,
- &outErr, &cell);
- if ( ev )
- {
- morkAtom* atom = cell->GetAtom();
- atom->GetYarn(outYarn);
- outErr = ev->AsErr();
- }
-
- return outErr;
-} // writes some yarn slots
-// copy content into the yarn buffer, and update mYarn_Fill and mYarn_Form
-
-/*virtual*/ mdb_err
-orkinCell::AliasYarn(nsIMdbEnv* mev,
- mdbYarn* outYarn)
-{
- mdb_err outErr = 0;
- morkCell* cell = 0;
- morkEnv* ev = this->CanUseCell(mev, /*inMutable*/ morkBool_kTrue,
- &outErr, &cell);
- if ( ev )
- {
- morkAtom* atom = cell->GetAtom();
- atom->AliasYarn(outYarn);
- outErr = ev->AsErr();
- }
-
- return outErr;
-} // writes ALL yarn slots
-
-// } ----- end attribute methods -----
-
-// } ===== end nsIMdbBlob methods =====
-
-// { ===== begin nsIMdbCell methods =====
-
-// { ----- begin attribute methods -----
-/*virtual*/ mdb_err
-orkinCell::SetColumn(nsIMdbEnv* mev, mdb_column inColumn)
-{
- MORK_USED_1(inColumn);
- mdb_err outErr = 0;
- morkCell* cell = 0;
- morkEnv* ev = this->CanUseCell(mev, /*inMutable*/ morkBool_kTrue,
- &outErr, &cell);
- if ( ev )
- {
- // remember row->MaybeDirtySpaceStoreAndRow();
-
- morkCellObject* cellObj = (morkCellObject*) mHandle_Object;
- MORK_USED_1(cellObj);
-
- ev->StubMethodOnlyError();
- outErr = ev->AsErr();
- }
-
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinCell::GetColumn(nsIMdbEnv* mev, mdb_column* outColumn)
-{
- mdb_err outErr = 0;
- mdb_column col = 0;
- morkCell* cell = 0;
- morkEnv* ev = this->CanUseCell(mev, /*inMutable*/ morkBool_kTrue,
- &outErr, &cell);
- if ( ev )
- {
- morkCellObject* cellObj = (morkCellObject*) mHandle_Object;
- col = cellObj->mCellObject_Col;
- outErr = ev->AsErr();
- }
- if ( outColumn )
- *outColumn = col;
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinCell::GetCellInfo( // all cell metainfo except actual content
- nsIMdbEnv* mev,
- mdb_column* outColumn, // the column in the containing row
- mdb_fill* outBlobFill, // the size of text content in bytes
- mdbOid* outChildOid, // oid of possible row or table child
- mdb_bool* outIsRowChild) // nonzero if child, and a row child
-// Checking all cell metainfo is a good way to avoid forcing a large cell
-// in to memory when you don't actually want to use the content.
-{
- mdb_err outErr = 0;
- mdb_bool isRowChild = morkBool_kFalse;
- mdbOid childOid;
- childOid.mOid_Scope = 0;
- childOid.mOid_Id = 0;
- mork_fill blobFill = 0;
- mdb_column column = 0;
- morkCell* cell = 0;
- morkEnv* ev = this->CanUseCell(mev, /*inMutable*/ morkBool_kTrue,
- &outErr, &cell);
- if ( ev )
- {
- morkCellObject* cellObj;
- cellObj = (morkCellObject*) mHandle_Object;
- ev->StubMethodOnlyError();
- outErr = ev->AsErr();
- }
- if ( outIsRowChild )
- *outIsRowChild = isRowChild;
- if ( outChildOid )
- *outChildOid = childOid;
- if ( outBlobFill )
- *outBlobFill = blobFill;
- if ( outColumn )
- *outColumn = column;
-
- return outErr;
-}
-
-
-/*virtual*/ mdb_err
-orkinCell::GetRow(nsIMdbEnv* mev, // parent row for this cell
- nsIMdbRow** acqRow)
-{
- mdb_err outErr = 0;
- nsIMdbRow* outRow = 0;
- morkCell* cell = 0;
- morkEnv* ev = this->CanUseCell(mev, /*inMutable*/ morkBool_kTrue,
- &outErr, &cell);
- if ( ev )
- {
- morkCellObject* cellObj = (morkCellObject*) mHandle_Object;
- morkRowObject* rowObj = cellObj->mCellObject_RowObject;
- outRow = rowObj->AcquireRowHandle(ev);
-
- outErr = ev->AsErr();
- }
- if ( acqRow )
- *acqRow = outRow;
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinCell::GetPort(nsIMdbEnv* mev, // port containing cell
- nsIMdbPort** acqPort)
-{
- mdb_err outErr = 0;
- nsIMdbPort* outPort = 0;
- morkCell* cell = 0;
- morkEnv* ev = this->CanUseCell(mev, /*inMutable*/ morkBool_kTrue,
- &outErr, &cell);
- if ( ev )
- {
- morkCellObject* cellObj = (morkCellObject*) mHandle_Object;
- morkRow* row = cellObj->mCellObject_Row;
- if ( row )
- {
- morkStore* store = row->GetRowSpaceStore(ev);
- if ( store )
- outPort = store->AcquireStoreHandle(ev);
- }
- else
- ev->NilPointerError();
-
- outErr = ev->AsErr();
- }
- if ( acqPort )
- *acqPort = outPort;
- return outErr;
-}
-// } ----- end attribute methods -----
-
-// { ----- begin children methods -----
-/*virtual*/ mdb_err
-orkinCell::HasAnyChild( // does cell have a child instead of text?
- nsIMdbEnv* mev,
- mdbOid* outOid, // out id of row or table (or unbound if no child)
- mdb_bool* outIsRow) // nonzero if child is a row (rather than a table)
-{
- mdb_err outErr = 0;
- mdb_bool isRow = morkBool_kFalse;
- outOid->mOid_Scope = 0;
- outOid->mOid_Id = morkId_kMinusOne;
- morkCell* cell = 0;
- morkEnv* ev = this->CanUseCell(mev, /*inMutable*/ morkBool_kTrue,
- &outErr, &cell);
- if ( ev )
- {
- morkCellObject* cellObj = (morkCellObject*) mHandle_Object;
- morkAtom* atom = cellObj->GetCellAtom(ev);
- if ( atom )
- {
- isRow = atom->IsRowOid();
- if ( isRow || atom->IsTableOid() )
- *outOid = ((morkOidAtom*) atom)->mOidAtom_Oid;
- }
-
- outErr = ev->AsErr();
- }
- if ( outIsRow )
- *outIsRow = isRow;
-
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinCell::GetAnyChild( // access table of specific attribute
- nsIMdbEnv* mev, // context
- nsIMdbRow** acqRow, // child row (or null)
- nsIMdbTable** acqTable) // child table (or null)
-{
- mdb_err outErr = 0;
- nsIMdbRow* outRow = 0;
- nsIMdbTable* outTable = 0;
- morkCell* cell = 0;
- morkEnv* ev = this->CanUseCell(mev, /*inMutable*/ morkBool_kTrue,
- &outErr, &cell);
- if ( ev )
- {
- morkCellObject* cellObj;
- cellObj = (morkCellObject*) mHandle_Object;
- ev->StubMethodOnlyError();
- outErr = ev->AsErr();
- }
- MORK_ASSERT(acqTable);
- if ( acqTable )
- *acqTable = outTable;
- MORK_ASSERT(acqRow);
- if ( acqRow )
- *acqRow = outRow;
-
- return outErr;
-}
-
-
-/*virtual*/ mdb_err
-orkinCell::SetChildRow( // access table of specific attribute
- nsIMdbEnv* mev, // context
- nsIMdbRow* ioRow)
-{
- MORK_USED_1(ioRow);
- mdb_err outErr = 0;
- morkCell* cell = 0;
- morkEnv* ev = this->CanUseCell(mev, /*inMutable*/ morkBool_kTrue,
- &outErr, &cell);
- if ( ev )
- {
- // remember row->MaybeDirtySpaceStoreAndRow();
-
- morkCellObject* cellObj = (morkCellObject*) mHandle_Object;
- MORK_USED_1(cellObj);
-
- ev->StubMethodOnlyError();
- outErr = ev->AsErr();
- }
-
- return outErr;
-} // inRow must be bound inside this same db port
-
-/*virtual*/ mdb_err
-orkinCell::GetChildRow( // access row of specific attribute
- nsIMdbEnv* mev, // context
- nsIMdbRow** acqRow) // acquire child row (or nil if no child)
-{
- mdb_err outErr = 0;
- nsIMdbRow* outRow = 0;
- morkCell* cell = 0;
- morkEnv* ev = this->CanUseCell(mev, /*inMutable*/ morkBool_kTrue,
- &outErr, &cell);
- if ( ev )
- {
- morkCellObject* cellObj;
- cellObj = (morkCellObject*) mHandle_Object;
- ev->StubMethodOnlyError();
- outErr = ev->AsErr();
- }
- if ( acqRow )
- *acqRow = outRow;
-
- return outErr;
-}
-
-
-/*virtual*/ mdb_err
-orkinCell::SetChildTable( // access table of specific attribute
- nsIMdbEnv* mev, // context
- nsIMdbTable* inTable) // table must be bound inside this same db port
-{
- MORK_USED_1(inTable);
- mdb_err outErr = 0;
- morkCell* cell = 0;
- morkEnv* ev = this->CanUseCell(mev, /*inMutable*/ morkBool_kTrue,
- &outErr, &cell);
- if ( ev )
- {
- // remember row->MaybeDirtySpaceStoreAndRow();
-
- morkCellObject* cellObj = (morkCellObject*) mHandle_Object;
- MORK_USED_1(cellObj);
-
- ev->StubMethodOnlyError();
- outErr = ev->AsErr();
- }
-
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinCell::GetChildTable( // access table of specific attribute
- nsIMdbEnv* mev, // context
- nsIMdbTable** acqTable) // acquire child tabdle (or nil if no chil)
-{
- mdb_err outErr = 0;
- nsIMdbTable* outTable = 0;
- morkCell* cell = 0;
- morkEnv* ev = this->CanUseCell(mev, /*inMutable*/ morkBool_kTrue,
- &outErr, &cell);
- if ( ev )
- {
- morkCellObject* cellObj;
- cellObj = (morkCellObject*) mHandle_Object;
- ev->StubMethodOnlyError();
- outErr = ev->AsErr();
- }
- if ( acqTable )
- *acqTable = outTable;
-
- return outErr;
-}
-// } ----- end children methods -----
-
-// } ===== end nsIMdbCell methods =====
-
-
-//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
deleted file mode 100644
--- a/db/mork/src/orkinCell.h
+++ /dev/null
@@ -1,269 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (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.mozilla.org/MPL/
- *
- * 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 mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1999
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef _ORKINCELL_
-#define _ORKINCELL_ 1
-
-#ifndef _MDB_
-#include "mdb.h"
-#endif
-
-#ifndef _MORK_
-#include "mork.h"
-#endif
-
-#ifndef _MORKNODE_
-#include "morkNode.h"
-#endif
-
-#ifndef _MORKHANDLE_
-#include "morkHandle.h"
-#endif
-
-#ifndef _MORKCELL_
-#include "morkCell.h"
-#endif
-
-//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
-
-#define morkMagic_kCell 0x43656C6C /* ascii 'Cell' */
-
-class orkinCell : public morkHandle, public nsIMdbCell { // nsIMdbBlob
-
-// { ===== begin morkNode interface =====
-public: // morkNode virtual methods
- // virtual void CloseMorkNode(morkEnv* ev); // morkHandle is fine
- virtual ~orkinCell(); // morkHandle destructor does everything
-
-protected: // construction is protected (use the static Make() method)
- orkinCell(morkEnv* ev, // note morkUsage is always morkUsage_kPool
- morkHandleFace* ioFace, // must not be nil, cookie for this handle
- morkCellObject* ioObject); // must not be nil, the object for this handle
-
- // void CloseHandle(morkEnv* ev); // don't need to specialize closing
-
-private: // copying is not allowed
- orkinCell(const morkHandle& other);
- orkinCell& operator=(const morkHandle& other);
-
-// public: // dynamic type identification
- // mork_bool IsHandle() const //
- // { return IsNode() && mNode_Derived == morkDerived_kHandle; }
-// } ===== end morkNode methods =====
-
-protected: // morkHandle memory management operators
- void* operator new(size_t inSize, morkPool& ioPool, morkZone& ioZone, morkEnv* ev) CPP_THROW_NEW
- { return ioPool.NewHandle(ev, inSize, &ioZone); }
-
- void* operator new(size_t inSize, morkPool& ioPool, morkEnv* ev) CPP_THROW_NEW
- { return ioPool.NewHandle(ev, inSize, (morkZone*) 0); }
-
- void* operator new(size_t inSize, morkHandleFace* ioFace) CPP_THROW_NEW
- { MORK_USED_1(inSize); return ioFace; }
-
-
-public: // construction:
-
- static orkinCell* MakeCell(morkEnv* ev, morkCellObject* ioObject);
-
-public: // utilities:
-
- // ResyncWithRow() moved to the morkCellObject class:
- // mork_bool ResyncWithRow(morkEnv* ev); // return ev->Good()
-
- morkEnv* CanUseCell(nsIMdbEnv* ev, mork_bool inMutable,
- mdb_err* outErr, morkCell** outCell) const;
-
-public: // type identification
- mork_bool IsOrkinCell() const
- { return mHandle_Magic == morkMagic_kCell; }
-
- mork_bool IsOrkinCellHandle() const
- { return this->IsHandle() && this->IsOrkinCell(); }
-
- NS_DECL_ISUPPORTS
-
-// { ===== begin nsIMdbObject methods =====
-
- // { ----- begin attribute methods -----
- NS_IMETHOD IsFrozenMdbObject(nsIMdbEnv* ev, mdb_bool* outIsReadonly);
- // same as nsIMdbPort::GetIsPortReadonly() when this object is inside a port.
- // } ----- end attribute methods -----
-
- // { ----- begin factory methods -----
- NS_IMETHOD GetMdbFactory(nsIMdbEnv* ev, nsIMdbFactory** acqFactory);
- // } ----- end factory methods -----
-
- // { ----- begin ref counting for well-behaved cyclic graphs -----
- NS_IMETHOD GetWeakRefCount(nsIMdbEnv* ev, // weak refs
- mdb_count* outCount);
- NS_IMETHOD GetStrongRefCount(nsIMdbEnv* ev, // strong refs
- mdb_count* outCount);
-
- NS_IMETHOD AddWeakRef(nsIMdbEnv* ev);
- NS_IMETHOD AddStrongRef(nsIMdbEnv* ev);
-
- NS_IMETHOD CutWeakRef(nsIMdbEnv* ev);
- NS_IMETHOD CutStrongRef(nsIMdbEnv* ev);
-
- NS_IMETHOD CloseMdbObject(nsIMdbEnv* ev); // called at strong refs zero
- NS_IMETHOD IsOpenMdbObject(nsIMdbEnv* ev, mdb_bool* outOpen);
- // } ----- end ref counting -----
-
-// } ===== end nsIMdbObject methods =====
-
-// { ===== begin nsIMdbBlob methods =====
-
- // { ----- begin attribute methods -----
- NS_IMETHOD SetBlob(nsIMdbEnv* ev,
- nsIMdbBlob* ioBlob); // reads inBlob slots
- // when inBlob is in the same suite, this might be fastest cell-to-cell
-
- NS_IMETHOD ClearBlob( // make empty (so content has zero length)
- nsIMdbEnv* ev);
- // clearing a yarn is like SetYarn() with empty yarn instance content
-
- NS_IMETHOD GetBlobFill(nsIMdbEnv* ev,
- mdb_fill* outFill); // size of blob
- // Same value that would be put into mYarn_Fill, if one called GetYarn()
- // with a yarn instance that had mYarn_Buf==nil and mYarn_Size==0.
-
- NS_IMETHOD SetYarn(nsIMdbEnv* ev,
- const mdbYarn* inYarn); // reads from yarn slots
- // make this text object contain content from the yarn's buffer
-
- NS_IMETHOD GetYarn(nsIMdbEnv* ev,
- mdbYarn* outYarn); // writes some yarn slots
- // copy content into the yarn buffer, and update mYarn_Fill and mYarn_Form
-
- NS_IMETHOD AliasYarn(nsIMdbEnv* ev,
- mdbYarn* outYarn); // writes ALL yarn slots
- // AliasYarn() reveals sensitive internal text buffer state to the caller
- // by setting mYarn_Buf to point into the guts of this text implementation.
- //
- // The caller must take great care to avoid writing on this space, and to
- // avoid calling any method that would cause the state of this text object
- // to change (say by directly or indirectly setting the text to hold more
- // content that might grow the size of the buffer and free the old buffer).
- // In particular, callers should scrupulously avoid making calls into the
- // mdb interface to write any content while using the buffer pointer found
- // in the returned yarn instance. Best safe usage involves copying content
- // into some other kind of external content representation beyond mdb.
- //
- // (The original design of this method a week earlier included the concept
- // of very fast and efficient cooperative locking via a pointer to some lock
- // member slot. But let's ignore that complexity in the current design.)
- //
- // AliasYarn() is specifically intended as the first step in transferring
- // content from nsIMdbBlob to a nsString representation, without forcing extra
- // allocations and/or memory copies. (A standard nsIMdbBlob_AsString() utility
- // will use AliasYarn() as the first step in setting a nsString instance.)
- //
- // This is an alternative to the GetYarn() method, which has copy semantics
- // only; AliasYarn() relaxes a robust safety principle only for performance
- // reasons, to accomodate the need for callers to transform text content to
- // some other canonical representation that would necessitate an additional
- // copy and transformation when such is incompatible with the mdbYarn format.
- //
- // The implementation of AliasYarn() should have extremely little overhead
- // besides the virtual dispatch to the method implementation, and the code
- // necessary to populate all the mdbYarn member slots with internal buffer
- // address and metainformation that describes the buffer content. Note that
- // mYarn_Grow must always be set to nil to indicate no resizing is allowed.
-
- // } ----- end attribute methods -----
-
-// } ===== end nsIMdbBlob methods =====
-
-// { ===== begin nsIMdbCell methods =====
-
- // { ----- begin attribute methods -----
- NS_IMETHOD SetColumn(nsIMdbEnv* ev, mdb_column inColumn);
- NS_IMETHOD GetColumn(nsIMdbEnv* ev, mdb_column* outColumn);
-
- NS_IMETHOD GetCellInfo( // all cell metainfo except actual content
- nsIMdbEnv* ev,
- mdb_column* outColumn, // the column in the containing row
- mdb_fill* outBlobFill, // the size of text content in bytes
- mdbOid* outChildOid, // oid of possible row or table child
- mdb_bool* outIsRowChild); // nonzero if child, and a row child
-
- // Checking all cell metainfo is a good way to avoid forcing a large cell
- // in to memory when you don't actually want to use the content.
-
- NS_IMETHOD GetRow(nsIMdbEnv* ev, // parent row for this cell
- nsIMdbRow** acqRow);
- NS_IMETHOD GetPort(nsIMdbEnv* ev, // port containing cell
- nsIMdbPort** acqPort);
- // } ----- end attribute methods -----
-
- // { ----- begin children methods -----
- NS_IMETHOD HasAnyChild( // does cell have a child instead of text?
- nsIMdbEnv* ev,
- mdbOid* outOid, // out id of row or table (or unbound if no child)
- mdb_bool* outIsRow); // nonzero if child is a row (rather than a table)
-
- NS_IMETHOD GetAnyChild( // access table of specific attribute
- nsIMdbEnv* ev, // context
- nsIMdbRow** acqRow, // child row (or null)
- nsIMdbTable** acqTable); // child table (or null)
-
-
- NS_IMETHOD SetChildRow( // access table of specific attribute
- nsIMdbEnv* ev, // context
- nsIMdbRow* ioRow); // inRow must be bound inside this same db port
-
- NS_IMETHOD GetChildRow( // access row of specific attribute
- nsIMdbEnv* ev, // context
- nsIMdbRow** acqRow); // acquire child row (or nil if no child)
-
-
- NS_IMETHOD SetChildTable( // access table of specific attribute
- nsIMdbEnv* ev, // context
- nsIMdbTable* inTable); // table must be bound inside this same db port
-
- NS_IMETHOD GetChildTable( // access table of specific attribute
- nsIMdbEnv* ev, // context
- nsIMdbTable** acqTable); // acquire child table (or nil if no child)
- // } ----- end children methods -----
-
-// } ===== end nsIMdbCell methods =====
-};
-
-//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
-
-#endif /* _ORKINCELL_ */
deleted file mode 100644
--- a/db/mork/src/orkinCompare.cpp
+++ /dev/null
@@ -1,147 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (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.mozilla.org/MPL/
- *
- * 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 mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1999
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef _MDB_
-#include "mdb.h"
-#endif
-
-#ifndef _MORK_
-#include "mork.h"
-#endif
-
-#ifndef _ORKINCOMPARE_
-#include "orkinCompare.h"
-#endif
-
-#ifndef _MORKENV_
-#include "morkEnv.h"
-#endif
-
-//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
-
-
-orkinCompare::orkinCompare() // does nothing
-{
-}
-
-/*virtual*/
-orkinCompare::~orkinCompare() // does nothing
-{
-}
-
-
-mdb_order // standard yarn comparison for nsIMdbCompare::Order()
-mdbYarn_Order(const mdbYarn* inSelf, morkEnv* ev, const mdbYarn* inYarn)
-{
- // This code is a close copy of public domain Mithril's AgYarn_CompareLen().
- // Note all comments are from the original public domain Mithril code.
-
- mork_u1* self = (mork_u1*) inSelf->mYarn_Buf;
- mork_u1* yarn = (mork_u1*) inYarn->mYarn_Buf;
-
- mdb_fill selfFill = inSelf->mYarn_Fill;
- mdb_fill yarnFill = inYarn->mYarn_Fill;
-
- if ( selfFill && yarnFill ) /* neither yarn is empty? */
- {
- register int a; /* a byte from self */
- register int b; /* a byte from yarn */
-
- /* predecrement is normally used in loop tests to minimize instructions: */
- ++selfFill; /* prepare for predecrement */
- ++yarnFill; /* prepare for predecrement */
- /* we check only self len at loop top, but yarn len check must follow: */
-
- while ( --selfFill ) /* another byte in self? */
- {
- if ( !--yarnFill ) /* yarn runs out first? self is greater (pos)? */
- return 1;
-
- b = (mork_u1) *yarn++; /* next byte in other yarn */
- a = (mork_u1) *self++; /* next byte in self yarn */
-
- if ( a != b ) /* found first different byte? */
- return ( a - b ); /* return relative order */
- }
- /* if remaining yarn len is exactly 1, it runs out at same time as self: */
- return ( yarnFill == 1 )? 0 : -1; /* yarn is same len? or self is less? */
- }
- else
- return ((mdb_order) selfFill) - ((mdb_order) yarnFill);
-}
-
-// { ===== begin nsIMdbCompare methods =====
-/*virtual*/ mdb_err
-orkinCompare::Order(nsIMdbEnv* mev, // compare first to second yarn
- const mdbYarn* inFirst, // first yarn in comparison
- const mdbYarn* inSecond, // second yarn in comparison
- mdb_order* outOrder) // negative="<", zero="=", positive=">"
-{
- mdb_err outErr = 1; // nonzero means FAILURE
-
- morkEnv* ev = morkEnv::FromMdbEnv(mev);
- if ( ev )
- {
- if ( inFirst && inSecond && outOrder )
- {
- *outOrder = mdbYarn_Order(inFirst, ev, inSecond);
- }
- else
- ev->NilPointerError();
-
- outErr = ev->AsErr();
- }
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinCompare::AddStrongRef(nsIMdbEnv* ev) // does nothing
-{
- MORK_USED_1(ev);
- return 0;
-}
-
-/*virtual*/ mdb_err
-orkinCompare::CutStrongRef(nsIMdbEnv* ev) // does nothing
-{
- MORK_USED_1(ev);
- return 0;
-}
-
-// } ===== end nsIMdbCompare methods =====
-
-//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
deleted file mode 100644
--- a/db/mork/src/orkinCompare.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (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.mozilla.org/MPL/
- *
- * 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 mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1999
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef _ORKINCOMPARE_
-#define _ORKINCOMPARE_ 1
-
-#ifndef _MDB_
-#include "mdb.h"
-#endif
-
-#ifndef _MORK_
-#include "mork.h"
-#endif
-
-//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
-
-/*| orkinCompare:
-|*/
-class orkinCompare : public nsIMdbCompare { //
-
-public:
- orkinCompare(); // does nothing
- virtual ~orkinCompare(); // does nothing
-
-private: // copying is not allowed
- orkinCompare(const orkinCompare& other);
- orkinCompare& operator=(const orkinCompare& other);
-
-public:
-
-// { ===== begin nsIMdbCompare methods =====
- NS_IMETHOD Order(nsIMdbEnv* ev, // compare first to second yarn
- const mdbYarn* inFirst, // first yarn in comparison
- const mdbYarn* inSecond, // second yarn in comparison
- mdb_order* outOrder); // negative="<", zero="=", positive=">"
-
- NS_IMETHOD AddStrongRef(nsIMdbEnv* ev); // does nothing
- NS_IMETHOD CutStrongRef(nsIMdbEnv* ev); // does nothing
-// } ===== end nsIMdbCompare methods =====
-
-};
-
-extern mdb_order // standard yarn comparison for nsIMdbCompare::ORder()
-mdbYarn_Order(const mdbYarn* inSelf, morkEnv* ev, const mdbYarn* inSecond);
-
-//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
-
-#endif /* _ORKINCOMPARE_ */
deleted file mode 100644
--- a/db/mork/src/orkinEnv.cpp
+++ /dev/null
@@ -1,488 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (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.mozilla.org/MPL/
- *
- * 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 mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1999
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef _MDB_
-#include "mdb.h"
-#endif
-
-#ifndef _MORK_
-#include "mork.h"
-#endif
-
-#ifndef _MORKNODE_
-#include "morkNode.h"
-#endif
-
-#ifndef _MORKHANDLE_
-#include "morkHandle.h"
-#endif
-
-#ifndef _MORKENV_
-#include "morkEnv.h"
-#endif
-
-#ifndef _ORKINENV_
-#include "orkinEnv.h"
-#endif
-
-#ifndef _ORKINHEAP_
-#include "orkinHeap.h"
-#endif
-
-//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
-
-/* public virtual*/
-orkinEnv:: ~orkinEnv() // morkHandle destructor does everything
-{
-}
-
-void orkinEnv::CloseMorkNode(morkEnv* ev) // override to clean up mork env
-{
- morkEnv* mev = (morkEnv*) this->mHandle_Object;
-
- if ( mev->IsOpenNode() )
- {
- mev->MarkClosing();
- mev->CloseEnv(ev);
- mev->MarkShut();
- }
- morkHandle::CloseMorkNode(ev);
-}
-
-/*protected non-poly construction*/
-orkinEnv::orkinEnv(morkEnv* ev, // morkUsage is morkUsage_kPool
- morkHandleFace* ioFace, // must not be nil, cookie for this handle
- morkEnv* ioObject) // must not be nil, the object for this handle
-: morkHandle(ev, ioFace, ioObject, morkMagic_kEnv)
-{
- // do not modify mNode_Derived; leave it equal to morkDerived_kHandle
-}
-
-
-/*static */ orkinEnv*
-orkinEnv::MakeEnv(morkEnv* ev, morkEnv* ioObject)
-{
- mork_bool isEnv = ev->IsEnv();
- MORK_ASSERT(isEnv);
- if ( isEnv )
- {
- morkHandleFace* face = ev->NewHandle(sizeof(orkinEnv));
- if ( face )
- return new(face) orkinEnv(ev, face, ioObject);
- else
- ev->OutOfMemoryError();
- }
-
- return (orkinEnv*) 0;
-}
-
-morkEnv*
-orkinEnv::CanUseEnv(mork_bool inMutable, mdb_err* outErr) const
-{
- MORK_USED_1(inMutable);
- morkEnv* outEnv = 0;
- mdb_err err = morkEnv_kBadEnvError;
- if ( this->IsHandle() )
- {
- if ( this->IsOpenNode() )
- {
- morkEnv* ev = (morkEnv*) this->mHandle_Object;
- if ( ev && ev->IsEnv() )
- {
- outEnv = ev;
- err = 0;
- }
- else
- {
- err = morkEnv_kNonEnvTypeError;
- MORK_ASSERT(outEnv);
- }
- }
- else
- {
- err = morkEnv_kNonOpenNodeError;
- MORK_ASSERT(outEnv);
- }
- }
- else
- {
- err = morkEnv_kNonHandleTypeError;
- MORK_ASSERT(outEnv);
- }
- *outErr = err;
- return outEnv;
-}
-
-
-// { ===== begin nsIMdbISupports methods =====
-NS_IMPL_QUERY_INTERFACE0(orkinEnv)
-
-/*virtual*/ nsrefcnt
-orkinEnv::AddRef() // add strong ref with no
-{
- morkEnv* ev = mHandle_Env;
- if ( ev && ev->IsEnv() )
- return this->Handle_AddStrongRef(ev->AsMdbEnv());
- else
- return morkEnv_kNonEnvTypeError;
-}
-
-/*virtual*/ nsrefcnt
-orkinEnv::Release() // cut strong ref
-{
- morkEnv* ev = mHandle_Env;
- if ( ev && ev->IsEnv() )
- return this->Handle_CutStrongRef(ev->AsMdbEnv());
- else
- return morkEnv_kNonEnvTypeError;
-}
-// } ===== end nsIMdbObject methods =====
-
-// { ===== begin nsIMdbObject methods =====
-
-// { ----- begin attribute methods -----
-/*virtual*/ mdb_err
-orkinEnv::IsFrozenMdbObject(nsIMdbEnv* mev, mdb_bool* outIsReadonly)
-{
- return this->Handle_IsFrozenMdbObject(mev, outIsReadonly);
-}
-// same as nsIMdbPort::GetIsPortReadonly() when this object is inside a port.
-// } ----- end attribute methods -----
-
-// { ----- begin factory methods -----
-/*virtual*/ mdb_err
-orkinEnv::GetMdbFactory(nsIMdbEnv* mev, nsIMdbFactory** acqFactory)
-{
- return this->Handle_GetMdbFactory(mev, acqFactory);
-}
-// } ----- end factory methods -----
-
-// { ----- begin ref counting for well-behaved cyclic graphs -----
-/*virtual*/ mdb_err
-orkinEnv::GetWeakRefCount(nsIMdbEnv* mev, // weak refs
- mdb_count* outCount)
-{
- return this->Handle_GetWeakRefCount(mev, outCount);
-}
-/*virtual*/ mdb_err
-orkinEnv::GetStrongRefCount(nsIMdbEnv* mev, // strong refs
- mdb_count* outCount)
-{
- return this->Handle_GetStrongRefCount(mev, outCount);
-}
-
-/*virtual*/ mdb_err
-orkinEnv::AddWeakRef(nsIMdbEnv* mev)
-{
- return this->Handle_AddWeakRef(mev);
-}
-/*virtual*/ mdb_err
-orkinEnv::AddStrongRef(nsIMdbEnv* mev)
-{
- return this->Handle_AddStrongRef(mev);
-}
-
-/*virtual*/ mdb_err
-orkinEnv::CutWeakRef(nsIMdbEnv* mev)
-{
- return this->Handle_CutWeakRef(mev);
-}
-/*virtual*/ mdb_err
-orkinEnv::CutStrongRef(nsIMdbEnv* mev)
-{
- return this->Handle_CutStrongRef(mev);
-}
-
-/*virtual*/ mdb_err
-orkinEnv::CloseMdbObject(nsIMdbEnv* mev)
-{
- morkEnv* ev = (morkEnv*) this->mHandle_Object;
- mdb_err ret = this->Handle_CloseMdbObject(mev);
- if (ev && ev->mEnv_Heap)
- {
- mork_bool ownsHeap = ev->mEnv_OwnsHeap;
- nsIMdbHeap*saveHeap = ev->mEnv_Heap;
-
- ev->mEnv_Heap->Free(this, ev);
- if (ownsHeap)
- {
-#ifdef MORK_DEBUG_HEAP_STATS
- printf("%d blocks remaining \n", ((orkinHeap *) saveHeap)->HeapBlockCount());
-#endif // MORK_DEBUG_HEAP_STATS
- delete saveHeap;
- }
-
- }
- return ret;
-}
-
-/*virtual*/ mdb_err
-orkinEnv::IsOpenMdbObject(nsIMdbEnv* mev, mdb_bool* outOpen)
-{
- return this->Handle_IsOpenMdbObject(mev, outOpen);
-}
-// } ----- end ref counting -----
-
-// } ===== end nsIMdbObject methods =====
-
-// { ===== begin nsIMdbEnv methods =====
-
-// { ----- begin attribute methods -----
-/*virtual*/ mdb_err
-orkinEnv::GetErrorCount(mdb_count* outCount,
- mdb_bool* outShouldAbort)
-{
- mdb_err outErr = 0;
- mdb_count count = 1;
- mork_bool shouldAbort = morkBool_kFalse;
- morkEnv* ev = this->CanUseEnv(/*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- count = (mdb_count) ev->mEnv_ErrorCount;
- shouldAbort = ev->mEnv_ShouldAbort;
- }
- if ( outCount )
- *outCount = count;
- if ( outShouldAbort )
- *outShouldAbort = shouldAbort;
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinEnv::GetWarningCount(mdb_count* outCount,
- mdb_bool* outShouldAbort)
-{
- mdb_err outErr = 0;
- mdb_count count = 1;
- mork_bool shouldAbort = morkBool_kFalse;
- morkEnv* ev = this->CanUseEnv(/*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- count = (mdb_count) ev->mEnv_WarningCount;
- shouldAbort = ev->mEnv_ShouldAbort;
- }
- if ( outCount )
- *outCount = count;
- if ( outShouldAbort )
- *outShouldAbort = shouldAbort;
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinEnv::GetEnvBeVerbose(mdb_bool* outBeVerbose)
-{
- mdb_err outErr = 0;
- mork_bool beVerbose = morkBool_kFalse;
- morkEnv* ev = this->CanUseEnv(/*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- beVerbose = ev->mEnv_BeVerbose;
- }
- if ( outBeVerbose )
- *outBeVerbose = beVerbose;
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinEnv::SetEnvBeVerbose(mdb_bool inBeVerbose)
-{
- mdb_err outErr = 0;
- morkEnv* ev = this->CanUseEnv(/*inMutable*/ morkBool_kTrue, &outErr);
- if ( ev )
- {
- ev->mEnv_BeVerbose = inBeVerbose;
- }
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinEnv::GetDoTrace(mdb_bool* outDoTrace)
-{
- mdb_err outErr = 0;
- mork_bool doTrace = morkBool_kFalse;
- morkEnv* ev = this->CanUseEnv(/*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- doTrace = ev->mEnv_DoTrace;
- }
- if ( outDoTrace )
- *outDoTrace = doTrace;
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinEnv::SetDoTrace(mdb_bool inDoTrace)
-{
- mdb_err outErr = 0;
- morkEnv* ev = this->CanUseEnv(/*inMutable*/ morkBool_kTrue, &outErr);
- if ( ev )
- {
- ev->mEnv_DoTrace = inDoTrace;
- }
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinEnv::GetAutoClear(mdb_bool* outAutoClear)
-{
- mdb_err outErr = 0;
- mork_bool autoClear = morkBool_kFalse;
- morkEnv* ev = this->CanUseEnv(/*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- autoClear = ev->DoAutoClear();
- }
- if ( outAutoClear )
- *outAutoClear = autoClear;
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinEnv::SetAutoClear(mdb_bool inAutoClear)
-{
- mdb_err outErr = 0;
- morkEnv* ev = this->CanUseEnv(/*inMutable*/ morkBool_kTrue, &outErr);
- if ( ev )
- {
- if ( inAutoClear )
- ev->EnableAutoClear();
- else
- ev->DisableAutoClear();
- }
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinEnv::GetErrorHook(nsIMdbErrorHook** acqErrorHook)
-{
- mdb_err outErr = 0;
- nsIMdbErrorHook* outErrorHook = 0;
- morkEnv* ev = this->CanUseEnv(/*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- outErrorHook = ev->mEnv_ErrorHook;
- }
- if ( acqErrorHook )
- *acqErrorHook = outErrorHook;
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinEnv::SetErrorHook(
- nsIMdbErrorHook* ioErrorHook) // becomes referenced
-{
- mdb_err outErr = 0;
- morkEnv* ev = this->CanUseEnv(/*inMutable*/ morkBool_kTrue, &outErr);
- if ( ev )
- {
- ev->mEnv_ErrorHook = ioErrorHook;
- }
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinEnv::GetHeap(nsIMdbHeap** acqHeap)
-{
- mdb_err outErr = 0;
- nsIMdbHeap* outHeap = 0;
- morkEnv* ev = this->CanUseEnv(/*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- nsIMdbHeap* heap = ev->mEnv_Heap;
- if ( heap && heap->HeapAddStrongRef(this) == 0 )
- outHeap = heap;
- }
- if ( acqHeap )
- *acqHeap = outHeap;
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinEnv::SetHeap(
- nsIMdbHeap* ioHeap) // becomes referenced
-{
- mdb_err outErr = 0;
- morkEnv* ev = this->CanUseEnv(/*inMutable*/ morkBool_kTrue, &outErr);
- if ( ev )
- {
- nsIMdbHeap_SlotStrongHeap(ioHeap, ev, &ev->mEnv_Heap);
- }
- return outErr;
-}
-// } ----- end attribute methods -----
-
-/*virtual*/ mdb_err
-orkinEnv::ClearErrors() // clear errors beore re-entering db API
-{
- mdb_err outErr = 0;
- morkEnv* ev = this->CanUseEnv(/*inMutable*/ morkBool_kTrue, &outErr);
- if ( ev )
- {
- ev->mEnv_ErrorCount = 0;
- ev->mEnv_ErrorCode = 0;
- ev->mEnv_ShouldAbort = morkBool_kFalse;
- }
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinEnv::ClearWarnings() // clear warning
-{
- mdb_err outErr = 0;
- morkEnv* ev = this->CanUseEnv(/*inMutable*/ morkBool_kTrue, &outErr);
- if ( ev )
- {
- ev->mEnv_WarningCount = 0;
- }
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinEnv::ClearErrorsAndWarnings() // clear both errors & warnings
-{
- mdb_err outErr = 0;
- morkEnv* ev = this->CanUseEnv(/*inMutable*/ morkBool_kTrue, &outErr);
- if ( ev )
- {
- ev->ClearMorkErrorsAndWarnings();
- }
- return outErr;
-}
-// } ===== end nsIMdbEnv methods =====
-
-
-//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
deleted file mode 100644
--- a/db/mork/src/orkinEnv.h
+++ /dev/null
@@ -1,182 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (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.mozilla.org/MPL/
- *
- * 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 mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1999
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef _ORKINENV_
-#define _ORKINENV_ 1
-
-#ifndef _MDB_
-#include "mdb.h"
-#endif
-
-#ifndef _MORK_
-#include "mork.h"
-#endif
-
-#ifndef _MORKNODE_
-#include "morkNode.h"
-#endif
-
-#ifndef _MORKHANDLE_
-#include "morkHandle.h"
-#endif
-
-#ifndef _MORKEnv_
-#include "morkEnv.h"
-#endif
-
-//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
-
-#define morkMagic_kEnv 0x456E7669 /* ascii 'Envi' */
-
-/*| orkinEnv:
-|*/
-class orkinEnv : public morkHandle, public nsIMdbEnv { // nsIMdbObject
-
-// { ===== begin morkNode interface =====
-public: // morkNode virtual methods
- virtual void CloseMorkNode(morkEnv* ev); // override to clean up mork env
- virtual ~orkinEnv(); // morkHandle destructor does everything
-
-protected: // construction is protected (use the static Make() method)
- orkinEnv(morkEnv* ev, // note morkUsage is always morkUsage_kPool
- morkHandleFace* ioFace, // must not be nil, cookie for this handle
- morkEnv* ioObject); // must not be nil, the object for this handle
-
- // void CloseHandle(morkEnv* ev); // don't need to specialize closing
-
-private: // copying is not allowed
- orkinEnv(const morkHandle& other);
- orkinEnv& operator=(const morkHandle& other);
-
-// public: // dynamic type identification
- // mork_bool IsHandle() const //
- // { return IsNode() && mNode_Derived == morkDerived_kHandle; }
-// } ===== end morkNode methods =====
-
-protected: // morkHandle memory management operators
- void* operator new(size_t inSize, morkPool& ioPool, morkZone& ioZone, morkEnv* ev) CPP_THROW_NEW
- { return ioPool.NewHandle(ev, inSize, &ioZone); }
-
- void* operator new(size_t inSize, morkPool& ioPool, morkEnv* ev) CPP_THROW_NEW
- { return ioPool.NewHandle(ev, inSize, (morkZone*) 0); }
-
- void* operator new(size_t inSize, morkHandleFace* ioFace) CPP_THROW_NEW
- { MORK_USED_1(inSize); return ioFace; }
-
-
-public: // construction:
-
- static orkinEnv* MakeEnv(morkEnv* ev, morkEnv* ioObject);
-
-public: // utilities:
-
- morkEnv* CanUseEnv(mork_bool inMutable, mdb_err* outErr) const;
-
-public: // type identification
- mork_bool IsOrkinEnv() const
- { return mHandle_Magic == morkMagic_kEnv; }
-
- mork_bool IsOrkinEnvHandle() const
- { return this->IsHandle() && this->IsOrkinEnv(); }
-
-public:
-
- NS_DECL_ISUPPORTS
-// { ===== begin nsIMdbObject methods =====
-
- // { ----- begin attribute methods -----
- NS_IMETHOD IsFrozenMdbObject(nsIMdbEnv* ev, mdb_bool* outIsReadonly);
- // same as nsIMdbPort::GetIsPortReadonly() when this object is inside a port.
- // } ----- end attribute methods -----
-
- // { ----- begin factory methods -----
- NS_IMETHOD GetMdbFactory(nsIMdbEnv* ev, nsIMdbFactory** acqFactory);
- // } ----- end factory methods -----
-
- // { ----- begin ref counting for well-behaved cyclic graphs -----
- NS_IMETHOD GetWeakRefCount(nsIMdbEnv* ev, // weak refs
- mdb_count* outCount);
- NS_IMETHOD GetStrongRefCount(nsIMdbEnv* ev, // strong refs
- mdb_count* outCount);
-
- NS_IMETHOD AddWeakRef(nsIMdbEnv* ev);
- NS_IMETHOD AddStrongRef(nsIMdbEnv* ev);
-
- NS_IMETHOD CutWeakRef(nsIMdbEnv* ev);
- NS_IMETHOD CutStrongRef(nsIMdbEnv* ev);
-
- NS_IMETHOD CloseMdbObject(nsIMdbEnv* ev); // called at strong refs zero
- NS_IMETHOD IsOpenMdbObject(nsIMdbEnv* ev, mdb_bool* outOpen);
- // } ----- end ref counting -----
-
-// } ===== end nsIMdbObject methods =====
-
-// { ===== begin nsIMdbEnv methods =====
-
- // { ----- begin attribute methods -----
- NS_IMETHOD GetErrorCount(mdb_count* outCount,
- mdb_bool* outShouldAbort);
- NS_IMETHOD GetWarningCount(mdb_count* outCount,
- mdb_bool* outShouldAbort);
-
- NS_IMETHOD GetEnvBeVerbose(mdb_bool* outBeVerbose);
- NS_IMETHOD SetEnvBeVerbose(mdb_bool inBeVerbose);
-
- NS_IMETHOD GetDoTrace(mdb_bool* outDoTrace);
- NS_IMETHOD SetDoTrace(mdb_bool inDoTrace);
-
- NS_IMETHOD GetAutoClear(mdb_bool* outAutoClear);
- NS_IMETHOD SetAutoClear(mdb_bool inAutoClear);
-
- NS_IMETHOD GetErrorHook(nsIMdbErrorHook** acqErrorHook);
- NS_IMETHOD SetErrorHook(
- nsIMdbErrorHook* ioErrorHook); // becomes referenced
-
- NS_IMETHOD GetHeap(nsIMdbHeap** acqHeap);
- NS_IMETHOD SetHeap(
- nsIMdbHeap* ioHeap); // becomes referenced
- // } ----- end attribute methods -----
-
- NS_IMETHOD ClearErrors(); // clear errors beore re-entering db API
- NS_IMETHOD ClearWarnings(); // clear warnings
- NS_IMETHOD ClearErrorsAndWarnings(); // clear both errors & warnings
-// } ===== end nsIMdbEnv methods =====
-};
-
-//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
-
-#endif /* _ORKINENV_ */
deleted file mode 100644
--- a/db/mork/src/orkinErrorHook.cpp
+++ /dev/null
@@ -1,110 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (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.mozilla.org/MPL/
- *
- * 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 mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1999
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef _MDB_
-#include "mdb.h"
-#endif
-
-#ifndef _MORK_
-#include "mork.h"
-#endif
-
-#ifndef _ORKINERRORHOOK_
-#include "orkinErrorHook.h"
-#endif
-
-#ifndef _MORKENV_
-#include "morkEnv.h"
-#endif
-
-//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
-
-
-orkinHeap::orkinHeap() // does nothing
-{
-}
-
-/*virtual*/
-orkinHeap::~orkinHeap() // does nothing
-{
-}
-
-// { ===== begin nsIMdbHeap methods =====
-/*virtual*/ mdb_err
-orkinHeap::Alloc(nsIMdbEnv* ev, // allocate a piece of memory
- mdb_size inSize, // requested size of new memory block
- void** outBlock) // memory block of inSize bytes, or nil
-{
- mdb_err outErr = 0;
- void* block = new char[ inSize ];
- if ( !block )
- outErr = morkEnv_kOutOfMemoryError;
-
- MORK_ASSERT(outBlock);
- if ( outBlock )
- *outBlock = block;
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinHeap::Free(nsIMdbEnv* ev, // free block allocated earlier by Alloc()
- void* inBlock)
-{
- MORK_ASSERT(inBlock);
- if ( inBlock )
- delete [] inBlock;
-
- return 0;
-}
-
-/*virtual*/ mdb_err
-orkinHeap::AddStrongRef(nsIMdbEnv* ev) // does nothing
-{
- MORK_USED_1(ev);
- return 0;
-}
-
-/*virtual*/ mdb_err
-orkinHeap::CutStrongRef(nsIMdbEnv* ev) // does nothing
-{
- MORK_USED_1(ev);
- return 0;
-}
-
-// } ===== end nsIMdbHeap methods =====
-
-//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
deleted file mode 100644
--- a/db/mork/src/orkinErrorHook.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (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.mozilla.org/MPL/
- *
- * 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 mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1999
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef _ORKINERRORHOOK_
-#define _ORKINERRORHOOK_ 1
-
-#ifndef _MDB_
-#include "mdb.h"
-#endif
-
-#ifndef _MORK_
-#include "mork.h"
-#endif
-
-//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
-
-/*| orkinErrorHook:
-|*/
-class orkinErrorHook : public nsIMdbErrorHook { //
-
-public:
- orkinErrorHook(); // does nothing
- virtual ~orkinErrorHook(); // does nothing
-
-private: // copying is not allowed
- orkinErrorHook(const orkinErrorHook& other);
- orkinErrorHook& operator=(const orkinErrorHook& other);
-
-public:
-
-// { ===== begin nsIMdbHeap methods =====
- virtual mdb_err Alloc(nsIMdbEnv* ev, // allocate a piece of memory
- mdb_size inSize, // requested size of new memory block
- void** outBlock); // memory block of inSize bytes, or nil
-
- virtual mdb_err Free(nsIMdbEnv* ev, // free block allocated earlier by Alloc()
- void* inBlock);
-
- virtual mdb_err AddStrongRef(nsIMdbEnv* ev); // does nothing
- virtual mdb_err CutStrongRef(nsIMdbEnv* ev); // does nothing
-// } ===== end nsIMdbHeap methods =====
-
-};
-
-//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
-
-#endif /* _ORKINERRORHOOK_ */
deleted file mode 100644
--- a/db/mork/src/orkinFactory.cpp
+++ /dev/null
@@ -1,802 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (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.mozilla.org/MPL/
- *
- * 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 mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1999
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef _MDB_
-#include "mdb.h"
-#endif
-
-#ifndef _MORK_
-#include "mork.h"
-#endif
-
-#ifndef _MORKNODE_
-#include "morkNode.h"
-#endif
-
-#ifndef _MORKHANDLE_
-#include "morkHandle.h"
-#endif
-
-#ifndef _MORKENV_
-#include "morkEnv.h"
-#endif
-
-#ifndef _MORKFACTORY_
-#include "morkFactory.h"
-#endif
-
-#ifndef _ORKINFACTORY_
-#include "orkinFactory.h"
-#endif
-
-#ifndef _ORKINENV_
-#include "orkinEnv.h"
-#endif
-
-#ifndef _MORKROW_
-#include "morkRow.h"
-#endif
-
-#ifndef _ORKINROW_
-#include "orkinRow.h"
-#endif
-
-#ifndef _MORKFILE_
-#include "morkFile.h"
-#endif
-
-#ifndef _MORKWRITER_
-#include "morkWriter.h"
-#endif
-
-#ifndef _MORKSTORE_
-#include "morkStore.h"
-#endif
-
-#ifndef _ORKINSTORE_
-#include "orkinStore.h"
-#endif
-
-#ifndef _ORKINTHUMB_
-#include "orkinThumb.h"
-#endif
-
-#ifndef _MORKTHUMB_
-#include "morkThumb.h"
-#endif
-
-#ifndef _ORKINHEAP_
-#include "orkinHeap.h"
-#endif
-
-#ifndef _ORKINCOMPARE_
-#include "orkinCompare.h"
-#endif
-
-//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
-
-/* public virtual*/
-orkinFactory:: ~orkinFactory() // morkHandle destructor does everything
-{
-}
-
-/*protected non-poly construction*/
-orkinFactory::orkinFactory(morkEnv* ev, // morkUsage is morkUsage_kPool
- morkHandleFace* ioFace, // must not be nil, cookie for this handle
- morkFactory* ioObject) // must not be nil, object for this handle
-: morkHandle(ev, ioFace, ioObject, morkMagic_kFactory)
-{
- // do not modify mNode_Derived; leave it equal to morkDerived_kHandle
-}
-
-extern "C" nsIMdbFactory* MakeMdbFactory()
-{
- return orkinFactory::MakeGlobalFactory();
-}
-
-/*static */ orkinFactory*
-orkinFactory::MakeGlobalFactory()
-// instantiate objects using almost no context information.
-{
- morkFactory* factory = new morkFactory(new orkinHeap());
- MORK_ASSERT(factory);
- if ( factory )
- return orkinFactory::MakeFactory(&factory->mFactory_Env, factory);
- else
- return (orkinFactory*) 0;
-}
-
-/*static */ orkinFactory*
-orkinFactory::MakeFactory(morkEnv* ev, morkFactory* ioObject)
-{
- mork_bool isEnv = ev->IsEnv();
- MORK_ASSERT(isEnv);
- if ( isEnv )
- {
- morkHandleFace* face = ev->NewHandle(sizeof(orkinFactory));
- if ( face )
- {
- orkinFactory* f = new(face) orkinFactory(ev, face, ioObject);
- if ( f )
- f->mNode_Refs += morkFactory_kWeakRefCountBonus;
- return f;
- }
- else
- ev->OutOfMemoryError();
- }
-
- return (orkinFactory*) 0;
-}
-
-morkEnv*
-orkinFactory::CanUseFactory(nsIMdbEnv* mev, mork_bool inMutable,
- mdb_err* outErr) const
-{
- morkEnv* outEnv = 0;
- morkEnv* ev = morkEnv::FromMdbEnv(mev);
- if ( ev )
- {
- morkFactory* factory = (morkFactory*)
- this->GetGoodHandleObject(ev, inMutable, morkMagic_kFactory,
- /*inClosedOkay*/ morkBool_kFalse);
- if ( factory )
- {
- if ( factory->IsFactory() )
- outEnv = ev;
- else
- factory->NonFactoryTypeError(ev);
- }
- *outErr = ev->AsErr();
- }
- MORK_ASSERT(outEnv);
- return outEnv;
-}
-
-morkEnv* orkinFactory::GetInternalFactoryEnv(mdb_err* outErr)
-{
- morkEnv* outEnv = 0;
- morkFactory* f = (morkFactory*) this->mHandle_Object;
- if ( f && f->IsNode() && f->IsOpenNode() && f->IsFactory() )
- {
- morkEnv* fenv = &f->mFactory_Env;
- if ( fenv && fenv->IsNode() && fenv->IsOpenNode() && fenv->IsEnv() )
- {
- fenv->ClearMorkErrorsAndWarnings(); // drop any earlier errors
- outEnv = fenv;
- }
- else
- *outErr = morkEnv_kBadFactoryEnvError;
- }
- else
- *outErr = morkEnv_kBadFactoryError;
-
- return outEnv;
-}
-
-// { ===== begin nsIMdbISupports methods =====
-NS_IMPL_QUERY_INTERFACE0(orkinFactory)
-
-/*virtual*/ nsrefcnt
-orkinFactory::AddRef() // add strong ref with no
-{
- morkEnv* ev = mHandle_Env;
- if ( ev && ev->IsEnv() )
- return this->Handle_AddStrongRef(ev->AsMdbEnv());
- else
- return morkEnv_kNonEnvTypeError;
-}
-
-/*virtual*/ nsrefcnt
-orkinFactory::Release() // cut strong ref
-{
- morkEnv* ev = mHandle_Env;
- if ( ev && ev->IsEnv() )
- return this->Handle_CutStrongRef(ev->AsMdbEnv());
- else
- return morkEnv_kNonEnvTypeError;
-}
-// } ===== end nsIMdbObject methods =====
-
-
-// { ===== begin nsIMdbObject methods =====
-
-// { ----- begin attribute methods -----
-/*virtual*/ mdb_err
-orkinFactory::IsFrozenMdbObject(nsIMdbEnv* mev, mdb_bool* outIsReadonly)
-{
- return this->Handle_IsFrozenMdbObject(mev, outIsReadonly);
-}
-// same as nsIMdbPort::GetIsPortReadonly() when this object is inside a port.
-// } ----- end attribute methods -----
-
-// { ----- begin factory methods -----
-/*virtual*/ mdb_err
-orkinFactory::GetMdbFactory(nsIMdbEnv* mev, nsIMdbFactory** acqFactory)
-{
- return this->Handle_GetMdbFactory(mev, acqFactory);
-}
-// } ----- end factory methods -----
-
-// { ----- begin ref counting for well-behaved cyclic graphs -----
-/*virtual*/ mdb_err
-orkinFactory::GetWeakRefCount(nsIMdbEnv* mev, // weak refs
- mdb_count* outCount)
-{
- return this->Handle_GetWeakRefCount(mev, outCount);
-}
-/*virtual*/ mdb_err
-orkinFactory::GetStrongRefCount(nsIMdbEnv* mev, // strong refs
- mdb_count* outCount)
-{
- return this->Handle_GetStrongRefCount(mev, outCount);
-}
-
-/*virtual*/ mdb_err
-orkinFactory::AddWeakRef(nsIMdbEnv* mev)
-{
- return this->Handle_AddWeakRef(mev);
-}
-/*virtual*/ mdb_err
-orkinFactory::AddStrongRef(nsIMdbEnv* mev)
-{
- return this->Handle_AddStrongRef(mev);
-}
-
-/*virtual*/ mdb_err
-orkinFactory::CutWeakRef(nsIMdbEnv* mev)
-{
- return this->Handle_CutWeakRef(mev);
-}
-/*virtual*/ mdb_err
-orkinFactory::CutStrongRef(nsIMdbEnv* mev)
-{
- return this->Handle_CutStrongRef(mev);
-}
-
-/*virtual*/ mdb_err
-orkinFactory::CloseMdbObject(nsIMdbEnv* mev)
-{
- return this->Handle_CloseMdbObject(mev);
-}
-
-/*virtual*/ mdb_err
-orkinFactory::IsOpenMdbObject(nsIMdbEnv* mev, mdb_bool* outOpen)
-{
- return this->Handle_IsOpenMdbObject(mev, outOpen);
-}
-// } ----- end ref counting -----
-
-// } ===== end nsIMdbObject methods =====
-
-// { ===== begin nsIMdbFactory methods =====
-
-// { ----- begin file methods -----
-/*virtual*/ mdb_err
-orkinFactory::OpenOldFile(nsIMdbEnv* mev, nsIMdbHeap* ioHeap,
- const char* inFilePath,
- mork_bool inFrozen, nsIMdbFile** acqFile)
- // Choose some subclass of nsIMdbFile to instantiate, in order to read
- // (and write if not frozen) the file known by inFilePath. The file
- // returned should be open and ready for use, and presumably positioned
- // at the first byte position of the file. The exact manner in which
- // files must be opened is considered a subclass specific detail, and
- // other portions or Mork source code don't want to know how it's done.
-{
- mdb_err outErr = 0;
- nsIMdbFile* outFile = 0;
- morkEnv* ev = this->CanUseFactory(mev,
- /*inMutable*/ morkBool_kFalse, &outErr);
- morkFile* file = nsnull;
- if ( ev )
- {
- morkFactory* factory = (morkFactory*) this->mHandle_Object;
- if ( !ioHeap )
- ioHeap = &factory->mFactory_Heap;
-
- file = morkFile::OpenOldFile(ev, ioHeap, inFilePath, inFrozen);
- NS_IF_ADDREF( file );
-
- outErr = ev->AsErr();
- }
- if ( acqFile )
- *acqFile = file;
-
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinFactory::CreateNewFile(nsIMdbEnv* mev, nsIMdbHeap* ioHeap,
- const char* inFilePath, nsIMdbFile** acqFile)
- // Choose some subclass of nsIMdbFile to instantiate, in order to read
- // (and write if not frozen) the file known by inFilePath. The file
- // returned should be created and ready for use, and presumably positioned
- // at the first byte position of the file. The exact manner in which
- // files must be opened is considered a subclass specific detail, and
- // other portions or Mork source code don't want to know how it's done.
-{
- mdb_err outErr = 0;
- nsIMdbFile* outFile = 0;
- morkEnv* ev = this->CanUseFactory(mev,
- /*inMutable*/ morkBool_kFalse, &outErr);
- morkFile* file = nsnull;
- if ( ev )
- {
- morkFactory* factory = (morkFactory*) this->mHandle_Object;
- if ( !ioHeap )
- ioHeap = &factory->mFactory_Heap;
-
- file = morkFile::CreateNewFile(ev, ioHeap, inFilePath);
- if ( file )
- NS_ADDREF(file);
-
- outErr = ev->AsErr();
- }
- if ( acqFile )
- *acqFile = file;
-
- return outErr;
-}
-// } ----- end file methods -----
-
-// { ----- begin env methods -----
-/*virtual*/ mdb_err
-orkinFactory::MakeEnv(nsIMdbHeap* ioHeap, nsIMdbEnv** acqEnv)
-// ioHeap can be nil, causing a MakeHeap() style heap instance to be used
-{
- mdb_err outErr = 0;
- nsIMdbEnv* outEnv = 0;
- mork_bool ownsHeap = (ioHeap == 0);
- if ( !ioHeap )
- ioHeap = new orkinHeap();
-
- if ( acqEnv && ioHeap )
- {
- morkEnv* fenv = this->GetInternalFactoryEnv(&outErr);
- if ( fenv )
- {
- morkFactory* factory = (morkFactory*) this->mHandle_Object;
- morkEnv* newEnv = new(*ioHeap, fenv)
- morkEnv(morkUsage::kHeap, ioHeap, factory, ioHeap);
-
- if ( newEnv )
- {
- newEnv->mEnv_OwnsHeap = ownsHeap;
- newEnv->mNode_Refs += morkEnv_kWeakRefCountEnvBonus;
- NS_ADDREF(newEnv);
- newEnv->mEnv_SelfAsMdbEnv = newEnv;
- outEnv = newEnv;
- }
- else
- outErr = morkEnv_kOutOfMemoryError;
- }
-
- *acqEnv = outEnv;
- }
- else
- outErr = morkEnv_kNilPointerError;
-
- return outErr;
-}
-// } ----- end env methods -----
-
-// { ----- begin heap methods -----
-/*virtual*/ mdb_err
-orkinFactory::MakeHeap(nsIMdbEnv* mev, nsIMdbHeap** acqHeap)
-{
- mdb_err outErr = 0;
- nsIMdbHeap* outHeap = 0;
- morkEnv* ev = this->CanUseFactory(mev,
- /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- outHeap = new orkinHeap();
- if ( !outHeap )
- ev->OutOfMemoryError();
- }
- MORK_ASSERT(acqHeap);
- if ( acqHeap )
- *acqHeap = outHeap;
- return outErr;
-}
-// } ----- end heap methods -----
-
-// { ----- begin compare methods -----
-/*virtual*/ mdb_err
-orkinFactory::MakeCompare(nsIMdbEnv* mev, nsIMdbCompare** acqCompare)
-{
- mdb_err outErr = 0;
- nsIMdbCompare* outCompare = 0;
- morkEnv* ev = this->CanUseFactory(mev,
- /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- NS_ASSERTION(PR_FALSE, "not implemented");
- outErr = NS_ERROR_NOT_IMPLEMENTED;
-// outCompare = new orkinCompare();
- if ( !outCompare )
- ev->OutOfMemoryError();
- }
- if ( acqCompare )
- *acqCompare = outCompare;
- return outErr;
-}
-// } ----- end compare methods -----
-
-// { ----- begin row methods -----
-/*virtual*/ mdb_err
-orkinFactory::MakeRow(nsIMdbEnv* mev, nsIMdbHeap* ioHeap,
- nsIMdbRow** acqRow)
-{
- MORK_USED_1(ioHeap);
- mdb_err outErr = 0;
- nsIMdbRow* outRow = 0;
- morkEnv* ev = this->CanUseFactory(mev,
- /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- ev->StubMethodOnlyError();
- outErr = ev->AsErr();
- }
- if ( acqRow )
- *acqRow = outRow;
-
- return outErr;
-}
-// ioHeap can be nil, causing the heap associated with ev to be used
-// } ----- end row methods -----
-
-// { ----- begin port methods -----
-/*virtual*/ mdb_err
-orkinFactory::CanOpenFilePort(
- nsIMdbEnv* mev, // context
- // const char* inFilePath, // the file to investigate
- // const mdbYarn* inFirst512Bytes,
- nsIMdbFile* ioFile, // db abstract file interface
- mdb_bool* outCanOpen, // whether OpenFilePort() might succeed
- mdbYarn* outFormatVersion)
-{
- mdb_err outErr = 0;
- if ( outFormatVersion )
- {
- outFormatVersion->mYarn_Fill = 0;
- }
- mdb_bool canOpenAsPort = morkBool_kFalse;
- morkEnv* ev = this->CanUseFactory(mev,
- /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- if ( ioFile && outCanOpen )
- {
- canOpenAsPort = this->CanOpenMorkTextFile(ev, ioFile);
- }
- else
- ev->NilPointerError();
-
- outErr = ev->AsErr();
- }
-
- if ( outCanOpen )
- *outCanOpen = canOpenAsPort;
-
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinFactory::OpenFilePort(
- nsIMdbEnv* mev, // context
- nsIMdbHeap* ioHeap, // can be nil to cause ev's heap attribute to be used
- // const char* inFilePath, // the file to open for readonly import
- nsIMdbFile* ioFile, // db abstract file interface
- const mdbOpenPolicy* inOpenPolicy, // runtime policies for using db
- nsIMdbThumb** acqThumb)
-{
- MORK_USED_1(ioHeap);
- mdb_err outErr = 0;
- nsIMdbThumb* outThumb = 0;
- morkEnv* ev = this->CanUseFactory(mev,
- /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- if ( ioFile && inOpenPolicy && acqThumb )
- {
- }
- else
- ev->NilPointerError();
-
- outErr = ev->AsErr();
- }
- if ( acqThumb )
- *acqThumb = outThumb;
- return outErr;
-}
-// Call nsIMdbThumb::DoMore() until done, or until the thumb is broken, and
-// then call nsIMdbFactory::ThumbToOpenPort() to get the port instance.
-
-/*virtual*/ mdb_err
-orkinFactory::ThumbToOpenPort( // redeeming a completed thumb from OpenFilePort()
- nsIMdbEnv* mev, // context
- nsIMdbThumb* ioThumb, // thumb from OpenFilePort() with done status
- nsIMdbPort** acqPort)
-{
- mdb_err outErr = 0;
- nsIMdbPort* outPort = 0;
- morkEnv* ev = this->CanUseFactory(mev,
- /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- if ( ioThumb && acqPort )
- {
- morkThumb* thumb = (morkThumb*) ioThumb;
- morkStore* store = thumb->ThumbToOpenStore(ev);
- if ( store )
- {
- store->mStore_CanAutoAssignAtomIdentity = morkBool_kTrue;
- store->mStore_CanDirty = morkBool_kTrue;
- store->SetStoreAndAllSpacesCanDirty(ev, morkBool_kTrue);
-
- NS_ADDREF(store);
- outPort = store;
- }
- }
- else
- ev->NilPointerError();
-
- outErr = ev->AsErr();
- }
- if ( acqPort )
- *acqPort = outPort;
- return outErr;
-}
-// } ----- end port methods -----
-
-mork_bool
-orkinFactory::CanOpenMorkTextFile(morkEnv* ev,
- // const mdbYarn* inFirst512Bytes,
- nsIMdbFile* ioFile)
-{
- MORK_USED_1(ev);
- mork_bool outBool = morkBool_kFalse;
- mork_size headSize = MORK_STRLEN(morkWriter_kFileHeader);
-
- char localBuf[ 256 + 4 ]; // for extra for sloppy safety
- mdbYarn localYarn;
- mdbYarn* y = &localYarn;
- y->mYarn_Buf = localBuf; // space to hold content
- y->mYarn_Fill = 0; // no logical content yet
- y->mYarn_Size = 256; // physical capacity is 256 bytes
- y->mYarn_More = 0;
- y->mYarn_Form = 0;
- y->mYarn_Grow = 0;
-
- if ( ioFile )
- {
- nsIMdbEnv* menv = ev->AsMdbEnv();
- mdb_size actualSize = 0;
- ioFile->Get(menv, y->mYarn_Buf, y->mYarn_Size, /*pos*/ 0, &actualSize);
- y->mYarn_Fill = actualSize;
-
- if ( y->mYarn_Buf && actualSize >= headSize && ev->Good() )
- {
- mork_u1* buf = (mork_u1*) y->mYarn_Buf;
- outBool = ( MORK_MEMCMP(morkWriter_kFileHeader, buf, headSize) == 0 );
- }
- }
- else
- ev->NilPointerError();
-
- return outBool;
-}
-
-// { ----- begin store methods -----
-/*virtual*/ mdb_err
-orkinFactory::CanOpenFileStore(
- nsIMdbEnv* mev, // context
- // const char* inFilePath, // the file to investigate
- // const mdbYarn* inFirst512Bytes,
- nsIMdbFile* ioFile, // db abstract file interface
- mdb_bool* outCanOpenAsStore, // whether OpenFileStore() might succeed
- mdb_bool* outCanOpenAsPort, // whether OpenFilePort() might succeed
- mdbYarn* outFormatVersion)
-{
- mdb_bool canOpenAsStore = morkBool_kFalse;
- mdb_bool canOpenAsPort = morkBool_kFalse;
- if ( outFormatVersion )
- {
- outFormatVersion->mYarn_Fill = 0;
- }
- mdb_err outErr = 0;
- morkEnv* ev = this->CanUseFactory(mev,
- /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- if ( ioFile && outCanOpenAsStore )
- {
- // right now always say true; later we should look for magic patterns
- canOpenAsStore = this->CanOpenMorkTextFile(ev, ioFile);
- canOpenAsPort = canOpenAsStore;
- }
- else
- ev->NilPointerError();
-
- outErr = ev->AsErr();
- }
- if ( outCanOpenAsStore )
- *outCanOpenAsStore = canOpenAsStore;
-
- if ( outCanOpenAsPort )
- *outCanOpenAsPort = canOpenAsPort;
-
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinFactory::OpenFileStore( // open an existing database
- nsIMdbEnv* mev, // context
- nsIMdbHeap* ioHeap, // can be nil to cause ev's heap attribute to be used
- // const char* inFilePath, // the file to open for general db usage
- nsIMdbFile* ioFile, // db abstract file interface
- const mdbOpenPolicy* inOpenPolicy, // runtime policies for using db
- nsIMdbThumb** acqThumb)
-{
- mdb_err outErr = 0;
- nsIMdbThumb* outThumb = 0;
- morkEnv* ev = this->CanUseFactory(mev,
- /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- if ( !ioHeap ) // need to use heap from env?
- ioHeap = ev->mEnv_Heap;
-
- if ( ioFile && inOpenPolicy && acqThumb )
- {
- morkFactory* factory = (morkFactory*) this->mHandle_Object;
- morkStore* store = new(*ioHeap, ev)
- morkStore(ev, morkUsage::kHeap, ioHeap, factory, ioHeap);
-
- if ( store )
- {
- mork_bool frozen = morkBool_kFalse; // open store mutable access
- if ( store->OpenStoreFile(ev, frozen, ioFile, inOpenPolicy) )
- {
- morkThumb* thumb = morkThumb::Make_OpenFileStore(ev, ioHeap, store);
- if ( thumb )
- {
- outThumb = thumb;
- thumb->AddRef();
- }
- }
-// store->CutStrongRef(mev); // always cut ref (handle has its own ref)
- }
- }
- else
- ev->NilPointerError();
-
- outErr = ev->AsErr();
- }
- if ( acqThumb )
- *acqThumb = outThumb;
- return outErr;
-}
-// Call nsIMdbThumb::DoMore() until done, or until the thumb is broken, and
-// then call nsIMdbFactory::ThumbToOpenStore() to get the store instance.
-
-/*virtual*/ mdb_err
-orkinFactory::ThumbToOpenStore( // redeem completed thumb from OpenFileStore()
- nsIMdbEnv* mev, // context
- nsIMdbThumb* ioThumb, // thumb from OpenFileStore() with done status
- nsIMdbStore** acqStore)
-{
- mdb_err outErr = 0;
- nsIMdbStore* outStore = 0;
- morkEnv* ev = this->CanUseFactory(mev,
- /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- if ( ioThumb && acqStore )
- {
- morkThumb* thumb = (morkThumb*) ioThumb;
- morkStore* store = thumb->ThumbToOpenStore(ev);
- if ( store )
- {
- store->mStore_CanAutoAssignAtomIdentity = morkBool_kTrue;
- store->mStore_CanDirty = morkBool_kTrue;
- store->SetStoreAndAllSpacesCanDirty(ev, morkBool_kTrue);
-
- outStore = store;
- NS_ADDREF(store);
- }
- }
- else
- ev->NilPointerError();
-
- outErr = ev->AsErr();
- }
- if ( acqStore )
- *acqStore = outStore;
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinFactory::CreateNewFileStore( // create a new db with minimal content
- nsIMdbEnv* mev, // context
- nsIMdbHeap* ioHeap, // can be nil to cause ev's heap attribute to be used
- // const char* inFilePath, // name of file which should not yet exist
- nsIMdbFile* ioFile, // db abstract file interface
- const mdbOpenPolicy* inOpenPolicy, // runtime policies for using db
- nsIMdbStore** acqStore)
-{
- mdb_err outErr = 0;
- nsIMdbStore* outStore = 0;
- morkEnv* ev = this->CanUseFactory(mev,
- /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- if ( !ioHeap ) // need to use heap from env?
- ioHeap = ev->mEnv_Heap;
-
- if ( ioFile && inOpenPolicy && acqStore && ioHeap )
- {
- morkFactory* factory = (morkFactory*) this->mHandle_Object;
- morkStore* store = new(*ioHeap, ev)
- morkStore(ev, morkUsage::kHeap, ioHeap, factory, ioHeap);
-
- if ( store )
- {
- store->mStore_CanAutoAssignAtomIdentity = morkBool_kTrue;
- store->mStore_CanDirty = morkBool_kTrue;
- store->SetStoreAndAllSpacesCanDirty(ev, morkBool_kTrue);
-
- if ( store->CreateStoreFile(ev, ioFile, inOpenPolicy) )
- outStore = store;
- NS_ADDREF(store);
- }
- }
- else
- ev->NilPointerError();
-
- outErr = ev->AsErr();
- }
- if ( acqStore )
- *acqStore = outStore;
- return outErr;
-}
-// } ----- end store methods -----
-
-// } ===== end nsIMdbFactory methods =====
-
-
-//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
deleted file mode 100644
--- a/db/mork/src/orkinFactory.h
+++ /dev/null
@@ -1,266 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (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.mozilla.org/MPL/
- *
- * 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 mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1999
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef _ORKINFACTORY_
-#define _ORKINFACTORY_ 1
-
-#ifndef _MDB_
-#include "mdb.h"
-#endif
-
-#ifndef _MORK_
-#include "mork.h"
-#endif
-
-#ifndef _MORKNODE_
-#include "morkNode.h"
-#endif
-
-#ifndef _MORKHANDLE_
-#include "morkHandle.h"
-#endif
-
-#ifndef _MORKFACTORY_
-#include "morkFactory.h"
-#endif
-
-//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
-
-#define morkMagic_kFactory 0x46616374 /* ascii 'Fact' */
-
-/*| orkinFactory:
-|*/
-class orkinFactory : public morkHandle, public nsIMdbFactory { // nsIMdbObject
-
-// { ===== begin morkNode interface =====
-public: // morkNode virtual methods
- // virtual void CloseMorkNode(morkEnv* ev); // morkHandle is fine
- virtual ~orkinFactory(); // morkHandle destructor does everything
-
-protected: // construction is protected (use the static Make() method)
- orkinFactory(morkEnv* ev, // note morkUsage is always morkUsage_kPool
- morkHandleFace* ioFace, // must not be nil, cookie for this handle
- morkFactory* ioObject); // must not be nil, the object for this handle
-
- // void CloseHandle(morkEnv* ev); // don't need to specialize closing
-
-private: // copying is not allowed
- orkinFactory(const morkHandle& other);
- orkinFactory& operator=(const morkHandle& other);
-
-// public: // dynamic type identification
- // mork_bool IsHandle() const //
- // { return IsNode() && mNode_Derived == morkDerived_kHandle; }
-// } ===== end morkNode methods =====
-
-protected: // morkHandle memory management operators
- void* operator new(size_t inSize, morkPool& ioPool, morkZone& ioZone, morkEnv* ev) CPP_THROW_NEW
- { return ioPool.NewHandle(ev, inSize, &ioZone); }
-
- void* operator new(size_t inSize, morkPool& ioPool, morkEnv* ev) CPP_THROW_NEW
- { return ioPool.NewHandle(ev, inSize, (morkZone*) 0); }
-
- void* operator new(size_t inSize, morkHandleFace* ioFace) CPP_THROW_NEW
- { MORK_USED_1(inSize); return ioFace; }
-
-
-public: // construction:
-
- static orkinFactory* MakeGlobalFactory();
- // instantiate objects using almost no context information.
-
- static orkinFactory* MakeFactory(morkEnv* ev, morkFactory* ioObject);
-
-public: // utilities:
-
- morkEnv* CanUseFactory(nsIMdbEnv* mev, mork_bool inMutable,
- mdb_err* outErr) const;
-
- morkEnv* GetInternalFactoryEnv(mdb_err* outErr);
-
- mork_bool CanOpenMorkTextFile(morkEnv* ev,
- // const mdbYarn* inFirst512Bytes,
- nsIMdbFile* ioFile);
-
-public: // type identification
- mork_bool IsOrkinFactory() const
- { return mHandle_Magic == morkMagic_kFactory; }
-
- mork_bool IsOrkinFactoryHandle() const
- { return this->IsHandle() && this->IsOrkinFactory(); }
-
-public:
-
- NS_DECL_ISUPPORTS
-
-// { ===== begin nsIMdbObject methods =====
-
- // { ----- begin attribute methods -----
- NS_IMETHOD IsFrozenMdbObject(nsIMdbEnv* ev, mdb_bool* outIsReadonly);
- // same as nsIMdbPort::GetIsPortReadonly() when this object is inside a port.
- // } ----- end attribute methods -----
-
- // { ----- begin factory methods -----
- NS_IMETHOD GetMdbFactory(nsIMdbEnv* ev, nsIMdbFactory** acqFactory);
- // } ----- end factory methods -----
-
- // { ----- begin ref counting for well-behaved cyclic graphs -----
- NS_IMETHOD GetWeakRefCount(nsIMdbEnv* ev, // weak refs
- mdb_count* outCount);
- NS_IMETHOD GetStrongRefCount(nsIMdbEnv* ev, // strong refs
- mdb_count* outCount);
-
- NS_IMETHOD AddWeakRef(nsIMdbEnv* ev);
- NS_IMETHOD AddStrongRef(nsIMdbEnv* ev);
-
- NS_IMETHOD CutWeakRef(nsIMdbEnv* ev);
- NS_IMETHOD CutStrongRef(nsIMdbEnv* ev);
-
- NS_IMETHOD CloseMdbObject(nsIMdbEnv* ev); // called at strong refs zero
- NS_IMETHOD IsOpenMdbObject(nsIMdbEnv* ev, mdb_bool* outOpen);
- // } ----- end ref counting -----
-
-// } ===== end nsIMdbObject methods =====
-
-// { ===== begin nsIMdbFactory methods =====
-
- // { ----- begin file methods -----
- NS_IMETHOD OpenOldFile(nsIMdbEnv* ev, nsIMdbHeap* ioHeap,
- const char* inFilePath,
- mdb_bool inFrozen, nsIMdbFile** acqFile);
- // Choose some subclass of nsIMdbFile to instantiate, in order to read
- // (and write if not frozen) the file known by inFilePath. The file
- // returned should be open and ready for use, and presumably positioned
- // at the first byte position of the file. The exact manner in which
- // files must be opened is considered a subclass specific detail, and
- // other portions or Mork source code don't want to know how it's done.
-
- NS_IMETHOD CreateNewFile(nsIMdbEnv* ev, nsIMdbHeap* ioHeap,
- const char* inFilePath,
- nsIMdbFile** acqFile);
- // Choose some subclass of nsIMdbFile to instantiate, in order to read
- // (and write if not frozen) the file known by inFilePath. The file
- // returned should be created and ready for use, and presumably positioned
- // at the first byte position of the file. The exact manner in which
- // files must be opened is considered a subclass specific detail, and
- // other portions or Mork source code don't want to know how it's done.
- // } ----- end file methods -----
-
- // { ----- begin env methods -----
- NS_IMETHOD MakeEnv(nsIMdbHeap* ioHeap, nsIMdbEnv** acqEnv); // new env
- // ioHeap can be nil, causing a MakeHeap() style heap instance to be used
- // } ----- end env methods -----
-
- // { ----- begin heap methods -----
- NS_IMETHOD MakeHeap(nsIMdbEnv* ev, nsIMdbHeap** acqHeap); // new heap
- // } ----- end heap methods -----
-
- // { ----- begin compare methods -----
- NS_IMETHOD MakeCompare(nsIMdbEnv* ev, nsIMdbCompare** acqCompare); // ASCII
- // } ----- end compare methods -----
-
- // { ----- begin row methods -----
- NS_IMETHOD MakeRow(nsIMdbEnv* ev, nsIMdbHeap* ioHeap, nsIMdbRow** acqRow); // new row
- // ioHeap can be nil, causing the heap associated with ev to be used
- // } ----- end row methods -----
-
- // { ----- begin port methods -----
- NS_IMETHOD CanOpenFilePort(
- nsIMdbEnv* ev, // context
- // const char* inFilePath, // the file to investigate
- // const mdbYarn* inFirst512Bytes,
- nsIMdbFile* ioFile, // db abstract file interface
- mdb_bool* outCanOpen, // whether OpenFilePort() might succeed
- mdbYarn* outFormatVersion); // informal file format description
-
- NS_IMETHOD OpenFilePort(
- nsIMdbEnv* ev, // context
- nsIMdbHeap* ioHeap, // can be nil to cause ev's heap attribute to be used
- // const char* inFilePath, // the file to open for readonly import
- nsIMdbFile* ioFile, // db abstract file interface
- const mdbOpenPolicy* inOpenPolicy, // runtime policies for using db
- nsIMdbThumb** acqThumb); // acquire thumb for incremental port open
- // Call nsIMdbThumb::DoMore() until done, or until the thumb is broken, and
- // then call nsIMdbFactory::ThumbToOpenPort() to get the port instance.
-
- NS_IMETHOD ThumbToOpenPort( // redeeming a completed thumb from OpenFilePort()
- nsIMdbEnv* ev, // context
- nsIMdbThumb* ioThumb, // thumb from OpenFilePort() with done status
- nsIMdbPort** acqPort); // acquire new port object
- // } ----- end port methods -----
-
- // { ----- begin store methods -----
- NS_IMETHOD CanOpenFileStore(
- nsIMdbEnv* ev, // context
- // const char* inFilePath, // the file to investigate
- // const mdbYarn* inFirst512Bytes,
- nsIMdbFile* ioFile, // db abstract file interface
- mdb_bool* outCanOpenAsStore, // whether OpenFileStore() might succeed
- mdb_bool* outCanOpenAsPort, // whether OpenFilePort() might succeed
- mdbYarn* outFormatVersion); // informal file format description
-
- NS_IMETHOD OpenFileStore( // open an existing database
- nsIMdbEnv* ev, // context
- nsIMdbHeap* ioHeap, // can be nil to cause ev's heap attribute to be used
- // const char* inFilePath, // the file to open for general db usage
- nsIMdbFile* ioFile, // db abstract file interface
- const mdbOpenPolicy* inOpenPolicy, // runtime policies for using db
- nsIMdbThumb** acqThumb); // acquire thumb for incremental store open
- // Call nsIMdbThumb::DoMore() until done, or until the thumb is broken, and
- // then call nsIMdbFactory::ThumbToOpenStore() to get the store instance.
-
- NS_IMETHOD
- ThumbToOpenStore( // redeem completed thumb from OpenFileStore()
- nsIMdbEnv* ev, // context
- nsIMdbThumb* ioThumb, // thumb from OpenFileStore() with done status
- nsIMdbStore** acqStore); // acquire new db store object
-
- NS_IMETHOD CreateNewFileStore( // create a new db with minimal content
- nsIMdbEnv* ev, // context
- nsIMdbHeap* ioHeap, // can be nil to cause ev's heap attribute to be used
- // const char* inFilePath, // name of file which should not yet exist
- nsIMdbFile* ioFile, // db abstract file interface
- const mdbOpenPolicy* inOpenPolicy, // runtime policies for using db
- nsIMdbStore** acqStore); // acquire new db store object
- // } ----- end store methods -----
-
-// } ===== end nsIMdbFactory methods =====
-};
-
-//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
-
-#endif /* _ORKINFACTORY_ */
deleted file mode 100644
--- a/db/mork/src/orkinFile.cpp
+++ /dev/null
@@ -1,500 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (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.mozilla.org/MPL/
- *
- * 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 mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1999
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef _MDB_
-#include "mdb.h"
-#endif
-
-#ifndef _MORK_
-#include "mork.h"
-#endif
-
-#ifndef _MORKNODE_
-#include "morkNode.h"
-#endif
-
-#ifndef _MORKHANDLE_
-#include "morkHandle.h"
-#endif
-
-#ifndef _MORKFILE_
-#include "morkFile.h"
-#endif
-
-#ifndef _MORKENV_
-#include "morkEnv.h"
-#endif
-
-#ifndef _ORKINFILE_
-#include "orkinFile.h"
-#endif
-
-#ifndef _MORKFILE_
-#include "morkFile.h"
-#endif
-
-//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
-
-/* public virtual*/
-orkinFile:: ~orkinFile() // morkHandle destructor does everything
-{
-}
-
-/*protected non-poly construction*/
-orkinFile::orkinFile(morkEnv* ev, // morkUsage is morkUsage_kPool
- morkHandleFace* ioFace, // must not be nil, cookie for this handle
- morkFile* ioObject) // must not be nil, the object for this handle
-: morkHandle(ev, ioFace, ioObject, morkMagic_kFile)
-{
- // do not modify mNode_Derived; leave it equal to morkDerived_kHandle
-}
-
-
-/*static */ orkinFile*
-orkinFile::MakeFile(morkEnv* ev, morkFile* ioObject)
-{
- mork_bool isEnv = ev->IsEnv();
- MORK_ASSERT(isEnv);
- if ( isEnv )
- {
- morkHandleFace* face = ev->NewHandle(sizeof(orkinFile));
- if ( face )
- return new(face) orkinFile(ev, face, ioObject);
- else
- ev->OutOfMemoryError();
- }
-
- return (orkinFile*) 0;
-}
-
-morkEnv*
-orkinFile::CanUseFile(nsIMdbEnv* mev,
- mork_bool inMutable, mdb_err* outErr) const
-{
- morkEnv* outEnv = 0;
- morkEnv* ev = morkEnv::FromMdbEnv(mev);
- if ( ev )
- {
- morkFile* self = (morkFile*)
- this->GetGoodHandleObject(ev, inMutable, morkMagic_kFile,
- /*inClosedOkay*/ morkBool_kFalse);
- if ( self )
- {
- if ( self->IsFile() )
- outEnv = ev;
- else
- self->NonFileTypeError(ev);
- }
- *outErr = ev->AsErr();
- }
- MORK_ASSERT(outEnv);
- return outEnv;
-}
-
-
-// { ===== begin nsIMdbISupports methods =====
-NS_IMPL_QUERY_INTERFACE1(orkinFile, nsIMdbFile)
-
-/*virtual*/ nsrefcnt
-orkinFile::AddRef() // add strong ref with no
-{
- morkEnv* ev = mHandle_Env;
- if ( ev && ev->IsEnv() )
- return this->Handle_AddStrongRef(ev->AsMdbEnv());
- else
- return morkEnv_kNonEnvTypeError;
-}
-
-/*virtual*/ nsrefcnt
-orkinFile::Release() // cut strong ref
-{
- morkEnv* ev = mHandle_Env;
- if ( ev && ev->IsEnv() )
- return this->Handle_CutStrongRef(ev->AsMdbEnv());
- else
- return morkEnv_kNonEnvTypeError;
-}
-// } ===== end nsIMdbISupports methods =====
-
-// { ===== begin nsIMdbObject methods =====
-
-// { ----- begin attribute methods -----
-/*virtual*/ mdb_err
-orkinFile::IsFrozenMdbObject(nsIMdbEnv* mev, mdb_bool* outIsReadonly)
-{
- return this->Handle_IsFrozenMdbObject(mev, outIsReadonly);
-}
-// same as nsIMdbPort::GetIsPortReadonly() when this object is inside a port.
-// } ----- end attribute methods -----
-
-// { ----- begin factory methods -----
-/*virtual*/ mdb_err
-orkinFile::GetMdbFactory(nsIMdbEnv* mev, nsIMdbFactory** acqFactory)
-{
- return this->Handle_GetMdbFactory(mev, acqFactory);
-}
-// } ----- end factory methods -----
-
-// { ----- begin ref counting for well-behaved cyclic graphs -----
-/*virtual*/ mdb_err
-orkinFile::GetWeakRefCount(nsIMdbEnv* mev, // weak refs
- mdb_count* outCount)
-{
- return this->Handle_GetWeakRefCount(mev, outCount);
-}
-/*virtual*/ mdb_err
-orkinFile::GetStrongRefCount(nsIMdbEnv* mev, // strong refs
- mdb_count* outCount)
-{
- return this->Handle_GetStrongRefCount(mev, outCount);
-}
-
-/*virtual*/ mdb_err
-orkinFile::AddWeakRef(nsIMdbEnv* mev)
-{
- return this->Handle_AddWeakRef(mev);
-}
-/*virtual*/ mdb_err
-orkinFile::AddStrongRef(nsIMdbEnv* mev)
-{
- return this->Handle_AddStrongRef(mev);
-}
-
-/*virtual*/ mdb_err
-orkinFile::CutWeakRef(nsIMdbEnv* mev)
-{
- return this->Handle_CutWeakRef(mev);
-}
-/*virtual*/ mdb_err
-orkinFile::CutStrongRef(nsIMdbEnv* mev)
-{
- return this->Handle_CutStrongRef(mev);
-}
-
-/*virtual*/ mdb_err
-orkinFile::CloseMdbObject(nsIMdbEnv* mev)
-{
- return this->Handle_CloseMdbObject(mev);
-}
-
-/*virtual*/ mdb_err
-orkinFile::IsOpenMdbObject(nsIMdbEnv* mev, mdb_bool* outOpen)
-{
- return this->Handle_IsOpenMdbObject(mev, outOpen);
-}
-// } ----- end ref counting -----
-
-// } ===== end nsIMdbObject methods =====
-
-// { ===== begin nsIMdbFile methods =====
-
-// { ----- begin pos methods -----
-/*virtual*/ mdb_err
-orkinFile::Tell(nsIMdbEnv* mev, mdb_pos* outPos)
-{
- mdb_err outErr = 0;
- mdb_pos pos = -1;
- morkEnv* ev = this->CanUseFile(mev, /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- morkFile* file = (morkFile*) mHandle_Object;
- pos = file->Tell(ev);
- outErr = ev->AsErr();
- }
- if ( outPos )
- *outPos = pos;
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinFile::Seek(nsIMdbEnv* mev, mdb_pos inPos)
-{
- mdb_err outErr = 0;
- morkEnv* ev = this->CanUseFile(mev, /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- morkFile* file = (morkFile*) mHandle_Object;
- file->Seek(ev, inPos);
- outErr = ev->AsErr();
- }
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinFile::Eof(nsIMdbEnv* mev, mdb_pos* outPos)
-{
- mdb_err outErr = 0;
- mdb_pos pos = -1;
- morkEnv* ev = this->CanUseFile(mev, /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- morkFile* file = (morkFile*) mHandle_Object;
- pos = file->Length(ev);
- outErr = ev->AsErr();
- }
- if ( outPos )
- *outPos = pos;
- return outErr;
-}
-
-// } ----- end pos methods -----
-
-// { ----- begin read methods -----
-/*virtual*/ mdb_err
-orkinFile::Read(nsIMdbEnv* mev, void* outBuf, mdb_size inSize,
- mdb_size* outActualSize)
-{
- mdb_err outErr = 0;
- mdb_size actualSize = 0;
- morkEnv* ev = this->CanUseFile(mev, /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- morkFile* file = (morkFile*) mHandle_Object;
- actualSize = file->Read(ev, outBuf, inSize);
- outErr = ev->AsErr();
- }
- if ( outActualSize )
- *outActualSize = actualSize;
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinFile::Get(nsIMdbEnv* mev, void* outBuf, mdb_size inSize,
- mdb_pos inPos, mdb_size* outActualSize)
-{
- mdb_err outErr = 0;
- mdb_size actualSize = 0;
- morkEnv* ev = this->CanUseFile(mev, /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- morkFile* file = (morkFile*) mHandle_Object;
- file->Seek(ev, inPos);
- if ( ev->Good() )
- actualSize = file->Read(ev, outBuf, inSize);
- outErr = ev->AsErr();
- }
- if ( outActualSize )
- *outActualSize = actualSize;
- return outErr;
-}
-
-// } ----- end read methods -----
-
-// { ----- begin write methods -----
-/*virtual*/ mdb_err
-orkinFile::Write(nsIMdbEnv* mev, const void* inBuf, mdb_size inSize,
- mdb_size* outActualSize)
-{
- mdb_err outErr = 0;
- mdb_size actualSize = 0;
- morkEnv* ev = this->CanUseFile(mev, /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- morkFile* file = (morkFile*) mHandle_Object;
- actualSize = file->Write(ev, inBuf, inSize);
- outErr = ev->AsErr();
- }
- if ( outActualSize )
- *outActualSize = actualSize;
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinFile::Put(nsIMdbEnv* mev, const void* inBuf, mdb_size inSize,
- mdb_pos inPos, mdb_size* outActualSize)
-{
- mdb_err outErr = 0;
- mdb_size actualSize = 0;
- morkEnv* ev = this->CanUseFile(mev, /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- morkFile* file = (morkFile*) mHandle_Object;
- file->Seek(ev, inPos);
- if ( ev->Good() )
- actualSize = file->Write(ev, inBuf, inSize);
- outErr = ev->AsErr();
- }
- if ( outActualSize )
- *outActualSize = actualSize;
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinFile::Flush(nsIMdbEnv* mev)
-{
- mdb_err outErr = 0;
- morkEnv* ev = this->CanUseFile(mev, /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- morkFile* file = (morkFile*) mHandle_Object;
- file->Flush(ev);
- outErr = ev->AsErr();
- }
- return outErr;
-}
-
-// } ----- end attribute methods -----
-
-// { ----- begin path methods -----
-/*virtual*/ mdb_err
-orkinFile::Path(nsIMdbEnv* mev, mdbYarn* outFilePath)
-{
- mdb_err outErr = 0;
- if ( outFilePath )
- outFilePath->mYarn_Fill = 0;
- morkEnv* ev = this->CanUseFile(mev, /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- morkFile* file = (morkFile*) mHandle_Object;
- ev->StringToYarn(file->GetFileNameString(), outFilePath);
- outErr = ev->AsErr();
- }
- return outErr;
-}
-
-// } ----- end path methods -----
-
-// { ----- begin replacement methods -----
-
-/*virtual*/ mdb_err
-orkinFile::Steal(nsIMdbEnv* mev, nsIMdbFile* ioThief)
-{
- mdb_err outErr = 0;
- morkEnv* ev = this->CanUseFile(mev, /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- if ( ioThief )
- {
- // orkinFile* thief = (orkinFile*) ioThief; // unsafe cast -- must type check:
- // thief->CanUseFile(mev, /*inMutable*/ morkBool_kFalse, &outErr);
-
- morkFile* file = (morkFile*) mHandle_Object;
- file->Steal(ev, ioThief);
- outErr = ev->AsErr();
- }
- else
- ev->NilPointerError();
- }
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinFile::Thief(nsIMdbEnv* mev, nsIMdbFile** acqThief)
-{
- mdb_err outErr = 0;
- nsIMdbFile* outThief = 0;
- morkEnv* ev = this->CanUseFile(mev, /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- morkFile* file = (morkFile*) mHandle_Object;
- outThief = file->GetThief();
- if ( outThief )
- outThief->AddStrongRef(ev->AsMdbEnv());
- outErr = ev->AsErr();
- }
- if ( acqThief )
- *acqThief = outThief;
- return outErr;
-}
-
-// } ----- end replacement methods -----
-
-// { ----- begin versioning methods -----
-
-/*virtual*/ mdb_err
-orkinFile::BecomeTrunk(nsIMdbEnv* mev)
-// If this file is a file version branch created by calling AcquireBud(),
-// BecomeTrunk() causes this file's content to replace the original
-// file's content, typically by assuming the original file's identity.
-// This default implementation of BecomeTrunk() does nothing, and this
-// is appropriate behavior for files which are not branches, and is
-// also the right behavior for files returned from AcquireBud() which are
-// in fact the original file that has been truncated down to zero length.
-{
- mdb_err outErr = 0;
- morkEnv* ev = this->CanUseFile(mev, /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- morkFile* file = (morkFile*) mHandle_Object;
- file->BecomeTrunk(ev);
- outErr = ev->AsErr();
- }
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinFile::AcquireBud(nsIMdbEnv* mev, nsIMdbHeap* ioHeap,
- nsIMdbFile** acqBud) // acquired file for new version of content
-// AcquireBud() starts a new "branch" version of the file, empty of content,
-// so that a new version of the file can be written. This new file
-// can later be told to BecomeTrunk() the original file, so the branch
-// created by budding the file will replace the original file. Some
-// file subclasses might initially take the unsafe but expedient
-// approach of simply truncating this file down to zero length, and
-// then returning the same morkFile pointer as this, with an extra
-// reference count increment. Note that the caller of AcquireBud() is
-// expected to eventually call CutStrongRef() on the returned file
-// in order to release the strong reference. High quality versions
-// of morkFile subclasses will create entirely new files which later
-// are renamed to become the old file, so that better transactional
-// behavior is exhibited by the file, so crashes protect old files.
-// Note that AcquireBud() is an illegal operation on readonly files.
-{
- mdb_err outErr = 0;
- nsIMdbFile* outBud = 0;
- morkEnv* ev = this->CanUseFile(mev, /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- morkFile* file = (morkFile*) mHandle_Object;
- morkFile* bud = file->AcquireBud(ev, ioHeap);
- if ( bud )
- {
- outBud = bud->AcquireFileHandle(ev);
- bud->CutStrongRef(mev);
- }
- outErr = ev->AsErr();
- }
- if ( acqBud )
- *acqBud = outBud;
- return outErr;
-}
-// } ----- end versioning methods -----
-
-// } ===== end nsIMdbFile methods =====
-
-
-//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
deleted file mode 100644
--- a/db/mork/src/orkinFile.h
+++ /dev/null
@@ -1,212 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (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.mozilla.org/MPL/
- *
- * 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 mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1999
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef _ORKINTABLE_
-#define _ORKINTABLE_ 1
-
-#ifndef _MDB_
-#include "mdb.h"
-#endif
-
-#ifndef _MORK_
-#include "mork.h"
-#endif
-
-#ifndef _MORKNODE_
-#include "morkNode.h"
-#endif
-
-#ifndef _MORKHANDLE_
-#include "morkHandle.h"
-#endif
-
-#ifndef _MORKFILE_
-#include "morkFile.h"
-#endif
-
-//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
-
-#define morkMagic_kFile 0x46696C65 /* ascii 'File' */
-
-/*| orkinFile:
-|*/
-class orkinFile : public morkHandle, public nsIMdbFile { // nsIMdbFile
-
-// { ===== begin morkNode interface =====
-public: // morkNode virtual methods
- // virtual void CloseMorkNode(morkEnv* ev); // morkHandle is fine
- virtual ~orkinFile(); // morkHandle destructor does everything
-
-protected: // construction is protected (use the static Make() method)
- orkinFile(morkEnv* ev, // note morkUsage is always morkUsage_kPool
- morkHandleFace* ioFace, // must not be nil, cookie for this handle
- morkFile* ioObject); // must not be nil, the object for this handle
-
- // void CloseHandle(morkEnv* ev); // don't need to specialize closing
-
-private: // copying is not allowed
- orkinFile(const morkHandle& other);
- orkinFile& operator=(const morkHandle& other);
-
-// public: // dynamic type identification
- // mork_bool IsHandle() const //
- // { return IsNode() && mNode_Derived == morkDerived_kHandle; }
-// } ===== end morkNode methods =====
-
-protected: // morkHandle memory management operators
- void* operator new(size_t inSize, morkPool& ioPool, morkZone& ioZone, morkEnv* ev) CPP_THROW_NEW
- { return ioPool.NewHandle(ev, inSize, &ioZone); }
-
- void* operator new(size_t inSize, morkPool& ioPool, morkEnv* ev) CPP_THROW_NEW
- { return ioPool.NewHandle(ev, inSize, (morkZone*) 0); }
-
- void* operator new(size_t inSize, morkHandleFace* ioFace) CPP_THROW_NEW
- { MORK_USED_1(inSize); return ioFace; }
-
-
-public: // construction:
-
- static orkinFile* MakeFile(morkEnv* ev, morkFile* ioObject);
-
-public: // utilities:
-
- morkEnv* CanUseFile(nsIMdbEnv* mev, mork_bool inMutable,
- mdb_err* outErr) const;
-
-public: // type identification
- mork_bool IsOrkinFile() const
- { return mHandle_Magic == morkMagic_kFile; }
-
- mork_bool IsOrkinFileHandle() const
- { return this->IsHandle() && this->IsOrkinFile(); }
-
- NS_DECL_ISUPPORTS
-// { ===== begin nsIMdbObject methods =====
-
- // { ----- begin attribute methods -----
- NS_IMETHOD IsFrozenMdbObject(nsIMdbEnv* ev, mdb_bool* outIsReadonly);
- // same as nsIMdbPort::GetIsPortReadonly() when this object is inside a port.
- // } ----- end attribute methods -----
-
- // { ----- begin factory methods -----
- NS_IMETHOD GetMdbFactory(nsIMdbEnv* ev, nsIMdbFactory** acqFactory);
- // } ----- end factory methods -----
-
- // { ----- begin ref counting for well-behaved cyclic graphs -----
- NS_IMETHOD GetWeakRefCount(nsIMdbEnv* ev, // weak refs
- mdb_count* outCount);
- NS_IMETHOD GetStrongRefCount(nsIMdbEnv* ev, // strong refs
- mdb_count* outCount);
-
- NS_IMETHOD AddWeakRef(nsIMdbEnv* ev);
- NS_IMETHOD AddStrongRef(nsIMdbEnv* ev);
-
- NS_IMETHOD CutWeakRef(nsIMdbEnv* ev);
- NS_IMETHOD CutStrongRef(nsIMdbEnv* ev);
-
- NS_IMETHOD CloseMdbObject(nsIMdbEnv* ev); // called at strong refs zero
- NS_IMETHOD IsOpenMdbObject(nsIMdbEnv* ev, mdb_bool* outOpen);
- // } ----- end ref counting -----
-
-// } ===== end nsIMdbObject methods =====
-
-// { ===== begin nsIMdbFile methods =====
-
- // { ----- begin pos methods -----
- NS_IMETHOD Tell(nsIMdbEnv* ev, mdb_pos* outPos);
- NS_IMETHOD Seek(nsIMdbEnv* ev, mdb_pos inPos);
- NS_IMETHOD Eof(nsIMdbEnv* ev, mdb_pos* outPos);
- // } ----- end pos methods -----
-
- // { ----- begin read methods -----
- NS_IMETHOD Read(nsIMdbEnv* ev, void* outBuf, mdb_size inSize,
- mdb_size* outActualSize);
- NS_IMETHOD Get(nsIMdbEnv* ev, void* outBuf, mdb_size inSize,
- mdb_pos inPos, mdb_size* outActualSize);
- // } ----- end read methods -----
-
- // { ----- begin write methods -----
- NS_IMETHOD Write(nsIMdbEnv* ev, const void* inBuf, mdb_size inSize,
- mdb_size* outActualSize);
- NS_IMETHOD Put(nsIMdbEnv* ev, const void* inBuf, mdb_size inSize,
- mdb_pos inPos, mdb_size* outActualSize);
- NS_IMETHOD Flush(nsIMdbEnv* ev);
- // } ----- end attribute methods -----
-
- // { ----- begin path methods -----
- NS_IMETHOD Path(nsIMdbEnv* ev, mdbYarn* outFilePath);
- // } ----- end path methods -----
-
- // { ----- begin replacement methods -----
- NS_IMETHOD Steal(nsIMdbEnv* ev, nsIMdbFile* ioThief);
- NS_IMETHOD Thief(nsIMdbEnv* ev, nsIMdbFile** acqThief);
- // } ----- end replacement methods -----
-
- // { ----- begin versioning methods -----
- NS_IMETHOD BecomeTrunk(nsIMdbEnv* ev);
- // If this file is a file version branch created by calling AcquireBud(),
- // BecomeTrunk() causes this file's content to replace the original
- // file's content, typically by assuming the original file's identity.
- // This default implementation of BecomeTrunk() does nothing, and this
- // is appropriate behavior for files which are not branches, and is
- // also the right behavior for files returned from AcquireBud() which are
- // in fact the original file that has been truncated down to zero length.
-
- NS_IMETHOD AcquireBud(nsIMdbEnv* ev, nsIMdbHeap* ioHeap,
- nsIMdbFile** acqBud); // acquired file for new version of content
- // AcquireBud() starts a new "branch" version of the file, empty of content,
- // so that a new version of the file can be written. This new file
- // can later be told to BecomeTrunk() the original file, so the branch
- // created by budding the file will replace the original file. Some
- // file subclasses might initially take the unsafe but expedient
- // approach of simply truncating this file down to zero length, and
- // then returning the same morkFile pointer as this, with an extra
- // reference count increment. Note that the caller of AcquireBud() is
- // expected to eventually call CutStrongRef() on the returned file
- // in order to release the strong reference. High quality versions
- // of morkFile subclasses will create entirely new files which later
- // are renamed to become the old file, so that better transactional
- // behavior is exhibited by the file, so crashes protect old files.
- // Note that AcquireBud() is an illegal operation on readonly files.
- // } ----- end versioning methods -----
-
-// } ===== end nsIMdbFile methods =====
-};
-
-//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
-
-#endif /* _ORKINTABLE_ */
deleted file mode 100644
--- a/db/mork/src/orkinPortTableCursor.cpp
+++ /dev/null
@@ -1,473 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (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.mozilla.org/MPL/
- *
- * 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 mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1999
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef _MDB_
-#include "mdb.h"
-#endif
-
-#ifndef _MORK_
-#include "mork.h"
-#endif
-
-#ifndef _MORKNODE_
-#include "morkNode.h"
-#endif
-
-#ifndef _MORKHANDLE_
-#include "morkHandle.h"
-#endif
-
-#ifndef _MORKENV_
-#include "morkEnv.h"
-#endif
-
-#ifndef _MORKSTORE_
-#include "morkStore.h"
-#endif
-
-#ifndef _ORKINSTORE_
-#include "orkinStore.h"
-#endif
-
-#ifndef _MORKPORTTABLECURSOR_
-#include "morkPortTableCursor.h"
-#endif
-
-#ifndef _ORKINPORTTABLECURSOR_
-#include "orkinPortTableCursor.h"
-#endif
-
-//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
-
-/* public virtual*/
-orkinPortTableCursor:: ~orkinPortTableCursor() // morkHandle destructor does everything
-{
-}
-
-/*protected non-poly construction*/
-orkinPortTableCursor::orkinPortTableCursor(morkEnv* ev, // morkUsage is morkUsage_kPool
- morkHandleFace* ioFace, // must not be nil, cookie for this handle
- morkPortTableCursor* ioObject) // must not be nil, object for this handle
-: morkHandle(ev, ioFace, ioObject,
- morkMagic_kPortTableCursor)
-{
- // do not modify mNode_Derived; leave it equal to morkDerived_kHandle
-}
-
-
-/*static */ orkinPortTableCursor*
-orkinPortTableCursor::MakePortTableCursor(morkEnv* ev,
- morkPortTableCursor* ioObject)
-{
- mork_bool isEnv = ev->IsEnv();
- MORK_ASSERT(isEnv);
- if ( isEnv )
- {
- morkHandleFace* face = ev->NewHandle(sizeof(orkinPortTableCursor));
- if ( face )
- return new(face) orkinPortTableCursor(ev, face, ioObject);
- else
- ev->OutOfMemoryError();
- }
-
- return (orkinPortTableCursor*) 0;
-}
-
-morkEnv*
-orkinPortTableCursor::CanUsePortTableCursor(nsIMdbEnv* mev,
- mork_bool inMutable, mdb_err* outErr) const
-{
- morkEnv* outEnv = 0;
- morkEnv* ev = morkEnv::FromMdbEnv(mev);
- if ( ev )
- {
- morkPortTableCursor* self = (morkPortTableCursor*)
- this->GetGoodHandleObject(ev, inMutable, morkMagic_kPortTableCursor,
- /*inClosedOkay*/ morkBool_kFalse);
- if ( self )
- {
- if ( self->IsPortTableCursor() )
- outEnv = ev;
- else
- self->NonPortTableCursorTypeError(ev);
- }
- *outErr = ev->AsErr();
- }
- MORK_ASSERT(outEnv);
- return outEnv;
-}
-
-// { ===== begin nsIMdbISupports methods =====
-NS_IMPL_QUERY_INTERFACE0(orkinPortTableCursor)
-
-/*virtual*/ nsrefcnt
-orkinPortTableCursor::AddRef() // add strong ref with no
-{
- morkEnv* ev = mHandle_Env;
- if ( ev && ev->IsEnv() )
- return this->Handle_AddStrongRef(ev->AsMdbEnv());
- else
- return morkEnv_kNonEnvTypeError;
-}
-
-/*virtual*/ nsrefcnt
-orkinPortTableCursor::Release() // cut strong ref
-{
- morkEnv* ev = mHandle_Env;
- if ( ev && ev->IsEnv() )
- return this->Handle_CutStrongRef(ev->AsMdbEnv());
- else
- return morkEnv_kNonEnvTypeError;
-}
-// } ===== end nsIMdbObject methods =====
-
-
-// { ===== begin nsIMdbObject methods =====
-
-// { ----- begin attribute methods -----
-/*virtual*/ mdb_err
-orkinPortTableCursor::IsFrozenMdbObject(nsIMdbEnv* mev, mdb_bool* outIsReadonly)
-{
- return this->Handle_IsFrozenMdbObject(mev, outIsReadonly);
-}
-// same as nsIMdbPort::GetIsPortReadonly() when this object is inside a port.
-// } ----- end attribute methods -----
-
-// { ----- begin factory methods -----
-/*virtual*/ mdb_err
-orkinPortTableCursor::GetMdbFactory(nsIMdbEnv* mev, nsIMdbFactory** acqFactory)
-{
- return this->Handle_GetMdbFactory(mev, acqFactory);
-}
-// } ----- end factory methods -----
-
-// { ----- begin ref counting for well-behaved cyclic graphs -----
-/*virtual*/ mdb_err
-orkinPortTableCursor::GetWeakRefCount(nsIMdbEnv* mev, // weak refs
- mdb_count* outCount)
-{
- return this->Handle_GetWeakRefCount(mev, outCount);
-}
-/*virtual*/ mdb_err
-orkinPortTableCursor::GetStrongRefCount(nsIMdbEnv* mev, // strong refs
- mdb_count* outCount)
-{
- return this->Handle_GetStrongRefCount(mev, outCount);
-}
-
-/*virtual*/ mdb_err
-orkinPortTableCursor::AddWeakRef(nsIMdbEnv* mev)
-{
- return this->Handle_AddWeakRef(mev);
-}
-/*virtual*/ mdb_err
-orkinPortTableCursor::AddStrongRef(nsIMdbEnv* mev)
-{
- return this->Handle_AddStrongRef(mev);
-}
-
-/*virtual*/ mdb_err
-orkinPortTableCursor::CutWeakRef(nsIMdbEnv* mev)
-{
- return this->Handle_CutWeakRef(mev);
-}
-/*virtual*/ mdb_err
-orkinPortTableCursor::CutStrongRef(nsIMdbEnv* mev)
-{
- return this->Handle_CutStrongRef(mev);
-}
-
-/*virtual*/ mdb_err
-orkinPortTableCursor::CloseMdbObject(nsIMdbEnv* mev)
-{
- return this->Handle_CloseMdbObject(mev);
-}
-
-/*virtual*/ mdb_err
-orkinPortTableCursor::IsOpenMdbObject(nsIMdbEnv* mev, mdb_bool* outOpen)
-{
- return this->Handle_IsOpenMdbObject(mev, outOpen);
-}
-// } ----- end ref counting -----
-
-// } ===== end nsIMdbObject methods =====
-
-// { ===== begin nsIMdbCursor methods =====
-
-// { ----- begin attribute methods -----
-/*virtual*/ mdb_err
-orkinPortTableCursor::GetCount(nsIMdbEnv* mev, mdb_count* outCount)
-{
- mdb_err outErr = 0;
- mdb_count count = 0;
- morkEnv* ev =
- this->CanUsePortTableCursor(mev, /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- ev->StubMethodOnlyError();
- outErr = ev->AsErr();
- }
- if ( outCount )
- *outCount = count;
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinPortTableCursor::GetSeed(nsIMdbEnv* mev, mdb_seed* outSeed)
-{
- mdb_err outErr = 0;
- mdb_seed seed = 0;
- morkEnv* ev =
- this->CanUsePortTableCursor(mev, /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- ev->StubMethodOnlyError();
- outErr = ev->AsErr();
- }
- if ( outSeed )
- *outSeed = seed;
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinPortTableCursor::SetPos(nsIMdbEnv* mev, mdb_pos inPos)
-{
- MORK_USED_1(inPos);
- mdb_err outErr = 0;
- morkEnv* ev =
- this->CanUsePortTableCursor(mev, /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- ev->StubMethodOnlyError();
- outErr = ev->AsErr();
- }
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinPortTableCursor::GetPos(nsIMdbEnv* mev, mdb_pos* outPos)
-{
- mdb_err outErr = 0;
- mdb_pos pos = 0;
- morkEnv* ev =
- this->CanUsePortTableCursor(mev, /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- ev->StubMethodOnlyError();
- outErr = ev->AsErr();
- }
- if ( outPos )
- *outPos = pos;
-
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinPortTableCursor::SetDoFailOnSeedOutOfSync(nsIMdbEnv* mev, mdb_bool inFail)
-{
- MORK_USED_1(inFail);
- mdb_err outErr = 0;
- morkEnv* ev =
- this->CanUsePortTableCursor(mev, /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- ev->StubMethodOnlyError();
- outErr = ev->AsErr();
- }
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinPortTableCursor::GetDoFailOnSeedOutOfSync(nsIMdbEnv* mev, mdb_bool* outFail)
-{
- mdb_err outErr = 0;
- mdb_bool fail = 0;
- morkEnv* ev =
- this->CanUsePortTableCursor(mev, /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- ev->StubMethodOnlyError();
- outErr = ev->AsErr();
- }
- if ( outFail )
- *outFail = fail;
- return outErr;
-}
-// } ----- end attribute methods -----
-
-// } ===== end nsIMdbCursor methods =====
-
-// { ===== begin nsIMdbPortTableCursor methods =====
-
-// { ----- begin attribute methods -----
-/*virtual*/ mdb_err
-orkinPortTableCursor::SetPort(nsIMdbEnv* mev, nsIMdbPort* ioPort)
-{
- MORK_USED_1(ioPort);
- mdb_err outErr = 0;
- morkEnv* ev =
- this->CanUsePortTableCursor(mev, /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- ev->StubMethodOnlyError();
- outErr = ev->AsErr();
- }
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinPortTableCursor::GetPort(nsIMdbEnv* mev, nsIMdbPort** acqPort)
-{
- mdb_err outErr = 0;
- nsIMdbPort* outPort = 0;
- morkEnv* ev =
- this->CanUsePortTableCursor(mev, /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- morkPortTableCursor* cursor = (morkPortTableCursor*) mHandle_Object;
- morkStore* store = cursor->mPortTableCursor_Store;
- if ( store )
- outPort = store->AcquireStoreHandle(ev);
- outErr = ev->AsErr();
- }
- if ( acqPort )
- *acqPort = outPort;
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinPortTableCursor::SetRowScope(nsIMdbEnv* mev, // sets pos to -1
- mdb_scope inRowScope)
-{
- mdb_err outErr = 0;
- morkEnv* ev =
- this->CanUsePortTableCursor(mev, /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- morkPortTableCursor* cursor = (morkPortTableCursor*) mHandle_Object;
- cursor->mCursor_Pos = -1;
-
- cursor->SetRowScope(ev, inRowScope);
- outErr = ev->AsErr();
- }
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinPortTableCursor::GetRowScope(nsIMdbEnv* mev, mdb_scope* outRowScope)
-{
- mdb_err outErr = 0;
- mdb_scope rowScope = 0;
- morkEnv* ev =
- this->CanUsePortTableCursor(mev, /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- morkPortTableCursor* cursor = (morkPortTableCursor*) mHandle_Object;
- rowScope = cursor->mPortTableCursor_RowScope;
- outErr = ev->AsErr();
- }
- *outRowScope = rowScope;
- return outErr;
-}
-// setting row scope to zero iterates over all row scopes in port
-
-/*virtual*/ mdb_err
-orkinPortTableCursor::SetTableKind(nsIMdbEnv* mev, // sets pos to -1
- mdb_kind inTableKind)
-{
- mdb_err outErr = 0;
- morkEnv* ev =
- this->CanUsePortTableCursor(mev, /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- morkPortTableCursor* cursor = (morkPortTableCursor*) mHandle_Object;
- cursor->mCursor_Pos = -1;
-
- cursor->SetTableKind(ev, inTableKind);
- outErr = ev->AsErr();
- }
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinPortTableCursor::GetTableKind(nsIMdbEnv* mev, mdb_kind* outTableKind)
-// setting table kind to zero iterates over all table kinds in row scope
-{
- mdb_err outErr = 0;
- mdb_kind tableKind = 0;
- morkEnv* ev =
- this->CanUsePortTableCursor(mev, /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- morkPortTableCursor* cursor = (morkPortTableCursor*) mHandle_Object;
- tableKind = cursor->mPortTableCursor_TableKind;
- outErr = ev->AsErr();
- }
- *outTableKind = tableKind;
- return outErr;
-}
-// } ----- end attribute methods -----
-
-// { ----- begin table iteration methods -----
-/*virtual*/ mdb_err
-orkinPortTableCursor::NextTable( // get table at next position in the db
- nsIMdbEnv* mev, // context
- nsIMdbTable** acqTable)
-{
- mdb_err outErr = 0;
- nsIMdbTable* outTable = 0;
- morkEnv* ev =
- this->CanUsePortTableCursor(mev, /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- morkPortTableCursor* cursor = (morkPortTableCursor*) mHandle_Object;
- morkTable* table = cursor->NextTable(ev);
- if ( table && ev->Good() )
- outTable = table->AcquireTableHandle(ev);
-
- outErr = ev->AsErr();
- }
- if ( acqTable )
- *acqTable = outTable;
- return outErr;
-}
-// } ----- end table iteration methods -----
-
-// } ===== end nsIMdbPortTableCursor methods =====
-
-
-//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
deleted file mode 100644
--- a/db/mork/src/orkinPortTableCursor.h
+++ /dev/null
@@ -1,198 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (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.mozilla.org/MPL/
- *
- * 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 mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1999
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef _ORKINPORTTABLECURSOR_
-#define _ORKINPORTTABLECURSOR_ 1
-
-#ifndef _MDB_
-#include "mdb.h"
-#endif
-
-#ifndef _MORK_
-#include "mork.h"
-#endif
-
-#ifndef _MORKNODE_
-#include "morkNode.h"
-#endif
-
-#ifndef _MORKHANDLE_
-#include "morkHandle.h"
-#endif
-
-#ifndef _MORKPORTTABLECURSOR_
-#include "morkPortTableCursor.h"
-#endif
-
-//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
-
-class morkPortTableCursor;
-#define morkMagic_kPortTableCursor 0x50744375 /* ascii 'PtCu' */
-
-/*| orkinPortTableCursor: cursor class for iterating port tables
-**|
-**|| port: the cursor is associated with a specific port, which can be
-**| set to a different port (which resets the position to -1 so the
-**| next table acquired is the first in the port.
-**|
-|*/
-class orkinPortTableCursor :
- public morkHandle, public nsIMdbPortTableCursor { // nsIMdbCursor
-
-// { ===== begin morkNode interface =====
-public: // morkNode virtual methods
- // virtual void CloseMorkNode(morkEnv* ev); // morkHandle is fine
- virtual ~orkinPortTableCursor(); // morkHandle destructor does everything
-
-protected: // construction is protected (use the static Make() method)
- orkinPortTableCursor(morkEnv* ev, // note morkUsage is always morkUsage_kPool
- morkHandleFace* ioFace, // must not be nil, cookie for this handle
- morkPortTableCursor* ioObject); // must not be nil, the object for this handle
-
- // void CloseHandle(morkEnv* ev); // don't need to specialize closing
-
-private: // copying is not allowed
- orkinPortTableCursor(const morkHandle& other);
- orkinPortTableCursor& operator=(const morkHandle& other);
-
-// public: // dynamic type identification
- // mork_bool IsHandle() const //
- // { return IsNode() && mNode_Derived == morkDerived_kHandle; }
-// } ===== end morkNode methods =====
-
-protected: // morkHandle memory management operators
- void* operator new(size_t inSize, morkPool& ioPool, morkZone& ioZone, morkEnv* ev) CPP_THROW_NEW
- { return ioPool.NewHandle(ev, inSize, &ioZone); }
-
- void* operator new(size_t inSize, morkPool& ioPool, morkEnv* ev) CPP_THROW_NEW
- { return ioPool.NewHandle(ev, inSize, (morkZone*) 0); }
-
- void* operator new(size_t inSize, morkHandleFace* ioFace) CPP_THROW_NEW
- { MORK_USED_1(inSize); return ioFace; }
-
-
-public: // construction:
-
- static orkinPortTableCursor* MakePortTableCursor(morkEnv* ev,
- morkPortTableCursor* ioObject);
-
-public: // utilities:
-
- morkEnv* CanUsePortTableCursor(nsIMdbEnv* mev, mork_bool inMutable,
- mdb_err* outErr) const;
-
-public: // type identification
- mork_bool IsOrkinPortTableCursor() const
- { return mHandle_Magic == morkMagic_kPortTableCursor; }
-
- mork_bool IsOrkinPortTableCursorHandle() const
- { return this->IsHandle() && this->IsOrkinPortTableCursor(); }
-
- NS_DECL_ISUPPORTS
-// { ===== begin nsIMdbObject methods =====
-
- // { ----- begin attribute methods -----
- NS_IMETHOD IsFrozenMdbObject(nsIMdbEnv* ev, mdb_bool* outIsReadonly);
- // same as nsIMdbPort::GetIsPortReadonly() when this object is inside a port.
- // } ----- end attribute methods -----
-
- // { ----- begin factory methods -----
- NS_IMETHOD GetMdbFactory(nsIMdbEnv* ev, nsIMdbFactory** acqFactory);
- // } ----- end factory methods -----
-
- // { ----- begin ref counting for well-behaved cyclic graphs -----
- NS_IMETHOD GetWeakRefCount(nsIMdbEnv* ev, // weak refs
- mdb_count* outCount);
- NS_IMETHOD GetStrongRefCount(nsIMdbEnv* ev, // strong refs
- mdb_count* outCount);
-
- NS_IMETHOD AddWeakRef(nsIMdbEnv* ev);
- NS_IMETHOD AddStrongRef(nsIMdbEnv* ev);
-
- NS_IMETHOD CutWeakRef(nsIMdbEnv* ev);
- NS_IMETHOD CutStrongRef(nsIMdbEnv* ev);
-
- NS_IMETHOD CloseMdbObject(nsIMdbEnv* ev); // called at strong refs zero
- NS_IMETHOD IsOpenMdbObject(nsIMdbEnv* ev, mdb_bool* outOpen);
- // } ----- end ref counting -----
-
-// } ===== end nsIMdbObject methods =====
-
-// { ===== begin nsIMdbCursor methods =====
-
- // { ----- begin attribute methods -----
- NS_IMETHOD GetCount(nsIMdbEnv* ev, mdb_count* outCount); // readonly
- NS_IMETHOD GetSeed(nsIMdbEnv* ev, mdb_seed* outSeed); // readonly
-
- NS_IMETHOD SetPos(nsIMdbEnv* ev, mdb_pos inPos); // mutable
- NS_IMETHOD GetPos(nsIMdbEnv* ev, mdb_pos* outPos);
-
- NS_IMETHOD SetDoFailOnSeedOutOfSync(nsIMdbEnv* ev, mdb_bool inFail);
- NS_IMETHOD GetDoFailOnSeedOutOfSync(nsIMdbEnv* ev, mdb_bool* outFail);
- // } ----- end attribute methods -----
-
-// } ===== end nsIMdbCursor methods =====
-
-// { ===== begin nsIMdbPortTableCursor methods =====
-
- // { ----- begin attribute methods -----
- NS_IMETHOD SetPort(nsIMdbEnv* ev, nsIMdbPort* ioPort); // sets pos to -1
- NS_IMETHOD GetPort(nsIMdbEnv* ev, nsIMdbPort** acqPort);
-
- NS_IMETHOD SetRowScope(nsIMdbEnv* ev, // sets pos to -1
- mdb_scope inRowScope);
- NS_IMETHOD GetRowScope(nsIMdbEnv* ev, mdb_scope* outRowScope);
- // setting row scope to zero iterates over all row scopes in port
-
- NS_IMETHOD SetTableKind(nsIMdbEnv* ev, // sets pos to -1
- mdb_kind inTableKind);
- NS_IMETHOD GetTableKind(nsIMdbEnv* ev, mdb_kind* outTableKind);
- // setting table kind to zero iterates over all table kinds in row scope
- // } ----- end attribute methods -----
-
- // { ----- begin table iteration methods -----
- NS_IMETHOD NextTable( // get table at next position in the db
- nsIMdbEnv* ev, // context
- nsIMdbTable** acqTable); // the next table in the iteration
- // } ----- end table iteration methods -----
-
-// } ===== end nsIMdbPortTableCursor methods =====
-};
-
-//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
-
-#endif /* _ORKINPORTTABLECURSOR_ */
deleted file mode 100644
--- a/db/mork/src/orkinRow.cpp
+++ /dev/null
@@ -1,849 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (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.mozilla.org/MPL/
- *
- * 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 mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1999
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef _MDB_
-#include "mdb.h"
-#endif
-
-#ifndef _MORK_
-#include "mork.h"
-#endif
-
-#ifndef _MORKNODE_
-#include "morkNode.h"
-#endif
-
-#ifndef _MORKHANDLE_
-#include "morkHandle.h"
-#endif
-
-#ifndef _MORKATOM_
-#include "morkAtom.h"
-#endif
-
-#ifndef _MORKROW_
-#include "morkRow.h"
-#endif
-
-#ifndef _ORKINROW_
-#include "orkinRow.h"
-#endif
-
-#ifndef _MORKENV_
-#include "morkEnv.h"
-#endif
-
-#ifndef _MORKROWOBJECT_
-#include "morkRowObject.h"
-#endif
-
-#ifndef _MORKCELLOBJECT_
-#include "morkCellObject.h"
-#endif
-
-#ifndef _MORKSTORE_
-#include "morkStore.h"
-#endif
-
-#ifndef _ORKINSTORE_
-#include "orkinStore.h"
-#endif
-
-#ifndef _MORKROWSPACE_
-#include "morkRowSpace.h"
-#endif
-
-#ifndef _MORKROWCELLCURSOR_
-#include "morkRowCellCursor.h"
-#endif
-
-#ifndef _ORKINROWCELLCURSOR_
-#include "orkinRowCellCursor.h"
-#endif
-
-#ifndef _ORKINCELL_
-#include "orkinCell.h"
-#endif
-
-//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
-
-/* public virtual*/
-orkinRow:: ~orkinRow() // morkHandle destructor does everything
-{
-}
-
-/*protected non-poly construction*/
-orkinRow::orkinRow(morkEnv* ev, // morkUsage is morkUsage_kPool
- morkHandleFace* ioFace, // must not be nil, cookie for this handle
- morkRowObject* ioObject) // must not be nil, the object for this handle
-: morkHandle(ev, ioFace, ioObject, morkMagic_kRow)
-{
- // do not modify mNode_Derived; leave it equal to morkDerived_kHandle
-}
-
-
-/*static */ orkinRow*
-orkinRow::MakeRow(morkEnv* ev, morkRowObject* ioObject)
-{
- mork_bool isEnv = ev->IsEnv();
- MORK_ASSERT(isEnv);
- if ( isEnv )
- {
- morkHandleFace* face = ev->NewHandle(sizeof(orkinRow));
- if ( face )
- return new(face) orkinRow(ev, face, ioObject);
- else
- ev->OutOfMemoryError();
- }
-
- return (orkinRow*) 0;
-}
-
-morkEnv*
-orkinRow::CanUseRow(nsIMdbEnv* mev, mork_bool inMutable,
- mdb_err* outErr, morkRow** outRow) const
-{
- morkEnv* outEnv = 0;
- morkRow* innerRow = 0;
- morkEnv* ev = morkEnv::FromMdbEnv(mev);
- if ( ev )
- {
- morkRowObject* rowObj = (morkRowObject*)
- this->GetGoodHandleObject(ev, inMutable, morkMagic_kRow,
- /*inClosedOkay*/ morkBool_kFalse);
- if ( rowObj )
- {
- if ( rowObj->IsRowObject() )
- {
- morkRow* row = rowObj->mRowObject_Row;
- if ( row )
- {
- if ( row->IsRow() )
- {
- if ( row->mRow_Object == rowObj )
- {
- outEnv = ev;
- innerRow = row;
- }
- else
- rowObj->RowObjectRowNotSelfError(ev);
- }
- else
- row->NonRowTypeError(ev);
- }
- else
- rowObj->NilRowError(ev);
- }
- else
- rowObj->NonRowObjectTypeError(ev);
- }
- *outErr = ev->AsErr();
- }
- if ( outRow )
- *outRow = innerRow;
- MORK_ASSERT(outEnv);
- return outEnv;
-}
-
-morkStore*
-orkinRow::CanUseRowStore(morkEnv* ev) const
-{
- morkStore* outStore = 0;
- morkRowObject* rowObj = (morkRowObject*) mHandle_Object;
- if ( rowObj && rowObj->IsRowObject() )
- {
- morkStore* store = rowObj->mRowObject_Store;
- if ( store )
- {
- if ( store->IsStore() )
- {
- outStore = store;
- }
- else
- store->NonStoreTypeError(ev);
- }
- else
- rowObj->NilStoreError(ev);
- }
- return outStore;
-}
-
-
-// { ===== begin nsISupports methods =====
-NS_IMPL_QUERY_INTERFACE1(orkinRow, nsIMdbRow)
-
-/*virtual*/ nsrefcnt
-orkinRow::AddRef() // add strong ref with no
-{
- morkEnv* ev = mHandle_Env;
- if ( ev && ev->IsEnv() )
- return this->Handle_AddStrongRef(ev->AsMdbEnv());
- else
- return morkEnv_kNonEnvTypeError;
-}
-
-/*virtual*/ nsrefcnt
-orkinRow::Release() // cut strong ref
-{
- morkEnv* ev = mHandle_Env;
- if ( ev && ev->IsEnv() )
- return this->Handle_CutStrongRef(ev->AsMdbEnv());
- else
- return morkEnv_kNonEnvTypeError;
-}
-// } ===== end nsIMdbObject methods =====
-
-
-// { ===== begin nsIMdbObject methods =====
-
-// { ----- begin attribute methods -----
-/*virtual*/ mdb_err
-orkinRow::IsFrozenMdbObject(nsIMdbEnv* mev, mdb_bool* outIsReadonly)
-{
- return this->Handle_IsFrozenMdbObject(mev, outIsReadonly);
-}
-// same as nsIMdbPort::GetIsPortReadonly() when this object is inside a port.
-// } ----- end attribute methods -----
-
-// { ----- begin factory methods -----
-/*virtual*/ mdb_err
-orkinRow::GetMdbFactory(nsIMdbEnv* mev, nsIMdbFactory** acqFactory)
-{
- return this->Handle_GetMdbFactory(mev, acqFactory);
-}
-// } ----- end factory methods -----
-
-// { ----- begin ref counting for well-behaved cyclic graphs -----
-/*virtual*/ mdb_err
-orkinRow::GetWeakRefCount(nsIMdbEnv* mev, // weak refs
- mdb_count* outCount)
-{
- return this->Handle_GetWeakRefCount(mev, outCount);
-}
-/*virtual*/ mdb_err
-orkinRow::GetStrongRefCount(nsIMdbEnv* mev, // strong refs
- mdb_count* outCount)
-{
- return this->Handle_GetStrongRefCount(mev, outCount);
-}
-
-/*virtual*/ mdb_err
-orkinRow::AddWeakRef(nsIMdbEnv* mev)
-{
- return this->Handle_AddWeakRef(mev);
-}
-/*virtual*/ mdb_err
-orkinRow::AddStrongRef(nsIMdbEnv* mev)
-{
- return this->Handle_AddStrongRef(mev);
-}
-
-/*virtual*/ mdb_err
-orkinRow::CutWeakRef(nsIMdbEnv* mev)
-{
- return this->Handle_CutWeakRef(mev);
-}
-/*virtual*/ mdb_err
-orkinRow::CutStrongRef(nsIMdbEnv* mev)
-{
- return this->Handle_CutStrongRef(mev);
-}
-
-/*virtual*/ mdb_err
-orkinRow::CloseMdbObject(nsIMdbEnv* mev)
-{
- return this->Handle_CloseMdbObject(mev);
-}
-
-/*virtual*/ mdb_err
-orkinRow::IsOpenMdbObject(nsIMdbEnv* mev, mdb_bool* outOpen)
-{
- return this->Handle_IsOpenMdbObject(mev, outOpen);
-}
-// } ----- end ref counting -----
-
-// } ===== end nsIMdbObject methods =====
-
-
-// { ===== begin nsIMdbCollection methods =====
-
-// { ----- begin attribute methods -----
-/*virtual*/ mdb_err
-orkinRow::GetSeed(nsIMdbEnv* mev,
- mdb_seed* outSeed)
-{
- mdb_err outErr = 0;
- morkRow* row = 0;
- morkEnv* ev = this->CanUseRow(mev, /*inMutable*/ morkBool_kFalse,
- &outErr, &row);
- if ( ev )
- {
- *outSeed = (mdb_seed) row->mRow_Seed;
- outErr = ev->AsErr();
- }
- return outErr;
-}
-/*virtual*/ mdb_err
-orkinRow::GetCount(nsIMdbEnv* mev,
- mdb_count* outCount)
-{
- mdb_err outErr = 0;
- morkRow* row = 0;
- morkEnv* ev = this->CanUseRow(mev, /*inMutable*/ morkBool_kFalse,
- &outErr, &row);
- if ( ev )
- {
- *outCount = (mdb_count) row->mRow_Length;
- outErr = ev->AsErr();
- }
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinRow::GetPort(nsIMdbEnv* mev,
- nsIMdbPort** acqPort)
-{
- mdb_err outErr = 0;
- nsIMdbPort* outPort = 0;
- morkRow* row = 0;
- morkEnv* ev = this->CanUseRow(mev, /*inMutable*/ morkBool_kFalse,
- &outErr, &row);
- if ( ev )
- {
- morkRowSpace* rowSpace = row->mRow_Space;
- if ( rowSpace && rowSpace->mSpace_Store )
- {
- morkStore* store = row->GetRowSpaceStore(ev);
- if ( store )
- outPort = store->AcquireStoreHandle(ev);
- }
- else
- ev->NilPointerError();
-
- outErr = ev->AsErr();
- }
- if ( acqPort )
- *acqPort = outPort;
-
- return outErr;
-}
-// } ----- end attribute methods -----
-
-// { ----- begin cursor methods -----
-/*virtual*/ mdb_err
-orkinRow::GetCursor( // make a cursor starting iter at inMemberPos
- nsIMdbEnv* mev, // context
- mdb_pos inMemberPos, // zero-based ordinal pos of member in collection
- nsIMdbCursor** acqCursor)
-{
- return this->GetRowCellCursor(mev, inMemberPos,
- (nsIMdbRowCellCursor**) acqCursor);
-}
-// } ----- end cursor methods -----
-
-// { ----- begin ID methods -----
-/*virtual*/ mdb_err
-orkinRow::GetOid(nsIMdbEnv* mev,
- mdbOid* outOid)
-{
- mdb_err outErr = 0;
- morkRow* row = 0;
- morkEnv* ev = this->CanUseRow(mev, /*inMutable*/ morkBool_kFalse,
- &outErr, &row);
- if ( ev )
- {
- *outOid = row->mRow_Oid;
- outErr = ev->AsErr();
- }
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinRow::BecomeContent(nsIMdbEnv* mev,
- const mdbOid* inOid)
-{
- MORK_USED_1(inOid);
- mdb_err outErr = 0;
- morkRow* row = 0;
- morkEnv* ev = this->CanUseRow(mev, /*inMutable*/ morkBool_kFalse,
- &outErr, &row);
- if ( ev )
- {
- // remember row->MaybeDirtySpaceStoreAndRow();
-
- ev->StubMethodOnlyError();
- outErr = ev->AsErr();
- }
- return outErr;
-}
-// } ----- end ID methods -----
-
-// { ----- begin activity dropping methods -----
-/*virtual*/ mdb_err
-orkinRow::DropActivity( // tell collection usage no longer expected
- nsIMdbEnv* mev)
-{
- mdb_err outErr = 0;
- morkRow* row = 0;
- morkEnv* ev = this->CanUseRow(mev, /*inMutable*/ morkBool_kFalse,
- &outErr, &row);
- if ( ev )
- {
- // ev->StubMethodOnlyError(); // do nothing
- outErr = ev->AsErr();
- }
- return outErr;
- }
-// } ----- end activity dropping methods -----
-
-// } ===== end nsIMdbCollection methods =====
-
-// { ===== begin nsIMdbRow methods =====
-
-// { ----- begin cursor methods -----
-/*virtual*/ mdb_err
-orkinRow::GetRowCellCursor( // make a cursor starting iteration at inRowPos
- nsIMdbEnv* mev, // context
- mdb_pos inPos, // zero-based ordinal position of row in table
- nsIMdbRowCellCursor** acqCursor)
-{
- mdb_err outErr = 0;
- nsIMdbRowCellCursor* outCursor = 0;
- morkRow* row = 0;
- morkEnv* ev = this->CanUseRow(mev, /*inMutable*/ morkBool_kFalse,
- &outErr, &row);
- if ( ev )
- {
- morkRowCellCursor* cursor = row->NewRowCellCursor(ev, inPos);
- if ( cursor )
- {
- if ( ev->Good() )
- {
- cursor->mCursor_Seed = (mork_seed) inPos;
- outCursor = cursor->AcquireRowCellCursorHandle(ev);
- }
- else
- cursor->CutStrongRef(mev);
- }
- outErr = ev->AsErr();
- }
- if ( acqCursor )
- *acqCursor = outCursor;
- return outErr;
-}
-// } ----- end cursor methods -----
-
-// { ----- begin column methods -----
-/*virtual*/ mdb_err
-orkinRow::AddColumn( // make sure a particular column is inside row
- nsIMdbEnv* mev, // context
- mdb_column inColumn, // column to add
- const mdbYarn* inYarn)
-{
- mdb_err outErr = 0;
- morkRow* row = 0;
- morkEnv* ev = this->CanUseRow(mev, /*inMutable*/ morkBool_kFalse,
- &outErr, &row);
- if ( ev )
- {
- morkStore* store = this->CanUseRowStore(ev);
- if ( store )
- row->AddColumn(ev, inColumn, inYarn, store);
-
- outErr = ev->AsErr();
- }
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinRow::CutColumn( // make sure a column is absent from the row
- nsIMdbEnv* mev, // context
- mdb_column inColumn)
-{
- mdb_err outErr = 0;
- morkRow* row = 0;
- morkEnv* ev = this->CanUseRow(mev, /*inMutable*/ morkBool_kFalse,
- &outErr, &row);
- if ( ev )
- {
- row->CutColumn(ev, inColumn);
- outErr = ev->AsErr();
- }
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinRow::CutAllColumns( // remove all columns from the row
- nsIMdbEnv* mev)
-{
- mdb_err outErr = 0;
- morkRow* row = 0;
- morkEnv* ev = this->CanUseRow(mev, /*inMutable*/ morkBool_kFalse,
- &outErr, &row);
- if ( ev )
- {
- row->CutAllColumns(ev);
- outErr = ev->AsErr();
- }
- return outErr;
-}
-// } ----- end column methods -----
-
-// { ----- begin cell methods -----
-/*virtual*/ mdb_err
-orkinRow::NewCell( // get cell for specified column, or add new one
- nsIMdbEnv* mev, // context
- mdb_column inColumn, // column to add
- nsIMdbCell** acqCell)
-{
- mdb_err outErr = 0;
- nsIMdbCell* outCell = 0;
- morkRow* row = 0;
- morkEnv* ev = this->CanUseRow(mev, /*inMutable*/ morkBool_kFalse,
- &outErr, &row);
- if ( ev )
- {
- mork_pos pos = 0;
- morkCell* cell = row->GetCell(ev, inColumn, &pos);
- if ( !cell )
- {
- morkStore* store = this->CanUseRowStore(ev);
- if ( store )
- {
- mdbYarn yarn; // to pass empty yarn into morkRow::AddColumn()
- yarn.mYarn_Buf = 0;
- yarn.mYarn_Fill = 0;
- yarn.mYarn_Size = 0;
- yarn.mYarn_More = 0;
- yarn.mYarn_Form = 0;
- yarn.mYarn_Grow = 0;
- row->AddColumn(ev, inColumn, &yarn, store);
- cell = row->GetCell(ev, inColumn, &pos);
- }
- }
- if ( cell )
- outCell = row->AcquireCellHandle(ev, cell, inColumn, pos);
-
- outErr = ev->AsErr();
- }
- if ( acqCell )
- *acqCell = outCell;
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinRow::AddCell( // copy a cell from another row to this row
- nsIMdbEnv* mev, // context
- const nsIMdbCell* inCell)
-{
- mdb_err outErr = 0;
- morkRow* row = 0;
- morkEnv* ev = this->CanUseRow(mev, /*inMutable*/ morkBool_kFalse,
- &outErr, &row);
- if ( ev )
- {
- morkCell* cell = 0;
- morkCellObject* cellObj = (morkCellObject*) inCell;
- if ( cellObj->CanUseCell(mev, morkBool_kFalse, &outErr, &cell) )
- {
-
- morkRow* cellRow = cellObj->mCellObject_Row;
- if ( cellRow )
- {
- if ( row != cellRow )
- {
- morkStore* store = row->GetRowSpaceStore(ev);
- morkStore* cellStore = cellRow->GetRowSpaceStore(ev);
- if ( store && cellStore )
- {
- mork_column col = cell->GetColumn();
- morkAtom* atom = cell->mCell_Atom;
- mdbYarn yarn;
- atom->AliasYarn(&yarn); // works even when atom is nil
-
- if ( store != cellStore )
- col = store->CopyToken(ev, col, cellStore);
- if ( ev->Good() )
- row->AddColumn(ev, col, &yarn, store);
- }
- else
- ev->NilPointerError();
- }
- }
- else
- ev->NilPointerError();
- }
-
- outErr = ev->AsErr();
- }
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinRow::GetCell( // find a cell in this row
- nsIMdbEnv* mev, // context
- mdb_column inColumn, // column to find
- nsIMdbCell** acqCell)
-{
- mdb_err outErr = 0;
- nsIMdbCell* outCell = 0;
- morkRow* row = 0;
- morkEnv* ev = this->CanUseRow(mev, /*inMutable*/ morkBool_kFalse,
- &outErr, &row);
- if ( ev )
- {
- if ( inColumn )
- {
- mork_pos pos = 0;
- morkCell* cell = row->GetCell(ev, inColumn, &pos);
- if ( cell )
- {
- outCell = row->AcquireCellHandle(ev, cell, inColumn, pos);
- }
- }
- else
- row->ZeroColumnError(ev);
-
- outErr = ev->AsErr();
- }
- if ( acqCell )
- *acqCell = outCell;
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinRow::EmptyAllCells( // make all cells in row empty of content
- nsIMdbEnv* mev)
-{
- mdb_err outErr = 0;
- morkRow* row = 0;
- morkEnv* ev = this->CanUseRow(mev, /*inMutable*/ morkBool_kFalse,
- &outErr, &row);
- if ( ev )
- {
- row->EmptyAllCells(ev);
- outErr = ev->AsErr();
- }
- return outErr;
-}
-// } ----- end cell methods -----
-
-// { ----- begin row methods -----
-/*virtual*/ mdb_err
-orkinRow::AddRow( // add all cells in another row to this one
- nsIMdbEnv* mev, // context
- nsIMdbRow* ioSourceRow)
-{
- mdb_err outErr = 0;
- morkRow* row = 0;
- morkEnv* ev = this->CanUseRow(mev, /*inMutable*/ morkBool_kFalse,
- &outErr, &row);
- if ( ev )
- {
- morkRow* source = 0;
- orkinRow* unsafeSource = (orkinRow*) ioSourceRow; // unsafe cast
- if ( unsafeSource->CanUseRow(mev, morkBool_kFalse, &outErr, &source) )
- {
- row->AddRow(ev, source);
- }
- outErr = ev->AsErr();
- }
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinRow::SetRow( // make exact duplicate of another row
- nsIMdbEnv* mev, // context
- nsIMdbRow* ioSourceRow)
-{
- mdb_err outErr = 0;
- morkRow* row = 0;
- morkEnv* ev = this->CanUseRow(mev, /*inMutable*/ morkBool_kFalse,
- &outErr, &row);
- if ( ev )
- {
- morkRow* source = 0;
- orkinRow* unsafeSource = (orkinRow*) ioSourceRow; // unsafe cast
- if ( unsafeSource->CanUseRow(mev, morkBool_kFalse, &outErr, &source) )
- {
- row->SetRow(ev, source);
- }
- outErr = ev->AsErr();
- }
- return outErr;
-}
-// } ----- end row methods -----
-
-// { ----- begin blob methods -----
-/*virtual*/ mdb_err
-orkinRow::SetCellYarn( // synonym for AddColumn()
- nsIMdbEnv* mev, // context
- mdb_column inColumn, // column to add
- const mdbYarn* inYarn)
-{
- mdb_err outErr = 0;
- morkRow* row = 0;
- morkEnv* ev = this->CanUseRow(mev, /*inMutable*/ morkBool_kFalse,
- &outErr, &row);
- if ( ev )
- {
- morkStore* store = this->CanUseRowStore(ev);
- if ( store )
- row->AddColumn(ev, inColumn, inYarn, store);
-
- outErr = ev->AsErr();
- }
- return outErr;
-}
-/*virtual*/ mdb_err
-orkinRow::GetCellYarn(
- nsIMdbEnv* mev, // context
- mdb_column inColumn, // column to read
- mdbYarn* outYarn) // writes some yarn slots
-// copy content into the yarn buffer, and update mYarn_Fill and mYarn_Form
-{
- mdb_err outErr = 0;
- morkRow* row = 0;
- morkEnv* ev = this->CanUseRow(mev, /*inMutable*/ morkBool_kFalse,
- &outErr, &row);
- if ( ev )
- {
- morkStore* store = this->CanUseRowStore(ev);
- if ( store )
- {
- morkAtom* atom = row->GetColumnAtom(ev, inColumn);
- atom->GetYarn(outYarn);
- // note nil atom works and sets yarn correctly
- }
-
- outErr = ev->AsErr();
- }
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinRow::AliasCellYarn(
- nsIMdbEnv* mev, // context
- mdb_column inColumn, // column to alias
- mdbYarn* outYarn) // writes ALL yarn slots
-{
- mdb_err outErr = 0;
- morkRow* row = 0;
- morkEnv* ev = this->CanUseRow(mev, /*inMutable*/ morkBool_kFalse,
- &outErr, &row);
- if ( ev )
- {
- morkStore* store = this->CanUseRowStore(ev);
- if ( store )
- {
- morkAtom* atom = row->GetColumnAtom(ev, inColumn);
- atom->AliasYarn(outYarn);
- // note nil atom works and sets yarn correctly
- }
- outErr = ev->AsErr();
- }
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinRow::NextCellYarn(nsIMdbEnv* mev, // iterative version of GetCellYarn()
- mdb_column* ioColumn, // next column to read
- mdbYarn* outYarn) // writes some yarn slots
-// copy content into the yarn buffer, and update mYarn_Fill and mYarn_Form
-//
-// The ioColumn argument is an inout parameter which initially contains the
-// last column accessed and returns the next column corresponding to the
-// content read into the yarn. Callers should start with a zero column
-// value to say 'no previous column', which causes the first column to be
-// read. Then the value returned in ioColumn is perfect for the next call
-// to NextCellYarn(), since it will then be the previous column accessed.
-// Callers need only examine the column token returned to see which cell
-// in the row is being read into the yarn. When no more columns remain,
-// and the iteration has ended, ioColumn will return a zero token again.
-// So iterating over cells starts and ends with a zero column token.
-{
- mdb_err outErr = 0;
- morkRow* row = 0;
- morkEnv* ev = this->CanUseRow(mev, /*inMutable*/ morkBool_kFalse,
- &outErr, &row);
- if ( ev )
- {
- morkStore* store = this->CanUseRowStore(ev);
- if ( store )
- row->NextColumn(ev, ioColumn, outYarn);
-
- outErr = ev->AsErr();
- }
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinRow::SeekCellYarn( // resembles nsIMdbRowCellCursor::SeekCell()
- nsIMdbEnv* mev, // context
- mdb_pos inPos, // position of cell in row sequence
- mdb_column* outColumn, // column for this particular cell
- mdbYarn* outYarn) // writes some yarn slots
-// copy content into the yarn buffer, and update mYarn_Fill and mYarn_Form
-// Callers can pass nil for outYarn to indicate no interest in content, so
-// only the outColumn value is returned. NOTE to subclasses: you must be
-// able to ignore outYarn when the pointer is nil; please do not crash.
-
-{
- mdb_err outErr = 0;
- morkRow* row = 0;
- morkEnv* ev = this->CanUseRow(mev, /*inMutable*/ morkBool_kFalse,
- &outErr, &row);
- if ( ev )
- {
- morkStore* store = this->CanUseRowStore(ev);
- if ( store )
- row->SeekColumn(ev, inPos, outColumn, outYarn);
-
- outErr = ev->AsErr();
- }
- return outErr;
-}
-
-// } ----- end blob methods -----
-
-
-// } ===== end nsIMdbRow methods =====
-
-
-
-//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
-
deleted file mode 100644
--- a/db/mork/src/orkinRow.h
+++ /dev/null
@@ -1,284 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (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.mozilla.org/MPL/
- *
- * 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 mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1999
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef _ORKINROW_
-#define _ORKINROW_ 1
-
-#ifndef _MDB_
-#include "mdb.h"
-#endif
-
-#ifndef _MORK_
-#include "mork.h"
-#endif
-
-#ifndef _MORKNODE_
-#include "morkNode.h"
-#endif
-
-#ifndef _MORKHANDLE_
-#include "morkHandle.h"
-#endif
-
-#ifndef _MORKROW_
-#include "morkRow.h"
-#endif
-
-//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
-
-#define morkMagic_kRow 0x526F774D /* ascii 'RowM' */
-
-/*| orkinRow: a collection of cells
-**|
-|*/
-class orkinRow : public morkHandle, public nsIMdbRow { // nsIMdbCollection
-
-// { ===== begin morkNode interface =====
-public: // morkNode virtual methods
- // virtual void CloseMorkNode(morkEnv* ev); // morkHandle is fine
- virtual ~orkinRow(); // morkHandle destructor does everything
-
-protected: // construction is protected (use the static Make() method)
- orkinRow(morkEnv* ev, // note morkUsage is always morkUsage_kPool
- morkHandleFace* ioFace, // must not be nil, cookie for this handle
- morkRowObject* ioObject); // must not be nil, the object for this handle
-
- // void CloseHandle(morkEnv* ev); // don't need to specialize closing
-
-private: // copying is not allowed
- orkinRow(const morkHandle& other);
- orkinRow& operator=(const morkHandle& other);
-
-// public: // dynamic type identification
- // mork_bool IsHandle() const //
- // { return IsNode() && mNode_Derived == morkDerived_kHandle; }
-// } ===== end morkNode methods =====
-
-protected: // morkHandle memory management operators
- void* operator new(size_t inSize, morkPool& ioPool, morkZone& ioZone, morkEnv* ev) CPP_THROW_NEW
- { return ioPool.NewHandle(ev, inSize, &ioZone); }
-
- void* operator new(size_t inSize, morkPool& ioPool, morkEnv* ev) CPP_THROW_NEW
- { return ioPool.NewHandle(ev, inSize, (morkZone*) 0); }
-
- void* operator new(size_t inSize, morkHandleFace* ioFace) CPP_THROW_NEW
- { MORK_USED_1(inSize); return ioFace; }
-
-
-public: // construction:
-
- static orkinRow* MakeRow(morkEnv* ev, morkRowObject* ioObject);
-
-public: // utilities:
-
- morkEnv* CanUseRow(nsIMdbEnv* mev, mork_bool inMutable,
- mdb_err* outErr, morkRow** outRow) const;
-
- morkStore* CanUseRowStore(morkEnv* ev) const;
-
-public: // type identification
- mork_bool IsOrkinRow() const
- { return mHandle_Magic == morkMagic_kRow; }
-
- mork_bool IsOrkinRowHandle() const
- { return this->IsHandle() && this->IsOrkinRow(); }
-
- NS_DECL_ISUPPORTS
-// { ===== begin nsIMdbObject methods =====
-
- // { ----- begin attribute methods -----
- NS_IMETHOD IsFrozenMdbObject(nsIMdbEnv* ev, mdb_bool* outIsReadonly);
- // same as nsIMdbPort::GetIsPortReadonly() when this object is inside a port.
- // } ----- end attribute methods -----
-
- // { ----- begin factory methods -----
- NS_IMETHOD GetMdbFactory(nsIMdbEnv* ev, nsIMdbFactory** acqFactory);
- // } ----- end factory methods -----
-
- // { ----- begin ref counting for well-behaved cyclic graphs -----
- NS_IMETHOD GetWeakRefCount(nsIMdbEnv* ev, // weak refs
- mdb_count* outCount);
- NS_IMETHOD GetStrongRefCount(nsIMdbEnv* ev, // strong refs
- mdb_count* outCount);
-
- NS_IMETHOD AddWeakRef(nsIMdbEnv* ev);
- NS_IMETHOD AddStrongRef(nsIMdbEnv* ev);
-
- NS_IMETHOD CutWeakRef(nsIMdbEnv* ev);
- NS_IMETHOD CutStrongRef(nsIMdbEnv* ev);
-
- NS_IMETHOD CloseMdbObject(nsIMdbEnv* ev); // called at strong refs zero
- NS_IMETHOD IsOpenMdbObject(nsIMdbEnv* ev, mdb_bool* outOpen);
- // } ----- end ref counting -----
-
-// } ===== end nsIMdbObject methods =====
-
-// { ===== begin nsIMdbCollection methods =====
-
- // { ----- begin attribute methods -----
- NS_IMETHOD GetSeed(nsIMdbEnv* ev,
- mdb_seed* outSeed); // member change count
- NS_IMETHOD GetCount(nsIMdbEnv* ev,
- mdb_count* outCount); // member count
-
- NS_IMETHOD GetPort(nsIMdbEnv* ev,
- nsIMdbPort** acqPort); // collection container
- // } ----- end attribute methods -----
-
- // { ----- begin cursor methods -----
- NS_IMETHOD GetCursor( // make a cursor starting iter at inMemberPos
- nsIMdbEnv* ev, // context
- mdb_pos inMemberPos, // zero-based ordinal pos of member in collection
- nsIMdbCursor** acqCursor); // acquire new cursor instance
- // } ----- end cursor methods -----
-
- // { ----- begin ID methods -----
- NS_IMETHOD GetOid(nsIMdbEnv* ev,
- mdbOid* outOid); // read object identity
- NS_IMETHOD BecomeContent(nsIMdbEnv* ev,
- const mdbOid* inOid); // exchange content
- // } ----- end ID methods -----
-
- // { ----- begin activity dropping methods -----
- NS_IMETHOD DropActivity( // tell collection usage no longer expected
- nsIMdbEnv* ev);
- // } ----- end activity dropping methods -----
-
-// } ===== end nsIMdbCollection methods =====
-
-// { ===== begin nsIMdbRow methods =====
-
- // { ----- begin cursor methods -----
- NS_IMETHOD GetRowCellCursor( // make a cursor starting iteration at inRowPos
- nsIMdbEnv* ev, // context
- mdb_pos inRowPos, // zero-based ordinal position of row in table
- nsIMdbRowCellCursor** acqCursor); // acquire new cursor instance
- // } ----- end cursor methods -----
-
- // { ----- begin column methods -----
- NS_IMETHOD AddColumn( // make sure a particular column is inside row
- nsIMdbEnv* ev, // context
- mdb_column inColumn, // column to add
- const mdbYarn* inYarn); // cell value to install
-
- NS_IMETHOD CutColumn( // make sure a column is absent from the row
- nsIMdbEnv* ev, // context
- mdb_column inColumn); // column to ensure absent from row
-
- NS_IMETHOD CutAllColumns( // remove all columns from the row
- nsIMdbEnv* ev); // context
- // } ----- end column methods -----
-
- // { ----- begin cell methods -----
- NS_IMETHOD NewCell( // get cell for specified column, or add new one
- nsIMdbEnv* ev, // context
- mdb_column inColumn, // column to add
- nsIMdbCell** acqCell); // cell column and value
-
- NS_IMETHOD AddCell( // copy a cell from another row to this row
- nsIMdbEnv* ev, // context
- const nsIMdbCell* inCell); // cell column and value
-
- NS_IMETHOD GetCell( // find a cell in this row
- nsIMdbEnv* ev, // context
- mdb_column inColumn, // column to find
- nsIMdbCell** acqCell); // cell for specified column, or null
-
- NS_IMETHOD EmptyAllCells( // make all cells in row empty of content
- nsIMdbEnv* ev); // context
- // } ----- end cell methods -----
-
- // { ----- begin row methods -----
- NS_IMETHOD AddRow( // add all cells in another row to this one
- nsIMdbEnv* ev, // context
- nsIMdbRow* ioSourceRow); // row to union with
-
- NS_IMETHOD SetRow( // make exact duplicate of another row
- nsIMdbEnv* ev, // context
- nsIMdbRow* ioSourceRow); // row to duplicate
- // } ----- end row methods -----
-
- // { ----- begin blob methods -----
- NS_IMETHOD SetCellYarn(nsIMdbEnv* ev, // synonym for AddColumn()
- mdb_column inColumn, // column to write
- const mdbYarn* inYarn); // reads from yarn slots
- // make this text object contain content from the yarn's buffer
-
- NS_IMETHOD GetCellYarn(nsIMdbEnv* ev,
- mdb_column inColumn, // column to read
- mdbYarn* outYarn); // writes some yarn slots
- // copy content into the yarn buffer, and update mYarn_Fill and mYarn_Form
-
- NS_IMETHOD AliasCellYarn(nsIMdbEnv* ev,
- mdb_column inColumn, // column to alias
- mdbYarn* outYarn); // writes ALL yarn slots
-
- NS_IMETHOD NextCellYarn(nsIMdbEnv* ev, // iterative version of GetCellYarn()
- mdb_column* ioColumn, // next column to read
- mdbYarn* outYarn); // writes some yarn slots
- // copy content into the yarn buffer, and update mYarn_Fill and mYarn_Form
- //
- // The ioColumn argument is an inout parameter which initially contains the
- // last column accessed and returns the next column corresponding to the
- // content read into the yarn. Callers should start with a zero column
- // value to say 'no previous column', which causes the first column to be
- // read. Then the value returned in ioColumn is perfect for the next call
- // to NextCellYarn(), since it will then be the previous column accessed.
- // Callers need only examine the column token returned to see which cell
- // in the row is being read into the yarn. When no more columns remain,
- // and the iteration has ended, ioColumn will return a zero token again.
- // So iterating over cells starts and ends with a zero column token.
-
- NS_IMETHOD SeekCellYarn( // resembles nsIMdbRowCellCursor::SeekCell()
- nsIMdbEnv* ev, // context
- mdb_pos inPos, // position of cell in row sequence
- mdb_column* outColumn, // column for this particular cell
- mdbYarn* outYarn); // writes some yarn slots
- // copy content into the yarn buffer, and update mYarn_Fill and mYarn_Form
- // Callers can pass nil for outYarn to indicate no interest in content, so
- // only the outColumn value is returned. NOTE to subclasses: you must be
- // able to ignore outYarn when the pointer is nil; please do not crash.
-
- // } ----- end blob methods -----
-
-// } ===== end nsIMdbRow methods =====
-};
-
-//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
-
-#endif /* _ORKINROW_ */
-
deleted file mode 100644
--- a/db/mork/src/orkinRowCellCursor.cpp
+++ /dev/null
@@ -1,564 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (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.mozilla.org/MPL/
- *
- * 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 mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1999
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef _MDB_
-#include "mdb.h"
-#endif
-
-#ifndef _MORK_
-#include "mork.h"
-#endif
-
-#ifndef _MORKNODE_
-#include "morkNode.h"
-#endif
-
-#ifndef _MORKHANDLE_
-#include "morkHandle.h"
-#endif
-
-#ifndef _MORKROWCELLCURSOR_
-#include "morkRowCellCursor.h"
-#endif
-
-#ifndef _ORKINROWCELLCURSOR_
-#include "orkinRowCellCursor.h"
-#endif
-
-#ifndef _MORKROWOBJECT_
-#include "morkRowObject.h"
-#endif
-
-#ifndef _MORKROW_
-#include "morkRow.h"
-#endif
-
-#ifndef _ORKINROW_
-#include "orkinRow.h"
-#endif
-
-#ifndef _MORKCELL_
-#include "morkCell.h"
-#endif
-
-#ifndef _MORKENV_
-#include "morkEnv.h"
-#endif
-
-//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
-
-/* public virtual*/
-orkinRowCellCursor:: ~orkinRowCellCursor() // morkHandle destructor does everything
-{
-}
-
-/*protected non-poly construction*/
-orkinRowCellCursor::orkinRowCellCursor(morkEnv* ev, // morkUsage is morkUsage_kPool
- morkHandleFace* ioFace, // must not be nil, cookie for this handle
- morkRowCellCursor* ioObject) // must not be nil, the object for this handle
-: morkHandle(ev, ioFace, ioObject, morkMagic_kRowCellCursor)
-{
- // do not modify mNode_Derived; leave it equal to morkDerived_kHandle
-}
-
-
-/*static */ orkinRowCellCursor*
-orkinRowCellCursor::MakeRowCellCursor(morkEnv* ev, morkRowCellCursor* ioObject)
-{
- mork_bool isEnv = ev->IsEnv();
- MORK_ASSERT(isEnv);
- if ( isEnv )
- {
- morkHandleFace* face = ev->NewHandle(sizeof(orkinRowCellCursor));
- if ( face )
- return new(face) orkinRowCellCursor(ev, face, ioObject);
- else
- ev->OutOfMemoryError();
- }
-
- return (orkinRowCellCursor*) 0;
-}
-
-morkEnv*
-orkinRowCellCursor::CanUseRowCellCursor(nsIMdbEnv* mev, mork_bool inMutable,
- mdb_err* outErr, morkRow** outRow) const
-{
- morkEnv* outEnv = 0;
- morkRow* row = 0;
- morkEnv* ev = morkEnv::FromMdbEnv(mev);
- if ( ev )
- {
- morkRowCellCursor* self = (morkRowCellCursor*)
- this->GetGoodHandleObject(ev, inMutable, morkMagic_kRowCellCursor,
- /*inClosedOkay*/ morkBool_kFalse);
- if ( self )
- {
- if ( self->IsRowCellCursor() )
- {
- if ( self->IsMutable() || !inMutable )
- {
- morkRowObject* rowObj = self->mRowCellCursor_RowObject;
- if ( rowObj )
- {
- morkRow* theRow = rowObj->mRowObject_Row;
- if ( theRow )
- {
- if ( theRow->IsRow() )
- {
- outEnv = ev;
- row = theRow;
- }
- else
- theRow->NonRowTypeError(ev);
- }
- else
- rowObj->NilRowError(ev);
- }
- else
- self->NilRowObjectError(ev);
- }
- else
- self->NonMutableNodeError(ev);
- }
- else
- self->NonRowCellCursorTypeError(ev);
- }
- *outErr = ev->AsErr();
- }
- *outRow = row;
- MORK_ASSERT(outEnv);
- return outEnv;
-}
-
-// { ===== begin nsIMdbISupports methods =====
-NS_IMPL_QUERY_INTERFACE0(orkinRowCellCursor)
-
-/*virtual*/ nsrefcnt
-orkinRowCellCursor::AddRef() // add strong ref with no
-{
- morkEnv* ev = mHandle_Env;
- if ( ev && ev->IsEnv() )
- return this->Handle_AddStrongRef(ev->AsMdbEnv());
- else
- return morkEnv_kNonEnvTypeError;
-}
-
-/*virtual*/ nsrefcnt
-orkinRowCellCursor::Release() // cut strong ref
-{
- morkEnv* ev = mHandle_Env;
- if ( ev && ev->IsEnv() )
- return this->Handle_CutStrongRef(ev->AsMdbEnv());
- else
- return morkEnv_kNonEnvTypeError;
-}
-// } ===== end nsIMdbObject methods =====
-
-// { ===== begin nsIMdbObject methods =====
-
-// { ----- begin attribute methods -----
-/*virtual*/ mdb_err
-orkinRowCellCursor::IsFrozenMdbObject(nsIMdbEnv* mev, mdb_bool* outIsReadonly)
-{
- return this->Handle_IsFrozenMdbObject(mev, outIsReadonly);
-}
-// same as nsIMdbPort::GetIsPortReadonly() when this object is inside a port.
-// } ----- end attribute methods -----
-
-// { ----- begin factory methods -----
-/*virtual*/ mdb_err
-orkinRowCellCursor::GetMdbFactory(nsIMdbEnv* mev, nsIMdbFactory** acqFactory)
-{
- return this->Handle_GetMdbFactory(mev, acqFactory);
-}
-// } ----- end factory methods -----
-
-// { ----- begin ref counting for well-behaved cyclic graphs -----
-/*virtual*/ mdb_err
-orkinRowCellCursor::GetWeakRefCount(nsIMdbEnv* mev, // weak refs
- mdb_count* outCount)
-{
- return this->Handle_GetWeakRefCount(mev, outCount);
-}
-/*virtual*/ mdb_err
-orkinRowCellCursor::GetStrongRefCount(nsIMdbEnv* mev, // strong refs
- mdb_count* outCount)
-{
- return this->Handle_GetStrongRefCount(mev, outCount);
-}
-
-/*virtual*/ mdb_err
-orkinRowCellCursor::AddWeakRef(nsIMdbEnv* mev)
-{
- return this->Handle_AddWeakRef(mev);
-}
-/*virtual*/ mdb_err
-orkinRowCellCursor::AddStrongRef(nsIMdbEnv* mev)
-{
- return this->Handle_AddStrongRef(mev);
-}
-
-/*virtual*/ mdb_err
-orkinRowCellCursor::CutWeakRef(nsIMdbEnv* mev)
-{
- return this->Handle_CutWeakRef(mev);
-}
-/*virtual*/ mdb_err
-orkinRowCellCursor::CutStrongRef(nsIMdbEnv* mev)
-{
- return this->Handle_CutStrongRef(mev);
-}
-
-/*virtual*/ mdb_err
-orkinRowCellCursor::CloseMdbObject(nsIMdbEnv* mev)
-{
- return this->Handle_CloseMdbObject(mev);
-}
-
-/*virtual*/ mdb_err
-orkinRowCellCursor::IsOpenMdbObject(nsIMdbEnv* mev, mdb_bool* outOpen)
-{
- return this->Handle_IsOpenMdbObject(mev, outOpen);
-}
-// } ----- end ref counting -----
-
-// } ===== end nsIMdbObject methods =====
-
-// { ===== begin nsIMdbCursor methods =====
-
-// { ----- begin attribute methods -----
-/*virtual*/ mdb_err
-orkinRowCellCursor::GetCount(nsIMdbEnv* mev, mdb_count* outCount)
-{
- mdb_err outErr = 0;
- mdb_count count = 0;
- morkRow* row = 0;
- morkEnv* ev =
- this->CanUseRowCellCursor(mev, /*mut*/ morkBool_kFalse, &outErr, &row);
- if ( ev )
- {
- count = row->mRow_Length;
- outErr = ev->AsErr();
- }
- if ( outCount )
- *outCount = count;
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinRowCellCursor::GetSeed(nsIMdbEnv* mev, mdb_seed* outSeed)
-{
- mdb_err outErr = 0;
- mdb_seed seed = 0;
- morkRow* row = 0;
- morkEnv* ev =
- this->CanUseRowCellCursor(mev, /*mut*/ morkBool_kFalse, &outErr, &row);
- if ( ev )
- {
- seed = row->mRow_Seed;
- outErr = ev->AsErr();
- }
- if ( outSeed )
- *outSeed = seed;
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinRowCellCursor::SetPos(nsIMdbEnv* mev, mdb_pos inPos)
-{
- mdb_err outErr = 0;
- morkRow* row = 0;
- morkEnv* ev =
- this->CanUseRowCellCursor(mev, /*mut*/ morkBool_kFalse, &outErr, &row);
- if ( ev )
- {
- morkRowCellCursor* cursor = (morkRowCellCursor*) mHandle_Object;
- cursor->mCursor_Pos = inPos;
- outErr = ev->AsErr();
- }
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinRowCellCursor::GetPos(nsIMdbEnv* mev, mdb_pos* outPos)
-{
- mdb_err outErr = 0;
- mdb_pos pos = 0;
- morkRow* row = 0;
- morkEnv* ev =
- this->CanUseRowCellCursor(mev, /*mut*/ morkBool_kFalse, &outErr, &row);
- if ( ev )
- {
- morkRowCellCursor* cursor = (morkRowCellCursor*) mHandle_Object;
- pos = cursor->mCursor_Pos;
- outErr = ev->AsErr();
- }
- if ( outPos )
- *outPos = pos;
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinRowCellCursor::SetDoFailOnSeedOutOfSync(nsIMdbEnv* mev, mdb_bool inFail)
-{
- mdb_err outErr = 0;
- morkRow* row = 0;
- morkEnv* ev =
- this->CanUseRowCellCursor(mev, /*mut*/ morkBool_kFalse, &outErr, &row);
- if ( ev )
- {
- morkRowCellCursor* cursor = (morkRowCellCursor*) mHandle_Object;
- cursor->mCursor_DoFailOnSeedOutOfSync = inFail;
- outErr = ev->AsErr();
- }
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinRowCellCursor::GetDoFailOnSeedOutOfSync(nsIMdbEnv* mev, mdb_bool* outFail)
-{
- mdb_err outErr = 0;
- mdb_bool doFail = morkBool_kFalse;
- morkRow* row = 0;
- morkEnv* ev =
- this->CanUseRowCellCursor(mev, /*mut*/ morkBool_kFalse, &outErr, &row);
- if ( ev )
- {
- morkRowCellCursor* cursor = (morkRowCellCursor*) mHandle_Object;
- doFail = cursor->mCursor_DoFailOnSeedOutOfSync;
- outErr = ev->AsErr();
- }
- if ( outFail )
- *outFail = doFail;
- return outErr;
-}
-// } ----- end attribute methods -----
-
-// } ===== end nsIMdbCursor methods =====
-
-// { ===== begin nsIMdbRowCellCursor methods =====
-
-// { ----- begin attribute methods -----
-/*virtual*/ mdb_err
-orkinRowCellCursor::SetRow(nsIMdbEnv* mev, nsIMdbRow* ioRow)
-{
- mdb_err outErr = 0;
- morkRow* row = 0;
- morkEnv* ev =
- this->CanUseRowCellCursor(mev, /*mut*/ morkBool_kFalse, &outErr, &row);
- if ( ev )
- {
- morkRowCellCursor* cursor = (morkRowCellCursor*) mHandle_Object;
- row = (morkRow *) ioRow;
- morkStore* store = row->GetRowSpaceStore(ev);
- if ( store )
- {
- morkRowObject* rowObj = row->AcquireRowObject(ev, store);
- if ( rowObj )
- {
- morkRowObject::SlotStrongRowObject((morkRowObject*) 0, ev,
- &cursor->mRowCellCursor_RowObject);
-
- cursor->mRowCellCursor_RowObject = rowObj; // take this strong ref
- cursor->mCursor_Seed = row->mRow_Seed;
-
- row->GetCell(ev, cursor->mRowCellCursor_Col, &cursor->mCursor_Pos);
- }
- }
- outErr = ev->AsErr();
- }
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinRowCellCursor::GetRow(nsIMdbEnv* mev, nsIMdbRow** acqRow)
-{
- mdb_err outErr = 0;
- nsIMdbRow* outRow = 0;
- morkRow* row = 0;
- morkEnv* ev =
- this->CanUseRowCellCursor(mev, /*mut*/ morkBool_kFalse, &outErr, &row);
- if ( ev )
- {
- morkRowCellCursor* cursor = (morkRowCellCursor*) mHandle_Object;
- morkRowObject* rowObj = cursor->mRowCellCursor_RowObject;
- if ( rowObj )
- outRow = rowObj->AcquireRowHandle(ev);
-
- outErr = ev->AsErr();
- }
- if ( acqRow )
- *acqRow = outRow;
- return outErr;
-}
-// } ----- end attribute methods -----
-
-// { ----- begin cell creation methods -----
-/*virtual*/ mdb_err
-orkinRowCellCursor::MakeCell( // get cell at current pos in the row
- nsIMdbEnv* mev, // context
- mdb_column* outColumn, // column for this particular cell
- mdb_pos* outPos, // position of cell in row sequence
- nsIMdbCell** acqCell)
-{
- mdb_err outErr = 0;
- nsIMdbCell* outCell = 0;
- mdb_pos pos = 0;
- mdb_column col = 0;
- morkRow* row = 0;
- morkEnv* ev =
- this->CanUseRowCellCursor(mev, /*mut*/ morkBool_kFalse, &outErr, &row);
- if ( ev )
- {
- morkRowCellCursor* cursor = (morkRowCellCursor*) mHandle_Object;
- pos = cursor->mCursor_Pos;
- morkCell* cell = row->CellAt(ev, pos);
- if ( cell )
- {
- col = cell->GetColumn();
- outCell = row->AcquireCellHandle(ev, cell, col, pos);
- }
- outErr = ev->AsErr();
- }
- if ( acqCell )
- *acqCell = outCell;
- if ( outPos )
- *outPos = pos;
- if ( outColumn )
- *outColumn = col;
-
- return outErr;
-}
-// } ----- end cell creation methods -----
-
-// { ----- begin cell seeking methods -----
-/*virtual*/ mdb_err
-orkinRowCellCursor::SeekCell( // same as SetRow() followed by MakeCell()
- nsIMdbEnv* mev, // context
- mdb_pos inPos, // position of cell in row sequence
- mdb_column* outColumn, // column for this particular cell
- nsIMdbCell** acqCell)
-{
- MORK_USED_1(inPos);
- mdb_err outErr = 0;
- mdb_column column = 0;
- nsIMdbCell* outCell = 0;
- morkRow* row = 0;
- morkEnv* ev =
- this->CanUseRowCellCursor(mev, /*mut*/ morkBool_kFalse, &outErr, &row);
- if ( ev )
- {
- morkRowCellCursor* cursor;
- cursor = (morkRowCellCursor*) mHandle_Object;
- ev->StubMethodOnlyError();
- outErr = ev->AsErr();
- }
- if ( acqCell )
- *acqCell = outCell;
- if ( outColumn )
- *outColumn = column;
- return outErr;
-}
-// } ----- end cell seeking methods -----
-
-// { ----- begin cell iteration methods -----
-/*virtual*/ mdb_err
-orkinRowCellCursor::NextCell( // get next cell in the row
- nsIMdbEnv* mev, // context
- nsIMdbCell* ioCell, // changes to the next cell in the iteration
- mdb_column* outColumn, // column for this particular cell
- mdb_pos* outPos)
-{
- MORK_USED_1(ioCell);
- mdb_err outErr = 0;
- mdb_pos pos = -1;
- mdb_column column = 0;
- morkRow* row = 0;
- morkEnv* ev =
- this->CanUseRowCellCursor(mev, /*mut*/ morkBool_kFalse, &outErr, &row);
- if ( ev )
- {
- morkRowCellCursor* cursor;
- cursor = (morkRowCellCursor*) mHandle_Object;
- ev->StubMethodOnlyError();
- outErr = ev->AsErr();
- }
- if ( outColumn )
- *outColumn = column;
- if ( outPos )
- *outPos = pos;
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinRowCellCursor::PickNextCell( // get next cell in row within filter set
- nsIMdbEnv* mev, // context
- nsIMdbCell* ioCell, // changes to the next cell in the iteration
- const mdbColumnSet* inFilterSet, // col set of actual caller interest
- mdb_column* outColumn, // column for this particular cell
- mdb_pos* outPos)
-// Note that inFilterSet should not have too many (many more than 10?)
-// cols, since this might imply a potential excessive consumption of time
-// over many cursor calls when looking for column and filter intersection.
-{
- MORK_USED_2(ioCell,inFilterSet);
- mdb_pos pos = -1;
- mdb_column column = 0;
- mdb_err outErr = 0;
- morkRow* row = 0;
- morkEnv* ev =
- this->CanUseRowCellCursor(mev, /*mut*/ morkBool_kFalse, &outErr, &row);
- if ( ev )
- {
- morkRowCellCursor* cursor;
- cursor = (morkRowCellCursor*) mHandle_Object;
- ev->StubMethodOnlyError();
- outErr = ev->AsErr();
- }
- if ( outColumn )
- *outColumn = column;
- if ( outPos )
- *outPos = pos;
- return outErr;
-}
-
-// } ----- end cell iteration methods -----
-
-// } ===== end nsIMdbRowCellCursor methods =====
-
-
-//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
deleted file mode 100644
--- a/db/mork/src/orkinRowCellCursor.h
+++ /dev/null
@@ -1,217 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (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.mozilla.org/MPL/
- *
- * 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 mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1999
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef _ORKINROWCELLCURSOR_
-#define _ORKINROWCELLCURSOR_ 1
-
-#ifndef _MDB_
-#include "mdb.h"
-#endif
-
-#ifndef _MORK_
-#include "mork.h"
-#endif
-
-#ifndef _MORKNODE_
-#include "morkNode.h"
-#endif
-
-#ifndef _MORKHANDLE_
-#include "morkHandle.h"
-#endif
-
-#ifndef _MORKROWCELLCURSOR_
-#include "morkRowCellCursor.h"
-#endif
-
-//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
-
-#define morkMagic_kRowCellCursor 0x52634375 /* ascii 'RcCu' */
-
-/*| orkinRowCellCursor: cursor class for iterating row cells
-**|
-**|| row: the cursor is associated with a specific row, which can be
-**| set to a different row (which resets the position to -1 so the
-**| next cell acquired is the first in the row.
-**|
-**|| NextCell: get the next cell in the row and return its position and
-**| a new instance of a nsIMdbCell to represent this next cell.
-|*/
-class orkinRowCellCursor :
- public morkHandle, public nsIMdbRowCellCursor { // nsIMdbCursor
-
-// { ===== begin morkNode interface =====
-public: // morkNode virtual methods
- // virtual void CloseMorkNode(morkEnv* ev); // morkHandle is fine
- virtual ~orkinRowCellCursor(); // morkHandle destructor does everything
-
-protected: // construction is protected (use the static Make() method)
- orkinRowCellCursor(morkEnv* ev, // note morkUsage is always morkUsage_kPool
- morkHandleFace* ioFace, // must not be nil, cookie for this handle
- morkRowCellCursor* ioObject); // must not be nil, the object for this handle
-
- // void CloseHandle(morkEnv* ev); // don't need to specialize closing
-
-private: // copying is not allowed
- orkinRowCellCursor(const morkHandle& other);
- orkinRowCellCursor& operator=(const morkHandle& other);
-
-// public: // dynamic type identification
- // mork_bool IsHandle() const //
- // { return IsNode() && mNode_Derived == morkDerived_kHandle; }
-// } ===== end morkNode methods =====
-
-protected: // morkHandle memory management operators
- void* operator new(size_t inSize, morkPool& ioPool, morkZone& ioZone, morkEnv* ev) CPP_THROW_NEW
- { return ioPool.NewHandle(ev, inSize, &ioZone); }
-
- void* operator new(size_t inSize, morkPool& ioPool, morkEnv* ev) CPP_THROW_NEW
- { return ioPool.NewHandle(ev, inSize, (morkZone*) 0); }
-
- void* operator new(size_t inSize, morkHandleFace* ioFace) CPP_THROW_NEW
- { MORK_USED_1(inSize); return ioFace; }
-
-public: // construction:
-
- static orkinRowCellCursor* MakeRowCellCursor(morkEnv* ev,
- morkRowCellCursor* ioObject);
-
-public: // utilities:
-
- morkEnv* CanUseRowCellCursor(nsIMdbEnv* mev, mork_bool inMutable,
- mdb_err* outErr, morkRow** outRow) const;
-
-public: // type identification
- mork_bool IsOrkinRowCellCursor() const
- { return mHandle_Magic == morkMagic_kRowCellCursor; }
-
- mork_bool IsOrkinRowCellCursorHandle() const
- { return this->IsHandle() && this->IsOrkinRowCellCursor(); }
-
- NS_DECL_ISUPPORTS
-// { ===== begin nsIMdbObject methods =====
-
- // { ----- begin attribute methods -----
- NS_IMETHOD IsFrozenMdbObject(nsIMdbEnv* ev, mdb_bool* outIsReadonly);
- // same as nsIMdbPort::GetIsPortReadonly() when this object is inside a port.
- // } ----- end attribute methods -----
-
- // { ----- begin factory methods -----
- NS_IMETHOD GetMdbFactory(nsIMdbEnv* ev, nsIMdbFactory** acqFactory);
- // } ----- end factory methods -----
-
- // { ----- begin ref counting for well-behaved cyclic graphs -----
- NS_IMETHOD GetWeakRefCount(nsIMdbEnv* ev, // weak refs
- mdb_count* outCount);
- NS_IMETHOD GetStrongRefCount(nsIMdbEnv* ev, // strong refs
- mdb_count* outCount);
-
- NS_IMETHOD AddWeakRef(nsIMdbEnv* ev);
- NS_IMETHOD AddStrongRef(nsIMdbEnv* ev);
-
- NS_IMETHOD CutWeakRef(nsIMdbEnv* ev);
- NS_IMETHOD CutStrongRef(nsIMdbEnv* ev);
-
- NS_IMETHOD CloseMdbObject(nsIMdbEnv* ev); // called at strong refs zero
- NS_IMETHOD IsOpenMdbObject(nsIMdbEnv* ev, mdb_bool* outOpen);
- // } ----- end ref counting -----
-
-// } ===== end nsIMdbObject methods =====
-
-// { ===== begin nsIMdbCursor methods =====
-
- // { ----- begin attribute methods -----
- NS_IMETHOD GetCount(nsIMdbEnv* ev, mdb_count* outCount); // readonly
- NS_IMETHOD GetSeed(nsIMdbEnv* ev, mdb_seed* outSeed); // readonly
-
- NS_IMETHOD SetPos(nsIMdbEnv* ev, mdb_pos inPos); // mutable
- NS_IMETHOD GetPos(nsIMdbEnv* ev, mdb_pos* outPos);
-
- NS_IMETHOD SetDoFailOnSeedOutOfSync(nsIMdbEnv* ev, mdb_bool inFail);
- NS_IMETHOD GetDoFailOnSeedOutOfSync(nsIMdbEnv* ev, mdb_bool* outFail);
- // } ----- end attribute methods -----
-
-// } ===== end nsIMdbCursor methods =====
-
-// { ===== begin nsIMdbRowCellCursor methods =====
-
- // { ----- begin attribute methods -----
- NS_IMETHOD SetRow(nsIMdbEnv* ev, nsIMdbRow* ioRow); // sets pos to -1
- NS_IMETHOD GetRow(nsIMdbEnv* ev, nsIMdbRow** acqRow);
- // } ----- end attribute methods -----
-
- // { ----- begin cell creation methods -----
- NS_IMETHOD MakeCell( // get cell at current pos in the row
- nsIMdbEnv* ev, // context
- mdb_column* outColumn, // column for this particular cell
- mdb_pos* outPos, // position of cell in row sequence
- nsIMdbCell** acqCell); // the cell at inPos
- // } ----- end cell creation methods -----
-
- // { ----- begin cell seeking methods -----
- NS_IMETHOD SeekCell( // same as SetRow() followed by MakeCell()
- nsIMdbEnv* ev, // context
- mdb_pos inPos, // position of cell in row sequence
- mdb_column* outColumn, // column for this particular cell
- nsIMdbCell** acqCell); // the cell at inPos
- // } ----- end cell seeking methods -----
-
- // { ----- begin cell iteration methods -----
- NS_IMETHOD NextCell( // get next cell in the row
- nsIMdbEnv* ev, // context
- nsIMdbCell* ioCell, // changes to the next cell in the iteration
- mdb_column* outColumn, // column for this particular cell
- mdb_pos* outPos); // position of cell in row sequence
-
- NS_IMETHOD PickNextCell( // get next cell in row within filter set
- nsIMdbEnv* ev, // context
- nsIMdbCell* ioCell, // changes to the next cell in the iteration
- const mdbColumnSet* inFilterSet, // col set of actual caller interest
- mdb_column* outColumn, // column for this particular cell
- mdb_pos* outPos); // position of cell in row sequence
-
- // Note that inFilterSet should not have too many (many more than 10?)
- // cols, since this might imply a potential excessive consumption of time
- // over many cursor calls when looking for column and filter intersection.
- // } ----- end cell iteration methods -----
-
-// } ===== end nsIMdbRowCellCursor methods =====
-};
-
-//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
-
-#endif /* _ORKINROWCELLCURSOR_ */
deleted file mode 100644
--- a/db/mork/src/orkinSorting.cpp
+++ /dev/null
@@ -1,457 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (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.mozilla.org/MPL/
- *
- * 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 mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1999
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef _MDB_
-#include "mdb.h"
-#endif
-
-#ifndef _MORK_
-#include "mork.h"
-#endif
-
-#ifndef _MORKNODE_
-#include "morkNode.h"
-#endif
-
-#ifndef _MORKHANDLE_
-#include "morkHandle.h"
-#endif
-
-#ifndef _MORKSORTING_
-#include "morkSorting.h"
-#endif
-
-#ifndef _MORKTABLE_
-#include "morkTable.h"
-#endif
-
-#ifndef _MORKENV_
-#include "morkEnv.h"
-#endif
-
-#ifndef _ORKINTABLE_
-#include "orkinTable.h"
-#endif
-
-#ifndef _ORKINSORTING_
-#include "orkinSorting.h"
-#endif
-
-#ifndef _ORKINROW_
-#include "orkinRow.h"
-#endif
-
-#ifndef _MORKTABLEROWCURSOR_
-#include "morkTableRowCursor.h"
-#endif
-
-#ifndef _ORKINTABLEROWCURSOR_
-#include "orkinTableRowCursor.h"
-#endif
-
-#ifndef _MORKROWSPACE_
-#include "morkRowSpace.h"
-#endif
-
-#ifndef _MORKSTORE_
-#include "morkStore.h"
-#endif
-
-#ifndef _ORKINSTORE_
-#include "orkinStore.h"
-#endif
-
-//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
-
-/* public virtual*/
-orkinSorting:: ~orkinSorting() // morkHandle destructor does everything
-{
-}
-
-/*protected non-poly construction*/
-orkinSorting::orkinSorting(morkEnv* ev, // morkUsage is morkUsage_kPool
- morkHandleFace* ioFace, // must not be nil, cookie for this handle
- morkSorting* ioObject) // must not be nil, the object for this handle
-: morkHandle(ev, ioFace, ioObject, morkMagic_kSorting)
-{
- // do not modify mNode_Derived; leave it equal to morkDerived_kHandle
-}
-
-
-/*static */ orkinSorting*
-orkinSorting::MakeSorting(morkEnv* ev, morkSorting* ioObject)
-{
- mork_bool isEnv = ev->IsEnv();
- MORK_ASSERT(isEnv);
- if ( isEnv )
- {
- morkHandleFace* face = ev->NewHandle(sizeof(orkinSorting));
- if ( face )
- return new(face) orkinSorting(ev, face, ioObject);
- else
- ev->OutOfMemoryError();
- }
-
- return (orkinSorting*) 0;
-}
-
-morkEnv*
-orkinSorting::CanUseSorting(nsIMdbEnv* mev,
- mork_bool inMutable, mdb_err* outErr) const
-{
- morkEnv* outEnv = 0;
- morkEnv* ev = morkEnv::FromMdbEnv(mev);
- if ( ev )
- {
- morkSorting* self = (morkSorting*)
- this->GetGoodHandleObject(ev, inMutable, morkMagic_kSorting,
- /*inClosedOkay*/ morkBool_kFalse);
- if ( self )
- {
- if ( self->IsSorting() )
- outEnv = ev;
- else
- self->NonSortingTypeError(ev);
- }
- *outErr = ev->AsErr();
- }
- MORK_ASSERT(outEnv);
- return outEnv;
-}
-
-
-// { ===== begin nsIMdbISupports methods =====
-NS_IMPL_QUERY_INTERFACE0(orkinSorting)
-
-/*virtual*/ nsrefcnt
-orkinSorting::AddRef() // add strong ref with no
-{
- morkEnv* ev = mHandle_Env;
- if ( ev && ev->IsEnv() )
- return this->Handle_AddStrongRef(ev->AsMdbEnv());
- else
- return morkEnv_kNonEnvTypeError;
-}
-
-/*virtual*/ nsrefcnt
-orkinSorting::Release() // cut strong ref
-{
- morkEnv* ev = mHandle_Env;
- if ( ev && ev->IsEnv() )
- return this->Handle_CutStrongRef(ev->AsMdbEnv());
- else
- return morkEnv_kNonEnvTypeError;
-}
-// } ===== end nsIMdbISupports methods =====
-
-// { ===== begin nsIMdbObject methods =====
-
-// { ----- begin attribute methods -----
-/*virtual*/ mdb_err
-orkinSorting::IsFrozenMdbObject(nsIMdbEnv* mev, mdb_bool* outIsReadonly)
-{
- return this->Handle_IsFrozenMdbObject(mev, outIsReadonly);
-}
-// same as nsIMdbPort::GetIsPortReadonly() when this object is inside a port.
-// } ----- end attribute methods -----
-
-// { ----- begin factory methods -----
-/*virtual*/ mdb_err
-orkinSorting::GetMdbFactory(nsIMdbEnv* mev, nsIMdbFactory** acqFactory)
-{
- return this->Handle_GetMdbFactory(mev, acqFactory);
-}
-// } ----- end factory methods -----
-
-// { ----- begin ref counting for well-behaved cyclic graphs -----
-/*virtual*/ mdb_err
-orkinSorting::GetWeakRefCount(nsIMdbEnv* mev, // weak refs
- mdb_count* outCount)
-{
- return this->Handle_GetWeakRefCount(mev, outCount);
-}
-/*virtual*/ mdb_err
-orkinSorting::GetStrongRefCount(nsIMdbEnv* mev, // strong refs
- mdb_count* outCount)
-{
- return this->Handle_GetStrongRefCount(mev, outCount);
-}
-
-/*virtual*/ mdb_err
-orkinSorting::AddWeakRef(nsIMdbEnv* mev)
-{
- return this->Handle_AddWeakRef(mev);
-}
-/*virtual*/ mdb_err
-orkinSorting::AddStrongRef(nsIMdbEnv* mev)
-{
- return this->Handle_AddStrongRef(mev);
-}
-
-/*virtual*/ mdb_err
-orkinSorting::CutWeakRef(nsIMdbEnv* mev)
-{
- return this->Handle_CutWeakRef(mev);
-}
-/*virtual*/ mdb_err
-orkinSorting::CutStrongRef(nsIMdbEnv* mev)
-{
- return this->Handle_CutStrongRef(mev);
-}
-
-/*virtual*/ mdb_err
-orkinSorting::CloseMdbObject(nsIMdbEnv* mev)
-{
- return this->Handle_CloseMdbObject(mev);
-}
-
-/*virtual*/ mdb_err
-orkinSorting::IsOpenMdbObject(nsIMdbEnv* mev, mdb_bool* outOpen)
-{
- return this->Handle_IsOpenMdbObject(mev, outOpen);
-}
-// } ----- end ref counting -----
-
-// } ===== end nsIMdbObject methods =====
-
-
-// { ===== begin nsIMdbSorting methods =====
-
-// { ----- begin attribute methods -----
-
-
-/*virtual*/ mdb_err
-orkinSorting::GetTable(nsIMdbEnv* mev, nsIMdbTable** acqTable)
-{
- mdb_err outErr = 0;
- nsIMdbTable* outTable = 0;
- morkEnv* ev = this->CanUseSorting(mev, /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- morkSorting* sorting = (morkSorting*) mHandle_Object;
- morkTable* table = sorting->mSorting_Table;
- if ( table && ev->Good() )
- {
- outTable = table->AcquireTableHandle(ev);
- }
- outErr = ev->AsErr();
- }
- if ( acqTable )
- *acqTable = outTable;
-
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinSorting::GetSortColumn( // query which col is currently sorted
- nsIMdbEnv* mev, // context
- mdb_column* outColumn) // col the table uses for sorting (or zero)
-{
- mdb_err outErr = 0;
- mdb_column col = 0;
- morkEnv* ev = this->CanUseSorting(mev, /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- morkSorting* sorting = (morkSorting*) mHandle_Object;
- col = sorting->mSorting_Col;
-
- outErr = ev->AsErr();
- }
- if ( outColumn )
- *outColumn = col;
-
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinSorting::SetNewCompare(nsIMdbEnv* mev,
- nsIMdbCompare* ioNewCompare)
- // Setting the sorting's compare object will typically cause the rows
- // to be resorted, presumably in a lazy fashion when the sorting is
- // next required to be in a valid row ordering state, such as when a
- // call to PosToOid() happens. ioNewCompare can be nil, in which case
- // implementations should revert to the default sort order, which must
- // be equivalent to whatever is used by nsIMdbFactory::MakeCompare().
-{
- mdb_err outErr = 0;
- morkEnv* ev = this->CanUseSorting(mev, /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- if ( ioNewCompare )
- {
- morkSorting* sorting = (morkSorting*) mHandle_Object;
- nsIMdbCompare_SlotStrongCompare(ioNewCompare, ev,
- &sorting->mSorting_Compare);
- }
- else
- ev->NilPointerError();
-
- outErr = ev->AsErr();
- }
-
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinSorting::GetOldCompare(nsIMdbEnv* mev,
- nsIMdbCompare** acqOldCompare)
- // Get this sorting instance's compare object, which handles the
- // ordering of rows in the sorting, by comparing yarns from the cells
- // in the column being sorted. Since nsIMdbCompare has no interface
- // to query the state of the compare object, it is not clear what you
- // would do with this object when returned, except maybe compare it
- // as a pointer address to some other instance, to check identities.
-{
- mdb_err outErr = 0;
- nsIMdbCompare* outCompare = 0;
- morkEnv* ev = this->CanUseSorting(mev, /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- morkSorting* sorting = (morkSorting*) mHandle_Object;
- nsIMdbCompare* compare = sorting->mSorting_Compare;
- if ( compare && ev->Good() )
- {
- compare->AddStrongRef(mev);
-
- if ( ev->Good() )
- outCompare = compare;
- }
- outErr = ev->AsErr();
- }
- if ( acqOldCompare )
- *acqOldCompare = outCompare;
-
- return outErr;
-}
-
-// } ----- end attribute methods -----
-
-
-// { ----- begin cursor methods -----
-/*virtual*/ mdb_err
-orkinSorting::GetSortingRowCursor( // make a cursor, starting at inRowPos
- nsIMdbEnv* mev, // context
- mdb_pos inRowPos, // zero-based ordinal position of row in table
- nsIMdbTableRowCursor** acqCursor) // acquire new cursor instance
- // A cursor interface turning same info as PosToOid() or PosToRow().
-{
- mdb_err outErr = 0;
- nsIMdbTableRowCursor* outCursor = 0;
- morkEnv* ev = this->CanUseSorting(mev, /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- morkSortingRowCursor* cursor =
- ((morkSorting*) mHandle_Object)->NewSortingRowCursor(ev, inRowPos);
- if ( cursor )
- {
- // $$$$$
- // if ( ev->Good() )
- // {
- // outCursor = cursor->AcquireSortingRowCursorHandle(ev);
- // }
- // else
- // cursor->CutStrongRef(ev);
- }
-
- outErr = ev->AsErr();
- }
- if ( acqCursor )
- *acqCursor = outCursor;
- return outErr;
-}
-
-// } ----- end row position methods -----
-
-// { ----- begin row position methods -----
-/*virtual*/ mdb_err
-orkinSorting::PosToOid( // get row member for a table position
- nsIMdbEnv* mev, // context
- mdb_pos inRowPos, // zero-based ordinal position of row in table
- mdbOid* outOid) // row oid at the specified position
-{
- mdb_err outErr = 0;
- mdbOid roid;
- roid.mOid_Scope = 0;
- roid.mOid_Id = (mork_id) -1;
-
- morkEnv* ev = this->CanUseSorting(mev, /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- morkSorting* sorting = (morkSorting*) mHandle_Object;
- morkRow* row = sorting->SafeRowAt(ev, inRowPos);
- if ( row )
- roid = row->mRow_Oid;
-
- outErr = ev->AsErr();
- }
- if ( outOid )
- *outOid = roid;
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinSorting::PosToRow( // get row member for a table position
- nsIMdbEnv* mev, // context
- mdb_pos inRowPos, // zero-based ordinal position of row in table
- nsIMdbRow** acqRow) // acquire row at table position inRowPos
-{
- mdb_err outErr = 0;
- nsIMdbRow* outRow = 0;
- morkEnv* ev = this->CanUseSorting(mev, /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- morkSorting* sorting = (morkSorting*) mHandle_Object;
- morkStore* store = sorting->mSorting_Table->mTable_Store;
- morkRow* row = sorting->SafeRowAt(ev, inRowPos);
- if ( row && store )
- outRow = row->AcquireRowHandle(ev, store);
-
- outErr = ev->AsErr();
- }
- if ( acqRow )
- *acqRow = outRow;
- return outErr;
-}
-
-// Note that HasRow() performs the inverse oid->pos mapping
-// } ----- end row position methods -----
-
-
-// } ===== end nsIMdbSorting methods =====
-
-
-//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
deleted file mode 100644
--- a/db/mork/src/orkinSorting.h
+++ /dev/null
@@ -1,204 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (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.mozilla.org/MPL/
- *
- * 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 mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1999
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef _ORKINSORTING_
-#define _ORKINSORTING_ 1
-
-#ifndef _MDB_
-#include "mdb.h"
-#endif
-
-#ifndef _MORK_
-#include "mork.h"
-#endif
-
-#ifndef _MORKNODE_
-#include "morkNode.h"
-#endif
-
-#ifndef _MORKHANDLE_
-#include "morkHandle.h"
-#endif
-
-#ifndef _MORKSORTING_
-#include "morkSorting.h"
-#endif
-
-//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
-
-#define morkMagic_kSorting 0x536F7274 /* ascii 'Sort' */
-
-/*| orkinSorting:
-|*/
-class orkinSorting : public morkHandle, public nsIMdbSorting { // nsIMdbSorting
-
-// { ===== begin morkNode interface =====
-public: // morkNode virtual methods
- // virtual void CloseMorkNode(morkEnv* ev); // morkHandle is fine
- virtual ~orkinSorting(); // morkHandle destructor does everything
-
-protected: // construction is protected (use the static Make() method)
- orkinSorting(morkEnv* ev, // note morkUsage is always morkUsage_kPool
- morkHandleFace* ioFace, // must not be nil, cookie for this handle
- morkSorting* ioObject); // must not be nil, the object for this handle
-
- // void CloseHandle(morkEnv* ev); // don't need to specialize closing
-
-private: // copying is not allowed
- orkinSorting(const orkinSorting& other);
- orkinSorting& operator=(const orkinSorting& other);
-
-// public: // dynamic type identification
- // mork_bool IsHandle() const //
- // { return IsNode() && mNode_Derived == morkDerived_kHandle; }
-// } ===== end morkNode methods =====
-
-protected: // morkHandle memory management operators
- void* operator new(size_t inSize, morkPool& ioPool, morkZone& ioZone, morkEnv* ev) CPP_THROW_NEW
- { return ioPool.NewHandle(ev, inSize, &ioZone); }
-
- void* operator new(size_t inSize, morkPool& ioPool, morkEnv* ev) CPP_THROW_NEW
- { return ioPool.NewHandle(ev, inSize, (morkZone*) 0); }
-
- void* operator new(size_t inSize, morkHandleFace* ioFace) CPP_THROW_NEW
- { MORK_USED_1(inSize); return ioFace; }
-
-
-public: // construction:
-
- static orkinSorting* MakeSorting(morkEnv* ev, morkSorting* ioObject);
-
-public: // utilities:
-
- morkEnv* CanUseSorting(nsIMdbEnv* mev, mork_bool inMutable,
- mdb_err* outErr) const;
-
-public: // type identification
- mork_bool IsOrkinSorting() const
- { return mHandle_Magic == morkMagic_kSorting; }
-
- mork_bool IsOrkinSortingHandle() const
- { return this->IsHandle() && this->IsOrkinSorting(); }
-
- NS_DECL_ISUPPORTS
-// { ===== begin nsIMdbObject methods =====
-
- // { ----- begin attribute methods -----
- NS_IMETHOD IsFrozenMdbObject(nsIMdbEnv* ev, mdb_bool* outIsReadonly);
- // same as nsIMdbPort::GetIsPortReadonly() when this object is inside a port.
- // } ----- end attribute methods -----
-
- // { ----- begin factory methods -----
- NS_IMETHOD GetMdbFactory(nsIMdbEnv* ev, nsIMdbFactory** acqFactory);
- // } ----- end factory methods -----
-
- // { ----- begin ref counting for well-behaved cyclic graphs -----
- NS_IMETHOD GetWeakRefCount(nsIMdbEnv* ev, // weak refs
- mdb_count* outCount);
- NS_IMETHOD GetStrongRefCount(nsIMdbEnv* ev, // strong refs
- mdb_count* outCount);
-
- NS_IMETHOD AddWeakRef(nsIMdbEnv* ev);
- NS_IMETHOD AddStrongRef(nsIMdbEnv* ev);
-
- NS_IMETHOD CutWeakRef(nsIMdbEnv* ev);
- NS_IMETHOD CutStrongRef(nsIMdbEnv* ev);
-
- NS_IMETHOD CloseMdbObject(nsIMdbEnv* ev); // called at strong refs zero
- NS_IMETHOD IsOpenMdbObject(nsIMdbEnv* ev, mdb_bool* outOpen);
- // } ----- end ref counting -----
-
-// } ===== end nsIMdbObject methods =====
-
-// { ===== begin nsIMdbSorting methods =====
-
- // { ----- begin attribute methods -----
- // sorting: note all rows are assumed sorted by row ID as a secondary
- // sort following the primary column sort, when table rows are sorted.
-
- NS_IMETHOD GetTable(nsIMdbEnv* ev, nsIMdbTable** acqTable);
- NS_IMETHOD GetSortColumn( // query which col is currently sorted
- nsIMdbEnv* ev, // context
- mdb_column* outColumn); // col the table uses for sorting (or zero)
-
- NS_IMETHOD SetNewCompare(nsIMdbEnv* ev,
- nsIMdbCompare* ioNewCompare);
- // Setting the sorting's compare object will typically cause the rows
- // to be resorted, presumably in a lazy fashion when the sorting is
- // next required to be in a valid row ordering state, such as when a
- // call to PosToOid() happens. ioNewCompare can be nil, in which case
- // implementations should revert to the default sort order, which must
- // be equivalent to whatever is used by nsIMdbFactory::MakeCompare().
-
- NS_IMETHOD GetOldCompare(nsIMdbEnv* ev,
- nsIMdbCompare** acqOldCompare);
- // Get this sorting instance's compare object, which handles the
- // ordering of rows in the sorting, by comparing yarns from the cells
- // in the column being sorted. Since nsIMdbCompare has no interface
- // to query the state of the compare object, it is not clear what you
- // would do with this object when returned, except maybe compare it
- // as a pointer address to some other instance, to check identities.
-
- // } ----- end attribute methods -----
-
- // { ----- begin cursor methods -----
- NS_IMETHOD GetSortingRowCursor( // make a cursor, starting at inRowPos
- nsIMdbEnv* ev, // context
- mdb_pos inRowPos, // zero-based ordinal position of row in table
- nsIMdbTableRowCursor** acqCursor); // acquire new cursor instance
- // A cursor interface turning same info as PosToOid() or PosToRow().
- // } ----- end row position methods -----
-
- // { ----- begin row position methods -----
- NS_IMETHOD PosToOid( // get row member for a table position
- nsIMdbEnv* ev, // context
- mdb_pos inRowPos, // zero-based ordinal position of row in table
- mdbOid* outOid); // row oid at the specified position
-
- NS_IMETHOD PosToRow( // test for the table position of a row member
- nsIMdbEnv* ev, // context
- mdb_pos inRowPos, // zero-based ordinal position of row in table
- nsIMdbRow** acqRow); // acquire row at table position inRowPos
- // } ----- end row position methods -----
-
-// } ===== end nsIMdbSorting methods =====
-
-};
-
-//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
-
-#endif /* _ORKINSORTING_ */
deleted file mode 100644
--- a/db/mork/src/orkinStore.cpp
+++ /dev/null
@@ -1,1264 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (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.mozilla.org/MPL/
- *
- * 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 mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1999
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef _MDB_
-#include "mdb.h"
-#endif
-
-#ifndef _MORK_
-#include "mork.h"
-#endif
-
-#ifndef _MORKNODE_
-#include "morkNode.h"
-#endif
-
-#ifndef _MORKHANDLE_
-#include "morkHandle.h"
-#endif
-
-#ifndef _MORKSTORE_
-#include "morkStore.h"
-#endif
-
-#ifndef _MORKENV_
-#include "morkEnv.h"
-#endif
-
-#ifndef _ORKINSTORE_
-#include "orkinStore.h"
-#endif
-
-#ifndef _MORKTABLE_
-#include "morkTable.h"
-#endif
-
-#ifndef _MORKPORTTABLECURSOR_
-#include "morkPortTableCursor.h"
-#endif
-
-#ifndef _ORKINPORTTABLECURSOR_
-#include "orkinPortTableCursor.h"
-#endif
-
-#ifndef _MORKROW_
-#include "morkRow.h"
-#endif
-
-#ifndef _MORKROWOBJECT_
-#include "morkRowObject.h"
-#endif
-
-#ifndef _MORKTHUMB_
-#include "morkThumb.h"
-#endif
-
-// #ifndef _MORKFILE_
-// #include "morkFile.h"
-// #endif
-
-#ifndef _ORKINTHUMB_
-#include "orkinThumb.h"
-#endif
-
-//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
-
-/* public virtual*/
-orkinStore:: ~orkinStore() // morkHandle destructor does everything
-{
-}
-
-/*protected non-poly construction*/
-orkinStore::orkinStore(morkEnv* ev, // morkUsage is morkUsage_kPool
- morkHandleFace* ioFace, // must not be nil, cookie for this handle
- morkStore* ioObject) // must not be nil, the object for this handle
-: morkHandle(ev, ioFace, ioObject, morkMagic_kStore)
-{
- // do not modify mNode_Derived; leave it equal to morkDerived_kHandle
-}
-
-
-/*static */ orkinStore*
-orkinStore::MakeStore(morkEnv* ev, morkStore* ioObject)
-{
- mork_bool isEnv = ev->IsEnv();
- MORK_ASSERT(isEnv);
- if ( isEnv )
- {
- morkHandleFace* face = ev->NewHandle(sizeof(orkinStore));
- if ( face )
- return new(face) orkinStore(ev, face, ioObject);
- else
- ev->OutOfMemoryError();
- }
-
- return (orkinStore*) 0;
-}
-
-morkEnv*
-orkinStore::CanUseStore(nsIMdbEnv* mev,
- mork_bool inMutable, mdb_err* outErr) const
-{
- morkEnv* outEnv = 0;
- morkEnv* ev = morkEnv::FromMdbEnv(mev);
- if ( ev )
- {
- morkStore* self = (morkStore*)
- this->GetGoodHandleObject(ev, inMutable, morkMagic_kStore,
- /*inClosedOkay*/ morkBool_kFalse);
- if ( self )
- {
- if ( self->IsStore() )
- outEnv = ev;
- else
- self->NonStoreTypeError(ev);
- }
- *outErr = ev->AsErr();
- }
- MORK_ASSERT(outEnv);
- return outEnv;
-}
-
-// { ===== begin nsIMdbISupports methods =====
-
-NS_IMPL_QUERY_INTERFACE0(orkinStore)
-
-/*virtual*/ nsrefcnt
-orkinStore::AddRef() // add strong ref with no
-{
- morkEnv* ev = mHandle_Env;
- if ( ev && ev->IsEnv() )
- return this->Handle_AddStrongRef(ev->AsMdbEnv());
- else
- return morkEnv_kNonEnvTypeError;
-}
-
-/*virtual*/ nsrefcnt
-orkinStore::Release() // cut strong ref
-{
- morkEnv* ev = mHandle_Env;
- if ( ev && ev->IsEnv() )
- return this->Handle_CutStrongRef(ev->AsMdbEnv());
- else
- return morkEnv_kNonEnvTypeError;
-}
-// } ===== end nsIMdbISupports methods =====
-
-// { ===== begin nsIMdbObject methods =====
-
-// { ----- begin attribute methods -----
-/*virtual*/ mdb_err
-orkinStore::IsFrozenMdbObject(nsIMdbEnv* mev, mdb_bool* outIsReadonly)
-{
- return this->Handle_IsFrozenMdbObject(mev, outIsReadonly);
-}
-// same as nsIMdbPort::GetIsPortReadonly() when this object is inside a port.
-// } ----- end attribute methods -----
-
-// { ----- begin factory methods -----
-/*virtual*/ mdb_err
-orkinStore::GetMdbFactory(nsIMdbEnv* mev, nsIMdbFactory** acqFactory)
-{
- return this->Handle_GetMdbFactory(mev, acqFactory);
-}
-// } ----- end factory methods -----
-
-// { ----- begin ref counting for well-behaved cyclic graphs -----
-/*virtual*/ mdb_err
-orkinStore::GetWeakRefCount(nsIMdbEnv* mev, // weak refs
- mdb_count* outCount)
-{
- return this->Handle_GetWeakRefCount(mev, outCount);
-}
-/*virtual*/ mdb_err
-orkinStore::GetStrongRefCount(nsIMdbEnv* mev, // strong refs
- mdb_count* outCount)
-{
- return this->Handle_GetStrongRefCount(mev, outCount);
-}
-
-/*virtual*/ mdb_err
-orkinStore::AddWeakRef(nsIMdbEnv* mev)
-{
- return this->Handle_AddWeakRef(mev);
-}
-/*virtual*/ mdb_err
-orkinStore::AddStrongRef(nsIMdbEnv* mev)
-{
- return this->Handle_AddStrongRef(mev);
-}
-
-/*virtual*/ mdb_err
-orkinStore::CutWeakRef(nsIMdbEnv* mev)
-{
- return this->Handle_CutWeakRef(mev);
-}
-/*virtual*/ mdb_err
-orkinStore::CutStrongRef(nsIMdbEnv* mev)
-{
- return this->Handle_CutStrongRef(mev);
-}
-
-/*virtual*/ mdb_err
-orkinStore::CloseMdbObject(nsIMdbEnv* mev)
-{
- return this->Handle_CloseMdbObject(mev);
-}
-
-/*virtual*/ mdb_err
-orkinStore::IsOpenMdbObject(nsIMdbEnv* mev, mdb_bool* outOpen)
-{
- return this->Handle_IsOpenMdbObject(mev, outOpen);
-}
-// } ----- end ref counting -----
-
-// } ===== end nsIMdbObject methods =====
-
-// { ===== begin nsIMdbPort methods =====
-
-// { ----- begin attribute methods -----
-/*virtual*/ mdb_err
-orkinStore::GetIsPortReadonly(nsIMdbEnv* mev, mdb_bool* outBool)
-{
- mdb_err outErr = 0;
- mdb_bool isReadOnly = morkBool_kFalse;
- morkEnv* ev = this->CanUseStore(mev, /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- ev->StubMethodOnlyError();
- outErr = ev->AsErr();
- }
- if ( outBool )
- *outBool = isReadOnly;
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinStore::GetIsStore(nsIMdbEnv* mev, mdb_bool* outBool)
-{
- MORK_USED_1(mev);
- if ( outBool )
- *outBool = morkBool_kTrue;
- return 0;
-}
-
-/*virtual*/ mdb_err
-orkinStore::GetIsStoreAndDirty(nsIMdbEnv* mev, mdb_bool* outBool)
-{
- mdb_err outErr = 0;
- mdb_bool isStoreAndDirty = morkBool_kFalse;
- morkEnv* ev = this->CanUseStore(mev, /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- ev->StubMethodOnlyError();
- outErr = ev->AsErr();
- }
- if ( outBool )
- *outBool = isStoreAndDirty;
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinStore::GetUsagePolicy(nsIMdbEnv* mev,
- mdbUsagePolicy* ioUsagePolicy)
-{
- MORK_USED_1(ioUsagePolicy);
- mdb_err outErr = 0;
- morkEnv* ev = this->CanUseStore(mev, /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- ev->StubMethodOnlyError();
- outErr = ev->AsErr();
- }
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinStore::SetUsagePolicy(nsIMdbEnv* mev,
- const mdbUsagePolicy* inUsagePolicy)
-{
- MORK_USED_1(inUsagePolicy);
- mdb_err outErr = 0;
- morkEnv* ev = this->CanUseStore(mev, /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- // ev->StubMethodOnlyError(); // okay to do nothing?
- outErr = ev->AsErr();
- }
- return outErr;
-}
-// } ----- end attribute methods -----
-
-// { ----- begin memory policy methods -----
-/*virtual*/ mdb_err
-orkinStore::IdleMemoryPurge( // do memory management already scheduled
- nsIMdbEnv* mev, // context
- mdb_size* outEstimatedBytesFreed) // approximate bytes actually freed
-{
- mdb_err outErr = 0;
- mdb_size estimatedBytesFreed = 0;
- morkEnv* ev = this->CanUseStore(mev, /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- // ev->StubMethodOnlyError(); // okay to do nothing?
- outErr = ev->AsErr();
- }
- if ( outEstimatedBytesFreed )
- *outEstimatedBytesFreed = estimatedBytesFreed;
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinStore::SessionMemoryPurge( // request specific footprint decrease
- nsIMdbEnv* mev, // context
- mdb_size inDesiredBytesFreed, // approximate number of bytes wanted
- mdb_size* outEstimatedBytesFreed) // approximate bytes actually freed
-{
- MORK_USED_1(inDesiredBytesFreed);
- mdb_err outErr = 0;
- mdb_size estimate = 0;
- morkEnv* ev = this->CanUseStore(mev, /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- // ev->StubMethodOnlyError(); // okay to do nothing?
- outErr = ev->AsErr();
- }
- if ( outEstimatedBytesFreed )
- *outEstimatedBytesFreed = estimate;
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinStore::PanicMemoryPurge( // desperately free all possible memory
- nsIMdbEnv* mev, // context
- mdb_size* outEstimatedBytesFreed) // approximate bytes actually freed
-{
- mdb_err outErr = 0;
- mdb_size estimate = 0;
- morkEnv* ev = this->CanUseStore(mev, /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- // ev->StubMethodOnlyError(); // okay to do nothing?
- outErr = ev->AsErr();
- }
- if ( outEstimatedBytesFreed )
- *outEstimatedBytesFreed = estimate;
- return outErr;
-}
-// } ----- end memory policy methods -----
-
-// { ----- begin filepath methods -----
-/*virtual*/ mdb_err
-orkinStore::GetPortFilePath(
- nsIMdbEnv* mev, // context
- mdbYarn* outFilePath, // name of file holding port content
- mdbYarn* outFormatVersion) // file format description
-{
- mdb_err outErr = 0;
- if ( outFormatVersion )
- outFormatVersion->mYarn_Fill = 0;
- if ( outFilePath )
- outFilePath->mYarn_Fill = 0;
- morkEnv* ev = this->CanUseStore(mev, /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- morkStore* store = (morkStore*) mHandle_Object;
- nsIMdbFile* file = store->mStore_File;
-
- if ( file )
- file->Path(mev, outFilePath);
- else
- store->NilStoreFileError(ev);
-
- outErr = ev->AsErr();
- }
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinStore::GetPortFile(
- nsIMdbEnv* mev, // context
- nsIMdbFile** acqFile) // acquire file used by port or store
-{
- mdb_err outErr = 0;
- if ( acqFile )
- *acqFile = 0;
-
- morkEnv* ev = this->CanUseStore(mev, /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- morkStore* store = (morkStore*) mHandle_Object;
- nsIMdbFile* file = store->mStore_File;
-
- if ( file )
- {
- if ( acqFile )
- {
- file->AddStrongRef(mev);
- if ( ev->Good() )
- *acqFile = file;
- }
- }
- else
- store->NilStoreFileError(ev);
-
- outErr = ev->AsErr();
- }
- return outErr;
-}
-// } ----- end filepath methods -----
-
-// { ----- begin export methods -----
-/*virtual*/ mdb_err
-orkinStore::BestExportFormat( // determine preferred export format
- nsIMdbEnv* mev, // context
- mdbYarn* outFormatVersion) // file format description
-{
- mdb_err outErr = 0;
- if ( outFormatVersion )
- outFormatVersion->mYarn_Fill = 0;
- morkEnv* ev = this->CanUseStore(mev, /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- ev->StubMethodOnlyError();
- outErr = ev->AsErr();
- }
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinStore::CanExportToFormat( // can export content in given specific format?
- nsIMdbEnv* mev, // context
- const char* inFormatVersion, // file format description
- mdb_bool* outCanExport) // whether ExportSource() might succeed
-{
- MORK_USED_1(inFormatVersion);
- mdb_bool canExport = morkBool_kFalse;
- mdb_err outErr = 0;
- morkEnv* ev = this->CanUseStore(mev, /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- ev->StubMethodOnlyError();
- outErr = ev->AsErr();
- }
- if ( outCanExport )
- *outCanExport = canExport;
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinStore::ExportToFormat( // export content in given specific format
- nsIMdbEnv* mev, // context
- // const char* inFilePath, // the file to receive exported content
- nsIMdbFile* ioFile, // destination abstract file interface
- const char* inFormatVersion, // file format description
- nsIMdbThumb** acqThumb) // acquire thumb for incremental export
-// Call nsIMdbThumb::DoMore() until done, or until the thumb is broken, and
-// then the export will be finished.
-{
- mdb_err outErr = 0;
- nsIMdbThumb* outThumb = 0;
- morkEnv* ev = this->CanUseStore(mev, /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- if ( ioFile && inFormatVersion && acqThumb )
- {
- ev->StubMethodOnlyError();
- }
- else
- ev->NilPointerError();
-
- outErr = ev->AsErr();
- }
- if ( acqThumb )
- *acqThumb = outThumb;
- return outErr;
-}
-
-// } ----- end export methods -----
-
-// { ----- begin token methods -----
-/*virtual*/ mdb_err
-orkinStore::TokenToString( // return a string name for an integer token
- nsIMdbEnv* mev, // context
- mdb_token inToken, // token for inTokenName inside this port
- mdbYarn* outTokenName) // the type of table to access
-{
- mdb_err outErr = 0;
- morkEnv* ev = this->CanUseStore(mev, /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- ((morkStore*) mHandle_Object)->TokenToString(ev, inToken, outTokenName);
- outErr = ev->AsErr();
- }
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinStore::StringToToken( // return an integer token for scope name
- nsIMdbEnv* mev, // context
- const char* inTokenName, // Latin1 string to tokenize if possible
- mdb_token* outToken) // token for inTokenName inside this port
- // String token zero is never used and never supported. If the port
- // is a mutable store, then StringToToken() to create a new
- // association of inTokenName with a new integer token if possible.
- // But a readonly port will return zero for an unknown scope name.
-{
- mdb_err outErr = 0;
- mdb_token token = 0;
- morkEnv* ev = this->CanUseStore(mev, /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- token = ((morkStore*) mHandle_Object)->StringToToken(ev, inTokenName);
- outErr = ev->AsErr();
- }
- if ( outToken )
- *outToken = token;
- return outErr;
-}
-
-
-/*virtual*/ mdb_err
-orkinStore::QueryToken( // like StringToToken(), but without adding
- nsIMdbEnv* mev, // context
- const char* inTokenName, // Latin1 string to tokenize if possible
- mdb_token* outToken) // token for inTokenName inside this port
- // QueryToken() will return a string token if one already exists,
- // but unlike StringToToken(), will not assign a new token if not
- // already in use.
-{
- mdb_err outErr = 0;
- mdb_token token = 0;
- morkEnv* ev = this->CanUseStore(mev, /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- token = ((morkStore*) mHandle_Object)->QueryToken(ev, inTokenName);
- outErr = ev->AsErr();
- }
- if ( outToken )
- *outToken = token;
- return outErr;
-}
-
-
-// } ----- end token methods -----
-
-// { ----- begin row methods -----
-/*virtual*/ mdb_err
-orkinStore::HasRow( // contains a row with the specified oid?
- nsIMdbEnv* mev, // context
- const mdbOid* inOid, // hypothetical row oid
- mdb_bool* outHasRow) // whether GetRow() might succeed
-{
- mdb_err outErr = 0;
- mdb_bool hasRow = morkBool_kFalse;
- morkEnv* ev = this->CanUseStore(mev, /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- morkStore* store = (morkStore*) mHandle_Object;
- morkRow* row = store->GetRow(ev, inOid);
- if ( row )
- hasRow = morkBool_kTrue;
-
- outErr = ev->AsErr();
- }
- if ( outHasRow )
- *outHasRow = hasRow;
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinStore::GetRow( // access one row with specific oid
- nsIMdbEnv* mev, // context
- const mdbOid* inOid, // hypothetical row oid
- nsIMdbRow** acqRow) // acquire specific row (or null)
-{
- mdb_err outErr = 0;
- nsIMdbRow* outRow = 0;
- morkEnv* ev = this->CanUseStore(mev, /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- morkStore* store = (morkStore*) mHandle_Object;
- morkRow* row = store->GetRow(ev, inOid);
- if ( row && ev->Good() )
- outRow = row->AcquireRowHandle(ev, store);
-
- outErr = ev->AsErr();
- }
- if ( acqRow )
- *acqRow = outRow;
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinStore::GetRowRefCount( // get number of tables that contain a row
- nsIMdbEnv* mev, // context
- const mdbOid* inOid, // hypothetical row oid
- mdb_count* outRefCount) // number of tables containing inRowKey
-{
- mdb_err outErr = 0;
- mdb_count count = 0;
- morkEnv* ev = this->CanUseStore(mev, /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- morkStore* store = (morkStore*) mHandle_Object;
- morkRow* row = store->GetRow(ev, inOid);
- if ( row && ev->Good() )
- count = row->mRow_GcUses;
-
- outErr = ev->AsErr();
- }
- if ( outRefCount )
- *outRefCount = count;
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinStore::FindRow(nsIMdbEnv* mev, // search for row with matching cell
- mdb_scope inRowScope, // row scope for row ids
- mdb_column inColumn, // the column to search (and maintain an index)
- const mdbYarn* inTargetCellValue, // cell value for which to search
- mdbOid* outRowOid, // out row oid on match (or {0,-1} for no match)
- nsIMdbRow** acqRow) // acquire matching row (or nil for no match)
- // FindRow() searches for one row that has a cell in column inColumn with
- // a contained value with the same form (i.e. charset) and is byte-wise
- // identical to the blob described by yarn inTargetCellValue. Both content
- // and form of the yarn must be an exact match to find a matching row.
- //
- // (In other words, both a yarn's blob bytes and form are significant. The
- // form is not expected to vary in columns used for identity anyway. This
- // is intended to make the cost of FindRow() cheaper for MDB implementors,
- // since any cell value atomization performed internally must necessarily
- // make yarn form significant in order to avoid data loss in atomization.)
- //
- // FindRow() can lazily create an index on attribute inColumn for all rows
- // with that attribute in row space scope inRowScope, so that subsequent
- // calls to FindRow() will perform faster. Such an index might or might
- // not be persistent (but this seems desirable if it is cheap to do so).
- // Note that lazy index creation in readonly DBs is not very feasible.
- //
- // This FindRow() interface assumes that attribute inColumn is effectively
- // an alternative means of unique identification for a row in a rowspace,
- // so correct behavior is only guaranteed when no duplicates for this col
- // appear in the given set of rows. (If more than one row has the same cell
- // value in this column, no more than one will be found; and cutting one of
- // two duplicate rows can cause the index to assume no other such row lives
- // in the row space, so future calls return nil for negative search results
- // even though some duplicate row might still live within the rowspace.)
- //
- // In other words, the FindRow() implementation is allowed to assume simple
- // hash tables mapping unqiue column keys to associated row values will be
- // sufficient, where any duplication is not recorded because only one copy
- // of a given key need be remembered. Implementors are not required to sort
- // all rows by the specified column.
-{
- mdb_err outErr = 0;
- nsIMdbRow* outRow = 0;
- mdbOid rowOid;
- rowOid.mOid_Scope = 0;
- rowOid.mOid_Id = (mdb_id) -1;
-
- morkEnv* ev = this->CanUseStore(mev, /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- morkStore* store = (morkStore*) mHandle_Object;
- morkRow* row = store->FindRow(ev, inRowScope, inColumn, inTargetCellValue);
- if ( row && ev->Good() )
- {
- outRow = row->AcquireRowHandle(ev, store);
- if ( outRow )
- rowOid = row->mRow_Oid;
- }
- outErr = ev->AsErr();
- }
- if ( acqRow )
- *acqRow = outRow;
-
- return outErr;
-}
-
-// } ----- end row methods -----
-
-// { ----- begin table methods -----
-/*virtual*/ mdb_err
-orkinStore::HasTable( // supports a table with the specified oid?
- nsIMdbEnv* mev, // context
- const mdbOid* inOid, // hypothetical table oid
- mdb_bool* outHasTable) // whether GetTable() might succeed
-{
- mdb_err outErr = 0;
- mork_bool hasTable = morkBool_kFalse;
- morkEnv* ev = this->CanUseStore(mev, /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- morkTable* table = ((morkStore*) mHandle_Object)->GetTable(ev, inOid);
- if ( table )
- hasTable = morkBool_kTrue;
-
- outErr = ev->AsErr();
- }
- if ( outHasTable )
- *outHasTable = hasTable;
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinStore::GetTable( // access one table with specific oid
- nsIMdbEnv* mev, // context
- const mdbOid* inOid, // hypothetical table oid
- nsIMdbTable** acqTable) // acquire specific table (or null)
-{
- mdb_err outErr = 0;
- nsIMdbTable* outTable = 0;
- morkEnv* ev = this->CanUseStore(mev, /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- morkTable* table =
- ((morkStore*) mHandle_Object)->GetTable(ev, inOid);
- if ( table && ev->Good() )
- outTable = table->AcquireTableHandle(ev);
- outErr = ev->AsErr();
- }
- if ( acqTable )
- *acqTable = outTable;
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinStore::HasTableKind( // supports a table of the specified type?
- nsIMdbEnv* mev, // context
- mdb_scope inRowScope, // rid scope for row ids
- mdb_kind inTableKind, // the type of table to access
- mdb_count* outTableCount, // current number of such tables
- mdb_bool* outSupportsTable) // whether GetTableKind() might succeed
-{
- mdb_err outErr = 0;
- morkEnv* ev = this->CanUseStore(mev, /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- *outSupportsTable =
- ((morkStore*) mHandle_Object)->HasTableKind(ev, inRowScope,
- inTableKind, outTableCount);
- outErr = ev->AsErr();
- }
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinStore::GetTableKind( // access one (random) table of specific type
- nsIMdbEnv* mev, // context
- mdb_scope inRowScope, // row scope for row ids
- mdb_kind inTableKind, // the type of table to access
- mdb_count* outTableCount, // current number of such tables
- mdb_bool* outMustBeUnique, // whether port can hold only one of these
- nsIMdbTable** acqTable) // acquire scoped collection of rows
-{
- mdb_err outErr = 0;
- nsIMdbTable* outTable = 0;
- morkEnv* ev = this->CanUseStore(mev, /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- morkTable* table =
- ((morkStore*) mHandle_Object)->GetTableKind(ev, inRowScope,
- inTableKind, outTableCount, outMustBeUnique);
- if ( table && ev->Good() )
- outTable = table->AcquireTableHandle(ev);
- outErr = ev->AsErr();
- }
- if ( acqTable )
- *acqTable = outTable;
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinStore::GetPortTableCursor( // get cursor for all tables of specific type
- nsIMdbEnv* mev, // context
- mdb_scope inRowScope, // row scope for row ids
- mdb_kind inTableKind, // the type of table to access
- nsIMdbPortTableCursor** acqCursor) // all such tables in the port
-{
- mdb_err outErr = 0;
- nsIMdbPortTableCursor* outCursor = 0;
- morkEnv* ev = this->CanUseStore(mev, /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- morkPortTableCursor* cursor =
- ((morkStore*) mHandle_Object)->GetPortTableCursor(ev, inRowScope,
- inTableKind);
- if ( cursor && ev->Good() )
- outCursor = cursor->AcquirePortTableCursorHandle(ev);
-
- outErr = ev->AsErr();
- }
- if ( acqCursor )
- *acqCursor = outCursor;
- return outErr;
-}
-// } ----- end table methods -----
-
-// { ----- begin commit methods -----
-
-/*virtual*/ mdb_err
-orkinStore::ShouldCompress( // store wastes at least inPercentWaste?
- nsIMdbEnv* mev, // context
- mdb_percent inPercentWaste, // 0..100 percent file size waste threshold
- mdb_percent* outActualWaste, // 0..100 percent of file actually wasted
- mdb_bool* outShould) // true when about inPercentWaste% is wasted
-{
- mdb_percent actualWaste = 0;
- mdb_bool shouldCompress = morkBool_kFalse;
- mdb_err outErr = 0;
- morkEnv* ev = this->CanUseStore(mev, /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- actualWaste = ((morkStore*) mHandle_Object)->PercentOfStoreWasted(ev);
- if ( inPercentWaste > 100 )
- inPercentWaste = 100;
- shouldCompress = ( actualWaste >= inPercentWaste );
- outErr = ev->AsErr();
- }
- if ( outActualWaste )
- *outActualWaste = actualWaste;
- if ( outShould )
- *outShould = shouldCompress;
- return outErr;
-}
-
-
-// } ===== end nsIMdbPort methods =====
-
-// { ===== begin nsIMdbStore methods =====
-
-// { ----- begin table methods -----
-/*virtual*/ mdb_err
-orkinStore::NewTable( // make one new table of specific type
- nsIMdbEnv* mev, // context
- mdb_scope inRowScope, // row scope for row ids
- mdb_kind inTableKind, // the type of table to access
- mdb_bool inMustBeUnique, // whether store can hold only one of these
- const mdbOid* inOptionalMetaRowOid, // can be nil to avoid specifying
- nsIMdbTable** acqTable) // acquire scoped collection of rows
-{
- mdb_err outErr = 0;
- nsIMdbTable* outTable = 0;
- morkEnv* ev = this->CanUseStore(mev, /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- morkTable* table =
- ((morkStore*) mHandle_Object)->NewTable(ev, inRowScope,
- inTableKind, inMustBeUnique, inOptionalMetaRowOid);
- if ( table && ev->Good() )
- outTable = table->AcquireTableHandle(ev);
- outErr = ev->AsErr();
- }
- if ( acqTable )
- *acqTable = outTable;
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinStore::NewTableWithOid( // make one new table of specific type
- nsIMdbEnv* mev, // context
- const mdbOid* inOid, // caller assigned oid
- mdb_kind inTableKind, // the type of table to access
- mdb_bool inMustBeUnique, // whether store can hold only one of these
- const mdbOid* inOptionalMetaRowOid, // can be nil to avoid specifying
- nsIMdbTable** acqTable) // acquire scoped collection of rows
-{
- mdb_err outErr = 0;
- nsIMdbTable* outTable = 0;
- morkEnv* ev = this->CanUseStore(mev, /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- morkTable* table = ((morkStore*) mHandle_Object)->OidToTable(ev, inOid,
- inOptionalMetaRowOid);
- if ( table && ev->Good() )
- {
- table->mTable_Kind = inTableKind;
- if ( inMustBeUnique )
- table->SetTableUnique();
- outTable = table->AcquireTableHandle(ev);
- }
- outErr = ev->AsErr();
- }
- if ( acqTable )
- *acqTable = outTable;
- return outErr;
-}
-// } ----- end table methods -----
-
-// { ----- begin row scope methods -----
-/*virtual*/ mdb_err
-orkinStore::RowScopeHasAssignedIds(nsIMdbEnv* mev,
- mdb_scope inRowScope, // row scope for row ids
- mdb_bool* outCallerAssigned, // nonzero if caller assigned specified
- mdb_bool* outStoreAssigned) // nonzero if store db assigned specified
-{
- MORK_USED_1(inRowScope);
- mdb_bool storeAssigned = morkBool_kFalse;
- mdb_bool callerAssigned = morkBool_kFalse;
- mdb_err outErr = 0;
- morkEnv* ev = this->CanUseStore(mev, /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- ev->StubMethodOnlyError();
- outErr = ev->AsErr();
- }
- if ( outCallerAssigned )
- *outCallerAssigned = callerAssigned;
- if ( outStoreAssigned )
- *outStoreAssigned = storeAssigned;
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinStore::SetCallerAssignedIds(nsIMdbEnv* mev,
- mdb_scope inRowScope, // row scope for row ids
- mdb_bool* outCallerAssigned, // nonzero if caller assigned specified
- mdb_bool* outStoreAssigned) // nonzero if store db assigned specified
-{
- MORK_USED_1(inRowScope);
- mdb_bool storeAssigned = morkBool_kFalse;
- mdb_bool callerAssigned = morkBool_kFalse;
- mdb_err outErr = 0;
- morkEnv* ev = this->CanUseStore(mev, /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- ev->StubMethodOnlyError();
- outErr = ev->AsErr();
- }
- if ( outCallerAssigned )
- *outCallerAssigned = callerAssigned;
- if ( outStoreAssigned )
- *outStoreAssigned = storeAssigned;
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinStore::SetStoreAssignedIds(nsIMdbEnv* mev,
- mdb_scope inRowScope, // row scope for row ids
- mdb_bool* outCallerAssigned, // nonzero if caller assigned specified
- mdb_bool* outStoreAssigned) // nonzero if store db assigned specified
-{
- MORK_USED_1(inRowScope);
- mdb_err outErr = 0;
- mdb_bool storeAssigned = morkBool_kFalse;
- mdb_bool callerAssigned = morkBool_kFalse;
- morkEnv* ev = this->CanUseStore(mev, /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- ev->StubMethodOnlyError();
- outErr = ev->AsErr();
- }
- if ( outCallerAssigned )
- *outCallerAssigned = callerAssigned;
- if ( outStoreAssigned )
- *outStoreAssigned = storeAssigned;
- return outErr;
-}
-// } ----- end row scope methods -----
-
-// { ----- begin row methods -----
-/*virtual*/ mdb_err
-orkinStore::NewRowWithOid(nsIMdbEnv* mev, // new row w/ caller assigned oid
- const mdbOid* inOid, // caller assigned oid
- nsIMdbRow** acqRow) // create new row
-{
- mdb_err outErr = 0;
- nsIMdbRow* outRow = 0;
- morkEnv* ev = this->CanUseStore(mev, /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- morkStore* store = (morkStore*) mHandle_Object;
- morkRow* row = store->NewRowWithOid(ev, inOid);
- if ( row && ev->Good() )
- outRow = row->AcquireRowHandle(ev, store);
-
- outErr = ev->AsErr();
- }
- if ( acqRow )
- *acqRow = outRow;
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinStore::NewRow(nsIMdbEnv* mev, // new row with db assigned oid
- mdb_scope inRowScope, // row scope for row ids
- nsIMdbRow** acqRow) // create new row
-// Note this row must be added to some table or cell child before the
-// store is closed in order to make this row persist across sesssions.
-{
- mdb_err outErr = 0;
- nsIMdbRow* outRow = 0;
- morkEnv* ev = this->CanUseStore(mev, /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- morkStore* store = (morkStore*) mHandle_Object;
- morkRow* row = store->NewRow(ev, inRowScope);
- if ( row && ev->Good() )
- outRow = row->AcquireRowHandle(ev, store);
-
- outErr = ev->AsErr();
- }
- if ( acqRow )
- *acqRow = outRow;
- return outErr;
-}
-// } ----- end row methods -----
-
-// { ----- begin inport/export methods -----
-/*virtual*/ mdb_err
-orkinStore::ImportContent( // import content from port
- nsIMdbEnv* mev, // context
- mdb_scope inRowScope, // scope for rows (or zero for all?)
- nsIMdbPort* ioPort, // the port with content to add to store
- nsIMdbThumb** acqThumb) // acquire thumb for incremental import
-// Call nsIMdbThumb::DoMore() until done, or until the thumb is broken, and
-// then the import will be finished.
-{
- MORK_USED_2(inRowScope,ioPort);
- nsIMdbThumb* outThumb = 0;
- mdb_err outErr = 0;
- morkEnv* ev = this->CanUseStore(mev, /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- ev->StubMethodOnlyError();
- outErr = ev->AsErr();
- }
- if ( acqThumb )
- *acqThumb = outThumb;
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinStore::ImportFile( // import content from port
- nsIMdbEnv* mev, // context
- nsIMdbFile* ioFile, // the file with content to add to store
- nsIMdbThumb** acqThumb) // acquire thumb for incremental import
-// Call nsIMdbThumb::DoMore() until done, or until the thumb is broken, and
-// then the import will be finished.
-{
- nsIMdbThumb* outThumb = 0;
- mdb_err outErr = 0;
- morkEnv* ev = this->CanUseStore(mev, /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- if ( ioFile && acqThumb )
- {
- ev->StubMethodOnlyError();
- }
- else
- ev->NilPointerError();
-
- outErr = ev->AsErr();
- }
- if ( acqThumb )
- *acqThumb = outThumb;
- return outErr;
-}
-// } ----- end inport/export methods -----
-
-// { ----- begin hinting methods -----
-/*virtual*/ mdb_err
-orkinStore::ShareAtomColumnsHint( // advise re shared col content atomizing
- nsIMdbEnv* mev, // context
- mdb_scope inScopeHint, // zero, or suggested shared namespace
- const mdbColumnSet* inColumnSet) // cols desired tokenized together
-{
- MORK_USED_2(inColumnSet,inScopeHint);
- mdb_err outErr = 0;
- morkEnv* ev = this->CanUseStore(mev, /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- // ev->StubMethodOnlyError(); // okay to do nothing for a hint method
- outErr = ev->AsErr();
- }
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinStore::AvoidAtomColumnsHint( // advise col w/ poor atomizing prospects
- nsIMdbEnv* mev, // context
- const mdbColumnSet* inColumnSet) // cols with poor atomizing prospects
-{
- MORK_USED_1(inColumnSet);
- mdb_err outErr = 0;
- morkEnv* ev = this->CanUseStore(mev, /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- // ev->StubMethodOnlyError(); // okay to do nothing for a hint method
- outErr = ev->AsErr();
- }
- return outErr;
-}
-// } ----- end hinting methods -----
-
-// { ----- begin commit methods -----
-/*virtual*/ mdb_err
-orkinStore::SmallCommit( // save minor changes if convenient and uncostly
- nsIMdbEnv* mev) // context
-{
- mdb_err outErr = 0;
- morkEnv* ev = this->CanUseStore(mev, /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- // ev->StubMethodOnlyError(); // it's okay to do nothing for small commit
- outErr = ev->AsErr();
- }
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinStore::LargeCommit( // save important changes if at all possible
- nsIMdbEnv* mev, // context
- nsIMdbThumb** acqThumb) // acquire thumb for incremental commit
-// Call nsIMdbThumb::DoMore() until done, or until the thumb is broken, and
-// then the commit will be finished. Note the store is effectively write
-// locked until commit is finished or canceled through the thumb instance.
-// Until the commit is done, the store will report it has readonly status.
-{
- mdb_err outErr = 0;
- nsIMdbThumb* outThumb = 0;
- morkEnv* ev = this->CanUseStore(mev, /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- morkStore* store = (morkStore*) mHandle_Object;
- nsIMdbHeap* heap = store->mPort_Heap;
-
- morkThumb* thumb = 0;
- // morkFile* file = store->mStore_File;
- if ( store->DoPreferLargeOverCompressCommit(ev) )
- {
- thumb = morkThumb::Make_LargeCommit(ev, heap, store);
- }
- else
- {
- mork_bool doCollect = morkBool_kFalse;
- thumb = morkThumb::Make_CompressCommit(ev, heap, store, doCollect);
- }
-
- if ( thumb )
- {
- outThumb = thumb;
- thumb->AddRef();
- }
-
- outErr = ev->AsErr();
- }
- if ( acqThumb )
- *acqThumb = outThumb;
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinStore::SessionCommit( // save all changes if large commits delayed
- nsIMdbEnv* mev, // context
- nsIMdbThumb** acqThumb) // acquire thumb for incremental commit
-// Call nsIMdbThumb::DoMore() until done, or until the thumb is broken, and
-// then the commit will be finished. Note the store is effectively write
-// locked until commit is finished or canceled through the thumb instance.
-// Until the commit is done, the store will report it has readonly status.
-{
- mdb_err outErr = 0;
- nsIMdbThumb* outThumb = 0;
- morkEnv* ev = this->CanUseStore(mev, /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- morkStore* store = (morkStore*) mHandle_Object;
- nsIMdbHeap* heap = store->mPort_Heap;
-
- morkThumb* thumb = 0;
- if ( store->DoPreferLargeOverCompressCommit(ev) )
- {
- thumb = morkThumb::Make_LargeCommit(ev, heap, store);
- }
- else
- {
- mork_bool doCollect = morkBool_kFalse;
- thumb = morkThumb::Make_CompressCommit(ev, heap, store, doCollect);
- }
-
- if ( thumb )
- {
- outThumb = thumb;
- thumb->AddRef();
- }
- outErr = ev->AsErr();
- }
- if ( acqThumb )
- *acqThumb = outThumb;
- return outErr;
-}
-
-/*virtual*/ mdb_err
-orkinStore::CompressCommit( // commit and make db smaller if possible
- nsIMdbEnv* mev, // context
- nsIMdbThumb** acqThumb) // acquire thumb for incremental commit
-// Call nsIMdbThumb::DoMore() until done, or until the thumb is broken, and
-// then the commit will be finished. Note the store is effectively write
-// locked until commit is finished or canceled through the thumb instance.
-// Until the commit is done, the store will report it has readonly status.
-{
- mdb_err outErr = 0;
- nsIMdbThumb* outThumb = 0;
- morkEnv* ev = this->CanUseStore(mev, /*inMutable*/ morkBool_kFalse, &outErr);
- if ( ev )
- {
- morkStore* store = (morkStore*) mHandle_Object;
- nsIMdbHeap* heap = store->mPort_Heap;
- mork_bool doCollect = morkBool_kFalse;
- morkThumb* thumb = morkThumb::Make_CompressCommit(ev, heap, store, doCollect);
- if ( thumb )
- {
- outThumb = thumb;
- thumb->AddRef();
- store->mStore_CanWriteIncremental = morkBool_kTrue;
- }
-
- outErr = ev->AsErr();
- }
- if ( acqThumb )
- *acqThumb = outThumb;
- return outErr;
-}
-
-// } ----- end commit methods -----
-
-// } ===== end nsIMdbStore methods =====
-
-
-//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
deleted file mode 100644
--- a/db/mork/src/orkinStore.h
+++ /dev/null
@@ -1,505 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (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.mozilla.org/MPL/
- *
- * 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 mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1999
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef _ORKINSTORE_
-#define _ORKINSTORE_ 1
-
-#ifndef _MDB_
-#include "mdb.h"
-#endif
-
-#ifndef _MORK_
-#include "mork.h"
-#endif
-
-#ifndef _MORKNODE_
-#include "morkNode.h"
-#endif
-
-#ifndef _MORKHANDLE_
-#include "morkHandle.h"
-#endif
-
-#ifndef _MORKStore_
-#include "morkStore.h"
-#endif
-
-//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
-
-#define morkMagic_kStore 0x53746F72 /* ascii 'Stor' */
-
-/*| orkinStore:
-|*/
-class orkinStore : public morkHandle, public nsIMdbStore { // nsIMdbPort
-
-// { ===== begin morkNode interface =====
-public: // morkNode virtual methods
- // virtual void CloseMorkNode(morkEnv* ev); // morkHandle is fine
- virtual ~orkinStore(); // morkHandle destructor does everything
-
-protected: // construction is protected (use the static Make() method)
- orkinStore(morkEnv* ev, // note morkUsage is always morkUsage_kPool
- morkHandleFace* ioFace, // must not be nil, cookie for this handle
- morkStore* ioObject); // must not be nil, the object for this handle
-
- // void CloseHandle(morkEnv* ev); // don't need to specialize closing
-
-private: // copying is not allowed
- orkinStore(const morkHandle& other);
- orkinStore& operator=(const morkHandle& other);
-
-// public: // dynamic type identification
- // mork_bool IsHandle() const //
- // { return IsNode() && mNode_Derived == morkDerived_kHandle; }
-// } ===== end morkNode methods =====
-
-protected: // morkHandle memory management operators
- void* operator new(size_t inSize, morkPool& ioPool, morkZone& ioZone, morkEnv* ev) CPP_THROW_NEW
- { return ioPool.NewHandle(ev, inSize, &ioZone); }
-
- void* operator new(size_t inSize, morkPool& ioPool, morkEnv* ev) CPP_THROW_NEW
- { return ioPool.NewHandle(ev, inSize, (morkZone*) 0); }
-
- void* operator new(size_t inSize, morkHandleFace* ioFace) CPP_THROW_NEW
- { MORK_USED_1(inSize); return ioFace; }
-