Skip to content
New issue

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

[UE] Bug: RegisterTSharedPtr报错 #1695

Closed
3 tasks done
9000miles opened this issue Apr 9, 2024 · 6 comments
Closed
3 tasks done

[UE] Bug: RegisterTSharedPtr报错 #1695

9000miles opened this issue Apr 9, 2024 · 6 comments
Assignees
Labels
bug Something isn't working Unreal

Comments

@9000miles
Copy link

前置阅读 | Pre-reading

Puer的版本 | Puer Version

Unreal_v1.0.6p1

UE的版本 | UE Version

5.2

发生在哪个平台 | Platform

Editor(mac)

错误信息 | Error Message

测试这个文档描述的UE模板类https://github.com/Tencent/puerts/blob/e83b036ce3b8c49f723e988ae972b136887b4a76/doc/unreal/zhcn/template_binding.md

TSharedPtr
声明:UsingTSharedPtr(FVector);
注册:RegisterTSharedPtr(FVector);

自己写了一个测试类,也会报错,但是 https://github.com/chexiongsheng/puerts_unreal_demo.git 这个项目的puerts插件不会报错
对比了一下修改的地方太多了,不知道是哪儿的问题

通过注释发现是RegisterTSharedPtr(FVector);这行的问题

报如下错误:

