Преглед на файлове

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.
legacy
Sam Hocevar sam преди 12 години
родител
ревизия
b83a7eccca
променени са 3 файла, в които са добавени 25 реда и са изтрити 14 реда
  1. +5
    -0
      src/core.h
  2. +16
    -14
      src/platform/nacl/nacl_instance.cpp
  3. +4
    -0
      src/platform/nacl/nacl_instance.h

+ 5
- 0
src/core.h Целия файл

@@ -61,6 +61,11 @@ static inline int isnan(float f)
}
#endif

/* If using NaCl, override main with our version */
#if defined __native_client__
# define main lol_nacl_main
#endif

// Base types
#include "lol/debug.h"
#include "math/trig.h"


+ 16
- 14
src/platform/nacl/nacl_instance.cpp Целия файл

@@ -25,6 +25,14 @@
#include "platform/nacl/nacl_instance.h"
#include "platform/nacl/opengl_context.h"

/* One of these wrappers will be overridden by the user's version */
void lol_nacl_main(void) __attribute__((weak));
void lol_nacl_main(void) {}
void lol_nacl_main(int argc, char **argv) __attribute__((weak));
void lol_nacl_main(int argc, char **argv) {}
void lol_nacl_main(int argc, char **argv, char **envp) __attribute__((weak));
void lol_nacl_main(int argc, char **argv, char **envp) {}

namespace lol
{

@@ -53,26 +61,20 @@ void TickCallback(void* data, int32_t result)
DELTA_MS, pp::CompletionCallback(&TickCallback, data), PP_OK);
}

}
#define main OLDMAIN
#include "../test/tutorial/tut03.cpp"
#undef main
namespace lol {

bool NaClInstance::Init(uint32_t /* argc */,
bool NaClInstance::Init(uint32_t argc,
const char* /* argn */[],
const char* /* argv */[])
const char* argv[])
{
Ticker::Setup(60.0f);

//new Kub();
//new DebugQuad();
new Fractal(ivec2(640, 480));

// My timer callback
pp::Module::Get()->core()->CallOnMainThread(
DELTA_MS, pp::CompletionCallback(&TickCallback, this), PP_OK);

/* Call the user's main() function. FIXME: run it in a thread */
char *env[] = { NULL };
lol_nacl_main();
lol_nacl_main(argc, const_cast<char **>(argv));
lol_nacl_main(argc, const_cast<char **>(argv), (char **)env);

return true;
}



+ 4
- 0
src/platform/nacl/nacl_instance.h Целия файл

@@ -45,6 +45,10 @@ class NaClInstance : public pp::Instance {
SharedOpenGLContext opengl_context_;

ivec2 m_size;

private:
static void CallIntMainWrappers(int argc, char const* argn[]);
static void CallVoidMainWrappers(int argc, char const* argn[]);
};

} // namespace lol


Зареждане…
Отказ
Запис