Robert
11/20/2019, 9:49 PM#include "libmy_api.h"
auto mylib = libmy_symbols();
So far so good. Now I would love to replace the orginal classes, for example CMyClass
with the one from the Kotlin library. So I remove CMyClass
from the C-source code, and I add a typedef:
typedef libmy_kref_MyClass MyClass;
Now I can use the regular MyClass
as a type: std::vector<MyClass> classes
So I don't have to touch that code, as it was already referencing "MyClass". Still good.
Now the problem is when I try to create an instance. The current code is like this:
classes.push_back(MyClass())
But to initiate the class in the KN dl way, I have to replace all the code with:
classes.push_back(mylib->kotlin.root.MyClass.MyClass())
Is there a way, like typedef or using does, to keep this code intact while it does actually reference the kotlin generated dynamic library?olonho
11/21/2019, 7:17 AMRobert
11/21/2019, 7:37 AM->
, ::
, 'struct`, *
and all that in the typedef, but it seems it is not allowed. I'll try to create a small example later today.YoshiRulz
11/21/2019, 2:25 PMRobert
11/21/2019, 2:55 PMRobert
11/21/2019, 2:55 PM#include <iostream>
#include "libmyn_api.h"
auto mylib = libmy_symbols();
using CPerson = libmy_kref_Person;
int main() {
CPerson person = mylib->kotlin.root.Person.Person("firstname", "lastname");
std::cout << "Hello, " << person.lastname << std::endl; // error on lastname, only "pinned" available"
return 0;
}
Robert
11/21/2019, 6:12 PMmylib->kotlin.root.Person.get_lastname(person)
.
Now I only need a way to shorten it to something like Person.get_lastname(person)
and a simple way to create a new instance, preferable like it was before (Person("first", "last")
)Robert
11/21/2019, 6:15 PMauto personlib = mylib->kotlin.root.Person;
auto person = personlib.Person("first", "last")
std std::cout << "Hello, " << personlib.get_lastname(person) << std::endl;
But as i'm very unexperienced with C++ there probably is a cleaner and more generic way.Robert
11/21/2019, 11:13 PMProcess finished with exit code 139 (interrupted by signal 11: SIGSEGV)
Robert
11/21/2019, 11:22 PMThere is a constructor in the Clazz field (aka kotlin.root.example.Clazz.Clazz), which is the constructor function to create an instance of the Clazz.
Should be possibe to create an instance..Robert
11/22/2019, 7:47 AMProcess finished with exit code 139 (interrupted by signal 11: SIGSEGV)
It happens when i try to create an instance.Robert
11/22/2019, 5:56 PMRobert
11/22/2019, 6:58 PMProcess finished with exit code 139 (interrupted by signal 11: SIGSEGV)
on this line https://github.com/RdeWilde/kotlin-dl-test/blob/master/main.cpp#L9Robert
11/23/2019, 10:49 AM