本文整理汇总了C++中Method类的典型用法代码示例。如果您正苦于以下问题:C++ Method类的具体用法?C++ Method怎么用?C++ Method使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Method类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: popFromStack
int MethodHandles::method_handle_entry_linkToVirtual(Method* method, intptr_t UNUSED, TRAPS) {
JavaThread *thread = (JavaThread *) THREAD;
InterpreterFrame *frame = thread->top_zero_frame()->as_interpreter_frame();
interpreterState istate = frame->interpreter_state();
// Pop appendix argument from stack. This is a MemberName which we resolve to the
// target method.
oop vmentry = popFromStack(THREAD);
intptr_t* topOfStack = istate->stack();
// Resolve target method by looking up in the receiver object's vtable.
intptr_t vmindex = java_lang_invoke_MemberName::vmindex(vmentry);
Method* target = (Method*) java_lang_invoke_MemberName::vmtarget(vmentry);
int numArgs = target->size_of_parameters();
oop recv = STACK_OBJECT(-numArgs);
Klass* clazz = recv->klass();
Klass* klass_part = InstanceKlass::cast(clazz);
klassVtable* vtable = klass_part->vtable();
Method* vmtarget = vtable->method_at(vmindex);
invoke_target(vmtarget, THREAD);
return 0;
}
示例2: handle
bool FilterHandler::handle(HttpRequest* req, HttpResponse* res, const string& ext, Reflector& reflector)
{
string acurl = req->getActUrl();
RegexUtil::replace(acurl,"[/]+","/");
if(acurl.find("/"+req->getCntxt_name())!=0)
acurl = "/" + req->getCntxt_name() + "/" + acurl;
RegexUtil::replace(acurl,"[/]+","/");
bool continue_proc_request = true;
Logger logger = LoggerFactory::getLogger("FilterHandler");
vector<string> filters;
if(getFilterForPath(req->getCntxt_name(), acurl, filters, "handle"))
{
for (int var = 0; var < (int)filters.size(); ++var)
{
string claz = filters.at(var);
void *_temp = ConfigurationData::getInstance()->ffeadContext.getBean("filter_"+claz, req->getCntxt_name());
args argus;
argus.push_back("HttpRequest*");
argus.push_back("HttpResponse*");
vals valus;
const ClassInfo& srv = ConfigurationData::getInstance()->ffeadContext.classInfoMap[req->getCntxt_name()][claz];
Method meth = srv.getMethod("doHandle", argus);
if(meth.getMethodName()!="")
{
valus.push_back(req);
valus.push_back(res);
continue_proc_request = reflector.invokeMethod<bool>(_temp,meth,valus);
logger << "Handler Filter called" << endl;
}
ConfigurationData::getInstance()->ffeadContext.release("filter_"+claz, req->getCntxt_name());
}
}
return continue_proc_request;
}
示例3: class_signature
ISequence<MethodSignature>*
MethodsList::extractAndSyncAnyExtraMethods( Method& method )
{
ISequence<MethodSignature>* method_signatures = new Sequence<MethodSignature>();
{
ISequence<Method>* extra_methods = method.extractExtraMethods();
if ( extra_methods )
{
ClassSignature class_signature( this->cu.getFQName() );
while ( ! extra_methods->isEmpty() )
{
Method* method = extra_methods->removeLast();
if ( method->sync() )
{
const char* method_key = method->getSignature().getMethodKey().getChars();
this->methods->insert( method_key, method );
method_signatures->addLast( new MethodSignature( class_signature, method_key ) );
}
else
{
delete method_signatures;
method_signatures = NULL;
break;
}
}
}
delete extra_methods;
}
return method_signatures;
}
示例4: sort_methods
static void sort_methods(GrowableArray<Method*>* methods) {
// Note that this must sort using the same key as is used for sorting
// methods in InstanceKlass.
bool sorted = true;
for (int i = methods->length() - 1; i > 0; --i) {
for (int j = 0; j < i; ++j) {
Method* m1 = methods->at(j);
Method* m2 = methods->at(j + 1);
if ((uintptr_t)m1->name() > (uintptr_t)m2->name()) {
methods->at_put(j, m2);
methods->at_put(j + 1, m1);
sorted = false;
}
}
if (sorted) break;
sorted = true;
}
#ifdef ASSERT
uintptr_t prev = 0;
for (int i = 0; i < methods->length(); ++i) {
Method* mh = methods->at(i);
uintptr_t nv = (uintptr_t)mh->name();
assert(nv >= prev, "Incorrect overpass method ordering");
prev = nv;
}
#endif
}
示例5: new_method
static Method* new_method(
BytecodeConstantPool* cp, BytecodeBuffer* bytecodes, Symbol* name,
Symbol* sig, AccessFlags flags, int max_stack, int params,
ConstMethod::MethodType mt, TRAPS) {
address code_start = 0;
int code_length = 0;
InlineTableSizes sizes;
if (bytecodes != NULL && bytecodes->length() > 0) {
code_start = static_cast<address>(bytecodes->adr_at(0));
code_length = bytecodes->length();
}
Method* m = Method::allocate(cp->pool_holder()->class_loader_data(),
code_length, flags, &sizes,
mt, CHECK_NULL);
m->set_constants(NULL); // This will get filled in later
m->set_name_index(cp->utf8(name));
m->set_signature_index(cp->utf8(sig));
#ifdef CC_INTERP
ResultTypeFinder rtf(sig);
m->set_result_index(rtf.type());
#endif
m->set_size_of_parameters(params);
m->set_max_stack(max_stack);
m->set_max_locals(params);
m->constMethod()->set_stackmap_data(NULL);
m->set_code(code_start);
return m;
}
示例6: ConstantPool
void InterpretTest::gcTest()
{
ConstantPool * pool = new ConstantPool();
Class * cls = initClass("GCTest", pool);
const char code[] =
{
PUSH, 0x00, 0x00,
STORE_LOCAL, 0x00,
PUSH, 0x01, 0x00, //label1
LOAD_LOCAL, 0x00,
SUB,
IF_GE, 0x0D,//if(i < 1000)
PUSH, 0x01, 0x00,
NEW_ARRAY,
STORE_LOCAL, 0x01,
LOAD_LOCAL, 0x00,
INC,
STORE_LOCAL, 0x00,
JMP, -21,
RET_VOID
};
Method * m = initMethod("gcTest", code, sizeof(code), 0, 2, 0);
ClassLoader cl("");
Interpret instance(&cl);
IntConst i;
i.value = 0;
pool->addItem(&i, INT_CONST);//0
i.value = 1000;
pool->addItem(&i, INT_CONST);//1
cls->addMethod(m);
cl.addClass(cls);
instance.run(cls->getName().c_str(), m->getName().c_str());
}
示例7: reflector
void ServiceTask::handleWebsockClose(WebSocketData* req) {
Reflector reflector(ConfigurationData::getInstance()->dlib);
std::string className;
std::map<std::string, std::map<std::string, std::string> >& websocketMappingMap = ConfigurationData::getInstance()->websocketMappingMap;
std::map<std::string, std::string> websockcntMap = websocketMappingMap[req->getCntxt_name()];
std::map<std::string, std::string>::iterator it;
for (it=websockcntMap.begin();it!=websockcntMap.end();++it) {
if(ConfigurationData::urlMatchesPath(req->getCntxt_name(), it->first, req->getUrl()))
{
className = it->second;
break;
}
}
if(className!="")
{
void *_temp = ConfigurationData::getInstance()->ffeadContext.getBean("websocketclass_"+className, req->getCntxt_name());
args argus;
vals valus;
const ClassInfo& srv = ConfigurationData::getClassInfo(className, req->getCntxt_name());
Method methc = srv.getMethod("onClose", argus);
if(methc.getMethodName()!="")
{
//logger << ("WebSocket Controller " + className + " called") << std::endl;
reflector.invokeMethodGVP(_temp,methc,valus);
logger << "WebSocket Controller onClose" << std::endl;
}
else
{
logger << "Invalid WebSocket Controller" << std::endl;
}
}
}
示例8: MarkProcedure
// check all the function to find precedures
void MarkProcedure() {
//check all the function if it calls wait for semwait mark it and mark all its parents as candidate
for(map<string, Method*>::iterator iter = methods.begin();
iter != methods.end(); iter++) {
Method *m = iter->second;
if (m->candidate) continue;
for (set<string>::iterator call_iter = m->callexprs.begin();
call_iter != m->callexprs.end(); call_iter++) {
string callee = *call_iter;
if (isWaitFunctionCall(callee) || isSemWaitCall(callee)) {
MakeAsCandidate(m);
break;
}
}
}
for(map<string, Method*>::iterator iter = methods.begin();
iter != methods.end(); iter++) {
iter->second->visit = false;
iter->second->isProcedure = false;
}
//start from starting procedure traverse the call chain
for(map<string, Method*>::iterator iter = methods.begin();
iter != methods.end(); iter++) {
Method *m = iter->second;
if (m->isStartingProcedure(records)) {
TraverseProcedure(m);
}
}
}
示例9: assert
void BackEnd::resolve(FuncDeclaration& decl)
{
assert(!decl.csym);
ModuleEmitter& modScope = getModuleScope(decl.loc);
// is the function declared in the scope of the current module?
if (decl.scope && decl.scope->module == &modScope.getModule())
{
if (ClassDeclaration* classDecl = decl.isClassMember())
{
Class& c = static_cast<Class&>(DEREF(classDecl->csym));
modScope.createMethod(c.getBlock(), decl);
}
else
{
modScope.createFunction(decl);
}
}
else
{
// create a method at the assembly level (where it does not get emitted)
Method* method = new Method(decl, 0);
getAssembly().add(*method);
decl.csym = method;
if (decl.ident == Id::eq)
{
//force dispatch thru the System.Object's vtable
method->setProto(L"bool object::Equals(object)", 1);
}
}
}
示例10: methodToListObj
static TclObject
methodToListObj (const Method &method)
{
TclObject list(Tcl_NewListObj(0, 0));
// Put member id.
list.lappend(Tcl_NewIntObj(method.memberid()));
// Put return type.
list.lappend(typeToListObj(method.type()));
// Put method name.
list.lappend(
Tcl_NewStringObj(const_cast<char *>(method.name().c_str()), -1));
// Put parameters.
TclObject parameterList(Tcl_NewListObj(0, 0));
const Method::Parameters ¶meters = method.parameters();
for (Method::Parameters::const_iterator p = parameters.begin();
p != parameters.end(); ++p) {
parameterList.lappend(parameterToListObj(*p));
}
list.lappend(parameterList);
return list;
}
示例11: QStandardItemModel
QStandardItemModel * LookupDialog::modelForMethod(const QString & methodName)
{
const Introspection & introspection = Main::scProcess()->introspection();
const MethodMap & methods = introspection.methodMap();
pair<MethodMap::const_iterator, MethodMap::const_iterator> matchingMethods = methods.equal_range(methodName);
if (matchingMethods.first == matchingMethods.second)
return NULL;
QStandardItemModel * model = new QStandardItemModel(this);
QStandardItem *parentItem = model->invisibleRootItem();
for (MethodMap::const_iterator it = matchingMethods.first; it != matchingMethods.second; ++it) {
Method *method = it->second.data();
QString signature = method->signature( Method::SignatureWithoutArguments );
const QString & path = method->definition.path;
QString displayPath = introspection.compactLibraryPath(path);
parentItem->appendRow(makeDialogItem( signature, displayPath,
method->definition.path.get(),
method->definition.position,
method->ownerClass->name.get(), method->name.get(),
false ));
}
model->sort(0);
return model;
}
示例12: cpp_file
void GenerateServerMethods::generate_CPP_USER(const std::string &destdir, const std::string &name)
{
const std::string h_name = theClass.getBaseName() + "_ulxr_server.h";
std::string cpp_name = destdir + theClass.getBaseName() + "_ulxr_server_user.cpp";
struct stat statbuf;
if (stat(cpp_name.c_str(), &statbuf) >= 0)
{
std::cout << "User file already exists: " << cpp_name << std::endl;
cpp_name += ".new";
std::cout << "New template will be created: " << cpp_name << std::endl;
}
std::ofstream cpp_file(cpp_name.c_str());
std::cout << "User file will be created: " << cpp_name << std::endl;
generateUserSourceHead(cpp_file, h_name);
cpp_file << "#include <ulxmlrpcpp/ulxr_response.h>\n";
cpp_file << "#include <ulxmlrpcpp/ulxr_method_adder.h>\n";
cpp_file << "#include <ulxmlrpcpp/ulxr_signature.h>\n\n";
cpp_file << "#include \"" << theClass.getSource() << "\"\n";
cpp_file << "#include \"" << name + "_ulxr_names.h" << "\"\n\n";
cpp_file <<
"\nvoid " << name << "Server::setupServerMethods()\n"
"{\n";
for (unsigned i = 0; i < theClass.numMethods(); ++i)
{
if (i != 0)
cpp_file << "\n";
Method method = theClass.getMethod(i);
method.extractNamespace();
cpp_file << " // mapped to: " << method.getCppString(0, false, "");
if (method.getName() != method.getOverloadName())
cpp_file << " (there are overloaded methods)";
cpp_file <<
"\n"
" method_adder.addMethod(ulxr::make_method(*this, &" << method.getOverloadName(true, "Server") << "),\n"
" " << method.getType().getRpcName() << "::getValueName(),\n"
" ULXR_CALLTO_" << method.getOverloadName(true, "", "_") << ",\n"
" ulxr::Signature()";
for (unsigned p = 0; p < method.numArgs(); ++p)
cpp_file << "\n << " << method.getArg(p).getType().getRpcName() << "::getValueName()";
cpp_file <<
",\n"
" ulxr_i18n(ULXR_PCHAR(\"Some descriptive comment about '" << method.getCppString(0, true, "") << "'.\"))); // TODO adjust comment\n";
}
cpp_file <<
"}\n\n";
}
示例13: methodTest
bool methodTest() {
Class A(NULL, "A");
Class B(&A, "B");
ASSERT_NO_THROW(B.addMethod("nothing", doesNothing));
ASSERT_EQUALS("nothing", B.getMethod("nothing").name());
ASSERT_EQUALS("B", B.getMethod("nothing").getDeclaringClass());
Method m = B.getMethod("nothing");
Object* inst = A.newInstance();
Object* b_inst = B.newInstance();
ASSERT_THROW(MethodNotFound, m.invoke(inst));
ASSERT_NO_THROW(m.invoke(b_inst));
ASSERT_NO_THROW(A.addInstanceField("x", INT));
// set accessible must be zero but invoke must succeed
ASSERT_NO_THROW(A.addMethod("goblin", goblinIsHere));
Object* obj = A.newInstance();
Field f = A.getField("x");
Class::setAccessible(true);
ASSERT_EQUALS(f.getInt(obj), 0);
Class::setAccessible(false);
ASSERT_NO_THROW(obj->invokeMethod("goblin"));
ASSERT_THROW(FieldNotAccessible, f.getInt(obj));
Class::setAccessible(true);
ASSERT_EQUALS(f.getInt(obj), 7);
/* delete inst;
delete b_inst;
delete obj;*/
return true;
}
示例14: run
BytesPtr ExecutorDummy::run(MethodId const& id, BytesPtr srcArgs)
{
try
{
//updateTraffic(id, srcArgs->size());
if (id == makeMethodId(Interfaces::IDirect3DDevice9, Methods_IDirect3DDevice9::Present))
++numFrames_;
BytesPtr dstArgs = bytes::make();
Method method = methods_->getMethod(id);
method.first(srcArgs, dstArgs);
return dstArgs;
}
catch(std::exception const &e)
{
LogError(e.what());
Verify(false);
}
catch(...)
{
LogError("Unknown exception");
Verify(false);
}
}
示例15: findMethod
Method Class::findMethod(string name, string vsig, string rsig, int static_) {
Method m;
if (!this->valid) {
Method m;
m.init(this->jvm, "can't call find method for invalid class");
return m;
}
m.jvm = this->jvm;
m.cls = *this;
m.name = name;
m.vsig = vsig;
m.rsig = rsig;
m.static_ = static_;
string sig_ = "(" + vsig + ")" + rsig;
if (static_) {
m.mid = this->jvm->env_->GetStaticMethodID(this->cls, name.c_str(),
sig_.c_str());
} else {
m.mid = this->jvm->env_->GetMethodID(this->cls, name.c_str(),
sig_.c_str());
}
if (m.mid) {
m.init(this->jvm, "");
} else {
m.init(this->jvm, "method(" + m.name + ") not found by sig:" + sig_);
}
return m;
}