1>E:\UE\5.2\UnrealKit\Plugins\Puerts\Source\JsEnv\Public\TypeInfo.hpp(125): error C2039: 'value': is not a member of 'puerts::ScriptTypeName<T,void>'
1>        with
1>        [
1>            T=FVector
1>        ]
1>E:\UE\5.2\UnrealKit\Plugins\Puerts\Source\JsEnv\Public\TypeInfo.hpp(125): note: see declaration of 'puerts::ScriptTypeName<T,void>'
1>        with
1>        [
1>            T=FVector
1>        ]
1>E:\UE\5.2\UnrealKit\Plugins\Puerts\Source\JsEnv\Public\TypeInfo.hpp(124): note: while compiling class template member function 'auto puerts::ScriptTypeNameWithNamespace<T,void>::value(void)'
1>        with
1>        [
1>            T=FVector
1>        ]
1>E:\UE\5.2\UnrealKit\Plugins\Puerts\Source\JsEnv\Public\UEDataBinding.hpp(428): note: see reference to class template instantiation 'puerts::ScriptTypeNameWithNamespace<T,void>' being compiled
1>        with
1>        [
1>            T=FVector
1>        ]
1>E:\UE\5.2\UnrealKit\Plugins\Puerts\Source\JsEnv\Public\UEDataBinding.hpp(427): note: while compiling class template member function 'auto puerts::ScriptTypeName<T,void>::value(void)'
1>        with
1>        [
1>            T=TSharedPtr<FVector,ESPMode::ThreadSafe>
1>        ]
1>E:\UE\5.2\UnrealKit\Plugins\Puerts\Source\JsEnv\Public\TypeInfo.hpp(320): note: see reference to class template instantiation 'puerts::ScriptTypeName<T,void>' being compiled
1>        with
1>        [
1>            T=TSharedPtr<FVector,ESPMode::ThreadSafe>
1>        ]
1>E:\UE\5.2\UnrealKit\Plugins\Puerts\Source\JsEnv\Public\TypeInfo.hpp(319): note: while compiling class template member function 'const char *puerts::CTypeInfoImpl<TSharedPtr<FVector,ESPMode::ThreadSafe>,true>::Name(void) const'
1>E:\UE\5.2\UnrealKit\Plugins\Puerts\Source\JsEnv\Public\TypeInfo.hpp(364): note: see reference to class template instantiation 'puerts::CTypeInfoImpl<TSharedPtr<FVector,ESPMode::ThreadSafe>,true>' being compiled
1>E:\UE\5.2\UnrealKit\Plugins\Puerts\Source\JsEnv\Public\TypeInfo.hpp(364): note: while compiling class template member function 'puerts::CFunctionInfoImpl<Ret,true,1,TSharedPtr<FVector,ESPMode::ThreadSafe>,TSharedPtr<FVector,ESPMode::ThreadSafe>>::CFunctionInfoImpl(void)'
1>        with
1>        [
1>            Ret=bool
1>        ]
1>E:\UE\5.2\UnrealKit\Plugins\Puerts\Source\JsEnv\Public\TypeInfo.hpp(436): note: see reference to function template instantiation 'puerts::CFunctionInfoImpl<Ret,true,1,TSharedPtr<FVector,ESPMode::ThreadSafe>,TSharedPtr<FVector,ESPMode::ThreadSafe>>::CFunctionInfoImpl(void)' being compiled
1>        with
1>        [
1>            Ret=bool
1>        ]
1>E:\UE\5.2\UnrealKit\Plugins\Puerts\Source\JsEnv\Public\TypeInfo.hpp(418): note: see reference to class template instantiation 'puerts::CFunctionInfoImpl<Ret,true,1,TSharedPtr<FVector,ESPMode::ThreadSafe>,TSharedPtr<FVector,ESPMode::ThreadSafe>>' being compiled
1>        with
1>        [
1>            Ret=bool
1>        ]
1>E:\UE\5.2\UnrealKit\Plugins\Puerts\Source\JsEnv\Public\StaticCall.hpp(979): note: see reference to class template instantiation 'puerts::CFunctionInfoByPtrImpl<Ret (__cdecl *)(TSharedPtr<FVector,ESPMode::ThreadSafe>,TSharedPtr<FVector,ESPMode::ThreadSafe>),bool TSharedPtrExtension<FVector>::Equals(const TSharedPtr<FVector,ESPMode::ThreadSafe>,const TSharedPtr<FVector,ESPMode::ThreadSafe>),true,1>' being compiled
1>        with
1>        [
1>            Ret=bool
1>        ]
1>E:\UE\5.2\UnrealKit\Plugins\Puerts\Source\JsEnv\Public\StaticCall.hpp(979): note: while compiling class template member function 'const puerts::CFunctionInfo *puerts::FuncCallWrapper<puerts::v8_impl::API,bool (__cdecl *)(TSharedPtr<FVector,ESPMode::ThreadSafe>,TSharedPtr<FVector,ESPMode::ThreadSafe>),bool TSharedPtrExtension<FVector>::Equals(const TSharedPtr<FVector,ESPMode::ThreadSafe>,const TSharedPtr<FVector,ESPMode::ThreadSafe>),false,true,false>::extensionInfo(unsigned int)'
1>E:\UE\5.2\UnrealKit\Plugins\PuertsSlate\Source\PuertsSlate\Private\SlateBinding.hpp(136): note: see reference to function template instantiation 'const puerts::CFunctionInfo *puerts::FuncCallWrapper<puerts::v8_impl::API,bool (__cdecl *)(TSharedPtr<FVector,ESPMode::ThreadSafe>,TSharedPtr<FVector,ESPMode::ThreadSafe>),bool TSharedPtrExtension<FVector>::Equals(const TSharedPtr<FVector,ESPMode::ThreadSafe>,const TSharedPtr<FVector,ESPMode::ThreadSafe>),false,true,false>::extensionInfo(unsigned int)' being compiled
1>E:\UE\5.2\UnrealKit\Plugins\PuertsSlate\Source\PuertsSlate\Private\SlateBinding.hpp(136): note: see reference to class template instantiation 'puerts::FuncCallWrapper<puerts::v8_impl::API,bool (__cdecl *)(TSharedPtr<FVector,ESPMode::ThreadSafe>,TSharedPtr<FVector,ESPMode::ThreadSafe>),bool TSharedPtrExtension<FVector>::Equals(const TSharedPtr<FVector,ESPMode::ThreadSafe>,const TSharedPtr<FVector,ESPMode::ThreadSafe>),false,true,false>' being compiled
1>E:\UE\5.2\UnrealKit\Plugins\Puerts\Source\JsEnv\Public\TypeInfo.hpp(125): error C3779: 'puerts::ScriptTypeNameWithNamespace<T,void>::value': a function that returns 'auto' cannot be used before it is defined
1>        with
1>        [
1>            T=FVector
1>        ]
1>E:\UE\5.2\UnrealKit\Plugins\Puerts\Source\JsEnv\Public\TypeInfo.hpp(123): note: see declaration of 'puerts::ScriptTypeNameWithNamespace<T,void>::value'
1>        with
1>        [
1>            T=FVector
1>        ]
1>E:\UE\5.2\UnrealKit\Plugins\Puerts\Source\JsEnv\Public\UEDataBinding.hpp(428): error C2676: binary '+': 'puerts::internal::StringLiteral<14>' does not define this operator or a conversion to a type acceptable to the predefined operator
1>E:\Program Files\Epic Games\UE_5.2\Engine\Source\Runtime\Core\Public\Memory\MemoryView.h(248): note: could be 'TMemoryView<DataType> operator +(uint64,const TMemoryView<DataType> &)'
1>E:\UE\5.2\UnrealKit\Plugins\Puerts\Source\JsEnv\Public\UEDataBinding.hpp(428): note: 'TMemoryView<DataType> operator +(uint64,const TMemoryView<DataType> &)': could not deduce template argument for 'const TMemoryView<DataType> &' from 'void'
1>E:\Program Files\Epic Games\UE_5.2\Engine\Source\Runtime\Core\Public\Memory\MemoryView.h(241): note: or       'TMemoryView<DataType> operator +(const TMemoryView<DataType> &,uint64)'
1>E:\UE\5.2\UnrealKit\Plugins\Puerts\Source\JsEnv\Public\UEDataBinding.hpp(428): note: 'TMemoryView<DataType> operator +(const TMemoryView<DataType> &,uint64)': could not deduce template argument for 'const TMemoryView<DataType> &' from 'puerts::internal::StringLiteral<14>'
1>E:\Program Files\Epic Games\UE_5.2\Engine\Source\Runtime\Core\Public\Containers\Array.h(182): note: or       'TIndexedContainerIterator<ContainerType,ElementType,SizeType> operator +(SizeType,TIndexedContainerIterator<ContainerType,ElementType,SizeType>)'
1>E:\UE\5.2\UnrealKit\Plugins\Puerts\Source\JsEnv\Public\UEDataBinding.hpp(428): note: 'TIndexedContainerIterator<ContainerType,ElementType,SizeType> operator +(SizeType,TIndexedContainerIterator<ContainerType,ElementType,SizeType>)': could not deduce template argument for 'TIndexedContainerIterator<ContainerType,ElementType,SizeType>' from 'void'
1>E:\UE\5.2\UnrealKit\Plugins\Puerts\Source\JsEnv\Public\TypeInfo.hpp(102): note: or       'puerts::internal::StringLiteral<X+Y> puerts::internal::operator +(const puerts::internal::StringLiteral<N> &,const puerts::internal::StringLiteral<Y> &)'
1>E:\UE\5.2\UnrealKit\Plugins\Puerts\Source\JsEnv\Public\UEDataBinding.hpp(428): note: 'puerts::internal::StringLiteral<X+Y> puerts::internal::operator +(const puerts::internal::StringLiteral<N> &,const puerts::internal::StringLiteral<Y> &)': could not deduce template argument for 'const puerts::internal::StringLiteral<Y> &' from 'void'
1>E:\UE\5.2\UnrealKit\Plugins\Puerts\Source\JsEnv\Public\TypeInfo.hpp(320): error C3313: 'NameLiteral': variable cannot have the type 'void'
1>E:\UE\5.2\UnrealKit\Plugins\Puerts\Source\JsEnv\Public\TypeInfo.hpp(321): error C3536: 'NameLiteral': cannot be used before it is initialized

