Skip to content

Commit

Permalink
Merge pull request #3 from dneg/sync
Browse files Browse the repository at this point in the history
Sync AX
  • Loading branch information
Idclip authored Nov 3, 2020
2 parents b34840c + f39ca33 commit 5429be6
Show file tree
Hide file tree
Showing 147 changed files with 2,814 additions and 2,341 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ax.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ jobs:
matrix:
compiler: ['clang++']
build: ['Release']
llvm: ['7','8','9','10']
llvm: ['7','8','9'] #@todo add back llvm 10 when the brew formula is fixed
# Extra builds
include:
- compiler: 'g++'
Expand Down
25 changes: 5 additions & 20 deletions openvdb_ax/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -98,20 +98,6 @@ message(STATUS "Found LLVM: ${LLVM_DIR} (found suitable version \"${LLVM_PACKAGE

#########################################################################

# Configure other dependencies

if(OPENVDB_AX_SHARED AND NOT Boost_USE_STATIC_LIBS)
# @note Both of these must be set for Boost 1.70 (VFX2020) to link against
# boost shared libraries (more specifically libraries built with -fPIC).
# http://boost.2283326.n4.nabble.com/CMake-config-scripts-broken-in-1-70-td4708957.html
# https://github.com/boostorg/boost_install/commit/160c7cb2b2c720e74463865ef0454d4c4cd9ae7c
set(BUILD_SHARED_LIBS ON)
set(Boost_USE_STATIC_LIBS OFF)
endif()
find_package(Boost REQUIRED COMPONENTS random)

#########################################################################

set(OPENVDB_AX_LIBRARY_SOURCE_FILES
openvdb_ax/ast/Parse.cc
openvdb_ax/ast/PrintTree.cc
Expand All @@ -123,12 +109,13 @@ set(OPENVDB_AX_LIBRARY_SOURCE_FILES
openvdb_ax/codegen/PointComputeGenerator.cc
openvdb_ax/codegen/PointFunctions.cc
openvdb_ax/codegen/StandardFunctions.cc
openvdb_ax/codegen/Types.cc
openvdb_ax/codegen/VolumeComputeGenerator.cc
openvdb_ax/codegen/VolumeFunctions.cc
openvdb_ax/compiler/Compiler.cc
openvdb_ax/compiler/Logger.cc
openvdb_ax/compiler/PointExecutable.cc
openvdb_ax/compiler/VolumeExecutable.cc
openvdb_ax/compiler/Logger.cc
openvdb_ax/math/OpenSimplexNoise.cc
)

Expand All @@ -145,7 +132,6 @@ endif()
set(OPENVDB_AX_AST_INCLUDE_FILES
openvdb_ax/ast/AST.h
openvdb_ax/ast/Parse.h
openvdb_ax/ast/Literals.h
openvdb_ax/ast/PrintTree.h
openvdb_ax/ast/Scanners.h
openvdb_ax/ast/Tokens.h
Expand All @@ -159,6 +145,7 @@ set(OPENVDB_AX_CODEGEN_INCLUDE_FILES
openvdb_ax/codegen/Functions.h
openvdb_ax/codegen/FunctionTypes.h
openvdb_ax/codegen/PointComputeGenerator.h
openvdb_ax/codegen/PointLeafLocalData.h
openvdb_ax/codegen/SymbolTable.h
openvdb_ax/codegen/Types.h
openvdb_ax/codegen/Utils.h
Expand All @@ -167,14 +154,13 @@ set(OPENVDB_AX_CODEGEN_INCLUDE_FILES
)

set(OPENVDB_AX_COMPILER_INCLUDE_FILES
openvdb_ax/compiler/AttributeRegistry.h
openvdb_ax/compiler/Compiler.h
openvdb_ax/compiler/CompilerOptions.h
openvdb_ax/compiler/CustomData.h
openvdb_ax/compiler/LeafLocalData.h
openvdb_ax/compiler/Logger.h
openvdb_ax/compiler/PointExecutable.h
openvdb_ax/compiler/AttributeRegistry.h
openvdb_ax/compiler/VolumeExecutable.h
openvdb_ax/compiler/Logger.h
)

# @todo CMake >= 3.12, use an object library to consolidate shared/static
Expand Down Expand Up @@ -208,7 +194,6 @@ endif()
set(OPENVDB_AX_CORE_DEPENDENT_LIBS
${OPENVDB_LIB}
${LLVM_LIBS}
Boost::random
)

##########################################################################
Expand Down
58 changes: 13 additions & 45 deletions openvdb_ax/openvdb_ax/ast/AST.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#ifndef OPENVDB_AX_AST_HAS_BEEN_INCLUDED
#define OPENVDB_AX_AST_HAS_BEEN_INCLUDED

#include "Literals.h"
#include "Tokens.h"

#include <openvdb/version.h>
Expand Down Expand Up @@ -2255,11 +2254,11 @@ struct Value : public ValueBase
using UniquePtr = std::unique_ptr<Value<T>>;

using Type = T;
using LiteralLimitsT = LiteralLimits<Type>;
/// @brief Integers and Floats store their value as ContainerType, which is
/// guaranteed to be at least large enough to represent the maximum
/// possible supported type for the requested precision.
using ContainerType = typename LiteralLimitsT::ContainerT;
using ContainerType = typename std::conditional<
std::is_integral<T>::value, uint64_t, T>::type;

/// @brief The list of supported numerical constants.
/// @note Strings are specialized and handled separately
Expand All @@ -2272,36 +2271,17 @@ struct Value : public ValueBase
std::is_same<T, double>::value;
static_assert(IsSupported, "Incompatible ast::Value node instantiated.");

/// @brief Construct a numerical Value from a given string. The string
/// should be a positive integer or floating point number.
/// Exponent-signs are supported for floating point numbers.
/// @note If the maximum container type cannot be used to store the value
/// or if the string is invalid, the resulting value is the maximum
/// possible container type for scalars or infinity for floats and
/// mText is initialized to the original string
/// @note This constructor should not be used to construct booleans
Value(const std::string number)
: mValue(LiteralLimitsT::onLimitOverflow())
, mText(nullptr) {
try {
mValue = LiteralLimitsT::convert(number);
}
catch (std::out_of_range&) {
mText.reset(new std::string(number));
}
}
/// @brief Directly construct a Value from a source integer, float or
/// boolean, guaranteeing valid construction. Note that the provided
/// argument should not be negative
Value(const ContainerType value)
: mValue(value), mText(nullptr) {}
: mValue(value) {}
/// @brief Deep copy constructor for a Value
/// @note No parent information needs updating as a Value is a "leaf
/// level" node (contains no children)
/// @param other A const reference to another Value to deep copy
Value(const Value<T>& other)
: mValue(other.mValue)
, mText(other.mText ? new std::string(*other.mText) : nullptr) {}
: mValue(other.mValue) {}
~Value() override = default;

/// @copybrief Node::copy()
Expand All @@ -2318,47 +2298,35 @@ struct Value : public ValueBase
/// @copybrief Node::nodename()
const char* nodename() const override {
if (std::is_same<T, bool>::value) return "boolean literal";
if (std::is_same<T, int16_t>::value) return "short (16bit) literal";
if (std::is_same<T, int32_t>::value) return "integer (32bit) literal";
if (std::is_same<T, int64_t>::value) return "long (64bit) literal";
if (std::is_same<T, int16_t>::value) return "int16 literal";
if (std::is_same<T, int32_t>::value) return "int32 literal";
if (std::is_same<T, int64_t>::value) return "int64 literal";
if (std::is_same<T, float>::value) return "float (32bit) literal";
if (std::is_same<T, double>::value) return "double (64bit) literal";
}
/// @copybrief Node::subname()
const char* subname() const override {
if (std::is_same<T, bool>::value) return "bool";
if (std::is_same<T, int16_t>::value) return "shrt";
if (std::is_same<T, int32_t>::value) return "int";
if (std::is_same<T, int64_t>::value) return "long";
if (std::is_same<T, int16_t>::value) return "i16";
if (std::is_same<T, int32_t>::value) return "i32";
if (std::is_same<T, int64_t>::value) return "i64";
if (std::is_same<T, float>::value) return "flt";
if (std::is_same<T, double>::value) return "dble";
if (std::is_same<T, double>::value) return "dbl";
}
/// @copybrief Node::basetype()
const ValueBase* basetype() const override { return this; }

/// @brief Query whether or not this Value ended up with a ContainerType
/// overflow by checking to see if mText was initialized. This
/// overflow is specific to the highest precision ContainerType, not
/// necessarily the value type T.
/// @return True if mText was set
inline bool overflow() const { return static_cast<bool>(this->text()); }
/// @brief Access any text stored on the Value. This set if construction
/// of the value failed from the provided string argument
/// @return A const pointer to the text. Can be a nullptr
inline const std::string* text() const { return mText.get(); }
/// @brief Access the value as its stored type
/// @return The value as its stored ContainerType
inline ContainerType asContainerType() const { return mValue; }
/// @brief Access the value as its requested (templated) type
/// @return The value as its templed type T
inline T value() const { return static_cast<T>(mValue); }

private:
// A container of a max size defined by LiteralValueContainer to hold values
// which may be out of scope. This is only used for warnings
ContainerType mValue;
// The original string representation of the variable used for warnings if
// it's unable to be represented (usually due to overflow)
std::unique_ptr<std::string> mText;
const ContainerType mValue;
};

/// @brief Specialization of Values for strings
Expand Down
97 changes: 0 additions & 97 deletions openvdb_ax/openvdb_ax/ast/Literals.h

This file was deleted.

49 changes: 12 additions & 37 deletions openvdb_ax/openvdb_ax/ast/Tokens.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ enum CoreType
{
BOOL = 0,
CHAR,
SHORT,
INT,
LONG,
INT16,
INT32,
INT64,
FLOAT,
DOUBLE,
//
Expand Down Expand Up @@ -86,11 +86,14 @@ inline CoreType tokenFromTypeString(const std::string& type)
if (type == "quatf") return QUATF;
if (type == "quatd") return QUATD;
}
else if (type[0] == 'i') {
if (type == "int16") return INT16;
if (type == "int") return INT32;
if (type == "int32") return INT32;
if (type == "int64") return INT64;
}
else if (type == "bool") return BOOL;
else if (type == "char") return CHAR;
else if (type == "short") return SHORT;
else if (type == "int") return INT;
else if (type == "long") return LONG;
else if (type == "float") return FLOAT;
else if (type == "double") return DOUBLE;
else if (type == "string") return STRING;
Expand All @@ -108,11 +111,6 @@ inline CoreType tokenFromTypeString(const std::string& type)
if (type == "mat4s") return MAT4F;
}
else if (type == "quats") return QUATF;
else if (type[0] == 'i') {
if (type == "int16") return SHORT;
if (type == "int32") return INT;
if (type == "int64") return LONG;
}

return UNKNOWN;
}
Expand All @@ -122,9 +120,9 @@ inline std::string typeStringFromToken(const CoreType type)
switch (type) {
case BOOL : return "bool";
case CHAR : return "char";
case SHORT : return "short";
case INT : return "int";
case LONG : return "long";
case INT16 : return "int16";
case INT32 : return "int32";
case INT64 : return "int64";
case FLOAT : return "float";
case DOUBLE : return "double";
case VEC2I : return "vec2i";
Expand All @@ -149,29 +147,6 @@ inline std::string typeStringFromToken(const CoreType type)
}
}

