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

static methods don't see static members in same class #1495

Open
Enem-20 opened this issue May 29, 2023 · 0 comments
Open

static methods don't see static members in same class #1495

Enem-20 opened this issue May 29, 2023 · 0 comments

Comments

@Enem-20
Copy link

Enem-20 commented May 29, 2023

Hello mates. I'm trying to introduce resource manager parts to binding. the class I want to embed in lua consists of static methods and fields.
This is my small binding:

void ClassRegistrator::Reg_ResourceManager(sol::table* Lnamespace)
{
	Lnamespace->new_usertype<ResourceManager>("ResourceManager"
		, "", sol::no_constructor
		, "loadScene", &ResourceManager::loadSave
		, "getGameObject", &ResourceManager::getResource<GameObject>
	);
}

When I call getGameObject function it doesn't see resources which I stored before.
Here, for example, m_resources is clear:

template<class ResourceType>
std::shared_ptr<ResourceType> ResourceManager::getResource(const std::string& name) {
	static_assert(std::is_base_of<ResourceBase, ResourceType>::value, "this resource can't be attached due to the class isn't inherit from ResourceBase");
	auto resourcesByType = m_resources.find(ResourceType::type);
	if (resourcesByType != m_resources.cend()) {
		auto resource = resourcesByType->second.find(name);

		if (resource != resourcesByType->second.cend()) {
			return resource->second.getResource<ResourceType>();
		}
	}
	std::cerr << "Error: this resource type doesn't exist" << '\n';
	return nullptr;
} 

Is that due to sol just copy function signature and call it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant