Help with Macintosh programming

macintosh programming, mac programming, mac os programming, mac os x programming, mac programming language, mac programing

Archive for March, 2011

Project Builder won't open even after I updated to 10.1 devtools

After I updated to OS 10.1 the developer tools stopped working, so I
downloaded the 187 meg update file from connect.apple.com and installed
it, no dice. The application still fails to launch, the icon bounces
for a while and then I get an "Application unexpectedly quit" error,
any ideas?

Thanks in advance,
   Gabe

.
posted by admin in Uncategorized and have No Comments

Saving Thread Registers

Thanks to all who help be create the threading system. Code will soon be
available for all to use. It should be portable to any operating system,
supports Generic 680×0 and PowerPC (and Altivec) and I designed the code
with the intention of adding more processors.

http://www.jamescollins.org or http://home.austarnet.com.au/jcollins81

Now, I have 3 more questions:

1) Is there a #pragma or something to disable CodeWarrior (Macintosh Host,
Target PowerPC-General or 680×0) the compilier from using FPU registers? Is
it safe to assume the compilier is not using FPU registers if I dont use any
FPU functions or float, double and the rest of the FPU types? Sorry if there
is a checkbox in the compiling options that I have missed.

2) Provided the above is possible, is it safe not to save the FPU registers
in a thread switch? I dont see any problems which this so is there something
I am overlooking?

3) How would I implemented pre-emptive threads, mainly to complete the
thread system. From what I recall from something I was reading, I would
patch(?) one of the exceptions, decrement, increment I think. Is this right
and does the PowerPC even have this exception?

Thanks again.
I prefer reply’s to my email address as I can’t always read my newsgroup
postings.


James Collins
jamescoll…@austarnet.com.au

posted by admin in Uncategorized and have Comments (21)

Codewarrior 6 for OSX Applications ?

Hello,

I was using a sample from apple that used OSX features and the needed
headers for the IOKit couldn’t be found. Should I get 7.0 or can I just
download a new set of headers ?

RS

posted by admin in Uncategorized and have Comments (4)

Cocoa custom controll

Hi,
  I would like to use a similar controll to the one used in the finder
to switch beteen icon/list/columns view.  I have heard that this was a
custom controll, but I have no idea how it was implemented in carbon,
or how I would impliment a similar contoll in cocoa… Does anyone
have any ideas?

Bob


Unicycling in a kilt is not a recommended hobby.

posted by admin in Uncategorized and have Comment (1)

Converting strings to function calls

Hi all

Is the following possible in either C or C++ somehow?

I want to enter a string for the name of a function (or possibly
function object in C++) and then get the program to use the function
with that name, assuming it exists.

Pseudo-code that shows the idea in C (but doesn’t work)
=======================================================
double use_function( double (*func)(double), double x );

int main ( int argc, const char * argv[] )
{
        char*   name;
        double  a, x=1.0;

        get_the_func_name( "Please enter function name : ", name );

        a = use_function( name, x );  // how to convert string to function
                                  // pointer of the same name?

        return 0;

}

Thanks in advance & please CC to my email.

Michael

_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/

     _/_/_/   _/_/_/   _/_/_/              ACS Consultancy
   _/    _/ _/       _/            
  _/_/_/_/ _/         _/_/_/       Information Sciences for Industry
 _/    _/  _/              _/          
_/    _/    _/_/_/   _/_/_/     Tel: 01732~463519   Mobile: 0781~3467381

_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/

      `All models are wrong, but some are useful’ – George Box

posted by admin in Uncategorized and have Comments (24)

Altivec basics

Hi all

Just starting to look at Altivec with OS X Dev Tools and need to know a
couple of simple things.

1)  How do I ensure that the Altivec vectors are 16-byte aligned?  Do I
turn on a compiler switch (in gcc) or does the ‘vector float’ do it
automatically?

2)  If I want to send a pointer to the first element of a normal float[]
array to an Altivec function, how do I deal with the 16-byte alignment?
Can I ensure that a float[] is 16-byte aligned?

3)  Are there any good Altivec tutorials (for floating point in
particular) that start from the beginning?

4)  Is there a Public Domain source of Altivec code or libaries
available somewhere on the net?

Thanks in advance & please CC to my email

Michael

_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/

     _/_/_/   _/_/_/   _/_/_/              ACS Consultancy
   _/    _/ _/       _/            
  _/_/_/_/ _/         _/_/_/       Information Sciences for Industry
 _/    _/  _/              _/          
_/    _/    _/_/_/   _/_/_/     Tel: 01732~463519   Mobile: 0781~3467381

_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/

      `All models are wrong, but some are useful’ – George Box

posted by admin in Uncategorized and have Comments (2)

Where to get IOKit ?

Hello,

I am trying to use the IOKit to create an function on 9.1 for delivery
to someone using OSX. Are the headers for IOKit installed in 9.1 or
where can I get them.

RS

posted by admin in Uncategorized and have Comments (2)

ProjectBuilder

Hi all, I am learning C++ (Computer Science Class in school) and I was
wondering if there was any way I could use ProjectBuilder to make Terminal
applications similar to the ones we make with (shutter, Microsoft Visual
C++) I would much rather use my iBook than use the Compaqs we are forced to
use.  Any input is apreciated TIA.

posted by admin in Uncategorized and have Comment (1)

CGWindow

Anyone know how to create a CGWindow from carbon? Or maybe convert an
existing window to a CGWindow?

Alex

posted by admin in Uncategorized and have No Comments

Getting Another Application's Window Title?

I am trying to get another applications window title, like the finder or
netsape, but my application crashes when it’s done.

I am changing the size flag of background only to true, because that is
the only way I can get it to work displaying other applications window
titles.

This is the source code (very simple and ugly):

#include <Quickdraw.h>
#include <Events.h>
#include <Menus.h>
#include <Windows.h>
#include <OSUtils.h>

#define    kNoEvents                0
Rect windRect;

QDGlobals qd;

void Initialize(void);
void NewGame(void);

void main(void)
{
    Initialize();
    NewGame();

}

void Initialize(void)
{
    WindowPtr mainPtr;
    OSErr error;
    SysEnvRec theWorld;

    error = SysEnvirons(1, &theWorld);
    if (theWorld.hasColorQD == false) {
        SysBeep(50);
        ExitToShell();
    }
    InitGraf(&qd.thePort);
    InitFonts();
    InitWindows();
    InitMenus();
    InitDialogs(nil);
    InitCursor();
    SetRect(&windRect, 100, 100, 100+160, 100+240);
    mainPtr = NewCWindow(nil, &windRect, "\pBob Feild", true, documentProc,
    (WindowPtr) -1, false, 0);
    SetPort(mainPtr);
    TextSize(10);

}

void Wait(int numticks)
{
    static long t = 0;
    t=TickCount();
    do {
    }
    while (TickCount()-t<numticks);

}

void NewGame(void)
{
    Point mouseloc;
    GrafPtr port;
    WindowPtr dawin;
    Str255 ntss;
    do {
    }
    while (!Button());
    GetGlobalMouse(&mouseloc);
    MacFindWindow(mouseloc,&port);
        dawin=GetWindowFromPort(port);
        MoveTo(10,50);
        GetWTitle(dawin,ntss);
        DrawString(ntss);
        MoveTo(10,100);
        DrawString("\pHello?");
    Wait(100);

}

#pragma segment Main
void GetGlobalMouse(Point *mouse)
{
    EventRecord    event;

    OSEventAvail(kNoEvents, &event);
    *mouse = event.where;

- — -

}

posted by admin in Uncategorized and have Comments (5)