问题重现 | Bug reproduce

添加如下代码
声明:UsingTSharedPtr(FVector);
注册:RegisterTSharedPtr(FVector);

@9000miles 9000miles added bug Something isn't working Unreal labels Apr 9, 2024
@chexiongsheng
Copy link
Collaborator

试试前面加上UsingUStruct(FVector);

@9000miles
Copy link
Author

试试前面加上UsingUStruct(FVector);

添加了,代码示例如下:

#include "CoreMinimal.h"
#include "Binding.hpp"
#include "UEDataBinding.hpp"

UsingUStruct(FVector);
UsingTSharedPtr(FVector);

struct AutoRegisterForTest
{
	AutoRegisterForTest()
	{
		RegisterTSharedPtr(FVector);
	}
};

AutoRegisterForTest __AutoRegisterForTest__;

依然报错:
正如前所述:同样的代码放在 https://github.com/chexiongsheng/puerts_unreal_demo.git 这个项目则不会报错

1>  [1/7] Module.PuertsTest.cpp
1>E:\UE\5.2\UnrealPuerts\Plugins\Puerts\Source\JsEnv\Public\StaticCall.hpp(816): error C3861: “GetArg”: 找不到标识符
1>  E:\UE\5.2\UnrealPuerts\Plugins\Puerts\Source\JsEnv\Public\StaticCall.hpp(898): note: 查看对正在编译的函数 模板 实例化“bool puerts::internal::FuncCallHelper<API,std::pair<Ret,std::tuple<TSharedPtr<FVector,ESPMode::NotThreadSafe>>>,false,false,true,false>::callExtension<Ins,bool(__cdecl *)(TSharedPtr<FVector,ESPMode::NotThreadSafe>,TSharedPtr<FVector,ESPMode::NotThreadSafe>),0,>(Func &,puerts::v8_impl::API::CallbackInfoType,std::integer_sequence<size_t,0>)”的引用
1>          with
1>          [
1>              API=puerts::v8_impl::API,
1>              Ret=bool,
1>              Ins=FirstDecayType,
1>              Func=bool (__cdecl *)(TSharedPtr<FVector,ESPMode::NotThreadSafe>,TSharedPtr<FVector,ESPMode::NotThreadSafe>)
1>          ]
1>  E:\UE\5.2\UnrealPuerts\Plugins\Puerts\Source\JsEnv\Public\StaticCall.hpp(897): note: 查看对正在编译的函数 模板 实例化“bool puerts::internal::FuncCallHelper<API,std::pair<Ret,std::tuple<TSharedPtr<FVector,ESPMode::NotThreadSafe>>>,false,false,true,false>::callExtension<Ins,bool(__cdecl *)(TSharedPtr<FVector,ESPMode::NotThreadSafe>,TSharedPtr<FVector,ESPMode::NotThreadSafe>),0,>(Func &,puerts::v8_impl::API::CallbackInfoType,std::integer_sequence<size_t,0>)”的引用
1>          with
1>          [
1>              API=puerts::v8_impl::API,
1>              Ret=bool,
1>              Ins=FirstDecayType,
1>              Func=bool (__cdecl *)(TSharedPtr<FVector,ESPMode::NotThreadSafe>,TSharedPtr<FVector,ESPMode::NotThreadSafe>)
1>          ]
1>  E:\UE\5.2\UnrealPuerts\Plugins\Puerts\Source\JsEnv\Public\StaticCall.hpp(970): note: 查看对正在编译的函数 模板 实例化“bool puerts::internal::FuncCallHelper<API,std::pair<Ret,std::tuple<TSharedPtr<FVector,ESPMode::NotThreadSafe>>>,false,false,true,false>::callExtension<FirstDecayType,bool(__cdecl *)(TSharedPtr<FVector,ESPMode::NotThreadSafe>,TSharedPtr<FVector,ESPMode::NotThreadSafe>),>(Func &&,puerts::v8_impl::API::CallbackInfoType)”的引用
1>          with
1>          [
1>              API=puerts::v8_impl::API,
1>              Ret=bool,
1>              Func=bool (__cdecl *)(TSharedPtr<FVector,ESPMode::NotThreadSafe>,TSharedPtr<FVector,ESPMode::NotThreadSafe>)
1>          ]
1>  E:\UE\5.2\UnrealPuerts\Plugins\Puerts\Source\JsEnv\Public\StaticCall.hpp(970): note: 查看对正在编译的函数 模板 实例化“bool puerts::internal::FuncCallHelper<API,std::pair<Ret,std::tuple<TSharedPtr<FVector,ESPMode::NotThreadSafe>>>,false,false,true,false>::callExtension<FirstDecayType,bool(__cdecl *)(TSharedPtr<FVector,ESPMode::NotThreadSafe>,TSharedPtr<FVector,ESPMode::NotThreadSafe>),>(Func &&,puerts::v8_impl::API::CallbackInfoType)”的引用
1>          with
1>          [
1>              API=puerts::v8_impl::API,
1>              Ret=bool,
1>              Func=bool (__cdecl *)(TSharedPtr<FVector,ESPMode::NotThreadSafe>,TSharedPtr<FVector,ESPMode::NotThreadSafe>)
1>          ]
1>  E:\UE\5.2\UnrealPuerts\Plugins\Puerts\Source\JsEnv\Public\StaticCall.hpp(976): note: 查看对正在编译的函数 模板 实例化“void puerts::FuncCallWrapper<puerts::v8_impl::API,bool (__cdecl *)(TSharedPtr<FVector,ESPMode::NotThreadSafe>,TSharedPtr<FVector,ESPMode::NotThreadSafe>),bool TSharedPtrExtension<FVector>::Equals(const TSharedPtr<FVector,ESPMode::NotThreadSafe>,const TSharedPtr<FVector,ESPMode::NotThreadSafe>),false,true,false>::ExtensionCallHelper<TSharedPtr<FVector,ESPMode::NotThreadSafe>,TSharedPtr<FVector,ESPMode::NotThreadSafe>>::call<>(puerts::v8_impl::API::CallbackInfoType)”的引用
1>  E:\UE\5.2\UnrealPuerts\Plugins\Puerts\Source\JsEnv\Public\StaticCall.hpp(976): note: 查看对正在编译的函数 模板 实例化“void puerts::FuncCallWrapper<puerts::v8_impl::API,bool (__cdecl *)(TSharedPtr<FVector,ESPMode::NotThreadSafe>,TSharedPtr<FVector,ESPMode::NotThreadSafe>),bool TSharedPtrExtension<FVector>::Equals(const TSharedPtr<FVector,ESPMode::NotThreadSafe>,const TSharedPtr<FVector,ESPMode::NotThreadSafe>),false,true,false>::ExtensionCallHelper<TSharedPtr<FVector,ESPMode::NotThreadSafe>,TSharedPtr<FVector,ESPMode::NotThreadSafe>>::call<>(puerts::v8_impl::API::CallbackInfoType)”的引用
1>  E:\UE\5.2\UnrealPuerts\Plugins\PuertsTest\Source\PuertsTest\Private\SlateBinding.hpp(12): note: 查看对正在编译的函数 模板 实例化“void puerts::FuncCallWrapper<puerts::v8_impl::API,bool (__cdecl *)(TSharedPtr<FVector,ESPMode::NotThreadSafe>,TSharedPtr<FVector,ESPMode::NotThreadSafe>),bool TSharedPtrExtension<FVector>::Equals(const TSharedPtr<FVector,ESPMode::NotThreadSafe>,const TSharedPtr<FVector,ESPMode::NotThreadSafe>),false,true,false>::callExtensionWithDefaultValues<>(puerts::v8_impl::API::CallbackInfoType)”的引用
1>  E:\UE\5.2\UnrealPuerts\Plugins\PuertsTest\Source\PuertsTest\Private\SlateBinding.hpp(12): note: 查看对正在编译的函数 模板 实例化“void puerts::FuncCallWrapper<puerts::v8_impl::API,bool (__cdecl *)(TSharedPtr<FVector,ESPMode::NotThreadSafe>,TSharedPtr<FVector,ESPMode::NotThreadSafe>),bool TSharedPtrExtension<FVector>::Equals(const TSharedPtr<FVector,ESPMode::NotThreadSafe>,const TSharedPtr<FVector,ESPMode::NotThreadSafe>),false,true,false>::callExtensionWithDefaultValues<>(puerts::v8_impl::API::CallbackInfoType)”的引用
1>E:\UE\5.2\UnrealPuerts\Plugins\Puerts\Source\JsEnv\Public\StaticCall.hpp(819): error C3861: “GetArgsLen”: 找不到标识符

