We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
0.2.6
All
C++层代码:
class Person { public: Person() {} virtual ~Person() {} };
class Student : public Person { public: Student() {} virtual ~Student() {} public: void study() {} };
class School { public: School() {} ~School() {} public: void addPerson(Person* pPerson) { m_persons.push_back(pPerson); } Person* getPerson(int index) { return m_persons[index]; } private: std::vector<Person*> m_persons; };
// module declaration begin
UsingCppType(Person); UsingCppType(Student); UsingCppType(School);
static void Init() {
puerts::DefineClass<Person>() .Constructor() .Register(); puerts::DefineClass<Student>() .Constructor() .Method("study", MakeFunction(&Student::study)) .Register(); puerts::DefineClass<School>() .Constructor() .Method("addPerson", MakeFunction(&School::addPerson)) .Method("getPerson", MakeFunction(&School::getPerson)) .Register();
}
PESAPI_MODULE(puertsTest, Init)
JS层代码:
let _school = new School();
let _student = new Student();
_school.addPerson(_student);
let temp = _school.getPerson(0); temp.study();
这种情况会报:Uncaught TypeError TypeError: temp.study is not a function 错误
The text was updated successfully, but these errors were encountered:
c++类型不一定能动态类型识别(得有虚函数而且编译没加-fno-rtti)。 所以并不能自动处理这种情况。 所以得你手动处理。 通过Object.setPrototypeOf。
Sorry, something went wrong.
chexiongsheng
No branches or pull requests
前置阅读 | Pre-reading
Puer的版本 | Puer Version
0.2.6
UE的版本 | UE Version
0.2.6
发生在哪个平台 | Platform
All
错误信息 | Error Message
C++层代码:
class Person
{
public:
Person() {}
virtual ~Person() {}
};
class Student : public Person
{
public:
Student() {}
virtual ~Student() {}
public:
void study() {}
};
class School
{
public:
School() {}
~School() {}
public:
void addPerson(Person* pPerson)
{
m_persons.push_back(pPerson);
}
Person* getPerson(int index)
{
return m_persons[index];
}
private:
std::vector<Person*> m_persons;
};
// module declaration begin
UsingCppType(Person);
UsingCppType(Student);
UsingCppType(School);
static void Init() {
}
PESAPI_MODULE(puertsTest, Init)
JS层代码:
let _school = new School();
let _student = new Student();
_school.addPerson(_student);
let temp = _school.getPerson(0);
temp.study();
这种情况会报:Uncaught TypeError TypeError: temp.study is not a function 错误
问题重现 | Bug reproduce
这种情况会报:Uncaught TypeError TypeError: temp.study is not a function 错误
The text was updated successfully, but these errors were encountered: