Charles Turner
2006-07-15 22:58:42 UTC
Hi all-
Working on some code to utilize the Component Manager with Carbon
MacForth, and can't figure out where I've gone wrong. Below I attach
source which has some of the Component Manager data and function
declarations and below prior.stream,, some simple code that
demonstrates where I'm stuck.
I wanted to get the number of components, in this case AU output
plug-ins and for all of them on my machine, get their name and info
string. For some reason, when I call _GetComponentInfo a second time,
it returns "zero" plug-ins, it seems because my component description
struct had gotten trashed.
The code is commented, so you should be able to Command-K it and then
step through some lines that will demonstrate my trouble.
Any thoughts on what I'm doing wrong here?
Best and thanks, Charles
- - - - - - - - - - - - - - <snip>- - - - - - - - - - - -
\ Components
\ Created: 07/14/06 10:19:08 PM CWT
\ Last Revision: 07/14/06 10:19:08 PM CWT
(*
*************************************************************************
File: CarbonCore/Components.h
Contains: Component Manager Interfaces.
Version: CarbonCore-677~2
Copyright: © 1991-2005 by Apple Computer, Inc., all rights
reserved.
Bugs?: For bug reports, consult the following page on
the World Wide Web:
http://developer.apple.com/bugreporter/
*************************************************************************
*)
Only Forth Definitions
Decimal
anew --Components--
lacking CoreServices.Framework framework CoreServices.Framework
CoreServices.Framework
STRUCTURE ComponentDescription
LONG: +componentType \ A unique 4-byte code indentifying the
command set
LONG: +componentSubType \ Particular flavor of this instance
LONG: +componentManufacturer \ Vendor indentification
LONG: +componentFlags \ 8 each for
Component,Type,SubType,Manuf/revision
LONG: +componentFlagsMask \ Mask for specifying which flags
\ to consider in search, zero during registration
STRUCTURE.END
(* ******************************************************
* *
* APPLICATION LEVEL CALLS *
* *
******************************************************* *)
(* ******************************************************
* Component Database Add, Delete, and Query Routines
******************************************************* *)
\ * RegisterComponent()
\ * RegisterComponentResource()
\ * UnregisterComponent()
2 machofunc _FindNextComponent ( Component aComponent
ComponentDescription* looking
return Component )
1 machofunc _CountComponents ( ComponentDescription* looking
return long )
5 machofunc _GetComponentInfo ( Component aComponent
ComponentDescription* cd
Handle componentName
Handle componentInfo
Handle componentIcon
return OSErr )
\ * GetComponentListModSeed()
\ * GetComponentTypeModSeed()
(* *******************************************************
* Component Instance Allocation and dispatch routines
******************************************************* *)
2 machofunc _OpenAComponent ( Component aComponent
ComponentInstance* ci
return OSErr )
1 machofunc _OpenComponent ( Component aComponent
return ComponentInstance )
1 machofunc _CloseComponent ( ComponentInstance aComponentInstance
return OSErr )
1 machofunc _GetComponentInstanceError (
ComponentInstance aComponentInstance
return OSErr )
(* *******************************************************
* Component aliases
******************************************************* *)
\ * ResolveComponentAlias()
(* *******************************************************
* Component public resources and public string lists
******************************************************* *)
\ * GetComponentPublicResource()
\ * GetComponentPublicResourceList()
\ * GetComponentPublicIndString()
\ and more...
\ *************** comments and/or test code below ***************
prior.stream
\ ** ENTER all the data definitions between here and the asterisks ****
0 CONSTANT nil
ascii auou constant kAudioUnitType_Output
CREATE MyComponentDescription ComponentDescription ALLOT
kAudioUnitType_Output MyComponentDescription +componentType !
0 MyComponentDescription +componentSubType !
0 MyComponentDescription +componentManufacturer !
0 MyComponentDescription +componentFlags !
0 MyComponentDescription +componentFlagsMask !
VARIABLE componentName 4 _NewHandle componentName !
VARIABLE componentInfo 4 _NewHandle componentInfo !
VARIABLE componentIcon 4 _NewHandle componentIcon !
\ *********************************************************************
\ ENTER these lines one at a time and observe the stack
\ returns the number of kAudioUnitType_Output
MyComponentDescription _CountComponents
\ leaves the address of the first component found on stack
nil MyComponentDescription _FindNextComponent
\ takes address of prev component on stack and finds next
MyComponentDescription _FindNextComponent
\ ...and so on. Leaves 0 when it finds no more
MyComponentDescription _FindNextComponent
MyComponentDescription _FindNextComponent
MyComponentDescription _FindNextComponent
MyComponentDescription _FindNextComponent
\ MyComponentDescription OK
MyComponentDescription 32 CHARS DUMP
\ NOW: ENTER these lines one at a time and observe the stack
\ As above...
MyComponentDescription _CountComponents
nil MyComponentDescription _FindNextComponent
\ DUP the component address because _GetComponentInfo will consume it
DUP
\ Get info. We use nil to remove the influence of the handle defined
above.
\ DROP the return code...
MyComponentDescription nil nil nil _GetComponentInfo DROP
\ Find next component. Why does it return )?
MyComponentDescription _FindNextComponent
\ MyComponentDescription is trashed...
MyComponentDescription 32 CHARS DUMP
Working on some code to utilize the Component Manager with Carbon
MacForth, and can't figure out where I've gone wrong. Below I attach
source which has some of the Component Manager data and function
declarations and below prior.stream,, some simple code that
demonstrates where I'm stuck.
I wanted to get the number of components, in this case AU output
plug-ins and for all of them on my machine, get their name and info
string. For some reason, when I call _GetComponentInfo a second time,
it returns "zero" plug-ins, it seems because my component description
struct had gotten trashed.
The code is commented, so you should be able to Command-K it and then
step through some lines that will demonstrate my trouble.
Any thoughts on what I'm doing wrong here?
Best and thanks, Charles
- - - - - - - - - - - - - - <snip>- - - - - - - - - - - -
\ Components
\ Created: 07/14/06 10:19:08 PM CWT
\ Last Revision: 07/14/06 10:19:08 PM CWT
(*
*************************************************************************
File: CarbonCore/Components.h
Contains: Component Manager Interfaces.
Version: CarbonCore-677~2
Copyright: © 1991-2005 by Apple Computer, Inc., all rights
reserved.
Bugs?: For bug reports, consult the following page on
the World Wide Web:
http://developer.apple.com/bugreporter/
*************************************************************************
*)
Only Forth Definitions
Decimal
anew --Components--
lacking CoreServices.Framework framework CoreServices.Framework
CoreServices.Framework
STRUCTURE ComponentDescription
LONG: +componentType \ A unique 4-byte code indentifying the
command set
LONG: +componentSubType \ Particular flavor of this instance
LONG: +componentManufacturer \ Vendor indentification
LONG: +componentFlags \ 8 each for
Component,Type,SubType,Manuf/revision
LONG: +componentFlagsMask \ Mask for specifying which flags
\ to consider in search, zero during registration
STRUCTURE.END
(* ******************************************************
* *
* APPLICATION LEVEL CALLS *
* *
******************************************************* *)
(* ******************************************************
* Component Database Add, Delete, and Query Routines
******************************************************* *)
\ * RegisterComponent()
\ * RegisterComponentResource()
\ * UnregisterComponent()
2 machofunc _FindNextComponent ( Component aComponent
ComponentDescription* looking
return Component )
1 machofunc _CountComponents ( ComponentDescription* looking
return long )
5 machofunc _GetComponentInfo ( Component aComponent
ComponentDescription* cd
Handle componentName
Handle componentInfo
Handle componentIcon
return OSErr )
\ * GetComponentListModSeed()
\ * GetComponentTypeModSeed()
(* *******************************************************
* Component Instance Allocation and dispatch routines
******************************************************* *)
2 machofunc _OpenAComponent ( Component aComponent
ComponentInstance* ci
return OSErr )
1 machofunc _OpenComponent ( Component aComponent
return ComponentInstance )
1 machofunc _CloseComponent ( ComponentInstance aComponentInstance
return OSErr )
1 machofunc _GetComponentInstanceError (
ComponentInstance aComponentInstance
return OSErr )
(* *******************************************************
* Component aliases
******************************************************* *)
\ * ResolveComponentAlias()
(* *******************************************************
* Component public resources and public string lists
******************************************************* *)
\ * GetComponentPublicResource()
\ * GetComponentPublicResourceList()
\ * GetComponentPublicIndString()
\ and more...
\ *************** comments and/or test code below ***************
prior.stream
\ ** ENTER all the data definitions between here and the asterisks ****
0 CONSTANT nil
ascii auou constant kAudioUnitType_Output
CREATE MyComponentDescription ComponentDescription ALLOT
kAudioUnitType_Output MyComponentDescription +componentType !
0 MyComponentDescription +componentSubType !
0 MyComponentDescription +componentManufacturer !
0 MyComponentDescription +componentFlags !
0 MyComponentDescription +componentFlagsMask !
VARIABLE componentName 4 _NewHandle componentName !
VARIABLE componentInfo 4 _NewHandle componentInfo !
VARIABLE componentIcon 4 _NewHandle componentIcon !
\ *********************************************************************
\ ENTER these lines one at a time and observe the stack
\ returns the number of kAudioUnitType_Output
MyComponentDescription _CountComponents
\ leaves the address of the first component found on stack
nil MyComponentDescription _FindNextComponent
\ takes address of prev component on stack and finds next
MyComponentDescription _FindNextComponent
\ ...and so on. Leaves 0 when it finds no more
MyComponentDescription _FindNextComponent
MyComponentDescription _FindNextComponent
MyComponentDescription _FindNextComponent
MyComponentDescription _FindNextComponent
\ MyComponentDescription OK
MyComponentDescription 32 CHARS DUMP
\ NOW: ENTER these lines one at a time and observe the stack
\ As above...
MyComponentDescription _CountComponents
nil MyComponentDescription _FindNextComponent
\ DUP the component address because _GetComponentInfo will consume it
DUP
\ Get info. We use nil to remove the influence of the handle defined
above.
\ DROP the return code...
MyComponentDescription nil nil nil _GetComponentInfo DROP
\ Find next component. Why does it return )?
MyComponentDescription _FindNextComponent
\ MyComponentDescription is trashed...
MyComponentDescription 32 CHARS DUMP