From owner-freebsd-current@FreeBSD.ORG Wed Nov 24 21:44:43 2004 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0C42A16A4CE for ; Wed, 24 Nov 2004 21:44:43 +0000 (GMT) Received: from mail1.speakeasy.net (mail1.speakeasy.net [216.254.0.201]) by mx1.FreeBSD.org (Postfix) with ESMTP id C0D8543D45 for ; Wed, 24 Nov 2004 21:44:42 +0000 (GMT) (envelope-from jmg@hydrogen.funkthat.com) Received: (qmail 15315 invoked from network); 24 Nov 2004 21:44:42 -0000 Received: from gate.funkthat.com (HELO hydrogen.funkthat.com) ([69.17.45.168]) (envelope-sender ) by mail1.speakeasy.net (qmail-ldap-1.03) with SMTP for ; 24 Nov 2004 21:44:42 -0000 Received: from hydrogen.funkthat.com (jqdovs@localhost.funkthat.com [127.0.0.1])iAOLifGH008657; Wed, 24 Nov 2004 13:44:41 -0800 (PST) (envelope-from jmg@hydrogen.funkthat.com) Received: (from jmg@localhost) by hydrogen.funkthat.com (8.12.10/8.12.10/Submit) id iAOLie4J008656; Wed, 24 Nov 2004 13:44:40 -0800 (PST) Date: Wed, 24 Nov 2004 13:44:40 -0800 From: John-Mark Gurney To: Charles Swiger Message-ID: <20041124214440.GC5166@funkthat.com> Mail-Followup-To: Charles Swiger , freebsd-current@freebsd.org References: <200411231226.38172.jkim@niksun.com> <200411231343.22760.jhb@FreeBSD.org> <20041124002603.GD20881@squash.dsto.defence.gov.au> <41A416E7.4030107@mac.com> <20041124184124.GA5166@funkthat.com> <88534D8A-3E57-11D9-BD47-003065ABFD92@mac.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <88534D8A-3E57-11D9-BD47-003065ABFD92@mac.com> User-Agent: Mutt/1.4.1i X-Operating-System: FreeBSD 4.2-RELEASE i386 X-PGP-Fingerprint: B7 EC EF F8 AE ED A7 31 96 7A 22 B3 D8 56 36 F4 X-Files: The truth is out there X-URL: http://resnet.uoregon.edu/~gurney_j/ X-Resume: http://resnet.uoregon.edu/~gurney_j/resume.html cc: freebsd-current@freebsd.org Subject: Re: Transparent bridges (a. k. a. HUB-to-PCI bridges)? X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: John-Mark Gurney List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 24 Nov 2004 21:44:43 -0000 Charles Swiger wrote this message on Wed, Nov 24, 2004 at 15:29 -0500: > On Nov 24, 2004, at 1:41 PM, John-Mark Gurney wrote: > >>True OOP involves encapsulation, polymorphism, and inheritence, and > >>requires language support which is not really available in pure C. > >>That > >>being said, careful programming in C lets you create several > >>closely-related structs for different types of "objects" which can > >>all be > >>utilized by a common set of functions. > > > >You should read up on KOBJ's which is how device_t's are implemented > >in FreeBSD... kobj's are a loop more OOP that you think... > > OK. I've taken a look at sys/kobj.h and sys/kern/subr_kobj.c, is there > something else I should read? There is also a man page, but it's not much more complete... > My take on it, for what it is worth, is that KOBJs implement the class > versus instance paradigm, have a dynamic runtime & method dispatch > rather similar to the implementation of Objective-C or virtual C++ > methods. Yes, this is a lot more object-oriented than what I said > about being disciplined using C struct's. :-) Correct, kobj implements the class side of things, and then if you look at device(9), you'll see the instance implementation part of kobj's.. > Things that one still doesn't have is encapsulation in the sense of > data hiding; what Java calls protected or private ivar's. Object > memory management for instances via reference counting or GC would also > be nice, although I even saw a hint of that in kobj_delete(), as well > as a bit of the alloc/init & delete/free seperation. As part of the device instance API, it provides the abilty to get/set ivars... You can look at the various *.m files for various device API calls. kern/device_if.m is the most common, but then you can also look at sys/dev/iicbus/*.m for a good example of how useful the kobj API is.. -- John-Mark Gurney Voice: +1 415 225 5579 "All that I will do, has been done, All that I have, has not."