Skip to content

Commit

Permalink
Allow the whole library to be wrapped in a (potentially versioned) cu…
Browse files Browse the repository at this point in the history
…stom

namespace to be determined at compile time with 'make NAMESPACE=foo'.  
By default, no such enclosing namespace is used.


git-svn-id: https://openshadinglanguage.googlecode.com/svn/trunk@140 a3683778-fedd-11de-87c3-653bb6514e15
  • Loading branch information
lgritzecho committed Jul 20, 2009
1 parent e3422fc commit 4e50a72
Show file tree
Hide file tree
Showing 33 changed files with 243 additions and 4 deletions.
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ ifneq (${VERBOSE},)
MY_MAKE_FLAGS += VERBOSE=${VERBOSE}
endif

ifneq (${USE_TBB},)
MY_CMAKE_FLAGS += -DUSE_TBB:BOOL=${USE_TBB}
endif

ifneq (${NAMESPACE},)
MY_CMAKE_FLAGS += -DOSL_NAMESPACE:STRING=${NAMESPACE}
endif

ifdef DEBUG
MY_CMAKE_FLAGS += -DCMAKE_BUILD_TYPE:STRING=Debug
endif
Expand Down Expand Up @@ -158,4 +166,6 @@ help:
@echo "Helpful modifiers:"
@echo " make VERBOSE=1 ... Show all compilation commands"
@echo " make MYCC=xx MYCXX=yy ... Use custom compilers"
@echo " make USE_TBB=0 ... Don't use TBB"
@echo " make NAMESPACE=name Wrap everything in another namespace"
@echo ""
4 changes: 4 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ if (CMAKE_BUILD_TYPE STREQUAL "Debug")
add_definitions ("-DDEBUG=1")
endif ()

if (OSL_NAMESPACE)
add_definitions ("-DOSL_NAMESPACE=${OSL_NAMESPACE}")
endif ()

# use, i.e. don't skip the full RPATH for the build tree
set (CMAKE_SKIP_BUILD_RPATH FALSE)
# when building, don't use the install RPATH already
Expand Down
8 changes: 8 additions & 0 deletions src/include/osl_pvt.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "OpenImageIO/ustring.h"


#ifdef OSL_NAMESPACE
namespace OSL_NAMESPACE {
#endif

namespace OSL {
namespace pvt {

Expand Down Expand Up @@ -519,5 +523,9 @@ typedef std::vector<Opcode> OpcodeVec;
}; // namespace OSL::pvt
}; // namespace OSL

#ifdef OSL_NAMESPACE
}; // end namespace OSL_NAMESPACE
using namespace OSL_NAMESPACE;
#endif

#endif /* OSL_PVT_H */
9 changes: 9 additions & 0 deletions src/include/oslcomp.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define OSLCOMP_H


