Table of Contents
BE ENGINEERING INSIGHTS: BeIDE Add-on API By John Dance - dance@be.com
A week or so ago, I needed to look into a program that was
partially generated by the tools The BeIDE comes with a shell tool add-on that lets you
specify shell scripts to be run during steps of the build.
This could actually be used for running As I was thinking about writing an add-on for The BeIDE supports editor and builder add-ons. I'll leave the editor add-on architecture for another article. The generic translator project can be found at ftp://ftp.be.com/pub/samples/beide/translator.zip. It would be more instructive to look at the source as you're reading the article. Unfortunately, R4 did not include the headers needed for writing BeIDE add-ons. Until you get your copy of R4.1, the headers and textual documentation for the add-on API can be found at ftp://ftp.be.com/pub/samples/beide/Plugin_API.zip. As the BeIDE starts up, it looks at all the add-ons in a known location and calls two important functions: extern "C" status_t MakePlugInView(int32 inIndex, BRect inRect, MPlugInPrefsView*& outView) extern "C" status_t MakePlugInBuilder(int32 inIndex, MPlugInBuilder*& outBuilder) These two functions return the In the functions above, the inIndex parameter allows me to
create more than one view and more than one builder. Both
functions will be called with an incrementing Writing an extern "C" status_t MakePlugInBuilder(int32 inIndex, MPlugInBuilder*& outBuilder) { long result; switch (inIndex) { case 0: outBuilder = new GenericBuilder(new FlexHelper); result = B_OK; break; case 1: outBuilder = new GenericBuilder(new BisonHelper); result = B_OK; break; case 2: outBuilder = new GenericBuilder(new ResHelper); result = B_OK; break; default: result = B_ERROR; break; } return result; } I support three tools: The concrete One of the main jobs of the status_t FlexHelper::BuildArgv(BList &inArgv, const char *filePath) { BString outputName; this->MakeOutputFileName(filePath, outputName); outputName.Prepend("-o"); inArgv.AddItem(strdup(outputName.String())); inArgv.AddItem(strdup(filePath)); return B_OK; } Notice that flex: .l -> .cpp bison: .y -> .cpp mwbres: .r -> .rsrc The new class FlexHelper::MakeOutputFileName(const char *filePath, BString & outputName) { outputName = filePath; outputName.ReplaceLast(".l", ".cpp"); } What happens when tools have errors? All output is captured
by the BeIDE and then sent to the add-on by calling
Looking at the type of tools that I wanted to support, I saw
they had a similar style for error messages. Here is an error
from "test.l", line 123: EOF encountered inside an action ("test.y", line 84) error: invalid $ value File test.r Line 6 # parse error near 'include' Since I didn't want to write N different parsers, I had
something (Here I am talking about Once the add-on is built, how do you use it? The add-on
needs to live in the BeIDE directory under
Extension: l Tool: flex Flags: Precompile Stage Extension: y Tool: bison Flags: Precompile Stage I then added the
BE ENGINEERING INSIGHTS: Automating Myself into a New Line of Work By Steven Black - steven@be.com
My father used to tell me stories about how he tried to create systems that took care of themselves so well that no human intervention was needed. He's had at least one job that, according to him, he succeeded getting to run itself so well that he had nothing to do and left out of boredom. I try to do the same, although even when I think I have something taking care of itself, there are always more changes to fold in, new features to test, new conditions to take into account. So far, I can't foresee any time in the future when what I do could get boring. Baron Arnold told you that a newer, better release of the InputRecorder would be available in March with my newsletter article http://www.be.com/aboutbe/benewsletter/volume_III/Issue4.html#Insight2. This is so. He also mentioned that it would contain source code. This is also true. The source has been cleaned up a lot since last month, along with the user interface. A memory leak in the input filter was fixed. And now you may even be able to run multiple recorders at the same time, though that hasn't really been tested much. While the original author used I decided not to use attributes to store the input records
for several reasons. The first one is that I don't really
need to, since I don't need to randomly locate input events
in the file (I treat it as a simple stream). The second is
that there's currently no easy way to tell how large a
file's attributes are (with A reminder: We do not recommend using One reason for the delay in getting the InputRecorder (especially as source) to you has been that some input server-related parts aren't quite finished. Some device and filter elements may be changing, breaking compatibility, at some future date, in order to improve them. Some of these things may still be subject to change, although I've convinced Those On High that it would be great let developers have access to the InputRecorder. The source this week is amazingly straightforward. The
headers for the input filter stuff are in
<ftp://ftp.be.com/pub/samples/input_server/InputRecorder.zip>
Input scripting uses only two of the three It should be clear to some of you that the design of the
Here in the QA Lab we use a simple, straightforward little tool to do just that -- I'll tell you about it in a later article. It contains within it the details of the kinds of messages devices can send. It contains many arcane facts that in some cases I just guessed about, based on how our devices appear do it and what did and didn't work. That's why it needs to be looked at carefully before it's released, to ensure that all the information it contains is accurate. As an example, one of my favorite scripts that use this tool
is called So you see, the long trek toward my dream of a fully automated QA, where all the QA engineers sit back drinking coffee and watching subprocesses kill machines and fetch engineers is on the way. Not in the near future, but it's coming slowly. Maybe one day QA will become so boring that I'll start looking for a new line of work... though somehow that doesn't seem likely.
DEVELOPERS' WORKSHOP: Media Kit Basics: Build Your Own Mixer For Fun And Profit! By Owen Smith - orpheus@be.com
"Developers' Workshop" is a weekly feature that provides
answers to our developers' questions, or topic requests.
To submit a question, visit
[http://www.be.com/developers/suggestion_box.html].
I heard a rapidly approaching Canyonero, the deadliest of
sport utility vehicles, in the parking lot yesterday, and
once again recognized the sound of doom. And sad to say, I
was a convenient target for it. "You know, those audio sample apps you're coming up with are
pretty lame," spat Morgan le Be, BeOS hacker and mistress of
the black arts, bringing her smoking 'Ero to a halt against
the red curb. "Who plays only one sound at a time these
days?" "Well, you can hook up your sounds to the system mixer..." "Uh-uh, buster -- I want a mixer, just like the system
mixer, but for my own private use." The gauntlet was down, and for the first time, I knew
how to parry Ms. le Be's attack. Just a few minutes'
explanation, and she was satisfied. And so I say to you, O, True Believers: Heed the dark
magick of the Media Kit. Somewhere in the bowels of the
Media Add-On Server dwells a dormant mixer node, as
awesome in its slumber as a hibernating polar bear,
waiting for you to harness its power. This week's sample code shows how you, too, can build a
mixer. It's fast, easy, and KitchenAid approved. However,
please note that the mixer add-on will not support this
until R4.1, though the techniques I demonstrate are
indispensable to any application that has to deal with
media add-ons. Your URL for today is Mix-A-Lot is a simple app that borrows the sound playback
mechanism from SoundCapture to play your super-phat grooves.
Unlike SoundCapture, this one constantly loops your
favorite sounds and allows you to mix up to four sounds
simultaneously. How do you use it? Simple: fire it up and drag a sound file
from the Tracker into one of the icon docks at the top of
the Mix-A-Lot window. The sound will start promptly, and
continue to play in a loop until you drag it off the dock.
A new sound dragged onto an already occupied dock replaces
the old sound. The classes MixerManager and Channel do most of the
important work in this app. MixerManager is responsible for
instantiating the mixer and hooking it up. Channel
represents an input connection to the mixer, and is
responsible for instantiating input sources and connecting
them to the mixer. You'll also notice the standard set of mixer controls in
the Mix-A-Lot window. If you paid attention during last
week's Workshop, you'll already have a good idea where
those controls come from. If not, revisit Mr. Tate, and
be enlightened: The magic behind this mixer madness is the Media Roster's
ability to instantiate media add-ons for you. Media add-ons
are code modules that can provide media services to any
BeOS application. You can find them in two locations:
Here are some facts about Media Add-Ons: As I hinted at above, the BeOS system mixer node is provided
by none other than the Mixer Media Add-On. But there's
nothing to stop you from getting access to the mixer add-on
as well and instantiating your own mixer. That's exactly
what Mix-A-Lot does. To find the system mixer, you need to know what kinds of
media nodes are at your disposal. This information is
provided by objects called dormant media nodes. You can
query the Media Roster to get a list of dormant nodes
that are available to the system and specify any of the
following criteria for your query: The last criterion is the one we'll use. The "node kind" is
a set of flags that a media node uses to inform the Media
Roster about its particular characteristics. There are
several predefined kinds that help to categorize the nodes
you'll encounter -- for example, a node whose kind includes
Once we know the kind we're looking for, finding the mixer
node is trivial, especially since there's exactly one add-on
right now that fits our criterion. What do we do with this dormant_node_info? Well, we can use
it to get more information about the dormant node (called
the The only thing you need to know from here is how to hook the
mixer up. The mixer node supports an arbitrary number of inputs --
this means that you can always get as many free inputs for
the mixer as you want, via The mixer node supports exactly one output, which provides
-- surprise! -- the audio mix. For the system mixer, this
output is usually plugged straight into the audio output
node. For Mix-A-Lot, we take the output of our audio mixer
and plug it into the system mixer. The salient features of
the mixer output are these: I leave you with this challenge: How about adding stop and
play buttons for better playback control? Or perhaps you can
evolve this modest looper into a latter day Echoplex? Go
forth and twist Mix-A-Lot to your own sordid ends! Or, as
my childhood hero was fond of exclaiming: "C'mon Flash, let's
go catch them Duke boys!"
About a year ago, at our developers' conference in Santa
Clara, we formally unveiled the first version of the BeOS
for the Intel architecture. This year, on April 9-10, we'll
have our first Media Kit conference -- an even more
momentous event than our 1998 entry into the world of x-86
hardware. Not that we didn't enjoy the occasion. For me, developer
conferences are always a happy time. I get to meet the
people who, in a very real sense, "make" the platform. The
people who commit an incredible amount of time, energy, and
creativity to our product. We get vigorous feedback,
encouragement, and great ideas. I've often thought that, in our business, you know you've
done something right when your platform is perverted. By
which I mean -- before other interpretations are suggested
-- that programmers or normal people use your product in
ways you hadn't thought of. One reason you hadn't thought of
them is the myopia you get from seeing your product all the
time. Another reason is that developers represent so many
different areas of interest and expertise -- whereas, to a
hammer everything looks like a nail. The best part of having your platform "perverted" is seeing
that the product is rich enough for others to extract more
uses than you'd initially foreseen. For example, the
creators of the Macintosh didn't think of it as the engine
of what became Desktop Publishing, DTP. The concept had no
meaning at the time, just as home computing was ridiculed as
a fad. In retrospect it all seems logical and preordained:
if you have a great user interface, good fonts, and an
easy-to-use laser printer, you'll create DTP. Ah, but it wasn't so obvious beforehand, and retroactively
amused witnesses remember contorted positioning statements
suggested by the experts of the day. One of the best was
"Graphics Based Business Systems." I trust that I'll be
equally amused and humbled someday by a few of my own
suggestions for our little company. So, we had a good time last year, complete with an
enthusiastic speech from Intel's Claude L'Eglise and a quasi
slip-up from yours truly recounting a recent meeting with
Andy Grove. At the time, we had an agreement with Intel to
keep their investment in Be confidential -- it was disclosed
last November at Comdex. As I proceeded to describe a
meeting where I came to thank Andy for his support and to
give him a couple of black Be T-shirts -- and photocopies of
Intel's stock certificates fresh from the closing one hour
earlier, my colleagues grew a little agitated. I realized
the blunder I was about to make and abruptly moved to
another topic. This year, we'll reveal the secrets of the Media Kit. OS
platforms are sometimes compared to musical instruments,
with rendering power as well as expressive power. In our
case, to stretch the metaphor a bit, we could say that basic
BeOS features such as symmetric multiprocessing, pervasive
multithreading, and a 64-bit journaled file system give it
rendering power. The Media Kit, on the other hand, gives the
BeOS expressive power, the ability to write new music --
that is, new applications that aren't necessarily as easy to
write, or perhaps impossible, on other sets of APIs. We've often referred to the BeOS as the Media OS. The Media
Kit is the means by which what was the promise of new OS
technology can now be expressed in new applications that
address both the creation and the consumption of digital
media. I look forward to meeting you at this conference and to
seeing surprising new applications down the road.
1997 Be Newsletters | 1995 & 1996 Be Newsletters Copyright ©1999 Be, Inc. Be is a registered trademark, and BeOS, BeBox, BeWare, GeekPort, the Be logo and the BeOS logo are trademarks of Be, Inc. All other trademarks mentioned are the property of their respective owners. |