Quantcast

Can two or more wrapper packages share a single interface type

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Can two or more wrapper packages share a single interface type

Sasmi

Hi,


I am using Swig to generate java interfaces from C++ interfaces. The java interface example as of now only serves as a layer of abstraction and cannot be used as a collection. I hope below example can help you understand better.

 

Suppose I have two packages A, B and I have a temperature interface. Suppose, Both packages use temperature interface. Can two or more wrapper packages share a single interface type, basically can I do (A. Temperature == B.Temperature)? I have an example below with errors.

 

+++++++++++

import A.*;

import B.*.;

 

public class HelloWorld

{

public static void main(String[] args) {

     ITemperatureSensor a;

     }

}

 

Output:

<i>HelloWorld.java:7: error: reference to ITemperatureSensor is ambiguous

ITemperatureSensor a;</i>

 

both interface A.TemperatureSensor in A and interface B.TemperatureSensor in B match

1 error

+++++++++++


Thanks in advance,

Sasmita


Sent from Outlook


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Swig-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/swig-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Can two or more wrapper packages share a single interface type

William S Fulton


On 22 March 2017 at 17:30, Sasmita Sashi <[hidden email]> wrote:

Hi,


I am using Swig to generate java interfaces from C++ interfaces. The java interface example as of now only serves as a layer of abstraction and cannot be used as a collection. I hope below example can help you understand better.

 

Suppose I have two packages A, B and I have a temperature interface. Suppose, Both packages use temperature interface. Can two or more wrapper packages share a single interface type, basically can I do (A. Temperature == B.Temperature)? I have an example below with errors.

 

+++++++++++

import A.*;

import B.*.;

 

public class HelloWorld

{

public static void main(String[] args) {

     ITemperatureSensor a;

     }

}

 

Output:

<i>HelloWorld.java:7: error: reference to ITemperatureSensor is ambiguous

ITemperatureSensor a;</i>

 

both interface A.TemperatureSensor in A and interface B.TemperatureSensor in B match

1 error

+++++++++++



Try the nspace feature to put symbols with the same name in different C++ namespaces into different Java packages. As you are using interfaces, also take a good look at the section on Interfaces at http://swig.org/Doc3.0/Java.html.

William


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Swig-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/swig-user
Loading...