Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 24 Nov 2004 13:44:40 -0800
From:      John-Mark Gurney <gurney_j@resnet.uoregon.edu>
To:        Charles Swiger <cswiger@mac.com>
Cc:        freebsd-current@freebsd.org
Subject:   Re: Transparent bridges (a. k. a. HUB-to-PCI bridges)?
Message-ID:  <20041124214440.GC5166@funkthat.com>
In-Reply-To: <88534D8A-3E57-11D9-BD47-003065ABFD92@mac.com>
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>

next in thread | previous in thread | raw e-mail | index | archive | help
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."



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20041124214440.GC5166>