Professional Web Applications Themes

Converting CFM Carbon to Mach-O Carbon Application Package - Mac Programming

To make my application eassier to maintain, I changed the linker settings from CFM to Mach-O and built an "Application Package". The application uses Carbon. I encountered some problems. Is there an FAQ for that? 1. Function pointers are no longer indirect, so I have to omit one indirection when called from inline assembler. 2. Static variables from inline assembler is accessed no longer via rtoc and and a 16 bit offset, but with a mysterious RPIC register and a 32 bit offset. I did not find information about that register. Is it also gpr2? 3. The function GetProcessInformation() gives ...

  1. #1

    Default Converting CFM Carbon to Mach-O Carbon Application Package

    To make my application eassier to maintain, I changed the linker
    settings from CFM to Mach-O and built an "Application Package". The
    application uses Carbon.

    I encountered some problems. Is there an FAQ for that?

    1. Function pointers are no longer indirect, so I have to omit one
    indirection when called from inline assembler.
    2. Static variables from inline assembler is accessed no longer via
    rtoc and and a 16 bit offset, but with a mysterious RPIC register and
    a 32 bit offset. I did not find information about that register. Is it
    also gpr2?
    3. The function GetProcessInformation() gives me the path of the
    executable in MyPkg/contents/MacOS. Does that make any sense? I
    thought the bundle structure should not be visible.
    4. The current path also is MyPkg/contents/MacOS. In order to find
    files in the same directory of my application, I had to go three
    levels upwards. Is that doented somewhere?
    5. My application lost its icon, only a generic one is displayed in
    both the Dock and the Finder. I added the line
    "CFBundleIconFile=MyPkg.icns" to the plist and put the MyPkg.icns file
    to the Resources folder inside the package. Seems to be ignored. But
    the ececutable in MyPkg/contents/MacOS shows the correct icon in the
    Finder. Strange.
    6. Unfortunately the example project that came with CW (8.3) does not
    contain an icon, only a generic one is displayed. Is there a better
    example?
    Andreas Guest

  2. #2

    Default Re: Converting CFM Carbon to Mach-O Carbon Application Package

    On 24 Nov 2003, Andreas Kromke wrote:
     
    don't know about those.

     
    yes is the way it works. The bundle structure is not visible to the user,
    but it is at the file system level. There are APIs to get CFURLs to
    various parts of you bundle to make this easy

     
    The finder caches icon information quite stubbornly.

     

    Fred

    Frederick Guest

  3. #3

    Default Re: Converting CFM Carbon to Mach-O Carbon Application Package

    In article <google.com>,
    de (Andreas Kromke) wrote:

    [I'm snipping questions whose answers I don't know.] 

    You should be using CFBundle functions for this. It does make sense,
    because your actual executable is the file inside the Contents/MacOS
    directory.
     

    You should never rely on the current directory of your app. You should
    always use CFBundle to get the path to your app's bundle, and then find
    other paths from there.
     

    As another poster said, this is probably just really aggressive caching
    by the Finder. I think there are some LaunchServices files you can
    delete in Library/Caches, but I forget.
    Michael Guest

  4. #4

    Default Re: Converting CFM Carbon to Mach-O Carbon Application Package

    de (Andreas Kromke) wrote in message news:<google.com>... 

    Look in Processes.h - there are APIs for getting the bundle location
    instead of the executable's location.
     

    You asked for the executable's location, so that's what you got ;)
    Use the newer APIs for getting your bundle's location instead.

     

    Sounds like you are using an old-style plist (which is not necessarily
    a problem)
     

    If you make a copy of your application bundle does the copy have the
    correct icon? If so, then the problem is Launch Services caching.
    Google for how to deal with that. If not, then your plist is not
    correct. There are plist validation tools you might want to use.


    Bryan
    Bryan Guest

  5. #5

    Default Re: Converting CFM Carbon to Mach-O Carbon Application Package

    de (Andreas Kromke) wrote in message news:<google.com>...
    (..)
    Many thanks to all of you who gave me precious hints!

    Yesterday I managed to get the icon thing working, but I do not know
    why?!?

    Instead of using the Property List Editor and adding the line defining
    the icns file to the plist file (inside the package), I changed the
    plc file (seems to be a kind of source for the plist file) in
    CodeWarrior. Then I removed the package and rebuilt it. And - voilą it
    works. But I do not know why which makes me a little bit depressed ...

    (Yes, I delete all LS files without any effect)

    Now I will try to get the German Apple Menu. I do not know why, but
    the system now shows an English system menu together with my German
    program. Maybe that the natural language of mankind is English, and I
    have to provide an extra German localization for my program.
    Andreas Guest

  6. #6

    Default Re: Converting CFM Carbon to Mach-O Carbon Application Package

    On 25 Nov 2003, Andreas Kromke wrote:
     
    Either you need a German.lproj folder in your Resources folder, or I
    think you need to have
    key "CFBundleDevelopmentRegion" value string "English" in your .plc (or
    the equivalent in your plist).

    Fred

    Frederick Guest

  7. #7

    Default Re: Converting CFM Carbon to Mach-O Carbon Application Package

    Frederick Cheung <DUH.ucam.org> wrote in message news:<srcf.societies.cam.ac.uk>... 

    You are partially right. I left the development region to "Germany" (I
    think it is only treated as informational comment) and created an
    empty folder "German.lproj" (CW automatically had created an
    "English.lproj" folder, so it now is clear why my application felt
    English).

    Now the sytem menu is in German.

    How can I do localization automatically with CW without manually
    manipulating the package folder? Let's assume I have three resource
    files "German.rsrc", "French.rsrc", and "English.rsrc". Is CW able to
    automatically sort it into the appropriate localization folders of the
    package?

    Maybe XCode is.
    Andreas Guest

  8. #8

    Default Re: Converting CFM Carbon to Mach-O Carbon Application Package

    On 26 Nov 2003, Andreas Kromke wrote:
     
    >
    > You are partially right. I left the development region to "Germany" (I
    > think it is only treated as informational comment) and created an
    > empty folder "German.lproj" (CW automatically had created an
    > "English.lproj" folder, so it now is clear why my application felt
    > English).
    >
    > Now the sytem menu is in German.
    >
    > How can I do localization automatically with CW without manually
    > manipulating the package folder? Let's assume I have three resource
    > files "German.rsrc", "French.rsrc", and "English.rsrc". Is CW able to
    > automatically sort it into the appropriate localization folders of the
    > package?[/ref]

    I think CW9 can do that, but I'm not sure as i don't use resources any
    more for any of my interface stuff.

    Fred

    Frederick Guest

  9. #9

    Default Re: Converting CFM Carbon to Mach-O Carbon Application Package

    In article <google.com>,
    de (Andreas Kromke) wrote:
     

    You need CW 9. With CW 8, you're best bet is to use a shell script post
    linker.
    Sean Guest

  10. #10

    Default Re: Converting CFM Carbon to Mach-O Carbon Application Package

    Sean McBride <org> wrote in message news:<aei.ca>... 

    I think I will first give XCode a try. The need to have a new CW for
    every new MacOS version is a little bit frustrating. And, the need for
    localization (or localisation?) initially began when mankind built the
    tower of Babel. And still CW 8 does not support that? Hardly to
    believe. BTW: A linker postprocessing state has been part of
    Microsoft's Visual Studio for many years, so I think there must be a
    similar mechanism in CW8 and earlier.
    Andreas Guest

  11. #11

    Default Re: Converting CFM Carbon to Mach-O Carbon Application Package

    In article <google.com>, Andreas
    Kromke <de> wrote:
     

    the RPIC register is any register the compiler decide to use to get the
    start address of the module. I think GCC uses r31 for this. CW seems to
    use any register the compiler feel right to use.

    Under CFM you are suppose to do

    lwz r3,gBlitters(RTOC)

    Under Mach-O you must do

    addis r3,RPIC,ha16(gBlitters)
    la r3,lo16(gBlitters)(r3)

    Under CW 8.3 this only works if you are inside an asm scope. It's not
    working if your function is 100% pure assembler.
    FraKtus Guest

  12. #12

    Default Re: Converting CFM Carbon to Mach-O Carbon Application Package

    In article <google.com>,
    de (Andreas Kromke) wrote:
     

    In fairness, you need new Apple dev tool with each Mac OS version also!
    The difference is price.
    Sean Guest

  13. #13

    Default Re: Converting CFM Carbon to Mach-O Carbon Application Package

    In article <google.com>,
    de (Andreas Kromke) wrote:
     

    CW8 supports it just fine. It's just that you have to do more work than is
    desirable to get it to do what you want. Linker post-processing is exactly how
    you do it, and that's what you've been told to use.

    meeroh

    --
    If this message helped you, consider buying an item
    from my wish list: <http://web.meeroh.org/wishlist>

    Miro Guest

  14. #14

    Default Re: Converting CFM Carbon to Mach-O Carbon Application Package

    In article <google.com>,
    de (Andreas Kromke) wrote:
     
    >
    >I think I will first give XCode a try. The need to have a new CW for
    >every new MacOS version is a little bit frustrating.[/ref]

    I am sorry you feel this way, CodeWarrior is a low level tool and of
    course is affected by Operating systems. It has also take a lot for us
    to keep up with the Changes Apple has made with each Operating system.
    They may seem alike but these are very fundamentally different operating
    systems.

    Even Apple had to start with a new tools with this release, so it isn't
    just CodeWarrior.

    Ron

    --
    New from Metrowerks
    The CodeWarrior Wireless Development Kit for Symbian OS, SEMC P900 Edition
    Easy-to-use, integrated tools and hardware for SEMC P900 Development
    http://www.metrowerks.com/MW/Develop/Wireless/Symbian/SymbianWDKC.htm

    Ron Liechty - com - http://www.metrowerks.com
    Ron Liechty - com - http://www.metrowerks.com
    MW Guest

  15. #15

    Default Re: Converting CFM Carbon to Mach-O Carbon Application Package

    In article <aei.ca>,
    Sean McBride <org> wrote:
     
    >
    >In fairness, you need new Apple dev tool with each Mac OS version also!
    >The difference is price.[/ref]

    I know we are probably cheaper than Apple's "Free" tools but I try not
    to rub it in.

    Ron

    --
    New from Metrowerks
    The CodeWarrior Wireless Development Kit for Symbian OS, SEMC P900 Edition
    Easy-to-use, integrated tools and hardware for SEMC P900 Development
    http://www.metrowerks.com/MW/Develop/Wireless/Symbian/SymbianWDKC.htm

    Ron Liechty - com - http://www.metrowerks.com
    Ron Liechty - com - http://www.metrowerks.com
    MW Guest

  16. #16

    Default Re: Converting CFM Carbon to Mach-O Carbon Application Package

    de (Andreas Kromke) wrote in message news:<google.com>... 
     
    (..)

    Bad idea. I had lots of problems porting my project to XCode. I tried
    to follow Apple's porting guide, and I finally failed:

    1. Using the standard libraries instead of MSL did not work, and I
    only got myriads of error codes. But that was not the problem.
    2. When importing the project, the import process had lots of error
    messages like "source path empty" and "new source path empty", and it
    finally crashed.
    3. I then created a new XCode project and copied the source files one
    by one. The C and C++ files compiled rather well except the problem
    that gcc seems to treat Pascal string constants like "\phallo" as
    "signed char" instead of "unsigned char".
    4. When I copied the main file that mainly consists of inline
    assembler, XCode produced about 2500 errors and finally crashed with
    the error messages "internal compiler error: bus error".
    Andreas Guest

  17. #17

    Default Re: Converting CFM Carbon to Mach-O Carbon Application Package

    Hi Andreas,


    de (Andreas Kromke) writes: 

    GCC uses a different syntax for inline assmbler than CW. If you have
    lots of that, than you are locked in to a specific compiler.


    benny

    Benjamin Guest

  18. #18

    Default Re: Converting CFM Carbon to Mach-O Carbon Application Package

    Benjamin Riefenstahl <de> wrote in message news:<benny.turtle-trading.net>...
    (..) 

    Not necessarily. Apple's porting guide clearly states, that gcc shall
    understand the same syntax (as it does the "old" gcc syntax). They
    explicitely write that any incompatibility is a bug and should be
    reported to Apple.

    I then was thinking of using real assembler modules (file *.s or *.asm
    or whatever), but so far I have not found sufficient doentation
    about the assembler (as or gas or gasm or whatever its name is).
    Andreas Guest

  19. #19

    Default Re: Converting CFM Carbon to Mach-O Carbon Application Package

    FraKtus <arkaos.net> wrote in message news:<281120030948375766%arkaos.net>... 

    It seems that CW also uses r2 for this purpose. I suppose that because
    the assembler code heavily uses r31 for its own purposes, and it still
    seems to work.

    I feel a bit disappointed that the doentation of both CW and
    Apple's devtools does not clearly descibe the RPIC mechanism. But
    maybe programmers shall be discouraged when they intend to write
    assembler.
    Andreas Guest

  20. #20

    Default Re: Converting CFM Carbon to Mach-O Carbon Application Package

    Hi Andreas,


    de (Andreas Kromke) writes: 

    Ah, I didn't know that, thanks for the update.
     

    "man as" points to /Developer/Doentation/DeveloperTools/Assembler,
    which seems pretty large (I haven't looked into it ;-)).


    benny

    Benjamin Guest

Similar Threads

  1. Carbon and Mach-O?
    By Charles in forum Mac Programming
    Replies: 3
    Last Post: November 19th, 06:35 PM
  2. Starting a Carbon application at user login
    By Jorge in forum Mac Programming
    Replies: 12
    Last Post: September 23rd, 04:54 PM
  3. Carbon Window Help
    By Peter Ammon in forum Mac Programming
    Replies: 0
    Last Post: July 11th, 05:21 PM
  4. how to write carbon application
    By deedi in forum Mac Programming
    Replies: 1
    Last Post: July 7th, 02:26 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139