"Renaud Amar" <[EMAIL PROTECTED]> wrote in message
news:67938@palm-dev-forum...
>
>
> I've been digging the archives and the knowledge database for hours
(if not
> days),
> and I haven't found any precise information about creating some CODE
> resource
> in CodeWarrior. The article in KB called "Shared Libraries and Other
> Advanced Project Types"
> gives some information but it's really vague and they don't go into
details
> or give any sample code.
>
> I would like to create a CODE resource inside my application, and
being able
> to call some of
> the functions defined in that resource from my application.
> I don't want to create a standalone plugin prc file. I just want my
resource
> inside my application.
This is very doable. Look at the Demohack example included with
CodeWarrior for Palm OS 8 (or available for download) for how you can
build a code segment in one target, then pull the code segment into your
link for your main application target.
> Can someone tell me precisely what needs to be done to achieve that ?
> and what are the project settings I need to make it work.
>
> Here is what I've done so far:
>
> - I have created a new target within my application.
> - I've put the code I want to be accessible as a resource in that
target.
> - I've changed the 68K target settings to PalmOS Code Resource,
specified
> the restype CODE and a ResID (3000)
> and I also changed the target settings for the Post Linker to none
(instead
> of Palm Rez Post Linker) 'cause I don't
> want to generate another prc file for that resource.
> - in that code, I've defined an entry point function as __Startup__
> - I try to call that function from my app
This last step is not automatic. Code segments defined this way don't
get locked into memory when your application loads. Basically, you need
to write code like:
handle = DmGetResource('code', ID);
FuncPtr *fp = MemHandleLock(handle);
fp(args);
MemHandleUnlock(handle);
The joy of code segments is that you don't need them to be locked all
the time. The disadvantage is the manual banging you need to do. Look
at DemoHack, see how to setup a .r file that will pull the code segment
into your main application, then have fun.
Note: unless you're doing something odd, you really don't need to do
this -- multiple-segment applications solve most of the code size
problems that plagued early Palm OS apps. The KB article you're reading
is quite a bit out of date, written before CodeWarrior had good
multi-segment support.
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/