mirror of
https://github.com/eclipse/upm.git
synced 2025-11-06 18:14:45 +03:00
This commit translates C++ interfaces to Java interfaces, previously C++ Interfaces implemented java classes.
* Added java swig interface files for all C++ interfaces to simplify swig
javaupm_iADC.i
javaupm_iCO2Sensor.i
javaupm_iHumiditySensor.i
javaupm_iLightController.i
javaupm_iLightSensor.i
javaupm_iModuleStatus.i
javaupm_interfaces.i
javaupm_iPressureSensor.i
javaupm_iTemperatureSensor.i
<example Usage>
%include"../interfaces/javaupm_iADC.i"
* Modified swig interface files for few sensors that implements interfaces
ads1x15
bmp280
bmpx8x
ds1808lc
hlg150h
lp8860
max44009
ms5611
si1132
si7005
t6713
* Removed few methods that were mentioned Protected and made them public, so that menthods can be overridden
* Made IModuleStatus virtual to avoid ambiguity in multiple inheritance
For example
class A {};
class B : public A {};
class C : public A {};
class D : public B, public C {};
This can be solved as
class A {};
class B : virtual public A {};
class C : virtual public A {};
class D : public B, public C {};
* Modified java interface files to support multiple swig versions
* Modified javaupm interface file to support standard auto load library code
* Fixed autoloadlibrary tests for interfaces
* Created one interface example separately <BME280_InterfaceExample.java>,
<example Usage>
BME280_InterfaceExample.java
since we cann't define swig versions inside java example file.
So, instaed added swig versions in Cmake.
<example Usage>
if (SWIG_VERSION VERSION_GREATER 3.0.8)
add_example_with_path(BME280_InterfaceExample bmp280 bmp280)
endif()
Signed-off-by: sisinty sasmita patra <sisinty.s.patra@intel.com>
52 lines
1.7 KiB
Python
Executable File
52 lines
1.7 KiB
Python
Executable File
#!/usr/bin/python
|
|
|
|
import unittest as u
|
|
import re, fnmatch, os
|
|
|
|
rootDir = '../src/'
|
|
prefix = """
|
|
%pragma(java) jniclasscode=%{
|
|
static {
|
|
try {
|
|
System.loadLibrary(\""""
|
|
|
|
suffix = """\");
|
|
} catch (UnsatisfiedLinkError e) {
|
|
System.err.println("Native code library failed to load. \\n" + e);
|
|
System.exit(1);
|
|
}
|
|
}
|
|
%}"""
|
|
|
|
class AutoLoadLibrary(u.TestCase):
|
|
|
|
def test_existing_snippet(self):
|
|
broken_modules = []
|
|
|
|
for subdir, dirs, files in os.walk(rootDir):
|
|
for fileName in files:
|
|
if fnmatch.fnmatch(fileName, 'javaupm_*.i'):
|
|
moduleName = fileName[:-2]
|
|
snippet = prefix + moduleName + suffix
|
|
|
|
with open(os.path.join(subdir, fileName), "r") as f:
|
|
#read in entire file
|
|
data = f.read()
|
|
#Make sure it is module
|
|
if not '%module' in data:
|
|
print "%%module not found in %s, skipping" % fileName
|
|
continue
|
|
if not snippet in data:
|
|
broken_modules.append('%s: %s' % \
|
|
(moduleName, os.path.join(subdir, fileName)))
|
|
|
|
self.assertEqual( len(broken_modules), 0, \
|
|
"\nThe following modules do not contain the standard auto load library code:\n" + \
|
|
"\n".join(broken_modules) + \
|
|
"\nConsider adding the following snippet to the SWIG interface file:\n" + \
|
|
prefix + "<module_name>" + suffix)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
u.main()
|