#ifdef OSL_NAMESPACE
namespace OSL_NAMESPACE {
#endif

namespace OSL {


Expand All @@ -54,5 +58,10 @@ class OSLCompiler {

}; // namespace OSL

#ifdef OSL_NAMESPACE
}; // end namespace OSL_NAMESPACE
using namespace OSL_NAMESPACE;
#endif


#endif /* OSLCOMP_H */
9 changes: 9 additions & 0 deletions src/include/oslexec.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.



#ifdef OSL_NAMESPACE
namespace OSL_NAMESPACE {
#endif

namespace OSL {

class ShadingAttribState;
Expand Down Expand Up @@ -214,5 +218,10 @@ class ShaderGlobals

}; // namespace OSL

#ifdef OSL_NAMESPACE
}; // end namespace OSL_NAMESPACE
using namespace OSL_NAMESPACE;
#endif


#endif /* OSLEXEC_H */
9 changes: 9 additions & 0 deletions src/include/oslquery.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ Sony Pictures Imageworks terms, above.
#include "OpenImageIO/typedesc.h"


#ifdef OSL_NAMESPACE
namespace OSL_NAMESPACE {
#endif

namespace OSL {

namespace pvt {
Expand Down Expand Up @@ -138,5 +142,10 @@ class DLLPUBLIC OSLQuery {

}; /* end namespace OSL */

#ifdef OSL_NAMESPACE
}; // end namespace OSL_NAMESPACE
using namespace OSL_NAMESPACE;
#endif


#endif /* OSLQUERY_H */
8 changes: 8 additions & 0 deletions src/liboslcomp/ast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "ast.h"


#ifdef OSL_NAMESPACE
namespace OSL_NAMESPACE {
#endif

namespace OSL {
namespace pvt { // OSL::pvt

Expand Down Expand Up @@ -687,3 +691,7 @@ ASTliteral::print (std::ostream &out, int indentlevel) const

}; // namespace pvt
}; // namespace OSL

#ifdef OSL_NAMESPACE
}; // end namespace OSL_NAMESPACE
#endif
9 changes: 9 additions & 0 deletions src/liboslcomp/ast.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ class oslFlexLexer;
extern int oslparse ();


#ifdef OSL_NAMESPACE
namespace OSL_NAMESPACE {
#endif

namespace OSL {
namespace pvt {

Expand Down Expand Up @@ -686,5 +690,10 @@ class ASTliteral : public ASTNode
}; // namespace pvt
}; // namespace OSL

#ifdef OSL_NAMESPACE
}; // end namespace OSL_NAMESPACE
using namespace OSL_NAMESPACE;
#endif


#endif /* OSL_AST_H */
8 changes: 8 additions & 0 deletions src/liboslcomp/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "ast.h"


#ifdef OSL_NAMESPACE
namespace OSL_NAMESPACE {
#endif

namespace OSL {
namespace pvt { // OSL::pvt

Expand Down Expand Up @@ -381,3 +385,7 @@ ASTliteral::codegen (Symbol *dest)

}; // namespace pvt
}; // namespace OSL

#ifdef OSL_NAMESPACE
}; // end namespace OSL_NAMESPACE
#endif
8 changes: 8 additions & 0 deletions src/liboslcomp/oslcomp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "FlexLexer.h"


#ifdef OSL_NAMESPACE
namespace OSL_NAMESPACE {
#endif

namespace OSL {


Expand Down Expand Up @@ -539,3 +543,7 @@ OSLCompilerImpl::retrieve_source (ustring filename, int line)

}; // namespace pvt
}; // namespace OSL

#ifdef OSL_NAMESPACE
}; // end namespace OSL_NAMESPACE
#endif
9 changes: 9 additions & 0 deletions src/liboslcomp/oslcomp_pvt.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ class oslFlexLexer;
extern int oslparse ();


#ifdef OSL_NAMESPACE
namespace OSL_NAMESPACE {
#endif

namespace OSL {
namespace pvt {

Expand Down Expand Up @@ -208,5 +212,10 @@ extern OSLCompilerImpl *oslcompiler;
}; // namespace pvt
}; // namespace OSL

#ifdef OSL_NAMESPACE
}; // end namespace OSL_NAMESPACE
using namespace OSL_NAMESPACE;
#endif


#endif /* OSLCOMP_PVT_H */
6 changes: 6 additions & 0 deletions src/liboslcomp/oslgram.y
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,17 @@ using namespace OSL::pvt;


// Forward declaration
#ifdef OSL_NAMESPACE
namespace OSL_NAMESPACE {
#endif
namespace OSL {
namespace pvt {
TypeDesc lextype (int lex);
};
};
#ifdef OSL_NAMESPACE {
};
#endif

%}

Expand Down
8 changes: 8 additions & 0 deletions src/liboslcomp/symtab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "ast.h"


#ifdef OSL_NAMESPACE
namespace OSL_NAMESPACE {
#endif

namespace OSL {
namespace pvt { // OSL::pvt

Expand Down Expand Up @@ -255,3 +259,7 @@ SymbolTable::print ()

}; // namespace pvt
}; // namespace OSL

#ifdef OSL_NAMESPACE
}; // end namespace OSL_NAMESPACE
#endif
9 changes: 9 additions & 0 deletions src/liboslcomp/symtab.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ using std::hash_set;
#include "osl_pvt.h"


#ifdef OSL_NAMESPACE
namespace OSL_NAMESPACE {
#endif

namespace OSL {
namespace pvt {

Expand Down Expand Up @@ -256,5 +260,10 @@ class SymbolTable {
}; // namespace pvt
}; // namespace OSL

#ifdef OSL_NAMESPACE
}; // end namespace OSL_NAMESPACE
using namespace OSL_NAMESPACE;
#endif


#endif /* OSL_SYMTAB_H */
8 changes: 8 additions & 0 deletions src/liboslcomp/typecheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "ast.h"


#ifdef OSL_NAMESPACE
namespace OSL_NAMESPACE {
#endif

namespace OSL {
namespace pvt { // OSL::pvt

Expand Down Expand Up @@ -899,3 +903,7 @@ OSLCompilerImpl::typelist_from_code (const char *code)

}; // namespace pvt
}; // namespace OSL

#ifdef OSL_NAMESPACE
}; // end namespace OSL_NAMESPACE
#endif
8 changes: 7 additions & 1 deletion src/liboslexec/loadshader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.



#ifdef OSL_NAMESPACE
namespace OSL_NAMESPACE {
#endif
namespace OSL {

namespace pvt { // OSL::pvt


Expand Down Expand Up @@ -369,3 +371,7 @@ ShadingSystemImpl::loadshader (const char *cname)

}; // namespace pvt
}; // namespace OSL

#ifdef OSL_NAMESPACE
}; // end namespace OSL_NAMESPACE
#endif
7 changes: 6 additions & 1 deletion src/liboslexec/master.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.



#ifdef OSL_NAMESPACE
namespace OSL_NAMESPACE {
#endif
namespace OSL {

namespace pvt { // OSL::pvt


Expand Down Expand Up @@ -228,3 +230,6 @@ ShaderMaster::resolve_ops ()

}; // namespace pvt
}; // namespace OSL
#ifdef OSL_NAMESPACE
}; // end namespace OSL_NAMESPACE
#endif
6 changes: 6 additions & 0 deletions src/liboslexec/opassign.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "OpenImageIO/varyingref.h"


#ifdef OSL_NAMESPACE
namespace OSL_NAMESPACE {
#endif
namespace OSL {
namespace pvt {

Expand Down Expand Up @@ -162,3 +165,6 @@ DECLOP (OP_assign)

}; // namespace pvt
}; // namespace OSL
#ifdef OSL_NAMESPACE
}; // end namespace OSL_NAMESPACE
#endif
6 changes: 6 additions & 0 deletions src/liboslexec/opcompare.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "OpenImageIO/varyingref.h"


#ifdef OSL_NAMESPACE
namespace OSL_NAMESPACE {
#endif
namespace OSL {
namespace pvt {

Expand Down Expand Up @@ -417,3 +420,6 @@ DECLOP (OP_ge)

}; // namespace pvt
}; // namespace OSL
#ifdef OSL_NAMESPACE
}; // end namespace OSL_NAMESPACE
#endif
6 changes: 6 additions & 0 deletions src/liboslexec/opcontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "OpenImageIO/sysutil.h"


#ifdef OSL_NAMESPACE
namespace OSL_NAMESPACE {
#endif
namespace OSL {
namespace pvt {

Expand Down Expand Up @@ -124,3 +127,6 @@ DECLOP (OP_if)

}; // namespace pvt
}; // namespace OSL
#ifdef OSL_NAMESPACE
}; // end namespace OSL_NAMESPACE
#endif
Loading

0 comments on commit 4e50a72

Please sign in to comment.