Skip to content

Commit

Permalink
[TIMOB-25757] Fix Ti.API
Browse files Browse the repository at this point in the history
  • Loading branch information
Gary Mathews committed Feb 22, 2018
1 parent cbf0675 commit 93bac17
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
19 changes: 19 additions & 0 deletions android/runtime/v8/src/native/modules/APIModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,19 @@ void APIModule::Initialize(Local<Object> target, Local<Context> context)
SetProtoMethod(isolate, constructor, "log", log);
SetProtoMethod(isolate, constructor, "getApiName", APIModule::getApiName);

// these are documented but non-functional
SetProtoMethod(isolate, constructor, "getBubbleParent", APIModule::undefined);
SetProtoMethod(isolate, constructor, "getLifecycleContainer", APIModule::undefined);
SetProtoMethod(isolate, constructor, "setBubbleParent", APIModule::undefined);
SetProtoMethod(isolate, constructor, "setLifecycleContainer", APIModule::undefined);

// Add an "apiName" property to instances, which delegates to APIModule::getter_apiName
// TODO Use a constant here?
Local<ObjectTemplate> instanceTemplate = constructor->InstanceTemplate();
instanceTemplate->SetAccessor(NEW_SYMBOL(isolate, "apiName"), APIModule::getter_apiName);

instanceTemplate->SetAccessor(NEW_SYMBOL(isolate, "bubbleParent"), APIModule::getter_undefined);
instanceTemplate->SetAccessor(NEW_SYMBOL(isolate, "lifecycleContainer"), APIModule::getter_undefined);

// Expose a method for terminating the application for the debugger.
// Debugger will send an evaluation request calling this method
Expand Down Expand Up @@ -253,6 +262,11 @@ void APIModule::getter_apiName(Local<Name> name, const PropertyCallbackInfo<Valu
args.GetReturnValue().Set(STRING_NEW(args.GetIsolate(), "Ti.API"));
}

void APIModule::getter_undefined(Local<Name> name, const PropertyCallbackInfo<Value>& args)
{
args.GetReturnValue().Set(Undefined(args.GetIsolate()));
}

void APIModule::terminate(const FunctionCallbackInfo<Value>& args)
{
kill(getpid(), 9);
Expand All @@ -263,6 +277,11 @@ void APIModule::debugBreak(const FunctionCallbackInfo<Value>& args)
Debug::DebugBreak(args.GetIsolate());
}

void APIModule::undefined(const FunctionCallbackInfo<Value>& args)
{
args.GetReturnValue().Set(Undefined(args.GetIsolate()));
}

void APIModule::Dispose(Isolate* isolate)
{
constructorTemplate.Reset();
Expand Down
2 changes: 2 additions & 0 deletions android/runtime/v8/src/native/modules/APIModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ class APIModule
static Local<String> combineLogMessages(const FunctionCallbackInfo<Value>& args, int startIndex=0);
static void getApiName(const FunctionCallbackInfo<Value>& args);
static void getter_apiName(Local<Name> name, const PropertyCallbackInfo<Value>& args);
static void getter_undefined(Local<Name> name, const PropertyCallbackInfo<Value>& args);
static void undefined(const FunctionCallbackInfo<Value>& args);
};
}

Expand Down

0 comments on commit 93bac17

Please sign in to comment.