Skip to content

Conversation

@num3ric
Copy link
Contributor

@num3ric num3ric commented Feb 28, 2018

Note that I'm still seeing this occasional cl process hangs, though I don't think it's related to this since I've been experiencing it many times before this change.

@richardeakin
Copy link
Collaborator

What types of paths does this add support for? I don't think I understand why you'd walk up a folder structure to look for a file (the compiler doesn't do this), but maybe I'm missing something here.

@num3ric
Copy link
Contributor Author

num3ric commented Mar 1, 2018

@richardeakin with the current system, a full search of the include tree doesn't seem to be needed at this level. The factory-generated file produced the wrong include path for runtime-registered classes placed deeper than at a base level of one of the folders in the include paths, which is what this change fixes.

For instance if I take one of my classes located in the project include/panels/PanelCircle.h, the generated factory class would incorrectly be:

#include <new>
#include "PanelCircle.h"

extern "C" __declspec(dllexport) void* __cdecl rt_PanelCircle_new_operator( const std::string &className )
{
	void* ptr;
	if( className == "aicp::PanelCircle" ) {
		ptr = static_cast<void*>( ::new aicp::PanelCircle() );
	}
	return ptr;
}

extern "C" __declspec(dllexport) void* __cdecl rt_PanelCircle_placement_new_operator( const std::string &className, void* address )
{
	void* ptr;
	if( className == "aicp::PanelCircle" ) {
		ptr = static_cast<void*>( ::new (address) aicp::PanelCircle() );
	}
	return ptr;
}

This change correctly finds the full path with the subfolder:

#include <new>
#include "panels/PanelCircle.h"

extern "C" __declspec(dllexport) void* __cdecl rt_PanelCircle_new_operator( const std::string &className )
{
	void* ptr;
	if( className == "aicp::PanelCircle" ) {
		ptr = static_cast<void*>( ::new aicp::PanelCircle() );
	}
	return ptr;
}

extern "C" __declspec(dllexport) void* __cdecl rt_PanelCircle_placement_new_operator( const std::string &className, void* address )
{
	void* ptr;
	if( className == "aicp::PanelCircle" ) {
		ptr = static_cast<void*>( ::new (address) aicp::PanelCircle() );
	}
	return ptr;
}

Knowing that this is executed for successfully included & compiled files, let me know if you can think of a failure case here?

@simongeilfus
Copy link
Owner

Thanks for this @num3ric. Do you think the "cl process hang" issue could be link to this PR or did you had the same thing before?

@num3ric
Copy link
Contributor Author

num3ric commented Mar 2, 2018

@simongeilfus I had this issue many times before

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

Successfully merging this pull request may close these issues.

3 participants