Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync externals #323

Merged
merged 4 commits into from
Mar 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ TEST_CASE(testVertical)
math::linear::Line2D vertLine2(P1, P2);
TEST_EXCEPTION(vertLine.intersection(vertLine2));

// Intersecting a horizontal line should give (vertLine.xIntercept, \
// Intersecting a horizontal line should give (vertLine.xIntercept,
// horiLine.yIntercept)
math::linear::Line2D::Point P3(5,5);
math::linear::Line2D::Point P4(6,5);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class MyRunTask : public Runnable
}

private:
size_t mThread;
sys::AtomicCounter::ValueType mThread;
sys::Mutex mMutex;
sys::AtomicCounter& mThreadCounter;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@
* for the source and some discussion
*/
#if PY_MAJOR_VERSION >= 3
int init_numpy()
void* init_numpy()
{
import_array();
return nullptr;
}
#else
void init_numpy()
Expand Down
125 changes: 80 additions & 45 deletions externals/coda-oss/modules/c++/str/include/str/Convert.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,47 +23,57 @@
#ifndef __STR_CONVERT_H__
#define __STR_CONVERT_H__

#include <string>
#include <import/except.h>
#include <cerrno>
#include <complex>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <limits>
#include <ostream>
#include <sstream>
#include <iomanip>
#include <string>
#include <typeinfo>
#include <iostream>
#include <cstdlib>
#include <cerrno>
#include <limits>
#include <import/except.h>

