瀏覽代碼

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


Loading…
取消
儲存