1)不同语言间的类型转换;JSValue

2)调用耦合点:一种语言如何与另一种语言建立互动联系;进而相互合作完成功能。context[@"person"]=person;

3)不同语言间的调用约定:

(1)直接式函数调用;

 

//test.js
  var appendString = function(name) {
      return 'string:' + name;
  };
  var arr = [1, 2 , 'hello world'];

 

  JSValue *value = [context[@"appendString"] callWithArguments:@[@"hello"]];


 JSContext *context = [[JSContext alloc] init];
    context[@"sayhi"] = ^(NSString *name) {
        NSLog(@"say hi to %@",name);
    };
    [context evaluateScript:@"sayhi('Greg')"]; //"say hi to Greg"
 

 

 

(2)对象式函数调用;


 

4)平台对混合编程的支持。考虑编译运行语言和解释运行语言。解释运行语言:解释器和运行环境什么时候启动。

编译型语言:平台需要知道语言类型,开发者需要知道调用约定。

 

不同语言的混合编程,相当于持不同语言的人相互沟通:类型转换担当了翻译的角色;如何调用承担了沟通渠道的角色。

相关文章:

  • 2022-12-23
  • 2021-12-09
  • 2022-03-07
  • 2022-03-09
  • 2021-09-02
  • 2021-10-14
  • 2022-03-08
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-09-29
  • 2022-12-23
  • 2022-03-08
相关资源
相似解决方案