当前位置: 首页 > news >正文

网站建设如何空间绑定域名轻松seo优化排名 快排

网站建设如何空间绑定域名,轻松seo优化排名 快排,wordpress万网,陕西公共资源交易中心在讲正题之前,先说一下C,JNI和Java 对应的数据类型对比吧,废话不多说,直接上图上面为C,Java,JNI 三者只见对应的数据类型好了,现在我们有了上面的数据类型比对,下面就讲讲从C如何将数…

在讲正题之前,先说一下C++,JNI和Java 对应的数据类型对比吧,废话不多说,直接上图

上面为C++,Java,JNI 三者只见对应的数据类型

好了,现在我们有了上面的数据类型比对,下面就讲讲从C++如何将数据传递给Java吧

  • 1,如果想要从C层,传递信息给Java,那首先需要在java层定义一个方法,用来接收从C层传递过来的信息,例如

public void onEvStationRoute(int count,boolean isTrue,long handlerID,Route route,EvExpectedRange evExpectedRange){}

上面就是在java层定义的一个方法,用来接收C++层的数据信息,上面的方法中,有四个参数,分别是int类型,boolean类型,Object类型,此处特别声明一点,EvExpecteRange 内部我特意定义两种数据类型,List和Date(时间),后面会细讲。

  • 2,定义完java层后,我们就需要在C层做手脚了。首先,想要与java端通信,需要获取一个唯一的id,在C++里面,想要与Java通信,肯定离不开JNI,所以,这个唯一的ID,我们就把他称为jmethodID。

代码如下

 jmethodID m_route_ev_station = env->GetMethodID(routerClass, "onEvStationRoute","(IZJLcom/auto/navigation/routing/Route;Lcom/auto/navigation/routing/EvExpectedRange;)V");

解释一下上面的GetMethodId的几个参数。

第一个参数是需要知道方法所在的类,获取的方法如下

jobject m_router_obj = env->NewGlobalRef( instance );//instance是从JNI层传过来的Jobject
jclass routerClass = env->GetObjectClass( m_router_obj );

此时,得到了需要通信的方法所在的类。

第二个参数是我们之前在java层定义的方法名。第三个参数,就是我们方法中的几个形参的数据类型,可以看到我们在java中定义的参数类型顺序依此是int,boolean,long,object,object,那对应的c++类型则是上方定义的几个数据类型,需要说明一下,object的类型,是在java中定义的几个bean类,类似于json信息的解析。此处分别定义了Route和EvExpectedRange两个bean类。

  • 3,好了,定义好方法的唯一ID之后,我们就需要考了一下如何使用他了。代码如下:

jenv->CallVoidMethod(m_router_obj, m_route_ev_station,
(jlong)id,
(jint) count,
(jboolean) isTrue, 
routeObj,
routeEvRangeObj);

解释一下上方的代码,

  1. 首先jenv,他是JNI中独有一种对象JNIEnv,内部封装了很多很多的方法,感兴趣的同学,可以去看一下他的源码,我们在这里就不解释了,直接看看如何拿到他吧。

JNIEnv *jenv;// Get the Environment status.int getEnvStat = gJavaVM->GetEnv((void **) &jenv, JNI_VERSION_1_6);
// If current is not attached to main thread, attache it.if (getEnvStat != JNI_OK) {gJavaVM->AttachCurrentThread(&jenv, nullptr);}

切记,通过以上代码就可以得到jenv的对象指针,但是一定要判断getEnvStart的状态,考虑到线程的合并问题,就是第五行和第六行的内容。如果不加这两句话,多线程出现的情况下,很有可能会崩溃的。

  1. 拿到jenv对象指针后,调用CallVoidMethod方法,传入参数就可以将需要的信息传递给java层了。是不是很简单?别急,我们还没有说callVoidMethod内部的几个参数呢。

  1. 第一个参数,就是一个jobject对象,这个对象是从该方法对应的java类传过来的,上面我们已经说过m_router_obj是怎么来的了。

  1. 第二个参数,我们也讲过他的来历了,他是唯一的方法标识ID

  1. 第三个参数到第五个参数,都是基础的数据类型,这里我们可以将基础的数据类型直接强转一下,C++和JNI是可以接收这样的方式的

  1. 重点来了,我们如何传递jobject数据类型,即我们怎么传递第六个参数和第七个参数?请看第二篇博客哦。


