Multi-Language Programming : Accessing Interface Objects Defined In Other Language_4

本文介绍了两种跨语言访问对象的方法:一是通过环境提供的功能查找并访问其他语言定义的接口对象;二是面向对象环境下创建其他语言实体类实例,支持双向语言访问及回调功能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

     Common object environment provides run-time support. Based on support of the environment, applications can access interface objects defined in other language. There are two methods, we introduce them one by one in detail
    First method, application can find interface object defined in other language using the function of environment. And then, it can access object’s attributes or call object’s functions. Interface objects may be identified by its UUID or name. Object’s name should be used carefully because there may have multiple objects with the same name.

    Second method, for environment supporting object-oriented programming, application can create an instance of entity class object of other language as talking about previously. The instance can be accessed by the two languages simultaneously. This method is more flexible. Application can create overloading functions of class object to support callback. For examples, if an object with function “Add” is defined in python language, application in java can create an instance of it and overloading the function “Add”. Then, python can callback to java through the “Add” function.

    In above figure, python class object defines two functions “Add” and “Dec”. The “Add” function is overridden by java instance. The instance is managed by environment, and is visible to java and python. Python can call “Add” function of java instance to perform callback function. For “Dec” function, because instance does not override this function, the call will be redirected to class object of python.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值