realbasic-plugins
[Top] [All Lists]

Re: Xcode 2.1

To: REALbasic Plugins <realbasic-plugins at lists dot realsoftware dot com>
Subject: Re: Xcode 2.1
From: Bob Delaney <delaneyrm at earthlink dot net>
Date: Wed, 8 Jun 2005 01:23:06 -0500
Delivered-to: realbasic-plugins at lists dot realsoftware dot com
References: <p06210201beca8da2b17f at [24 dot 217 dot 116 dot 136]> <p06210200becab1691403 at [192 dot 168 dot 2 dot 55]> <p06210200becabc2e9a2f at [192 dot 168 dot 2 dot 55]>
At 9:54 PM -0500 6/6/05, Bob Delaney wrote:
As an experiment I tried building a Universal Binary. PluginMain gave 127 errors. Not a surprise.


I have now succeeded (with a big caveat at the end of this email) in building a universal binary dylib using Xcode 2.1. I commented out some sections of PluginMain.cpp, and made one insertion. No other file had to be modified. Here are the commented out sections:

/*
#ifdef _MSC_VER
        #include "winheader++.h"
#endif
 */

/*
#if TARGET_68K
        #include <A4Stuff.h>
        #include <SetupA4.h>
#endif
 */

/*
#if defined(MPW_CPLUS) || defined(MPW_C)
        #define NOSTATICINIT 1
#endif
 */

/*
#if TARGET_OS_MAC
        #ifndef powerc
                #define USECALLSHELL
        #endif
#endif
 */

/*
#ifdef USECALLSHELL
static REALproc buildEnvironmentShell(void *func)
{
        short *glue;
        REALproc proc;
        unsigned long originalCode;
        unsigned long unglue;
        unsigned long pluginA4 = GetCurrentA4();

        static int gRemainAllocCount;
        static Ptr gRemainAllocPtr;

        if (!func)
                return nil;
        if (func == REALstandardGetter)
                return REALstandardGetter;

        originalCode = (unsigned long) func;
        if (!gRemainAllocCount)
        {
                gRemainAllocCount = 8;
                gRemainAllocPtr = NewPtr(8 * 52);
        }

        glue = (short *) gRemainAllocPtr;
        gRemainAllocPtr += 52;
        gRemainAllocCount--;
        proc = (REALproc) glue;

        unglue = (unsigned long) (glue + 17);

        *glue++ = 0x2079; // movea.l $, A0
        *glue++ = a4stack >> 16;
        *glue++ = a4stack & 0xffff;
        *glue++ = 0x210c; // move.l A4, -(A0)
        *glue++ = 0x211f; // move.l (A7)+, -(A0)
        *glue++ = 0x287c; // move.l #, A4
        *glue++ = pluginA4 >> 16;
        *glue++ = pluginA4 & 0xffff;
        *glue++ = 0x2f3c; // move.l #, -(A7)
        *glue++ = unglue >> 16;
        *glue++ = unglue & 0xffff;
        *glue++ = 0x23c8; // move.l A0, $
        *glue++ = a4stack >> 16;
        *glue++ = a4stack & 0xffff;
        *glue++ = 0x4ef9; // jmp $
        *glue++ = originalCode >> 16;
        *glue++ = originalCode & 0xffff;

        *glue++ = 0x2279; // movea.l $, A1
        *glue++ = a4stack >> 16;
        *glue++ = a4stack & 0xffff;
        *glue++ = 0x2f19; // move.l (A1)+,-(A7)
        *glue++ = 0x2859; // movea.l (A1)+, A4
        *glue++ = 0x23c9; // move.l A1, $
        *glue++ = a4stack >> 16;
        *glue++ = a4stack & 0xffff;
        *glue++ = 0x4e75; // rts

        return proc;
}
#endif
*/


The insertion was due to one error at the line 2047 of PluginMain.cpp:

        gResolverPPC = (void *(*)(const char *)) gResolver("ResolverPPC");

in the REALPluginMain procedure. The error was:

error: 'gResolverPPC' was not declared in this scope

The context for this offending line was:

#ifdef USECALLSHELL
        unsigned long (*getA4stack)(void);

        getA4stack = (unsigned long(*)(void)) resolver("getA4stackReference");
        a4stack = getA4stack();
#else
#if TARGET_OS_MAC
 #if CARBON
        gResolverPPC = (void *(*)(const char *)) gResolver("ResolverPPC");
 #else
gResolverPPC = (void *(*)(const char *)) CallUniversalProc((RoutineDescriptor *) gResolver, kThinkCStackBased | RESULT_SIZE(SIZE_CODE(4)) | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(4)), "ResolverPPC");
 #endif
#endif
#endif


So, from an earlier declaration, I inserted before the offending line:

void *(*gResolverPPC)(const char *entryName);

And that did it. The Make was successful. The resulting universal binary dylib was 432 KB in size, and had an icon with a blue book stacked askew on top of a green book. My original Carbon only dylib was 244 KB in size, and had the same icon.

I did use the Plugin Converter to make an rbx plugin. But with that in RB's Plugin Folder, RB quit on launch.


The caveat:

When I went back to the original non-binary Carbon dylib project and did the commenting out, but did not insert the line
void *(*gResolverPPC)(const char *entryName);
the Make was successful, and the resulting plugin worked.

But when I did insert the line, the Make was successful, but the resulting plugin caused RB to quit on launch.

Any suggestions?

Bob





_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

<Prev in Thread] Current Thread [Next in Thread>