Jump to content
  • Advertisement
Sign in to follow this  
cvet

Imports in namespace

This topic is 1354 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello.

For now imports placed in global namespace, despite on named namespace where it's placed.
My preposition is include imports to appropriate namespaces, where it was placed.
Example:

namesace a
{
	import void Foo() from "module";
	import void Foo2() from "module";
}
namesace b
{
	import void Foo() from "module"; // Error for now, but must be ok after changes
	
	void Foo3()
	{
		Foo2(); // Ok for now, but must will be a::Foo2() after changes
	}
}
Edited by cvet

Share this post


Link to post
Share on other sites
Advertisement

It's work not as expected.

For now I can't import function from global namespace in some named namespace.

 

This code must work:

module1
int Foo1() { return 1; }
int Foo2() { return 2; }

module2
namesace A
{
	import int Foo1() from "module1";
	import int Foo2() from "module1";
}
namesace B
{
	import int Foo1() from "module1";
	
	void Test()
	{
		assert( Foo1() == A::Foo1() );
		assert( A::Foo2() == 2 );
	}
}

Share this post


Link to post
Share on other sites

BindAllImportedFunctions() cannot guess how you want to bind the functions. It will only match functions that are declared exactly the same way in the source module as the import is declared in the destination module, including the namespace.

 

If you want to match functions in a different way, then you can do so by manually binding the functions using BindImportedFunction() instead.

Share this post


Link to post
Share on other sites

Ok, you be able to do as you think is right, but there is not what I request in first post.

And for now I can't import function in some named namespace from different module and it's broke backward compatability.

module1

void foo(){}

module2

namespace NS{ import foo() from "module1"; } // error

Share this post


Link to post
Share on other sites

I'm sorry. I guess I misunderstood your original post.

 

I understand now that what you want is to import a function into a different namespace than where it had been declared in the original module.

 

I should be able to at least allow BindAllImportedFunctions do a recursive search in parent namespaces, but if you want to allow the import from an unrelated namespace then you really do have to implement the matching logic by yourself.

Share this post


Link to post
Share on other sites

I've added the support for recursively searching parent namespaces in revision 2119.

 

It should work more like you had originally requested now.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!