Cinder-Runtime icon indicating copy to clipboard operation
Cinder-Runtime copied to clipboard

Added support for subfolders by walking the paths backwards.

Open num3ric opened this issue 8 years ago • 4 comments

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.

num3ric avatar Feb 28 '18 16:02 num3ric

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.

richardeakin avatar Feb 28 '18 22:02 richardeakin

@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?

num3ric avatar Mar 01 '18 16:03 num3ric

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?

simongeilfus avatar Mar 01 '18 23:03 simongeilfus

@simongeilfus I had this issue many times before

num3ric avatar Mar 02 '18 18:03 num3ric