Question

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

In JS, earlier i used to do this::

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

So in 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.

My doubt>>Is this possible? My objective later on>> P.S:: DoSomethingWithObject(FB::variant& object) will get the members of the JSAPI object (set in the JS side) and process them

EDIT after Taxilian's answer:: what in the case of this, In JS side,

 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.? which method should i Look for to get the member of settings

Regards, Pratik

Was it helpful?

Solution

Definitely not possible to create a JSAPIPtr from javascript, but you can create a normal javascript object and pass it into a JSAPI method; it'll be a FB::JSObjectPtr type and you can then call methods/properties on it using Invoke, GetProperty, SetProperty, etc.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top