MCPcopy Create free account
hub / github.com/HelloBush/Java_MHXYdemo / Invoke

Method Invoke

lib/jacob-1.20_src/jacob-1.20/jni/EventProxy.cpp:155–279  ·  view source on GitHub ↗

The actual callback from the connection point arrives here

Source from the content-addressed store, hash-verified

153
154// The actual callback from the connection point arrives here
155STDMETHODIMP EventProxy::Invoke(DISPID dispID, REFIID riid,
156 LCID lcid, unsigned short wFlags, DISPPARAMS *pDispParams,
157 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
158{
159 const char *eventMethodName = NULL; //Sourceforge report 1394001
160 JNIEnv *env = NULL;
161
162 // map dispID to jmethodID
163 for(int i=0;i<MethNum;i++)
164 {
165 if (MethID[i] == dispID) {
166 USES_CONVERSION;
167 eventMethodName = W2A((OLECHAR *)MethName[i]);
168 }
169 }
170 // added 1.12
171 if (!eventMethodName) {
172 // just bail if can't find signature. no need to attach
173 // printf("Invoke: didn't find method name for dispatch id %d\n",dispID);
174 return S_OK;
175 }
176 if (DISPATCH_METHOD & wFlags)
177 {
178
179 // attach to the current running thread
180 //printf("Invoke: Attaching to current thread using JNI Version 1.2\n");
181 JavaVMAttachArgs attachmentArgs;
182 attachmentArgs.version = JNI_VERSION_1_2;
183 attachmentArgs.name = NULL;
184 attachmentArgs.group = NULL;
185 jvm->AttachCurrentThread((void **)&env, &attachmentArgs);
186 if (env->ExceptionOccurred()) { env->ExceptionDescribe(); env->ExceptionClear();}
187
188 if (!eventMethodName)
189 {
190 // could not find this signature in list
191 // printf("Invoke: didn't find method name for dispatch id %d\n",dispID);
192 // this probably leaves a native thread attached to the vm when we don't want it
193 ThrowComFail(env, "Event method received was not defined as part of callback interface", -1);
194
195 // should we detatch before returning?? We probably never get here if we ThrowComFail()
196 // jvm->DetachCurrentThread();
197 return S_OK;
198 }
199
200 // find the class of the InvocationHandler
201 jclass javaSinkClass = env->GetObjectClass(javaSinkObj);
202 if (env->ExceptionOccurred()) { env->ExceptionDescribe(); env->ExceptionClear();}
203 //printf("Invoke: Got sink class\n");
204 jmethodID invokeMethod;
205 invokeMethod = env->GetMethodID(javaSinkClass, "invoke", "(Ljava/lang/String;[Lcom/jacob/com/Variant;)Lcom/jacob/com/Variant;");
206 if (env->ExceptionOccurred()) { env->ExceptionDescribe(); env->ExceptionClear();}
207 jstring eventMethodNameAsString = env->NewStringUTF(eventMethodName);
208 //printf("Invoke: Got method name\n");
209 // now do what we need for the variant
210 jmethodID getVariantMethod = env->GetMethodID(javaSinkClass, "getVariant", "()Lcom/jacob/com/Variant;");
211 if (env->ExceptionOccurred()) { env->ExceptionDescribe(); env->ExceptionClear();}
212 //printf("Invoke: Found way too getVariant\n");

Callers 1

Calls 3

ThrowComFailFunction · 0.85
extractVariantFunction · 0.85
zeroVariantFunction · 0.85

Tested by

no test coverage detected