Skip to content

Commit dc910a2

Browse files
committed
removed commented code
1 parent 7258251 commit dc910a2

File tree

1 file changed

+66
-156
lines changed

1 file changed

+66
-156
lines changed

src/jni/NativeScriptRuntime.cpp

Lines changed: 66 additions & 156 deletions
Original file line numberDiff line numberDiff line change
@@ -194,184 +194,94 @@ void NativeScriptRuntime::CallJavaMethod(const Handle<Object>& caller, const str
194194
jmethodID mid;
195195
string sig;
196196

197-
// if ((entry != nullptr) && entry->isResolved)
198-
// {
199-
// isStatic = entry->isStatic;
200-
//
201-
// if (entry->memberId == nullptr)
202-
// {
203-
// entry->clazz = env.FindClass(className);
204-
// if (entry->clazz == nullptr)
205-
// {
206-
// MetadataNode* callerNode = MetadataNode::GetNodeFromHandle(caller);
207-
// const string callerClassName = callerNode->GetName();
208-
//
209-
// DEBUG_WRITE("Cannot resolve class: %s while calling method: %s callerClassName: %s", className.c_str(), methodName.c_str(), callerClassName.c_str());
210-
// clazz = env.FindClass(callerClassName);
211-
// if (clazz == nullptr)
212-
// {
213-
// DEBUG_WRITE("Cannot resolve caller's class name: %s", callerClassName.c_str());
214-
// return;
215-
// }
216-
//
217-
// mid = isStatic ?
218-
// env.GetStaticMethodID(clazz, methodName, entry->sig) :
219-
// env.GetMethodID(clazz, methodName, entry->sig);
220-
//
221-
// if (mid == nullptr)
222-
// {
223-
// DEBUG_WRITE("Cannot resolve a method %s on caller class: %s", methodName.c_str(), callerClassName.c_str());
224-
// return;
225-
// }
226-
//
227-
// }
228-
// else
229-
// {
230-
// entry->memberId = isStatic ?
231-
// env.GetStaticMethodID(entry->clazz, methodName, entry->sig) :
232-
// env.GetMethodID(entry->clazz, methodName, entry->sig);
233-
//
234-
// if (entry->memberId == nullptr)
235-
// {
236-
// DEBUG_WRITE("Cannot resolve a method %s on class: %s", methodName.c_str(), className.c_str());
237-
// return;
238-
// }
239-
// }
240-
// }
241-
//
242-
// if (entry->clazz != nullptr)
243-
// {
244-
// clazz = entry->clazz;
245-
// mid = reinterpret_cast<jmethodID>(entry->memberId);
246-
// }
247-
//
248-
// sig = entry->sig;
249-
// }
250-
// else
251-
// {
252-
// DEBUG_WRITE("Resolving method: %s.%s on className %s", className.c_str(), methodName.c_str(), className.c_str());
253-
// auto mi = MethodCache::ResolveMethodSignature(className, methodName, args, isStatic);
254-
// if (mi.mid == nullptr)
255-
// {
256-
// MetadataNode* callerNode = MetadataNode::GetNodeFromHandle(caller);
257-
// const string callerClassName = callerNode->GetName();
258-
// DEBUG_WRITE("Resolving method on caller class: %s.%s on className %s", callerClassName.c_str(), methodName.c_str(), className.c_str());
259-
// mi = MethodCache::ResolveMethodSignature(callerClassName, methodName, args, isStatic);
260-
// if (mi.mid == nullptr)
261-
// {
262-
// DEBUG_WRITE("Cannot resolve class=%s, method=%s, isStatic=%d, isSuper=%d, callerClass=%s", className.c_str(), methodName.c_str(), isStatic, isSuper, callerClassName.c_str());
263-
// return;
264-
// }
265-
// }
266-
//
267-
// clazz = mi.clazz;
268-
// mid = mi.mid;
269-
// sig = mi.signature;
270-
// }
271-
272-
273-
274-
275-
276-
if ((entry != nullptr) && entry->isResolved)
277-
{
278-
isStatic = entry->isStatic;
197+
if ((entry != nullptr) && entry->isResolved)
198+
{
199+
isStatic = entry->isStatic;
279200

280-
if (entry->memberId == nullptr)
201+
if (entry->memberId == nullptr)
202+
{
203+
entry->clazz = env.FindClass(className);
204+
if (entry->clazz == nullptr)
281205
{
282-
entry->clazz = env.FindClass(className);
283-
if (entry->clazz == nullptr)
284-
{
285-
MetadataNode* callerNode = MetadataNode::GetNodeFromHandle(caller);
286-
const string callerClassName = callerNode->GetName();
287-
288-
DEBUG_WRITE("Cannot resolve class: %s while calling method: %s callerClassName: %s", className.c_str(), methodName.c_str(), callerClassName.c_str());
289-
clazz = env.FindClass(callerClassName);
290-
if (clazz == nullptr)
291-
{
292-
DEBUG_WRITE("Cannot resolve caller's class name: %s", callerClassName.c_str());
293-
return;
294-
}
295-
296-
mid = isStatic ?
297-
env.GetStaticMethodID(clazz, methodName, entry->sig) :
298-
env.GetMethodID(clazz, methodName, entry->sig);
299-
300-
if (mid == nullptr)
301-
{
302-
DEBUG_WRITE("Cannot resolve a method %s on caller class: %s", methodName.c_str(), callerClassName.c_str());
303-
return;
304-
}
206+
MetadataNode* callerNode = MetadataNode::GetNodeFromHandle(caller);
207+
const string callerClassName = callerNode->GetName();
305208

306-
}
307-
else
209+
DEBUG_WRITE("Cannot resolve class: %s while calling method: %s callerClassName: %s", className.c_str(), methodName.c_str(), callerClassName.c_str());
210+
clazz = env.FindClass(callerClassName);
211+
if (clazz == nullptr)
308212
{
309-
entry->memberId = isStatic ?
310-
env.GetStaticMethodID(entry->clazz, methodName, entry->sig) :
311-
env.GetMethodID(entry->clazz, methodName, entry->sig);
312-
313-
if (entry->memberId == nullptr)
314-
{
315-
DEBUG_WRITE("Cannot resolve a method %s on class: %s", methodName.c_str(), className.c_str());
316-
return;
317-
}
213+
DEBUG_WRITE("Cannot resolve caller's class name: %s", callerClassName.c_str());
214+
return;
318215
}
319-
}
320216

321-
if (entry->clazz != nullptr)
322-
{
323-
clazz = entry->clazz;
324-
mid = reinterpret_cast<jmethodID>(entry->memberId);
325-
}
217+
mid = isStatic ?
218+
env.GetStaticMethodID(clazz, methodName, entry->sig) :
219+
env.GetMethodID(clazz, methodName, entry->sig);
326220

327-
sig = entry->sig;
328-
}
329-
else
330-
{
331-
// auto mi = MethodCache::ResolveMethodSignature(className, methodName, args, isStatic);
332-
// if (mi.mid == nullptr)
333-
// {
334-
// DEBUG_WRITE("Cannot resolve class=%s, method=%s, isStatic=%d, isSuper=%d", className.c_str(), methodName.c_str(), isStatic, isSuper);
335-
// return;
336-
// }
337-
// clazz = mi.clazz;
338-
// mid = mi.mid;
339-
// sig = mi.signature;
340-
341-
342-
//DEBUG_WRITE("Resolving method: %s.%s on className %s", className.c_str(), methodName.c_str(), className.c_str());
343-
MethodCache::CacheMethodInfo mi;
344-
345-
clazz = env.FindClass(className);
346-
if (clazz != nullptr)
347-
{
348-
mi = MethodCache::ResolveMethodSignature(className, methodName, args, isStatic);
349-
if (mi.mid == nullptr)
221+
if (mid == nullptr)
350222
{
351-
DEBUG_WRITE("Cannot resolve class=%s, method=%s, isStatic=%d, isSuper=%d", className.c_str(), methodName.c_str(), isStatic, isSuper);
223+
DEBUG_WRITE("Cannot resolve a method %s on caller class: %s", methodName.c_str(), callerClassName.c_str());
352224
return;
353225
}
226+
354227
}
355228
else
356229
{
357-
MetadataNode* callerNode = MetadataNode::GetNodeFromHandle(caller);
358-
const string callerClassName = callerNode->GetName();
359-
DEBUG_WRITE("Resolving method on caller class: %s.%s on className %s", callerClassName.c_str(), methodName.c_str(), className.c_str());
360-
mi = MethodCache::ResolveMethodSignature(callerClassName, methodName, args, isStatic);
361-
if (mi.mid == nullptr)
230+
entry->memberId = isStatic ?
231+
env.GetStaticMethodID(entry->clazz, methodName, entry->sig) :
232+
env.GetMethodID(entry->clazz, methodName, entry->sig);
233+
234+
if (entry->memberId == nullptr)
362235
{
363-
DEBUG_WRITE("Cannot resolve class=%s, method=%s, isStatic=%d, isSuper=%d, callerClass=%s", className.c_str(), methodName.c_str(), isStatic, isSuper, callerClassName.c_str());
236+
DEBUG_WRITE("Cannot resolve a method %s on class: %s", methodName.c_str(), className.c_str());
364237
return;
365238
}
366239
}
240+
}
241+
242+
if (entry->clazz != nullptr)
243+
{
244+
clazz = entry->clazz;
245+
mid = reinterpret_cast<jmethodID>(entry->memberId);
246+
}
367247

248+
sig = entry->sig;
249+
}
250+
else
251+
{
252+
DEBUG_WRITE("Resolving method: %s on className %s", methodName.c_str(), className.c_str());
253+
MethodCache::CacheMethodInfo mi;
368254

369-
clazz = mi.clazz;
370-
mid = mi.mid;
371-
sig = mi.signature;
255+
clazz = env.FindClass(className);
256+
if (clazz != nullptr)
257+
{
258+
mi = MethodCache::ResolveMethodSignature(className, methodName, args, isStatic);
259+
if (mi.mid == nullptr)
260+
{
261+
DEBUG_WRITE("Cannot resolve class=%s, method=%s, isStatic=%d, isSuper=%d", className.c_str(), methodName.c_str(), isStatic, isSuper);
262+
return;
263+
}
264+
}
265+
else
266+
{
267+
MetadataNode* callerNode = MetadataNode::GetNodeFromHandle(caller);
268+
const string callerClassName = callerNode->GetName();
269+
DEBUG_WRITE("Resolving method on caller class: %s.%s on className %s", callerClassName.c_str(), methodName.c_str(), className.c_str());
270+
mi = MethodCache::ResolveMethodSignature(callerClassName, methodName, args, isStatic);
271+
if (mi.mid == nullptr)
272+
{
273+
DEBUG_WRITE("Cannot resolve class=%s, method=%s, isStatic=%d, isSuper=%d, callerClass=%s", className.c_str(), methodName.c_str(), isStatic, isSuper, callerClassName.c_str());
274+
return;
275+
}
372276
}
373277

374278

279+
clazz = mi.clazz;
280+
mid = mi.mid;
281+
sig = mi.signature;
282+
}
283+
284+
375285

376286

377287

0 commit comments

Comments
 (0)