TOCLRclr20r3怎么解决打冰

仙剑五怎么打冰麟?_百度知道北方冬天鱼池用什么工具能打冰窟窿,求方法_百度知道/ jnitoclr
项目语言:PYTHON
权限:read-only(如需更高权限请先加入项目)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import JNIType as jniType
class Demo(object):
def GetVersion(self,strx):
def DefineClass(self,strx):
def FindClass(self,strx):
if strx.find('&') != -1:
#说明FindClass函数参数是字符串
ClassType = self.objectMap[strx.split('=')[0]][0]
self.objectMap[strx.split('=')[0]] = (ClassType, strx.split('&')[1].split('/')[-1])
return ''
#说明参数是字符串变量
def FromReflectedMethod(self,strx):
def FromReflectedField(self,strx):
def ToReflectedMethod(self,strx):
def GetSuperclass(self,strx):
def IsAssignableFrom(self,strx):
def ToReflectedField(self,strx):
def Throw(self,strx):
def ThrowNew(self,strx):
def ExceptionOccurred(self,strx):
def ExceptionDescribe(self,strx):
def ExceptionClear(self,strx):
def FatalError(self,strx):
def PushLocalFrame(self,strx):
def PopLocalFrame(self,strx):
def NewGlobalRef(self,strx):
def DeleteGlobalRef(self,strx):
def DeleteLocalRef(self,strx):
def IsSameObject(self,strx):
def NewLocalRef(self,strx):
def EnsureLocalCapacity(self,strx):
def AllocObject(self,strx):
def NewObject(self,strx):
EqualLeft = strx.split('=')[0]
ClassName = self.objectMap[strx.split('(')[1].split(',')[0]]
outputState = '%s^ %s = gcnew %s;'%(ClassName[1], EqualLeft, ClassName[1])
#self.functionSatesList.append(outputState)
return outputState
def NewObjectV(self,strx):
def NewObjectA(self,strx):
def GetObjectClass(self,strx):
def IsInstanceOf(self,strx):
def GetMethodID(self,strx):
equalLeft = strx.split('=')[0]
functionName = strx.split('(')[1].split('&')[1]
functiontuple = self.objectMap[equalLeft]
functiontuple = (functiontuple[0],functionName)
self.objectMap[equalLeft] = functiontuple
return ''
def CallObjectMethod(self,strx):
def CallObjectMethodV(self,strx):
def CallObjectMethodA(self,strx):
def CallBooleanMethod(self,strx):
equalLeft = ''
equalRight = ''
if strx.find('=')!=-1:
equalLeft = strx[:strx.find('=')]
equalRight=strx[strx.find('=')+1:]
equalRight=strx
strRet = ''
if equalLeft!='':
strRet = 'unsiged int %s = '%(equalLeft,)
strRet += self.CallVoidMethod(equalRight)
return strRet
def CallBooleanMethodV(self,strx):
def CallBooleanMethodA(self,strx):
def CallByteMethod(self,strx):
def CallByteMethodV(self,strx):
def CallByteMethodA(self,strx):
def CallCharMethod(self,strx):
def CallCharMethodV(self,strx):
def CallCharMethodA(self,strx):
def CallShortMethod(self,strx):
def CallShortMethodV(self,strx):
def CallShortMethodA(self,strx):
def CallIntMethod(self,strx):
def CallIntMethodV(self,strx):
def CallIntMethodA(self,strx):
def CallLongMethod(self,strx):
def CallLongMethodV(self,strx):
def CallLongMethodA(self,strx):
def CallFloatMethod(self,strx):
def CallFloatMethodV(self,strx):
def CallFloatMethodA(self,strx):
def CallDoubleMethod(self,strx):
def CallDoubleMethodV(self,strx):
def CallDoubleMethodA(self,strx):
def CallVoidMethod(self,strx):
strAfterLeftColon = strx[strx.find('(')+1:]
objName = strAfterLeftColon.split(',')[0]
= strAfterLeftColon.split(',')[1]
paramList = '(' + strAfterLeftColon.split(',')[2]
outputState = '%s-&%s%s'%(objName, self.objectMap[methodobj][1], paramList)
#self.functionSatesList.append(outputState)
return outputS
def CallVoidMethodV(self,strx):
def CallVoidMethodA(self,strx):
def CallNonvirtualObjectMethod(self,strx):
def CallNonvirtualObjectMethodV(self,strx):
def CallNonvirtualObjectMethodA(self,strx):
def CallNonvirtualBooleanMethod(self,strx):
def CallNonvirtualBooleanMethodV(self,strx):
def CallNonvirtualBooleanMethodA(self,strx):
def CallNonvirtualByteMethod(self,strx):
def CallNonvirtualByteMethodV(self,strx):
def CallNonvirtualByteMethodA(self,strx):
def CallNonvirtualCharMethod(self,strx):
def CallNonvirtualCharMethodV(self,strx):
def CallNonvirtualCharMethodA(self,strx):
def CallNonvirtualShortMethod(self,strx):
def CallNonvirtualShortMethodV(self,strx):
def CallNonvirtualShortMethodA(self,strx):
def CallNonvirtualIntMethod(self,strx):
def CallNonvirtualIntMethodV(self,strx):
def CallNonvirtualIntMethodA(self,strx):
def CallNonvirtualLongMethod(self,strx):
def CallNonvirtualLongMethodV(self,strx):
def CallNonvirtualLongMethodA(self,strx):
def CallNonvirtualFloatMethod(self,strx):
def CallNonvirtualFloatMethodV(self,strx):
def CallNonvirtualFloatMethodA(self,strx):
def CallNonvirtualDoubleMethod(self,strx):
def CallNonvirtualDoubleMethodV(self,strx):
def CallNonvirtualDoubleMethodA(self,strx):
def CallNonvirtualVoidMethod(self,strx):
def CallNonvirtualVoidMethodV(self,strx):
def CallNonvirtualVoidMethodA(self,strx):
def GetFieldID(self,strx):
def GetObjectField(self,strx):
def GetBooleanField(self,strx):
def GetByteField(self,strx):
def GetCharField(self,strx):
def GetShortField(self,strx):
def GetIntField(self,strx):
def GetLongField(self,strx):
def GetFloatField(self,strx):
def GetDoubleField(self,strx):
def SetObjectField(self,strx):
def SetBooleanField(self,strx):
def SetByteField(self,strx):
def SetCharField(self,strx):
def SetShortField(self,strx):
def SetIntField(self,strx):
def SetLongField(self,strx):
def SetFloatField(self,strx):
def SetDoubleField(self,strx):
def GetStaticMethodID(self,strx):
def CallStaticObjectMethod(self,strx):
def CallStaticObjectMethodV(self,strx):
def CallStaticObjectMethodA(self,strx):
def CallStaticBooleanMethod(self,strx):
def CallStaticBooleanMethodV(self,strx):
def CallStaticBooleanMethodA(self,strx):
def CallStaticByteMethod(self,strx):
def CallStaticByteMethodV(self,strx):
def CallStaticByteMethodA(self,strx):
def CallStaticCharMethod(self,strx):
def CallStaticCharMethodV(self,strx):
def CallStaticCharMethodA(self,strx):
def CallStaticShortMethod(self,strx):
def CallStaticShortMethodV(self,strx):
def CallStaticShortMethodA(self,strx):
def CallStaticIntMethod(self,strx):
def CallStaticIntMethodV(self,strx):
def CallStaticIntMethodA(self,strx):
def CallStaticLongMethod(self,strx):
def CallStaticLongMethodV(self,strx):
def CallStaticLongMethodA(self,strx):
def CallStaticFloatMethod(self,strx):
def CallStaticFloatMethodV(self,strx):
def CallStaticFloatMethodA(self,strx):
def CallStaticDoubleMethod(self,strx):
def CallStaticDoubleMethodV(self,strx):
def CallStaticDoubleMethodA(self,strx):
def CallStaticVoidMethod(self,strx):
def CallStaticVoidMethodV(self,strx):
def CallStaticVoidMethodA(self,strx):
def GetStaticFieldID(self,strx):
def GetStaticObjectField(self,strx):
def GetStaticBooleanField(self,strx):
def GetStaticByteField(self,strx):
def GetStaticCharField(self,strx):
def GetStaticShortField(self,strx):
def GetStaticIntField(self,strx):
def GetStaticLongField(self,strx):
def GetStaticFloatField(self,strx):
def GetStaticDoubleField(self,strx):
def SetStaticObjectField(self,strx):
def SetStaticBooleanField(self,strx):
def SetStaticByteField(self,strx):
def SetStaticCharField(self,strx):
def SetStaticShortField(self,strx):
def SetStaticIntField(self,strx):
def SetStaticLongField(self,strx):
def SetStaticFloatField(self,strx):
def SetStaticDoubleField(self,strx):
def NewString(self,strx):
def GetStringLength(self,strx):
def GetStringChars(self,strx):
def ReleaseStringChars(self,strx):
def NewStringUTF(self,strx):
equalLeft = strx.split('=')[0]
param = strx[strx.find('('):]
outputState = 'System::String^ %s = gcnew System::String%s' %(equalLeft, param)
#self.functionSatesList.append(outputState)
return outputState
def GetStringUTFLength(self,strx):
def GetStringUTFChars(self,strx):
equalLeft = strx.split('=')[0]
objInfo = self.objectMap[equalLeft]
jstr = strx[strx.find('(')+1:].split(',')[0]
objInfo = (objInfo[0], jstr)
self.objectMap[equalLeft]
param = strx[strx.find('('):]
outputState = '%s %s = marshal_as&std::string&(%s);' %(objInfo[0], equalLeft,jstr)
#self.functionSatesList.append(outputState)
return outputState
def ReleaseStringUTFChars(self,strx):
def GetArrayLength(self,strx):
def NewObjectArray(self,strx):
def GetObjectArrayElement(self,strx):
def SetObjectArrayElement(self,strx):
def NewBooleanArray(self,strx):
def NewByteArray(self,strx):
def NewCharArray(self,strx):
def NewShortArray(self,strx):
def NewIntArray(self,strx):
def NewLongArray(self,strx):
def NewFloatArray(self,strx):
def NewDoubleArray(self,strx):
def GetBooleanArrayElements(self,strx):
def GetByteArrayElements(self,strx):
def GetCharArrayElements(self,strx):
def GetShortArrayElements(self,strx):
def GetIntArrayElements(self,strx):
def GetLongArrayElements(self,strx):
def GetFloatArrayElements(self,strx):
def GetDoubleArrayElements(self,strx):
def ReleaseBooleanArrayElements(self,strx):
def ReleaseByteArrayElements(self,strx):
def ReleaseCharArrayElements(self,strx):
def ReleaseShortArrayElements(self,strx):
def ReleaseIntArrayElements(self,strx):
def ReleaseLongArrayElements(self,strx):
def ReleaseFloatArrayElements(self,strx):
def ReleaseDoubleArrayElements(self,strx):
def GetBooleanArrayRegion(self,strx):
def GetByteArrayRegion(self,strx):
def GetCharArrayRegion(self,strx):
def GetShortArrayRegion(self,strx):
def GetIntArrayRegion(self,strx):
def GetLongArrayRegion(self,strx):
def GetFloatArrayRegion(self,strx):
def GetDoubleArrayRegion(self,strx):
def SetBooleanArrayRegion(self,strx):
def SetByteArrayRegion(self,strx):
def SetCharArrayRegion(self,strx):
def SetShortArrayRegion(self,strx):
def SetIntArrayRegion(self,strx):
def SetLongArrayRegion(self,strx):
def SetFloatArrayRegion(self,strx):
def SetDoubleArrayRegion(self,strx):
def RegisterNatives(self,strx):
def UnregisterNatives(self,strx):
def MonitorEnter(self,strx):
def MonitorExit(self,strx):
def GetJavaVM(self,strx):
def GetStringRegion(self,strx):
def GetStringUTFRegion(self,strx):
def GetPrimitiveArrayCritical(self,strx):
def ReleasePrimitiveArrayCritical(self,strx):
def GetStringCritical(self,strx):
def ReleaseStringCritical(self,strx):
def NewWeakGlobalRef(self,strx):
def DeleteWeakGlobalRef(self,strx):
def ExceptionCheck(self,strx):
def NewDirectByteBuffer(self,strx):
def GetDirectBufferAddress(self,strx):
def GetDirectBufferCapacity(self,strx):
def GetObjectRefType(self,strx):
def __init__(self, pathIn, passOut):
self.filepathIn = pathIn
#输入的cpp文件路径
self.filepathOut = passOut
#输出的cpp文件路径
self.functionSignature = ''
#jni函数定义的签名
self.functionSatesList = []
#输出语句的链表
self.functionToRetureMap={'FindClass':'jclass', 'NewObject':'jobject',
'GetStringUTFChars':'const char*', 'GetMethodID':'jmethodID',
'CallBooleanMethod':'jboolean', 'DeleteLocalRef':'void'}
self.FunctionToMethodName={&SetObjectArrayElement&:Demo.SetObjectArrayElement,
&GetLongArrayRegion&:Demo.GetLongArrayRegion,
&CallNonvirtualIntMethod&:Demo.CallNonvirtualIntMethod,
&NewObject&:Demo.NewObject,
&GetCharArrayRegion&:Demo.GetCharArrayRegion,
&ReleaseLongArrayElements&:Demo.ReleaseLongArrayElements,
&CallNonvirtualObjectMethod&:Demo.CallNonvirtualObjectMethod,
&GetStaticMethodID&:Demo.GetStaticMethodID,
&CallStaticDoubleMethodV&:Demo.CallStaticDoubleMethodV,
&ReleaseIntArrayElements&:Demo.ReleaseIntArrayElements,
&DefineClass&:Demo.DefineClass,
&CallNonvirtualBooleanMethodV&:Demo.CallNonvirtualBooleanMethodV,
&CallNonvirtualBooleanMethodA&:Demo.CallNonvirtualBooleanMethodA,
&NewObjectArray&:Demo.NewObjectArray,
&GetStaticByteField&:Demo.GetStaticByteField,
&GetArrayLength&:Demo.GetArrayLength,
&MonitorExit&:Demo.MonitorExit,
&CallObjectMethodA&:Demo.CallObjectMethodA,
&GetBooleanField&:Demo.GetBooleanField,
&SetBooleanArrayRegion&:Demo.SetBooleanArrayRegion,
&PopLocalFrame&:Demo.PopLocalFrame,
&GetStaticFloatField&:Demo.GetStaticFloatField,
&SetCharField&:Demo.SetCharField,
&ReleaseCharArrayElements&:Demo.ReleaseCharArrayElements,
&SetCharArrayRegion&:Demo.SetCharArrayRegion,
&CallNonvirtualObjectMethodA&:Demo.CallNonvirtualObjectMethodA,
&SetStaticShortField&:Demo.SetStaticShortField,
&SetBooleanField&:Demo.SetBooleanField,
&CallLongMethodV&:Demo.CallLongMethodV,
&GetStaticDoubleField&:Demo.GetStaticDoubleField,
&CallNonvirtualByteMethodA&:Demo.CallNonvirtualByteMethodA,
&CallNonvirtualFloatMethodA&:Demo.CallNonvirtualFloatMethodA,
&CallStaticCharMethod&:Demo.CallStaticCharMethod,
&GetJavaVM&:Demo.GetJavaVM,
&DeleteLocalRef&:Demo.DeleteLocalRef,
&GetStringChars&:Demo.GetStringChars,
&FromReflectedField&:Demo.FromReflectedField,
&CallDoubleMethod&:Demo.CallDoubleMethod,
&NewDirectByteBuffer&:Demo.NewDirectByteBuffer,
&CallStaticBooleanMethodV&:Demo.CallStaticBooleanMethodV,
&ThrowNew&:Demo.ThrowNew,
&SetShortField&:Demo.SetShortField,
&CallNonvirtualLongMethodA&:Demo.CallNonvirtualLongMethodA,
&GetMethodID&:Demo.GetMethodID,
&SetIntField&:Demo.SetIntField,
&ReleaseBooleanArrayElements&:Demo.ReleaseBooleanArrayElements,
&CallNonvirtualObjectMethodV&:Demo.CallNonvirtualObjectMethodV,
&CallStaticIntMethod&:Demo.CallStaticIntMethod,
&GetShortArrayRegion&:Demo.GetShortArrayRegion,
&GetStaticCharField&:Demo.GetStaticCharField,
&ReleaseByteArrayElements&:Demo.ReleaseByteArrayElements,
&SetShortArrayRegion&:Demo.SetShortArrayRegion,
&CallBooleanMethodV&:Demo.CallBooleanMethodV,
&ReleaseStringChars&:Demo.ReleaseStringChars,
&GetLongArrayElements&:Demo.GetLongArrayElements,
&CallNonvirtualBooleanMethod&:Demo.CallNonvirtualBooleanMethod,
&DeleteWeakGlobalRef&:Demo.DeleteWeakGlobalRef,
&CallNonvirtualDoubleMethod&:Demo.CallNonvirtualDoubleMethod,
&FromReflectedMethod&:Demo.FromReflectedMethod,
&GetIntArrayRegion&:Demo.GetIntArrayRegion,
&MonitorEnter&:Demo.MonitorEnter,
&CallObjectMethod&:Demo.CallObjectMethod,
&GetObjectRefType&:Demo.GetObjectRefType,
&CallNonvirtualDoubleMethodV&:Demo.CallNonvirtualDoubleMethodV,
&CallNonvirtualIntMethodV&:Demo.CallNonvirtualIntMethodV,
&NewDoubleArray&:Demo.NewDoubleArray,
&CallStaticObjectMethodA&:Demo.CallStaticObjectMethodA,
&CallNonvirtualLongMethod&:Demo.CallNonvirtualLongMethod,
&GetBooleanArrayElements&:Demo.GetBooleanArrayElements,
&CallStaticIntMethodA&:Demo.CallStaticIntMethodA,
&CallVoidMethodA&:Demo.CallVoidMethodA,
&UnregisterNatives&:Demo.UnregisterNatives,
&CallStaticDoubleMethod&:Demo.CallStaticDoubleMethod,
&CallStaticLongMethodA&:Demo.CallStaticLongMethodA,
&CallBooleanMethodA&:Demo.CallBooleanMethodA,
&CallIntMethodV&:Demo.CallIntMethodV,
&GetStaticFieldID&:Demo.GetStaticFieldID,
&CallVoidMethodV&:Demo.CallVoidMethodV,
&ExceptionDescribe&:Demo.ExceptionDescribe,
&GetSuperclass&:Demo.GetSuperclass,
&GetFloatField&:Demo.GetFloatField,
&GetByteField&:Demo.GetByteField,
&GetIntField&:Demo.GetIntField,
&CallIntMethodA&:Demo.CallIntMethodA,
&GetShortField&:Demo.GetShortField,
&CallLongMethodA&:Demo.CallLongMethodA,
&CallShortMethodV&:Demo.CallShortMethodV,
&CallNonvirtualVoidMethod&:Demo.CallNonvirtualVoidMethod,
&GetDirectBufferAddress&:Demo.GetDirectBufferAddress,
&SetDoubleField&:Demo.SetDoubleField,
&NewString&:Demo.NewString,
&ReleaseStringCritical&:Demo.ReleaseStringCritical,
&SetStaticObjectField&:Demo.SetStaticObjectField,
&CallStaticBooleanMethodA&:Demo.CallStaticBooleanMethodA,
&CallShortMethodA&:Demo.CallShortMethodA,
&CallStaticLongMethod&:Demo.CallStaticLongMethod,
&CallNonvirtualShortMethodA&:Demo.CallNonvirtualShortMethodA,
&SetStaticBooleanField&:Demo.SetStaticBooleanField,
&CallNonvirtualByteMethod&:Demo.CallNonvirtualByteMethod,
&SetFloatField&:Demo.SetFloatField,
&CallStaticDoubleMethodA&:Demo.CallStaticDoubleMethodA,
&CallNonvirtualLongMethodV&:Demo.CallNonvirtualLongMethodV,
&CallStaticByteMethodA&:Demo.CallStaticByteMethodA,
&NewWeakGlobalRef&:Demo.NewWeakGlobalRef,
&GetObjectField&:Demo.GetObjectField,
&GetStaticBooleanField&:Demo.GetStaticBooleanField,
&NewFloatArray&:Demo.NewFloatArray,
&CallStaticFloatMethod&:Demo.CallStaticFloatMethod,
&ToReflectedMethod&:Demo.ToReflectedMethod,
&CallStaticShortMethodV&:Demo.CallStaticShortMethodV,
&ReleaseStringUTFChars&:Demo.ReleaseStringUTFChars,
&GetDoubleField&:Demo.GetDoubleField,
&CallNonvirtualCharMethodV&:Demo.CallNonvirtualCharMethodV,
&NewGlobalRef&:Demo.NewGlobalRef,
&GetBooleanArrayRegion&:Demo.GetBooleanArrayRegion,
&SetByteArrayRegion&:Demo.SetByteArrayRegion,
&CallStaticVoidMethod&:Demo.CallStaticVoidMethod,
&GetCharField&:Demo.GetCharField,
&CallVoidMethod&:Demo.CallVoidMethod,
&CallNonvirtualShortMethod&:Demo.CallNonvirtualShortMethod,
&ToReflectedField&:Demo.ToReflectedField,
&SetIntArrayRegion&:Demo.SetIntArrayRegion,
&CallDoubleMethodV&:Demo.CallDoubleMethodV,
&SetLongArrayRegion&:Demo.SetLongArrayRegion,
&CallDoubleMethodA&:Demo.CallDoubleMethodA,
&CallNonvirtualCharMethodA&:Demo.CallNonvirtualCharMethodA,
&FindClass&:Demo.FindClass,
&NewIntArray&:Demo.NewIntArray,
&CallObjectMethodV&:Demo.CallObjectMethodV,
&SetStaticByteField&:Demo.SetStaticByteField,
&GetByteArrayRegion&:Demo.GetByteArrayRegion,
&CallStaticVoidMethodA&:Demo.CallStaticVoidMethodA,
&GetVersion&:Demo.GetVersion,
&CallStaticBooleanMethod&:Demo.CallStaticBooleanMethod,
&CallShortMethod&:Demo.CallShortMethod,
&GetStaticShortField&:Demo.GetStaticShortField,
&GetByteArrayElements&:Demo.GetByteArrayElements,
&CallStaticObjectMethod&:Demo.CallStaticObjectMethod,
&CallNonvirtualFloatMethod&:Demo.CallNonvirtualFloatMethod,
&CallStaticObjectMethodV&:Demo.CallStaticObjectMethodV,
&IsSameObject&:Demo.IsSameObject,
&CallNonvirtualFloatMethodV&:Demo.CallNonvirtualFloatMethodV,
&GetFloatArrayRegion&:Demo.GetFloatArrayRegion,
&CallByteMethod&:Demo.CallByteMethod,
&PushLocalFrame&:Demo.PushLocalFrame,
&CallCharMethodA&:Demo.CallCharMethodA,
&SetStaticIntField&:Demo.SetStaticIntField,
&SetLongField&:Demo.SetLongField,
&ExceptionOccurred&:Demo.ExceptionOccurred,
&GetFieldID&:Demo.GetFieldID,
&GetFloatArrayElements&:Demo.GetFloatArrayElements,
&SetByteField&:Demo.SetByteField,
&GetIntArrayElements&:Demo.GetIntArrayElements,
&SetFloatArrayRegion&:Demo.SetFloatArrayRegion,
&CallFloatMethod&:Demo.CallFloatMethod,
&GetStaticObjectField&:Demo.GetStaticObjectField,
&CallNonvirtualByteMethodV&:Demo.CallNonvirtualByteMethodV,
&SetDoubleArrayRegion&:Demo.SetDoubleArrayRegion,
&CallStaticShortMethodA&:Demo.CallStaticShortMethodA,
&GetCharArrayElements&:Demo.GetCharArrayElements,
&Throw&:Demo.Throw,
&NewLongArray&:Demo.NewLongArray,
&GetStaticIntField&:Demo.GetStaticIntField,
&AllocObject&:Demo.AllocObject,
&ReleasePrimitiveArrayCritical&:Demo.ReleasePrimitiveArrayCritical,
&CallStaticIntMethodV&:Demo.CallStaticIntMethodV,
&GetStringUTFRegion&:Demo.GetStringUTFRegion,
&CallLongMethod&:Demo.CallLongMethod,
&CallStaticFloatMethodA&:Demo.CallStaticFloatMethodA,
&GetStringRegion&:Demo.GetStringRegion,
&GetObjectArrayElement&:Demo.GetObjectArrayElement,
&CallNonvirtualDoubleMethodA&:Demo.CallNonvirtualDoubleMethodA,
&GetObjectClass&:Demo.GetObjectClass,
&CallStaticLongMethodV&:Demo.CallStaticLongMethodV,
&CallStaticCharMethodV&:Demo.CallStaticCharMethodV,
&CallStaticVoidMethodV&:Demo.CallStaticVoidMethodV,
&CallFloatMethodV&:Demo.CallFloatMethodV,
&CallBooleanMethod&:Demo.CallBooleanMethod,
&CallStaticCharMethodA&:Demo.CallStaticCharMethodA,
&NewBooleanArray&:Demo.NewBooleanArray,
&CallNonvirtualVoidMethodV&:Demo.CallNonvirtualVoidMethodV,
&GetDoubleArrayRegion&:Demo.GetDoubleArrayRegion,
&GetStringLength&:Demo.GetStringLength,
&ReleaseFloatArrayElements&:Demo.ReleaseFloatArrayElements,
&ExceptionClear&:Demo.ExceptionClear,
&ReleaseShortArrayElements&:Demo.ReleaseShortArrayElements,
&CallFloatMethodA&:Demo.CallFloatMethodA,
&SetObjectField&:Demo.SetObjectField,
&CallIntMethod&:Demo.CallIntMethod,
&CallStaticShortMethod&:Demo.CallStaticShortMethod,
&IsAssignableFrom&:Demo.IsAssignableFrom,
&NewObjectA&:Demo.NewObjectA,
&CallNonvirtualIntMethodA&:Demo.CallNonvirtualIntMethodA,
&GetStaticLongField&:Demo.GetStaticLongField,
&SetStaticFloatField&:Demo.SetStaticFloatField,
&RegisterNatives&:Demo.RegisterNatives,
&NewCharArray&:Demo.NewCharArray,
&GetStringUTFChars&:Demo.GetStringUTFChars,
&CallNonvirtualShortMethodV&:Demo.CallNonvirtualShortMethodV,
&CallStaticByteMethod&:Demo.CallStaticByteMethod,
&NewObjectV&:Demo.NewObjectV,
&SetStaticDoubleField&:Demo.SetStaticDoubleField,
&CallNonvirtualCharMethod&:Demo.CallNonvirtualCharMethod,
&NewLocalRef&:Demo.NewLocalRef,
&GetStringCritical&:Demo.GetStringCritical,
&NewStringUTF&:Demo.NewStringUTF,
&CallCharMethodV&:Demo.CallCharMethodV,
&SetStaticCharField&:Demo.SetStaticCharField,
&SetStaticLongField&:Demo.SetStaticLongField,
&GetPrimitiveArrayCritical&:Demo.GetPrimitiveArrayCritical,
&NewByteArray&:Demo.NewByteArray,
&EnsureLocalCapacity&:Demo.EnsureLocalCapacity,
&GetLongField&:Demo.GetLongField,
&NewShortArray&:Demo.NewShortArray,
&DeleteGlobalRef&:Demo.DeleteGlobalRef,
&CallStaticFloatMethodV&:Demo.CallStaticFloatMethodV,
&ExceptionCheck&:Demo.ExceptionCheck,
&ReleaseDoubleArrayElements&:Demo.ReleaseDoubleArrayElements,
&GetDirectBufferCapacity&:Demo.GetDirectBufferCapacity,
&CallCharMethod&:Demo.CallCharMethod,
&CallByteMethodA&:Demo.CallByteMethodA,
&IsInstanceOf&:Demo.IsInstanceOf,
&GetStringUTFLength&:Demo.GetStringUTFLength,
&CallByteMethodV&:Demo.CallByteMethodV,
&FatalError&:Demo.FatalError,
&CallNonvirtualVoidMethodA&:Demo.CallNonvirtualVoidMethodA,
&GetShortArrayElements&:Demo.GetShortArrayElements,
&CallStaticByteMethodV&:Demo.CallStaticByteMethodV,
&GetDoubleArrayElements&:Demo.GetDoubleArrayElements,
self.objectMap
#所有对象到类类型的映射
self.ClassToMethod={}
#所有类型到函数集的映射
# self.classSet = set([])
#需要使用的java类的集合
# self.methodSet=set([])
#需要调用的函数名称集合
self.classMap = {}
#需要使用的java类的集合(key为class名,value为class的方法的set)
self.outputStream = []
#输出文件的临时保存数组
self.functionCommit=''
#函数声明的注释
#函数功能:把一行语句中的所有完整注释去掉
#函数参数:linex --需要去掉注释的句子
#函数返回:去掉注释后的句子
def FilterCommit(self, linex):
stringTemp = ''
commitIndexF = linex.find('/*')
commitIndexS = linex.find('//')
if commitIndexF != -1 and commitIndexS!=-1:
if commitIndexF&commitIndexS: # /* // ....
if linex.find('*/')!=-1: #
stringTemp += linex[:commitIndexF]
if len(linex)&linex.find('*/'):
stringTemp += linex[linex.find('*/')+2:]
/* // commit
else: # // /*
elif commitIndexF != -1:
if linex.find('*/')==-1:
stringTemp += linex[:commitIndexF]
stringTemp += linex[:commitIndexF]
stringTemp += linex[linex.find('*/')+2:]
elif commitIndexS != -1:
stringTemp += linex[:commitIndexS]
stringTemp =
return stringTemp
def ProcessFile(self):
with open(self.filepathIn, 'r') as f:
tempNodeType = ''
tempNodeMap = {}
#临时保存查找到的一个完整节点(函数查找,函数调用)的信息(主要是为了获取函数名称)
stringTemp
= ''
#临时保存所有未处理的节点所有行
for linex in f.readlines():
linexStrip = linex.strip('\t')
commitIndexF = linex.find('/*')
commitIndexS = linex.find('//')
if tempNodeMap.get('{',0)&0:
#这是在一个函数定义中,进行下面处理
if commitIndexF != -1 and commitIndexS!=-1:
if commitIndexF&commitIndexS: # /* // ....
if linex.find('*/')!=-1: #
stringTemp += linex[:commitIndexF]
if len(linex)&linex.find('*/'):
stringTemp += linex[linex.find('*/')+2:]
/* // commit
tempNodeType='commit'
else: # // /*
elif commitIndexF != -1:
if linex.find('*/')==-1:
stringTemp += linex[:commitIndexF]
tempNodeType = 'commit'
stringTemp += linex[:commitIndexF]
stringTemp += linex[linex.find('*/')+2:]
elif commitIndexS != -1:
stringTemp += linex[:commitIndexS]
if tempNodeType!='commit':
#此行是有效语句
stringTemp += linex
tempNodeMap['{'] = tempNodeMap.get('{',0) + linex.count('{')
tempNodeMap['}'] = tempNodeMap.get('}',0) + linex.count('}')
if tempNodeMap.get('{')&0 and (tempNodeMap['{'] == tempNodeMap['}']):
self.processOneFunction(stringTemp)
stringTemp=''
tempNodeMap.clear()
self.functionSignature = ''
#此行是注释的一部分
if linex.find('*/')!=-1:
#/**/注释结束,注意,注释行后面不能添加任何语句
tempNodeType=''
#在一个函数的定义之外,或者一个函数的开始
if linex.startswith('JNIEXPORT'):
tempNodeType = 'functionSignature'
self.functionSignature += linex
elif tempNodeType=='functionSignature':
openbrackcount = linex.find('{')
if(openbrackcount&0):
self.functionSignature += linex[:openbrackcount]
#stringTemp += linex[openbrackcount:]
stringTemp += self.FilterCommit(linex[openbrackcount:])
tempNodeMap['{'] = tempNodeMap.get('{',0)+linex.count('{')
tempNodeType = ''
self.functionSignature += linex
#这是函数申明的注释
self.functionCommit += linex
with open(self.filepathOut, 'w') as fo:
for it in self.functionSatesList:
#把输出写到文件中
fo.write(it)
fo.write('\n')
#函数功能:把一个jni函数定义转换成CLR定义
#函数参数:stringOneFunction(in)jni函数定义完整字符串
#函数返回:...
def processOneFunction(self, stringOneFunction):
tempNodeType = ''
stringTemp = ''
for linex in stringOneFunction.split('\n'):
OneLine = stringTemp + linex +'\n'
stringTemp = OneLine
braceIndexL = OneLine.find('{')
braceIndexR = OneLine.find('}')
= OneLine.find(';')
colonIndex
= OneLine.find(':')
while braceIndexL != -1 or braceIndexR != -1 or semicolon != -1:
stringTemp = ''
minNumber = min(x for x in (semicolon, braceIndexL, braceIndexR, colonIndex) if x&-1)
self.processOneNode(OneLine[:minNumber+1])
OneLine = OneLine[minNumber+1:]
braceIndexL = OneLine.find('{')
braceIndexR = OneLine.find('}')
= OneLine.find(';')
colonIndex
= OneLine.find(':')
#函数功能:把一条jni语句转换成CLR定义(;结尾的语句,{和}暂时不支持注释语句)
#函数参数:stringOneNode(in)jni语句字符串
#函数返回:...
def processOneNode(self, stringOneNode):
if stringOneNode.find('{')!=-1:
#有左大括号,需要分别对左括号的左边调用processOneNode,然后把{写入outputStream,再对{的右边调用processOneNode
#if len(stringOneNode.replace(' ','').split('{')[0])&0:
processOneNode(self, stringOneNode.replace(' ','').split('{')[0])
self.functionSatesList.append('{')
#if len(stringOneNode.replace(' ','').split('{')[1])&0:
processOneNode(stringOneNode.replace(' ','').split('{')[1])
elif stringOneNode.find('}') != -1:
#if len(stringOneNode.replace(' ','').split('}')[0])&0:
processOneNode(self, stringOneNode.replace(' ','').split('}')[0])
#self.outputStream += '}'
self.functionSatesList.append('}')
if len(stringOneNode.replace(' ','').split('}')[1])&0:
processOneNode(stringOneNode.replace(' ','').split('}')[1])
#以分号(; :)结尾的句子
NodeStrip = stringOneNode.replace('\n', '')
NodeStrip = NodeStrip.replace('\t', ' ')
NodeStrip = NodeStrip.lstrip(' ')
# NodeStrip = NodeStrip.lstrip('\t')
equalLeft = NodeStrip.split('=')[0].strip(' ')
firstItem =equalLeft[:equalLeft.find(equalLeft.split(' ')[-1])].strip(' ')
if firstItem in jniType.JNIType:
#这是一条声明语句
= NodeStrip.replace(firstItem,'')
= NodeStrip.lstrip(' ')
self.objectMap[NodeStrip.split(' ')[0]]=(firstItem,'')
if NodeStrip.find('env-&') !=-1:
#这是一条jni语句,不包括jclass
NodeStrip = NodeStrip.replace(' ', '')
FunctionName = NodeStrip[NodeStrip.find('env-&')+len('env-&'):].split('(')[0]
#获取函数名
callFunc = self.FunctionToMethodName.get(FunctionName,'')
if callFunc != '':
NodeStrip = NodeStrip.replace(' ', '')
stateAlqaz = self.FunctionToMethodName[FunctionName](self,NodeStrip)
#从map中找到对应函数调用的处理函数并调用
if stateAlqaz != '':
self.functionSatesList.append(stateAlqaz)
#正常的c++语句
#self.outputStream += stringOneN
self.functionSatesList.append(stringOneNode)
alqaz = Demo('in.cpp', 'out.cpp')
alqaz.ProcessFile()
(C)&&2013&&Alibaba&&Inc.&&All&&rights&&resvered.
Powered by

参考资料

 

随机推荐