At 11:22 PM 1/23/00 -0500, "Todd L. Miller" <[EMAIL PROTECTED]> wrote:
>> But two different classes should *never* have the same name. Since host and
>> i386 use different drivers, there must be three packages:
>
>       I disagree utterly.  Shared code which uses these drivers should
>be platform-agnostic, which for now means having the same class names.  At
>such a point where decaf and the class libraries can support factories --
>so that common code never sees a 'naked' driver to begin with -- I'll
>reconsider my position.

Why can't we switch to factories now? It would simplify the bytecode
directories. I can easily provide you with a factory. I can rework two
jos.platform.driver packages into jos.host.driver and jos.i386.driver.
Would you like me to do that?

Here is one example. The common code inside the keyboard class does not
need to know where the implementation of jos.platform.keyboard is stored.
Here is the first few lines of the original init() method from
jos.platform.keyboard:

----- jos/platform/keyboard.java
  public void init () {
    /* generate the default drivers */
    // System.err.println( "keyboard.init(): generating keyboard
interpreter..." );
    ki = new jos.platform.driver.KeyboardInterpreter();

    // System.err.println( "keyboard.init(): generating keyboard driver..."
);
    kd = new jos.platform.driver.keyboard();
-----

It could be reimplemented with a factory, like this:

----- jos/platform/keyboard.java
  public Object getFactoryObject( String v ) {
    return Factory.getFactory().getObject( v );
  }
  public void init () {
    /* generate the default drivers */
    // System.err.println( "keyboard.init(): generating keyboard
interpreter..." );
    ki = new jos.platform.driver.KeyboardInterpreter();

    // System.err.println( "keyboard.init(): generating keyboard driver..."
);
    // *D! kd = new jos.platform.driver.keyboard();
    kd = (jos.platform.keyboard) getFactoryObject( "jos.platform.keyboard" );
-----

Each variation of a build can return a different implementation of
jos.platform.keyboard, inside a different package.

For a host build, getFactoryObject( "jos.platform.keyboard" ) would return
jos.host.driver.keyboard.

For a i386 build, getFactoryObject( "jos.platform.keyboard" ) would return
jos.i386.driver.keyboard.

Where is the Factory class? It has already been distributed as the Bytecode
Native Interface. The factory class only needs to be "configured" for each
variation of a build.


_______________________________________________
Kernel maillist  -  [EMAIL PROTECTED]
http://jos.org/mailman/listinfo/kernel

Reply via email to