template<typename T> CoreType tokenFromType() { return UNKNOWN; }
template<> inline CoreType tokenFromType<bool>() { return BOOL; }
template<> inline CoreType tokenFromType<char>() { return CHAR; }
template<> inline CoreType tokenFromType<int16_t>() { return SHORT; }
template<> inline CoreType tokenFromType<int32_t>() { return INT; }
template<> inline CoreType tokenFromType<int64_t>() { return LONG; }
template<> inline CoreType tokenFromType<float>() { return FLOAT; }
template<> inline CoreType tokenFromType<double>() { return DOUBLE; }
template<> inline CoreType tokenFromType<math::Vec2<int32_t>>() { return VEC2I; }
template<> inline CoreType tokenFromType<math::Vec2<float>>() { return VEC2F; }
template<> inline CoreType tokenFromType<math::Vec2<double>>() { return VEC2D; }
template<> inline CoreType tokenFromType<math::Vec3<int32_t>>() { return VEC3I; }
template<> inline CoreType tokenFromType<math::Vec3<float>>() { return VEC3F; }
template<> inline CoreType tokenFromType<math::Vec3<double>>() { return VEC3D; }
template<> inline CoreType tokenFromType<math::Vec4<int32_t>>() { return VEC4I; }
template<> inline CoreType tokenFromType<math::Vec4<float>>() { return VEC4F; }
template<> inline CoreType tokenFromType<math::Vec4<double>>() { return VEC4D; }
template<> inline CoreType tokenFromType<math::Mat3<float>>() { return MAT3F; }
template<> inline CoreType tokenFromType<math::Mat3<double>>() { return MAT3D; }
template<> inline CoreType tokenFromType<math::Mat4<float>>() { return MAT4F; }
template<> inline CoreType tokenFromType<math::Mat4<double>>() { return MAT4D; }
template<> inline CoreType tokenFromType<std::string>() { return STRING; }

enum OperatorToken
{
////////////////////////////////////////////////////////////////
Expand Down
Loading

0 comments on commit 5429be6

Please sign in to comment.