简体   繁体   English

在firebreath的javascript端创建一个JSAPIPtr

[英]Create a JSAPIPtr in javascript side of firebreath

I have a requirement as follows: I wanted to initialize a user-defined class inheriting from FB::JSAPIAuto but I wanted to create it plugin independent..like 我有一个如下要求: 我想初始化一个继承自FB :: JSAPIAuto的用户定义类,但我想创建它独立的插件。

In JS , earlier i used to do this:: 在JS ,早些时候我曾经这样做::

plugin().CreateJSAPIObject("someParameter");
//in order to initialize the c++ object with a value..It was successfully compiling..

What I want to do is to create a c++ object plugin independent 我想要做的是创建一个独立的c ++对象插件

So in JS>> 所以在JS >>

UserDefinedJSAPIClassPtr obj=new UserDefinedJSAPIClass();
obj->SetMember1="This is Member 1";
//not necessarily using new keyword
plugin().DoSomethingWithObject(obj);

I came to know of boost::clipp library ..and other numerous frameworks but am finding difficulty...as everything is strongly tied to the root JSAPI. 我开始了解boost :: clipp库 ..以及其他众多框架,但我发现很难......因为一切都与根JSAPI紧密相关。

My doubt>>Is this possible? 我怀疑>>这可能吗? My objective later on>> PS:: DoSomethingWithObject(FB::variant& object) will get the members of the JSAPI object (set in the JS side) and process them 我后面的目标>> PS :: DoSomethingWithObject(FB :: variant&object)将获取JSAPI对象的成员(在JS端设置)并处理它们

EDIT after Taxilian's answer:: what in the case of this, In JS side, 在Taxilian的回答之后编辑::在这种情况下,在JS方面,

 function AnotherJavascriptfunction(member1)
        {
        member1='2';
        }
var UserClass=function(color,settings){}

var userObject=new UserClass('Red',AnotherJavascriptfunction);
 plugin().DoTheChanges(userObject);

In FB side, how do i access member1.? 在FB方面,我如何访问member1。 which method should i Look for to get the member of settings 我应该寻找哪种方法来获取设置成员

Regards, Pratik 此致,Pratik

Definitely not possible to create a JSAPIPtr from javascript, but you can create a normal javascript object and pass it into a JSAPI method; 绝对不可能从javascript创建JSAPIPtr,但你可以创建一个普通的javascript对象并将其传递给JSAPI方法; it'll be a FB::JSObjectPtr type and you can then call methods/properties on it using Invoke, GetProperty, SetProperty, etc. 它将是一个FB :: JSObjectPtr类型,然后您可以使用Invoke,GetProperty,SetProperty等调用其上的方法/属性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM