From owner-freebsd-libh Wed Jan 30 13:47: 7 2002 Delivered-To: freebsd-libh@freebsd.org Received: from tomts12-srv.bellnexxia.net (tomts12.bellnexxia.net [209.226.175.56]) by hub.freebsd.org (Postfix) with ESMTP id 610F537B400 for ; Wed, 30 Jan 2002 13:47:03 -0800 (PST) Received: from khan.anarcat.dyndns.org ([65.94.186.7]) by tomts12-srv.bellnexxia.net (InterMail vM.4.01.03.16 201-229-121-116-20010115) with ESMTP id <20020130214702.NZPF9396.tomts12-srv.bellnexxia.net@khan.anarcat.dyndns.org>; Wed, 30 Jan 2002 16:47:02 -0500 Received: from shall.anarcat.dyndns.org (shall.anarcat.dyndns.org [192.168.0.1]) by khan.anarcat.dyndns.org (Postfix) with ESMTP id 934FB189F; Wed, 30 Jan 2002 16:46:55 -0500 (EST) Received: by shall.anarcat.dyndns.org (Postfix, from userid 1000) id 8840E20ACA; Wed, 30 Jan 2002 16:46:56 -0500 (EST) Date: Wed, 30 Jan 2002 16:46:55 -0500 From: The Anarcat To: Libh , Alexander Langer Subject: making Database::create the "default" Database tclh command and Exceptions Message-ID: <20020130214652.GA441@shall.anarcat.dyndns.org> Mail-Followup-To: The Anarcat , Libh , Alexander Langer Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="UlVJffcvxoiEqYs2" Content-Disposition: inline User-Agent: Mutt/1.3.25i Sender: owner-freebsd-libh@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG --UlVJffcvxoiEqYs2 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi. I'm currently working to start looking around the packaging code, and i have something I think could be implemented and be quite helpful. I've been able to implement the default directory thing without big problems. In the making, I noticed that the Database::open and Database::create are just stubs to the Database() constructor. I think it could be a good idea to have the tcl "Database" command (defined in lib/sysinstall/Database.cd.cc) call Database::create instead of Database::open. Both functions perform almost the same tasks, except that Database::create allows creation of the database if missing. That would allow pkg tools to avoid handling cases where the database is not created. It would imply some modifications to the code, of course, but not only to the .cd.cc file. The Database() constructor needs to know that the database indeed exist. The best way to do this, IMHO, is to use exceptions. I hesitate to assume that a runtime_exception coming out of Database::create().=20 Also, exceptions is a proper way to handle many conditions in C++ and nothing keeps us from making extra exception namespaces for libh. Anyways, here's the patches to deal with this. Right now, it doesn't implement extra exception namespaces, but this is not too hard. --- Database.cc 2002/01/21 21:44:52 1.4 +++ Database.cc 2002/01/30 21:42:51 @@ -83,7 +83,11 @@ addSYSTEMpackage &=3D mOpenFlag =3D=3D ofCreate; if ( mOpenFlag =3D=3D ofCreate ) { mOpenFlag =3D ofReadWrite; - create(); + try { + create(); + } catch (...) { + =20 + } } =20 engine().lock(); --- Database.cd.cc 2002/01/21 21:44:52 1.6 +++ Database.cd.cc 2002/01/30 21:45:28 @@ -55,7 +55,7 @@ "Configuration::instance()->dbPath()", "base_dir")), =20 - MethodDescription("Database", "open", + MethodDescription("Database", "create", LanguageInterface::Object::MethodDescription::fStatic, "Opens existing Database", MethodDescription::Value(MethodDescription::vtObject, A. --UlVJffcvxoiEqYs2 Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (FreeBSD) Comment: For info see http://www.gnupg.org iEYEARECAAYFAjxYacsACgkQttcWHAnWiGcIdgCfdPugMzBAmxYnvtFyZwyyeEYl hcMAn1AK1uGNY2EAemBywSWw4yJYbxjy =UXmZ -----END PGP SIGNATURE----- --UlVJffcvxoiEqYs2-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-libh" in the body of the message