Changeset 1435


Ignore:
Timestamp:
Jun 3, 2012, 3:57:58 PM (8 years ago)
Author:
sam
Message:

nacl: remove our old hack of #including the file containing main() from
the NaCl instance object. Now we properly override main() and we can at
last build all the executables as NaCl binaries.

Location:
trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/core.h

    r1342 r1435  
    6262#endif
    6363
     64/* If using NaCl, override main with our version */
     65#if defined __native_client__
     66#   define main lol_nacl_main
     67#endif
     68
    6469// Base types
    6570#include "lol/debug.h"
  • trunk/src/platform/nacl/nacl_instance.cpp

    r1106 r1435  
    2525#include "platform/nacl/nacl_instance.h"
    2626#include "platform/nacl/opengl_context.h"
     27
     28/* One of these wrappers will be overridden by the user's version */
     29void lol_nacl_main(void) __attribute__((weak));
     30void lol_nacl_main(void) {}
     31void lol_nacl_main(int argc, char **argv) __attribute__((weak));
     32void lol_nacl_main(int argc, char **argv) {}
     33void lol_nacl_main(int argc, char **argv, char **envp) __attribute__((weak));
     34void lol_nacl_main(int argc, char **argv, char **envp) {}
    2735
    2836namespace lol
     
    5462}
    5563
    56 }
    57 #define main OLDMAIN
    58 #include "../test/tutorial/tut03.cpp"
    59 #undef main
    60 namespace lol {
    61 
    62 bool NaClInstance::Init(uint32_t /* argc */,
     64bool NaClInstance::Init(uint32_t argc,
    6365                        const char* /* argn */[],
    64                         const char* /* argv */[])
     66                        const char* argv[])
    6567{
    66     Ticker::Setup(60.0f);
    67 
    68     //new Kub();
    69     //new DebugQuad();
    70     new Fractal(ivec2(640, 480));
    71 
    7268    // My timer callback
    7369    pp::Module::Get()->core()->CallOnMainThread(
    7470            DELTA_MS, pp::CompletionCallback(&TickCallback, this), PP_OK);
     71
     72    /* Call the user's main() function. FIXME: run it in a thread */
     73    char *env[] = { NULL };
     74    lol_nacl_main();
     75    lol_nacl_main(argc, const_cast<char **>(argv));
     76    lol_nacl_main(argc, const_cast<char **>(argv), (char **)env);
    7577
    7678    return true;
  • trunk/src/platform/nacl/nacl_instance.h

    r1087 r1435  
    4646
    4747    ivec2 m_size;
     48
     49private:
     50    static void CallIntMainWrappers(int argc, char const* argn[]);
     51    static void CallVoidMainWrappers(int argc, char const* argn[]);
    4852};
    4953
Note: See TracChangeset for help on using the changeset viewer.