本文整理汇总了C++中MethodList::size方法的典型用法代码示例。如果您正苦于以下问题:C++ MethodList::size方法的具体用法?C++ MethodList::size怎么用?C++ MethodList::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MethodList
的用法示例。
在下文中一共展示了MethodList::size方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getOwnPropertySlot
bool RuntimeObject::getOwnPropertySlot(JSCell* cell, ExecState *exec, const Identifier& propertyName, PropertySlot& slot)
{
RuntimeObject* thisObject = static_cast<RuntimeObject*>(cell);
if (!thisObject->m_instance) {
throwInvalidAccessError(exec);
return false;
}
RefPtr<Instance> instance = thisObject->m_instance;
instance->begin();
Class *aClass = instance->getClass();
if (aClass) {
// See if the instance has a field with the specified name.
Field *aField = aClass->fieldNamed(propertyName, instance.get());
if (aField) {
slot.setCustom(thisObject, thisObject->fieldGetter);
instance->end();
return true;
} else {
// Now check if a method with specified name exists, if so return a function object for
// that method.
MethodList methodList = aClass->methodsNamed(propertyName, instance.get());
if (methodList.size() > 0) {
slot.setCustom(thisObject, thisObject->methodGetter);
instance->end();
return true;
}
}
// Try a fallback object.
if (!aClass->fallbackObject(exec, instance.get(), propertyName).isUndefined()) {
slot.setCustom(thisObject, thisObject->fallbackObjectGetter);
instance->end();
return true;
}
}
instance->end();
return instance->getOwnPropertySlot(thisObject, exec, propertyName, slot);
}
示例2: getOwnPropertySlot
bool RuntimeObjectImp::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot)
{
if (!instance) {
throwInvalidAccessError(exec);
return false;
}
instance->begin();
Class *aClass = instance->getClass();
if (aClass) {
// See if the instance has a field with the specified name.
Field *aField = aClass->fieldNamed(propertyName, instance.get());
if (aField) {
slot.setCustom(this, fieldGetter);
instance->end();
return true;
} else {
// Now check if a method with specified name exists, if so return a function object for
// that method.
MethodList methodList = aClass->methodsNamed(propertyName, instance.get());
if (methodList.size() > 0) {
slot.setCustom(this, methodGetter);
instance->end();
return true;
}
}
// Try a fallback object.
if (!aClass->fallbackObject(exec, instance.get(), propertyName)->isUndefined()) {
slot.setCustom(this, fallbackObjectGetter);
instance->end();
return true;
}
}
instance->end();
// don't call superclass, because runtime objects can't have custom properties or a prototype
return false;
}
示例3: filterMethod
LuaExportMethodDescriptor* LuaExportTypeDescriptor::filterMethod(std::string const& methodName, LuaArgumentList arguments, bool isStatic)
{
MethodList methodList;
if (isStatic)
{
MethodMap::iterator mapIt = _classMethods.find(methodName);
if (mapIt != _classMethods.end())
{
methodList = mapIt -> second;
}
}
else
{
MethodMap::iterator mapIt = _instanceMethods.find(methodName);
if (mapIt != _instanceMethods.end())
{
methodList = mapIt -> second;
}
}
if (methodList.size() > 1)
{
LuaExportMethodDescriptor *targetMethod = NULL;
int startIndex = isStatic ? 0 : 1;
if (arguments.size() > startIndex)
{
//带参数
std::deque<std::string> signList;
std::string signListStr;
std::string signStrRegexp;
for (LuaArgumentList::iterator it = arguments.begin() + startIndex; it != arguments.end(); it++)
{
LuaValue *value = *it;
switch (value -> getType())
{
case LuaValueTypeNumber:
signList.push_back("N");
signListStr += "N";
signStrRegexp += "[[email protected]]";
break;
case LuaValueTypeBoolean:
signList.push_back("B");
signListStr += "B";
signStrRegexp += "[[email protected]]";
break;
case LuaValueTypeInteger:
signList.push_back("I");
signListStr += "I";
signStrRegexp += "[[email protected]]";
break;
default:
signList.push_back("O");
signListStr += "O";
signStrRegexp += "@";
break;
}
}
std::string luaMethodSignStr = methodName + "_" + signListStr;
MappingMethodMap::iterator methodIt = _methodsMapping.find(luaMethodSignStr);
if (methodIt == _methodsMapping.end())
{
//映射表无该方法,查找匹配方法
MethodList matchMethods;
std::regex regExp(signStrRegexp);
for (MethodList::iterator methodIt = methodList.begin(); methodIt != methodList.end(); methodIt ++)
{
LuaExportMethodDescriptor *methodDesc = *methodIt;
if (std::regex_match(methodDesc -> methodSignature(), regExp))
{
matchMethods.push_back(methodDesc);
}
}
if (matchMethods.size() > 0)
{
//选择最匹配的方法
//备选方法,如果没有最匹配的情况下使用
LuaExportMethodDescriptor *alternateMethod = NULL;
for (MethodList::iterator methodIt = matchMethods.begin(); methodIt != matchMethods.end(); methodIt ++)
{
LuaExportMethodDescriptor *methodDesc = *methodIt;
bool hasMatch = true;
bool hasAlternate = false;
for (int i = 0; i < methodDesc -> methodSignature().length(); i++)
{
if (i < signList.size())
{
std::string luaSign = signList[i];
char nativeSign = methodDesc -> methodSignature()[i];
if (luaSign == "N" && nativeSign != 'f' && nativeSign != 'd')
{
hasAlternate = true;
luaSign = "I";
}
//.........这里部分代码省略.........
示例4: invokeMethod
bool JavaInstance::invokeMethod(const char* methodName, const NPVariant* args, uint32_t count, NPVariant* resultValue)
{
int i;
jvalue *jArgs;
JavaMethod *method = 0;
VOID_TO_NPVARIANT(*resultValue);
MethodList methodList = getClass()->methodsNamed(methodName);
size_t numMethods = methodList.size();
// Try to find a good match for the overloaded method. The
// fundamental problem is that JavaScript doesn have the
// notion of method overloading and Java does. We could
// get a bit more sophisticated and attempt to does some
// type checking as we as checking the number of parameters.
JavaMethod *aMethod;
for (size_t methodIndex = 0; methodIndex < numMethods; methodIndex++) {
aMethod = methodList[methodIndex];
if (aMethod->numParameters() == count) {
method = aMethod;
break;
}
}
if (method == 0) {
LOGW("unable to find an appropiate method\n");
return false;
}
const JavaMethod *jMethod = static_cast<const JavaMethod*>(method);
if (count > 0) {
jArgs = (jvalue *)malloc (count * sizeof(jvalue));
}
else
jArgs = 0;
for (i = 0; i < count; i++) {
JavaParameter* aParameter = jMethod->parameterAt(i);
jArgs[i] = convertNPVariantToJValue(args[i], aParameter->getJNIType(), aParameter->type());
}
jvalue result;
// The following code can be conditionally removed once we have a Tiger update that
// contains the new Java plugin. It is needed for builds prior to Tiger.
{
jobject obj = getLocalRef();
switch (jMethod->JNIReturnType()){
case void_type:
callJNIMethodIDA<void>(obj, jMethod->methodID(obj), jArgs);
break;
case object_type:
result.l = callJNIMethodIDA<jobject>(obj, jMethod->methodID(obj), jArgs);
break;
case boolean_type:
result.z = callJNIMethodIDA<jboolean>(obj, jMethod->methodID(obj), jArgs);
break;
case byte_type:
result.b = callJNIMethodIDA<jbyte>(obj, jMethod->methodID(obj), jArgs);
break;
case char_type:
result.c = callJNIMethodIDA<jchar>(obj, jMethod->methodID(obj), jArgs);
break;
case short_type:
result.s = callJNIMethodIDA<jshort>(obj, jMethod->methodID(obj), jArgs);
break;
case int_type:
result.i = callJNIMethodIDA<jint>(obj, jMethod->methodID(obj), jArgs);
break;
case long_type:
result.j = callJNIMethodIDA<jlong>(obj, jMethod->methodID(obj), jArgs);
break;
case float_type:
result.f = callJNIMethodIDA<jfloat>(obj, jMethod->methodID(obj), jArgs);
break;
case double_type:
result.d = callJNIMethodIDA<jdouble>(obj, jMethod->methodID(obj), jArgs);
break;
case invalid_type:
default:
break;
}
getJNIEnv()->DeleteLocalRef(obj);
}
convertJValueToNPVariant(result, jMethod->JNIReturnType(), jMethod->returnType(), resultValue);
free (jArgs);
return true;
}
示例5: invokeMethod
JSValuePtr JavaInstance::invokeMethod (ExecState *exec, const MethodList &methodList, const ArgList &args)
{
int i, count = args.size();
jvalue *jArgs;
JSValuePtr resultValue;
Method *method = 0;
size_t numMethods = methodList.size();
// Try to find a good match for the overloaded method. The
// fundamental problem is that JavaScript doesn have the
// notion of method overloading and Java does. We could
// get a bit more sophisticated and attempt to does some
// type checking as we as checking the number of parameters.
Method *aMethod;
for (size_t methodIndex = 0; methodIndex < numMethods; methodIndex++) {
aMethod = methodList[methodIndex];
if (aMethod->numParameters() == count) {
method = aMethod;
break;
}
}
if (method == 0) {
JS_LOG ("unable to find an appropiate method\n");
return jsUndefined();
}
const JavaMethod *jMethod = static_cast<const JavaMethod*>(method);
JS_LOG ("call %s %s on %p\n", UString(jMethod->name()).UTF8String().c_str(), jMethod->signature(), _instance->_instance);
if (count > 0) {
jArgs = (jvalue *)malloc (count * sizeof(jvalue));
}
else
jArgs = 0;
for (i = 0; i < count; i++) {
JavaParameter* aParameter = jMethod->parameterAt(i);
jArgs[i] = convertValueToJValue(exec, args.at(exec, i), aParameter->getJNIType(), aParameter->type());
JS_LOG("arg[%d] = %s\n", i, args.at(exec, i).toString(exec).ascii());
}
jvalue result;
// Try to use the JNI abstraction first, otherwise fall back to
// nornmal JNI. The JNI dispatch abstraction allows the Java plugin
// to dispatch the call on the appropriate internal VM thread.
RootObject* rootObject = this->rootObject();
if (!rootObject)
return jsUndefined();
bool handled = false;
if (rootObject->nativeHandle()) {
jobject obj = _instance->_instance;
JSValuePtr exceptionDescription = noValue();
const char *callingURL = 0; // FIXME, need to propagate calling URL to Java
handled = dispatchJNICall(exec, rootObject->nativeHandle(), obj, jMethod->isStatic(), jMethod->JNIReturnType(), jMethod->methodID(obj), jArgs, result, callingURL, exceptionDescription);
if (exceptionDescription) {
throwError(exec, GeneralError, exceptionDescription.toString(exec));
free (jArgs);
return jsUndefined();
}
}
// The following code can be conditionally removed once we have a Tiger update that
// contains the new Java plugin. It is needed for builds prior to Tiger.
if (!handled) {
jobject obj = _instance->_instance;
switch (jMethod->JNIReturnType()){
case void_type:
callJNIMethodIDA<void>(obj, jMethod->methodID(obj), jArgs);
break;
case object_type:
result.l = callJNIMethodIDA<jobject>(obj, jMethod->methodID(obj), jArgs);
break;
case boolean_type:
result.z = callJNIMethodIDA<jboolean>(obj, jMethod->methodID(obj), jArgs);
break;
case byte_type:
result.b = callJNIMethodIDA<jbyte>(obj, jMethod->methodID(obj), jArgs);
break;
case char_type:
result.c = callJNIMethodIDA<jchar>(obj, jMethod->methodID(obj), jArgs);
break;
case short_type:
result.s = callJNIMethodIDA<jshort>(obj, jMethod->methodID(obj), jArgs);
break;
case int_type:
result.i = callJNIMethodIDA<jint>(obj, jMethod->methodID(obj), jArgs);
break;
case long_type:
result.j = callJNIMethodIDA<jlong>(obj, jMethod->methodID(obj), jArgs);
break;
case float_type:
result.f = callJNIMethodIDA<jfloat>(obj, jMethod->methodID(obj), jArgs);
break;
case double_type:
result.d = callJNIMethodIDA<jdouble>(obj, jMethod->methodID(obj), jArgs);
break;
case invalid_type:
//.........这里部分代码省略.........