Skip to content

Commit

Permalink
Fix compiling issues for osx/cocoa
Browse files Browse the repository at this point in the history
  • Loading branch information
milani committed Oct 31, 2012
1 parent 5ac99f7 commit 73250d4
Show file tree
Hide file tree
Showing 18 changed files with 101 additions and 74 deletions.
5 changes: 3 additions & 2 deletions binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -269,15 +269,16 @@
'conditions': [
['OS=="mac"', {
'sources': [
'src/native_window/native_window_mac.mm'
'src/native_window/native_window_mac.mm',
'src/native_menu/native_menu_mac.mm'
],
'defines': [
'__MAC__',
],
'cflags': [ '-m32' ],
'ldflags': [ '-m32' ],
'xcode_settings': {
'OTHER_CFLAGS': ['-ObjC++']
'OTHER_CFLAGS': ['-ObjC++'],
'OTHER_LDFLAGS':['-Xlinker -rpath -Xlinker @loader_path/../../../../appjs-darwin/libs/'],
'ARCHS': [ 'i386' ]
},
Expand Down
4 changes: 2 additions & 2 deletions src/appjs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ namespace appjs {

using namespace v8;

Handle<Value> InitApp(const Arguments& args) {
v8::Handle<Value> InitApp(const Arguments& args) {

HandleScope scope;
return scope.Close(App::NewInstance(args));
}

void Init(Handle<v8::Object> target) {
void Init(v8::Handle<v8::Object> target) {
App::Init();
Window::Init();
Menu::Init();
Expand Down
8 changes: 4 additions & 4 deletions src/appjs.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ typedef std::basic_string<TCHAR> tstring;
obj->Set##PropertyName(SetterType(value)); \
} \
\
Handle<Value> Type::Get##PropertyName(Local<String> property, const AccessorInfo &info) { \
v8::Handle<Value> Type::Get##PropertyName(Local<String> property, const AccessorInfo &info) { \
HandleScope scope; \
Native##Type *obj = ObjectWrap::Unwrap<Native##Type>(info.Holder()); \
return scope.Close(GetterType::New(obj->Get##PropertyName())); \
return scope.Close(v8::GetterType::New(obj->Get##PropertyName())); \
}


Expand All @@ -95,15 +95,15 @@ typedef std::basic_string<TCHAR> tstring;
obj->Set##PropertyName(SetterType(value->ToString())); \
} \
\
Handle<Value> Type::Get##PropertyName(Local<String> property, const AccessorInfo &info) { \
v8::Handle<Value> Type::Get##PropertyName(Local<String> property, const AccessorInfo &info) { \
HandleScope scope; \
Native##Type *obj = ObjectWrap::Unwrap<Native##Type>(info.Holder()); \
return scope.Close(GetterType::New((uint16_t*)obj->Get##PropertyName())); \
}


#define CREATE_PROTOTYPE_INVOKER(Type, Method) \
Handle<Value> Type::Method(const Arguments& args) { \
v8::Handle<Value> Type::Method(const Arguments& args) { \
HandleScope scope; \
Native##Type *obj = ObjectWrap::Unwrap<Native##Type>(args.This()); \
obj->Method(); \
Expand Down
34 changes: 17 additions & 17 deletions src/appjs_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,49 +27,49 @@ void App::Init() {
END_CONSTRUCTOR();
}

Handle<Value> App::New(const Arguments& args) {
HandleScope scope;
v8::Handle<Value> App::New(const Arguments& args) {
v8::HandleScope scope;
App* obj = new App();
obj->Wrap(args.This());
return scope.Close(args.This());
}

Handle<Value> App::NewInstance(const Arguments& args) {
HandleScope scope;
v8::Handle<Value> App::NewInstance(const Arguments& args) {
v8::HandleScope scope;

Persistent<Object> options = Persistent<Object>::New(args[0]->ToObject());
Cef::Init(new Settings(options));

Handle<Value> argv[1] = { args[0] };
v8::Handle<Value> argv[1] = { args[0] };
Local<Object> instance = constructor->NewInstance(1, argv);

return scope.Close(instance);
}

Handle<Value> App::CreateWindow2(const Arguments& args) {
HandleScope scope;
v8::Handle<Value> App::CreateWindow2(const Arguments& args) {
v8::HandleScope scope;
return scope.Close(Window::NewInstance(args));
}

Handle<Value> App::CreateMenu(const Arguments& args) {
HandleScope scope;
v8::Handle<Value> App::CreateMenu(const Arguments& args) {
v8::HandleScope scope;
return scope.Close(Menu::NewInstance(args));
}

Handle<Value> App::CreateStatusIcon(const Arguments& args) {
HandleScope scope;
v8::Handle<Value> App::CreateStatusIcon(const Arguments& args) {
v8::HandleScope scope;
return scope.Close(StatusIcon::NewInstance(args));
}

Handle<Value> App::ScreenWidth(const Arguments& args) {
HandleScope scope;
Handle<Value> width = Integer::New(NativeWindow::ScreenWidth());
v8::Handle<Value> App::ScreenWidth(const Arguments& args) {
v8::HandleScope scope;
v8::Handle<Value> width = Integer::New(NativeWindow::ScreenWidth());
return scope.Close(width);
}

Handle<Value> App::ScreenHeight(const Arguments& args) {
HandleScope scope;
Handle<Value> height = Integer::New(NativeWindow::ScreenHeight());
v8::Handle<Value> App::ScreenHeight(const Arguments& args) {
v8::HandleScope scope;
v8::Handle<Value> height = Integer::New(NativeWindow::ScreenHeight());
return scope.Close(height);
}

Expand Down
6 changes: 3 additions & 3 deletions src/appjs_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ void Menu::Init() {
END_CONSTRUCTOR();
}

Handle<Value> Menu::New(const Arguments& args) {
v8::Handle<Value> Menu::New(const Arguments& args) {
HandleScope scope;

Persistent<Object> options = Persistent<Object>::New(args[0]->ToObject());
Expand All @@ -34,9 +34,9 @@ Handle<Value> Menu::New(const Arguments& args) {
return scope.Close(args.This());
}

Handle<Value> Menu::NewInstance(const Arguments& args) {
v8::Handle<Value> Menu::NewInstance(const Arguments& args) {
HandleScope scope;
Handle<Value> argv[1] = { args[0] };
v8::Handle<Value> argv[1] = { args[0] };
return scope.Close(constructor->NewInstance(1, argv));
}

Expand Down
6 changes: 3 additions & 3 deletions src/appjs_status_icon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ void StatusIcon::Init() {
END_CONSTRUCTOR();
}

Handle<Value> StatusIcon::New(const Arguments& args) {
v8::Handle<Value> StatusIcon::New(const Arguments& args) {
HandleScope scope;

Persistent<Object> options = Persistent<Object>::New(args[0]->ToObject());
Expand All @@ -36,9 +36,9 @@ Handle<Value> StatusIcon::New(const Arguments& args) {
return scope.Close(args.This());
}

Handle<Value> StatusIcon::NewInstance(const Arguments& args) {
v8::Handle<Value> StatusIcon::NewInstance(const Arguments& args) {
HandleScope scope;
Handle<Value> argv[1] = { args[0] };
v8::Handle<Value> argv[1] = { args[0] };
return scope.Close(constructor->NewInstance(1, argv));
}

Expand Down
28 changes: 14 additions & 14 deletions src/appjs_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void Window::Init() {
END_CONSTRUCTOR();
}

Handle<Value> Window::New(const Arguments& args) {
v8::Handle<Value> Window::New(const Arguments& args) {
HandleScope scope;

Persistent<Object> options = Persistent<Object>::New(args[0]->ToObject());
Expand All @@ -67,9 +67,9 @@ Handle<Value> Window::New(const Arguments& args) {
return scope.Close(args.This());
}

Handle<Value> Window::NewInstance(const Arguments& args) {
v8::Handle<Value> Window::NewInstance(const Arguments& args) {
HandleScope scope;
Handle<Value> argv[1] = { args[0] };
v8::Handle<Value> argv[1] = { args[0] };
return scope.Close(constructor->NewInstance(1, argv));
}

Expand Down Expand Up @@ -102,7 +102,7 @@ CREATE_PROTOTYPE_INVOKER(Window, Hide)
CREATE_PROTOTYPE_INVOKER(Window, Destroy)


Handle<Value> Window::SetMenuBar(const Arguments& args) {
v8::Handle<Value> Window::SetMenuBar(const Arguments& args) {
HandleScope scope;

NativeMenu *menu = ObjectWrap::Unwrap<NativeMenu>(args[0]->ToObject());//(NativeMenu*)args[0]->ToObject()->GetPointerFromInternalField(0);
Expand All @@ -113,7 +113,7 @@ Handle<Value> Window::SetMenuBar(const Arguments& args) {
return scope.Close(args.This());
}

Handle<Value> Window::OpenDialog(const Arguments& args) {
v8::Handle<Value> Window::OpenDialog(const Arguments& args) {
HandleScope scope;

Persistent<Object> options = Persistent<Object>::New(args[0]->ToObject());
Expand All @@ -126,7 +126,7 @@ Handle<Value> Window::OpenDialog(const Arguments& args) {
return scope.Close(args.This());
}

Handle<Value> Window::Move(const Arguments& args) {
v8::Handle<Value> Window::Move(const Arguments& args) {
HandleScope scope;
NativeWindow *window = ObjectWrap::Unwrap<NativeWindow>(args.This());

Expand All @@ -143,7 +143,7 @@ Handle<Value> Window::Move(const Arguments& args) {
return scope.Close(args.This());
}

Handle<Value> Window::Resize(const Arguments& args) {
v8::Handle<Value> Window::Resize(const Arguments& args) {
HandleScope scope;
NativeWindow *window = ObjectWrap::Unwrap<NativeWindow>(args.This());

Expand All @@ -156,7 +156,7 @@ Handle<Value> Window::Resize(const Arguments& args) {



Handle<Value> Window::RunInBrowser(const Arguments& args) {
v8::Handle<Value> Window::RunInBrowser(const Arguments& args) {
HandleScope scope;

if(!args[0]->IsFunction())
Expand All @@ -169,7 +169,7 @@ Handle<Value> Window::RunInBrowser(const Arguments& args) {
}

// synchronously send a string from Node to browser, then return string result from browser to Node
Handle<Value> Window::SendSync(const Arguments& args) {
v8::Handle<Value> Window::SendSync(const Arguments& args) {
HandleScope scope;

NativeWindow *window = ObjectWrap::Unwrap<NativeWindow> (args.This());
Expand All @@ -191,7 +191,7 @@ Handle<Value> Window::SendSync(const Arguments& args) {

// execute window.appjs fuction, passing in the string,
// then convert the return value from a CefValue to a Node V8 string
Handle<String> ret = CefStringToV8(callback->ExecuteFunction(appjsObject, argsOut)->GetStringValue());
v8::Handle<String> ret = CefStringToV8(callback->ExecuteFunction(appjsObject, argsOut)->GetStringValue());

// exit browser v8 context, return string result to Node caller
context->Exit();
Expand All @@ -203,7 +203,7 @@ Handle<Value> Window::SendSync(const Arguments& args) {
return scope.Close(args.This());
}

Handle<Value> Window::SetIcon(const Arguments& args) {
v8::Handle<Value> Window::SetIcon(const Arguments& args) {
HandleScope scope;
NativeWindow *window = ObjectWrap::Unwrap<NativeWindow>(args.This());

Expand All @@ -224,11 +224,11 @@ Handle<Value> Window::SetIcon(const Arguments& args) {
return scope.Close(args.This());
}

Handle<Value> Window::GetState(Local<String> property, const AccessorInfo &info) {
v8::Handle<Value> Window::GetState(Local<String> property, const AccessorInfo &info) {
HandleScope scope;
NativeWindow *window = ObjectWrap::Unwrap<NativeWindow>(info.Holder());

Handle<Value> val;
v8::Handle<Value> val;

switch (window->GetState()) {
ENUM_TO_STRING(NW_STATE_NORMAL, "normal")
Expand Down Expand Up @@ -258,7 +258,7 @@ void Window::SetState(Local<String> property, Local<Value> value, const Accessor

#if defined(__WIN__)

Handle<Value> Window::Style(const Arguments& args) {
v8::Handle<Value> Window::Style(const Arguments& args) {
HandleScope scope;
NativeWindow *window = ObjectWrap::Unwrap<NativeWindow>(args.This());
switch (args.Length()) {
Expand Down
2 changes: 1 addition & 1 deletion src/includes/cef_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ bool ClientHandler::DoClose(CefRefPtr<CefBrowser> browser) {
if (!browser->IsPopup() && --windowCount == 0) {
Local<Object> global = Context::GetCurrent()->Global();
Local<Object> emitter = global->Get(String::NewSymbol("process"))->ToObject();
Handle<Value> exitArgv[1] = {String::New("appjs-exit")};
v8::Handle<Value> exitArgv[1] = {String::New("appjs-exit")};
node::MakeCallback(emitter,"emit",1,exitArgv);
Cef::Shutdown();
mainBrowserHandle = NULL;
Expand Down
18 changes: 9 additions & 9 deletions src/includes/cef_scheme_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,22 @@ namespace appjs {

using namespace v8;

Handle<Value> WrapObject(void* obj) {
v8::Handle<Value> WrapObject(void* obj) {

HandleScope scope;

Persistent<ObjectTemplate> obj_template = Persistent<ObjectTemplate>::New(ObjectTemplate::New());
obj_template->SetInternalFieldCount(1);

Handle<Object> self = obj_template->NewInstance();
v8::Handle<Object> self = obj_template->NewInstance();

self->SetPointerInInternalField(0, obj);

return scope.Close(self);
}

void *UnwrapObject(Handle<Value> data) {
Handle<Object> obj = data->ToObject();
void *UnwrapObject(v8::Handle<Value> data) {
v8::Handle<Object> obj = data->ToObject();

return obj->GetPointerFromInternalField(0);
}
Expand All @@ -44,7 +44,7 @@ void AppjsSchemeHandler::Execute(CefThreadId threadId) {

const int argc = 3;

Handle<Value> self = WrapObject(this);
v8::Handle<Value> self = WrapObject(this);
Local<Function> cb = FunctionTemplate::New(NodeCallback,self)->GetFunction();
Local<Object> req = Object::New();
Local<String> post = String::New("");
Expand Down Expand Up @@ -93,21 +93,21 @@ void AppjsSchemeHandler::Execute(CefThreadId threadId) {
}
}

Handle<Value> method = String::New((uint16_t*)request_->GetMethod().c_str());
Handle<Value> url = String::New((uint16_t*)request_->GetURL().c_str());
v8::Handle<Value> method = String::New((uint16_t*)request_->GetMethod().c_str());
v8::Handle<Value> url = String::New((uint16_t*)request_->GetURL().c_str());

req->Set(String::NewSymbol("method"),method);
req->Set(String::NewSymbol("url"),url);
req->Set(String::NewSymbol("post"),post);
req->Set(String::NewSymbol("headers"),headers);
req->Set(String::NewSymbol("files"),files);

Handle<Value> argv[argc] = {String::New("appjs-request"),req,cb};
v8::Handle<Value> argv[argc] = {String::New("appjs-request"),req,cb};
node::MakeCallback(emitter,"emit",argc,argv);

}

Handle<Value> AppjsSchemeHandler::NodeCallback(const Arguments& args) {
v8::Handle<Value> AppjsSchemeHandler::NodeCallback(const Arguments& args) {
HandleScope scope;

AppjsSchemeHandler* me = static_cast<AppjsSchemeHandler *>(UnwrapObject(args.Data()));
Expand Down
2 changes: 1 addition & 1 deletion src/includes/cef_sync_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ bool AppjsSyncHandler::Execute(const CefString& name,
if (browser_.get()) {
HandleScope scope;
Local<Value> argv[1] = { CefStringToV8(arguments[0]->GetStringValue()) };
Handle<Object> window = NativeWindow::GetWindow(browser_)->GetV8Handle();;
v8::Handle<Object> window = NativeWindow::GetWindow(browser_)->GetV8Handle();;
Local<Function> handler = Local<Function>::Cast(window->Get(String::NewSymbol("onmessage")));
Local<Value> result = handler->Call(window, 1, argv);
if (result->IsString()) {
Expand Down
8 changes: 4 additions & 4 deletions src/native_menu/native_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@ NativeMenu::~NativeMenu(){
// destroy all v8 persistent objects
}

void NativeMenu::Emit(Handle<Value>* args,int length){
void NativeMenu::Emit(v8::Handle<Value>* args,int length){
node::MakeCallback(v8handle_, "emit", length, args);
}

void NativeMenu::Emit(const char* event){
Handle<Value> args[1] = { String::New(event) };
v8::Handle<Value> args[1] = { String::New(event) };
Emit(args,1);
}

void NativeMenu::Emit(const char* event, Handle<Value> arg){
void NativeMenu::Emit(const char* event, v8::Handle<Value> arg){

Handle<Value> args[2] = {
v8::Handle<Value> args[2] = {
String::New(event),
arg
};
Expand Down
Loading

0 comments on commit 73250d4

Please sign in to comment.