namespace str
{
template <typename T>
int getPrecision(const T& type);

template<typename T> int getPrecision(const T& type);
template<typename T> int getPrecision(const std::complex<T>& type);
template <typename T>
int getPrecision(const std::complex<T>& type);

template<typename T> std::string toString(const T& value)
template <typename T>
std::string toString(const T& value)
{
std::ostringstream buf;
buf.precision(getPrecision(value));
buf << std::boolalpha << value;
return buf.str();
}

template<> std::string toString(const uint8_t& value);
template <>
std::string toString(const uint8_t& value);

template<> std::string toString(const int8_t& value);
template <>
std::string toString(const int8_t& value);

template<typename T> std::string toString(const T& real, const T& imag)
template <typename T>
std::string toString(const T& real, const T& imag)
{
return toString(std::complex<T>(real, imag));
}

template<typename T> T toType(const std::string& s)
template <typename T>
T toType(const std::string& s)
{
if (s.empty())
throw except::BadCastException(except::Context(__FILE__, __LINE__,
std::string(""), std::string(""), std::string("Empty string")));
throw except::BadCastException(
except::Context(__FILE__,
__LINE__,
std::string(""),
std::string(""),
std::string("Empty string")));

T value;

Expand All @@ -73,26 +83,32 @@ template<typename T> T toType(const std::string& s)

if (buf.fail())
{
throw except::BadCastException(except::Context(__FILE__, __LINE__,
std::string(""), std::string(""),
std::string("Conversion failed: '")
+ s + std::string("' -> ") + typeid(T).name()));
throw except::BadCastException(
except::Context(__FILE__,
__LINE__,
std::string(""),
std::string(""),
std::string("Conversion failed: '") + s +
std::string("' -> ") +
typeid(T).name()));
}

return value;
}

template<> bool toType<bool> (const std::string& s);
template<> std::string toType<std::string> (const std::string& s);
template <>
bool toType<bool>(const std::string& s);
template <>
std::string toType<std::string>(const std::string& s);

/**
* strtoll wrapper for msvc compatibility.
*/
long long strtoll(const char *str, char **endptr, int base);
long long strtoll(const char* str, char** endptr, int base);
/**
* strtoull wrapper for msvc compatibility.
*/
unsigned long long strtoull(const char *str, char **endptr, int base);
unsigned long long strtoull(const char* str, char** endptr, int base);

/**
* Convert a string containing a number in any base to a numerical type.
Expand All @@ -102,7 +118,8 @@ unsigned long long strtoull(const char *str, char **endptr, int base);
* @return a numberical representation of the number
* @throw BadCastException thrown if cast cannot be performed.
*/
template<typename T> T toType(const std::string& s, int base)
template <typename T>
T toType(const std::string& s, int base)
{
char* end;
errno = 0;
Expand All @@ -113,8 +130,8 @@ template<typename T> T toType(const std::string& s, int base)
if (std::numeric_limits<T>::is_signed)
{
const long long longRes = str::strtoll(str, &end, base);
if (longRes < std::numeric_limits<T>::min() ||
longRes > std::numeric_limits<T>::max())
if (longRes < static_cast<long long>(std::numeric_limits<T>::min()) ||
longRes > static_cast<long long>(std::numeric_limits<T>::max()))
{
overflow = true;
}
Expand All @@ -123,25 +140,36 @@ template<typename T> T toType(const std::string& s, int base)
else
{
const unsigned long long longRes = str::strtoull(str, &end, base);
if (longRes < std::numeric_limits<T>::min() ||
longRes > std::numeric_limits<T>::max())
if (longRes < static_cast<unsigned long long>(
std::numeric_limits<T>::min()) ||
longRes > static_cast<unsigned long long>(
std::numeric_limits<T>::max()))
{
overflow = true;
}
res = static_cast<T>(longRes);
}

if (overflow || errno == ERANGE)
throw except::BadCastException(except::Context(__FILE__, __LINE__,
std::string(""), std::string(""),
std::string("Overflow: '")
+ s + std::string("' -> ") + typeid(T).name()));
// If the end pointer is at the start of the string, we didn't convert anything.
throw except::BadCastException(
except::Context(__FILE__,
__LINE__,
std::string(""),
std::string(""),
std::string("Overflow: '") + s +
std::string("' -> ") +
typeid(T).name()));
// If the end pointer is at the start of the string, we didn't convert
// anything.
else if (end == str)
throw except::BadCastException(except::Context(__FILE__, __LINE__,
std::string(""), std::string(""),
std::string("Conversion failed: '")
+ s + std::string("' -> ") + typeid(T).name()));
throw except::BadCastException(
except::Context(__FILE__,
__LINE__,
std::string(""),
std::string(""),
std::string("Conversion failed: '") + s +
std::string("' -> ") +
typeid(T).name()));

return res;
}
Expand All @@ -153,18 +181,26 @@ template<typename T> T toType(const std::string& s, int base)
* @return The integer argument required by ios::precision() to represent
* this type.
*/
template<typename T> int getPrecision(const T& )
template <typename T>
int getPrecision(const T&)
{
return 0;
}
template<typename T> int getPrecision(const std::complex<T>& type)

template <typename T>
int getPrecision(const std::complex<T>& type)
{
return getPrecision(type.real());
}

template<> int getPrecision(const float& type);
template<> int getPrecision(const double& type);
template<> int getPrecision(const long double& type);
template <>
int getPrecision(const float& type);

template <>
int getPrecision(const double& type);

template <>
int getPrecision(const long double& type);

/** Generic casting routine; used by explicitly overloaded
conversion operators.
Expand All @@ -174,12 +210,11 @@ template<> int getPrecision(const long double& type);
to the desired type, if possible.
@throw BadCastException thrown if cast cannot be performed.
*/
template<typename T>
template <typename T>
T generic_cast(const std::string& value)
{
return str::toType<T>(value);
}

}

#endif
10 changes: 9 additions & 1 deletion externals/coda-oss/modules/c++/wscript
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
import os


def options(opt):
opt.recurse()


def configure(conf):
conf.env.append_value('INCLUDES_UNITTEST', os.path.join(conf.path.abspath(), 'include'))
conf.env.append_value('INCLUDES_UNITTEST',
os.path.join(conf.path.abspath(), 'include'))
conf.recurse()


def build(bld):
bld.recurse()
testHeader = bld.path.make_node('include/TestCase.h')
bld.install_files(dest=bld.env['install_includedir'],
files=testHeader)


def distclean(context):
context.recurse()
22 changes: 10 additions & 12 deletions externals/coda-oss/modules/drivers/numpy/wscript
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
import os, sys
from os.path import join, exists
from waflib import Options
from waflib.TaskGen import feature, before, task_gen

build = distclean = lambda x: None


def options(opt):
opt.add_option('--disable-numpy', action='store_false', dest='enable_numpy', default=True,
opt.add_option('--disable-numpy', action='store_false',
dest='enable_numpy', default=True,
help='Turn off Numpy C headers/libs')

def configure(conf):

def configure(conf):
if Options.options.enable_numpy and \
hasattr(Options.options, 'python') and Options.options.python:
hasattr(Options.options, 'python') and Options.options.python:
# a little magic borrowed from python-config and extended for numpy and -L flags
try:
from distutils import sysconfig
import numpy.distutils
import os


np_info = numpy.distutils.misc_util.get_info('npymath')

warningmessage = ""
Expand All @@ -31,11 +29,11 @@ def configure(conf):

conf.check(uselib_store='NUMPY',
use='PYEXT',
lib='npymath',
header_name=['Python.h','numpy/arrayobject.h'],
lib='npymath',
header_name=['Python.h', 'numpy/arrayobject.h'],
includes=inc_dir,
libpath=lib_dir,
msg='Checking for library numpy' + warningmessage,
msg='Checking for library numpy' + warningmessage,
mandatory=True)

conf.undefine("HAVE_NUMPY_ARRAYOBJECT_H")
Expand Down
2 changes: 1 addition & 1 deletion externals/nitro/modules/c/nitf/shared/RSMIDA.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ static nitf_TREDescription description[] = {
{NITF_BCS_A, 21, "Illum Elevation Angle Coeff Per Row-Col", "IERC" },
{NITF_BCS_A, 21, "Illum Elevation Angle Coeff Per Col^2", "IECC" },

{NITF_BCS_A, 21, "Illum Azimuth Angle Const", "IE0" },
{NITF_BCS_A, 21, "Illum Azimuth Angle Const", "IA0" },
{NITF_BCS_A, 21, "Illum Azimuth Angle Coeff Per Row", "IAR" },
{NITF_BCS_A, 21, "Illum Azimuth Angle Coeff Per Col", "IAC" },

Expand Down
Loading