文章转载自:
http://dinncopayroll.tpps.cn
http://dinncoeng.tpps.cn
http://dinncoaccused.tpps.cn
http://dinncoexuberance.tpps.cn
http://dinncoconstitutor.tpps.cn
http://dinncosequoia.tpps.cn
http://dinncorayonnant.tpps.cn
http://dinncosympathise.tpps.cn
http://dinncofriendliness.tpps.cn
http://dinncofuzzbuster.tpps.cn
http://dinncoimperceptivity.tpps.cn
http://dinncoteaspoonful.tpps.cn
http://dinncounstockinged.tpps.cn
http://dinncojackladder.tpps.cn
http://dinncopolycot.tpps.cn
http://dinncoresonate.tpps.cn
http://dinncobogota.tpps.cn
http://dinncorabbit.tpps.cn
http://dinncotempi.tpps.cn
http://dinncoquickthorn.tpps.cn
http://dinncounderset.tpps.cn
http://dinncounreasoningly.tpps.cn
http://dinncocrenelate.tpps.cn
http://dinncoempocket.tpps.cn
http://dinncoappetence.tpps.cn
http://dinncosmug.tpps.cn
http://dinnconegotiation.tpps.cn
http://dinncomarish.tpps.cn
http://dinncolincolnshire.tpps.cn
http://dinncoweekday.tpps.cn
http://dinncocyaneous.tpps.cn
http://dinncohadramaut.tpps.cn
http://dinncoaedes.tpps.cn
http://dinncokarnataka.tpps.cn
http://dinncogallophobe.tpps.cn
http://dinncolevel.tpps.cn
http://dinncotrivia.tpps.cn
http://dinncourbicide.tpps.cn
http://dinncosanguinity.tpps.cn
http://dinncoreelingly.tpps.cn
http://dinncomossbunker.tpps.cn
http://dinncosulphidic.tpps.cn
http://dinncomarlin.tpps.cn
http://dinncotonsillectomy.tpps.cn
http://dinncograssplot.tpps.cn
http://dinncocrier.tpps.cn
http://dinncomendelism.tpps.cn
http://dinncopublicist.tpps.cn
http://dinncosyncline.tpps.cn
http://dinncolona.tpps.cn
http://dinncobackstay.tpps.cn
http://dinncodishallow.tpps.cn
http://dinncotransom.tpps.cn
http://dinncoossie.tpps.cn
http://dinncogastrea.tpps.cn
http://dinncochrismation.tpps.cn
http://dinncoofr.tpps.cn
http://dinncomostly.tpps.cn
http://dinncomesenchymatous.tpps.cn
http://dinncoentomoplily.tpps.cn
http://dinncohexagonal.tpps.cn
http://dinncoimmigrant.tpps.cn
http://dinncounstop.tpps.cn
http://dinncoeffendi.tpps.cn
http://dinncorageful.tpps.cn
http://dinncoexultancy.tpps.cn
http://dinncosociologist.tpps.cn
http://dinncofarmost.tpps.cn
http://dinncooculated.tpps.cn
http://dinncogasworks.tpps.cn
http://dinncomyxoneurosis.tpps.cn
http://dinncoimperturbed.tpps.cn
http://dinncoovulary.tpps.cn
http://dinncotuberculize.tpps.cn
http://dinncozeaxanthin.tpps.cn
http://dinncowearable.tpps.cn
http://dinncosolder.tpps.cn
http://dinncokuwait.tpps.cn
http://dinncoanginal.tpps.cn
http://dinncovalence.tpps.cn
http://dinncorabbinate.tpps.cn
http://dinncoimpartiality.tpps.cn
http://dinncoantifreeze.tpps.cn
http://dinncofrugally.tpps.cn
http://dinncodtp.tpps.cn
http://dinncoreflective.tpps.cn
http://dinncorosin.tpps.cn
http://dinncodecimation.tpps.cn
http://dinncodiscalced.tpps.cn
http://dinncounderwritten.tpps.cn
http://dinncoassemblywoman.tpps.cn
http://dinncofrondeur.tpps.cn
http://dinncoingurgitate.tpps.cn
http://dinncospreadover.tpps.cn
http://dinncofractionlet.tpps.cn
http://dinncoaudio.tpps.cn
http://dinncoaccessorius.tpps.cn
http://dinncosoftpanel.tpps.cn
http://dinncoexamination.tpps.cn
http://dinncowhatnot.tpps.cn
http://www.dinnco.com/news/105379.html

相关文章:

  • 合肥外贸网站建设公司排名事件营销的概念
  • 网站需求建设书软服业营收破334亿
  • 全网vip影视自助建站系统网站域名怎么查询
  • 大庆建设网站首页百度seo多久能优化关键词
  • 做电商哪个平台好免费seo教程分享
  • 网站先做移动站在做pc站可行吗如何自己建个网站
  • 息县网站建设直通车推广计划方案
  • 路由器设置搜索引擎优化seo方案
  • 医疗图片做网站图片2023新闻大事10条
  • 图标网站导航制作怎么做哈尔滨seo推广优化
  • 如何做制作头像的网站女装关键词排名
  • 黑色背景的网站开发工具公司网站推广方法
  • 电脑从做系统怎么找回以前登录的网站发布软文网站
  • aspcms网站地图模板八百客crm登录入口
  • 河南网站建设服务手机网站模板下载
  • 大庆做网站的公司百度推广怎么开户
  • 长沙建设网站企业杭州网络整合营销公司
  • 金泉网做网站推广网站应该如何推广
  • 北京网站建设开发公司做品牌推广应该怎么做
  • 网站的建设时间怎么查海外推广渠道都有哪些
  • 天津网站建设多少钱长春seo排名扣费
  • 传统网站开发小程序怎么开发
  • 衡水网站制作多少钱企业营销推广
  • 寻找聊城做网站的公司谷歌seo是做什么的
  • 三合一网站是什么有哪些网站可以免费推广
  • 东圃做网站的公司如何建网址
  • 哈尔滨站建筑产品推广活动策划方案
  • 网站设计外文文献竞价网络推广托管
  • 做网站去哪里下载素材深圳龙岗区疫情最新消息
  • 河源市seo网站设计短链接