@chexiongsheng
Copy link
Collaborator

是不是版本问题?puerts_unreal_demo.git的puerts同步到master。找不到GetArgsLen我记得是某个版本的问题,你试试更新到master

@9000miles
Copy link
Author

是不是版本问题?puerts_unreal_demo.git的puerts同步到master。找不到GetArgsLen我记得是某个版本的问题,你试试更新到master

我可能没说清楚,不是在puerts_unreal_demo.git这个库出的问题,而是Unreal_v1.0.6p1这个版本的插件出了问题,上面的报错都是在Unreal_v1.0.6p1发现的。

另外

demo项目已经更新到master最新提交,但是我发现demo项目的插件并不是Unreal_v1.0.6p1这个版本,在demo项目是OK的,并不会报上面的错误

建议

你可以直接在Unreal_v1.0.6p1插件里添加如下代码测试

#include "CoreMinimal.h"
#include "Binding.hpp"
#include "UEDataBinding.hpp"

UsingUStruct(FVector);
UsingTSharedPtr(FVector);

struct AutoRegisterForTest
{
	AutoRegisterForTest()
	{
		RegisterTSharedPtr(FVector);
	}
};

AutoRegisterForTest __AutoRegisterForTest__;

@chexiongsheng
Copy link
Collaborator

我说的某个版本,就是v1.0.6p1版本

@chexiongsheng
Copy link
Collaborator

我说的就是这个意思,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Unreal
Projects
None yet
Development

No branches or pull requests

2 participants