Skip to content

Commit 42ccf22

Browse files
authored
api: Switch to a 2-level namespace (#1922)
Related OIIO PR: AcademySoftwareFoundation/OpenImageIO#4567 Like in the corresponding OIIO PR, I'm proposing switching to a 2-level namespace scheme (basically, `OSL::v1_14` instead of the current `OSL_v1_14) because that opens the door to possible future schemes to preserve better ABI compatibility between minor releases. I would like to squeeze this in before I finalize a 1.14 beta, so that it doesn't change again during the beta period. Also, I changed some macro names. Signed-off-by: Larry Gritz <[email protected]>
1 parent 5446c1d commit 42ccf22

File tree

184 files changed

+449
-426
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

184 files changed

+449
-426
lines changed

CMakeLists.txt

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
cmake_minimum_required (VERSION 3.19)
66

7-
set (OSL_VERSION "1.14.3.0")
7+
set (OSL_VERSION "1.14.4.0")
88
set (OSL_VERSION_OVERRIDE "" CACHE STRING
99
"Version override (use with caution)!")
1010
mark_as_advanced (OSL_VERSION_OVERRIDE)
@@ -163,22 +163,32 @@ add_compile_definitions (OSL_INTERNAL=1)
163163
# OIIO_DISABLE_DEPRECATED before including any OIIO headers.
164164
add_compile_definitions (OIIO_DISABLE_DEPRECATED=900000)
165165

166-
# Set the default namespace. For symbol hiding reasons, it's important that
167-
# the project name is a subset of the namespace name.
168-
set (${PROJ_NAME}_NAMESPACE ${PROJECT_NAME} CACHE STRING
169-
"Customized outer namespace base name (version will be added)")
170-
option (${PROJ_NAME}_NAMESPACE_INCLUDE_PATCH
171-
"Should the inner namespace include the patch number" ${${PROJECT_NAME}_DEV_RELEASE})
172-
set (PROJ_NAMESPACE "${${PROJ_NAME}_NAMESPACE}")
173-
string(REGEX MATCH ${PROJECT_NAME} NAMESPACE_HAS_PROJECT_NAME ${PROJ_NAMESPACE})
174-
if (NOT NAMESPACE_HAS_PROJECT_NAME)
175-
set (PROJ_NAMESPACE ${PROJECT_NAME}_${PROJ_NAMESPACE})
166+
# Namespace settings
167+
#
168+
# The "outer namespace" defaults to the project name, but it can be overridden
169+
# to allow custom builds that put everything inside a unique namespace that
170+
# can't conflict with default builds.
171+
set (${PROJ_NAME}_OUTER_NAMESPACE ${PROJECT_NAME} CACHE STRING
172+
"Customized outer namespace")
173+
set (PROJ_NAMESPACE "${${PROJ_NAME}_OUTER_NAMESPACE}") # synonym
174+
if (NOT ${PROJ_NAME}_OUTER_NAMESPACE STREQUAL ${PROJECT_NAME})
175+
set (${PROJ_NAME}_CUSTOM_OUTER_NAMESPACE 1)
176176
endif ()
177-
set (PROJ_NAMESPACE_V "${PROJ_NAMESPACE}_v${PROJECT_VERSION_MAJOR}_${PROJECT_VERSION_MINOR}")
178-
if (${PROJ_NAME}_NAMESPACE_INCLUDE_PATCH)
179-
set (PROJ_NAMESPACE_V "${PROJ_NAMESPACE_V}_${PROJECT_VERSION_PATCH}")
177+
# There is also an inner namespace that is either vMAJ_MIN or vMAJ_MIN_PATCH,
178+
# depending on the setting of ${PROJ_NAME}_INNER_NAMESPACE_INCLUDE_PATCH.
179+
option (${PROJ_NAME}_INNER_NAMESPACE_INCLUDE_PATCH
180+
"Should the inner namespace include the patch number" ${${PROJECT_NAME}_DEV_RELEASE})
181+
if (${PROJ_NAME}_INNER_NAMESPACE_INCLUDE_PATCH)
182+
set (PROJ_VERSION_NAMESPACE "v${PROJECT_VERSION_MAJOR}_${PROJECT_VERSION_MINOR}_${PROJECT_VERSION_PATCH}")
183+
else ()
184+
set (PROJ_VERSION_NAMESPACE "v${PROJECT_VERSION_MAJOR}_${PROJECT_VERSION_MINOR}")
180185
endif ()
181-
message(STATUS "Setting Namespace to: ${PROJ_NAMESPACE_V}")
186+
# PROJ_NAMESPACE_V combines the outer and inner namespaces into one symbol
187+
set (PROJ_NAMESPACE_V "${PROJ_NAMESPACE}_${PROJ_VERSION_NAMESPACE}")
188+
message(STATUS "Outer namespace PROJ_OUTER_NAMESPACE: ${PROJ_NAMESPACE}")
189+
message(STATUS "Inner namespace PROJ_VERSION_NAMESPACE: ${PROJ_VERSION_NAMESPACE}")
190+
message(STATUS "Joint namespace PROJ_NAMESPACE_V: ${PROJ_NAMESPACE_V}")
191+
182192

183193
# Define OSL_INTERNAL symbol only when building OSL itself, will not be
184194
# defined for downstream projects using OSL.

src/doc/Doxyfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,7 @@ SHOW_FILES = YES
697697
# Folder Tree View (if specified).
698698
# The default value is: YES.
699699

700-
SHOW_NAMESPACES = YES
700+
SHOW_NAMESPACES = NO
701701

702702
# The FILE_VERSION_FILTER tag can be used to specify a program or script that
703703
# doxygen should invoke to get the current version for each file (typically from
@@ -2162,6 +2162,8 @@ PREDEFINED = DOXYGEN_SHOULD_SKIP_THIS \
21622162
OSL_HOSTDEVICE= \
21632163
OSL_NAMESPACE_BEGIN="namespace OSL {" \
21642164
OSL_NAMESPACE_END="}" \
2165+
OSL_NS_BEGIN="namespace OSL {" \
2166+
OSL_NS_END="}" \
21652167
OSL_CONSTEXPR14=constexpr \
21662168
OSL_CONSTEXPR17=constexpr \
21672169
OSL_CONSTEXPR20=constexpr \

src/include/OSL/Imathx/Imathx.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
// clang-format off
2020

21-
OSL_NAMESPACE_ENTER
21+
OSL_NAMESPACE_BEGIN
2222

2323

2424
// Choose to treat helper functions as static
@@ -494,4 +494,4 @@ det4x4(const Imath::Matrix44<F>& m)
494494
}
495495

496496

497-
OSL_NAMESPACE_EXIT
497+
OSL_NAMESPACE_END

src/include/OSL/accum.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include <list>
1010
#include <stack>
1111

12-
OSL_NAMESPACE_ENTER
12+
OSL_NAMESPACE_BEGIN
1313

1414
class Aov {
1515
public:
@@ -230,4 +230,4 @@ class OSLEXECPUBLIC Accumulator {
230230
};
231231

232232

233-
OSL_NAMESPACE_EXIT
233+
OSL_NAMESPACE_END

src/include/OSL/batched_rendererservices.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
#include <OpenImageIO/ustring.h>
1313

14-
OSL_NAMESPACE_ENTER
14+
OSL_NAMESPACE_BEGIN
1515

1616
// Implementation detail: virtual methods that have a corresponding
1717
// virtual bool is_overridden_* method
@@ -456,4 +456,4 @@ template<int WidthT> class OSLEXECPUBLIC BatchedRendererServices {
456456
};
457457

458458

459-
OSL_NAMESPACE_EXIT
459+
OSL_NAMESPACE_END

src/include/OSL/batched_shaderglobals.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
#include <OSL/shaderglobals.h>
1414

15-
OSL_NAMESPACE_ENTER
15+
OSL_NAMESPACE_BEGIN
1616

1717
namespace pvt {
1818
class BatchedBackendLLVM;
@@ -197,8 +197,7 @@ template<int WidthT> struct alignas(64) BatchedShaderGlobals {
197197
};
198198

199199
#define __OSL_USING_SHADERGLOBALS(WIDTH_OF_OSL_DATA) \
200-
using BatchedShaderGlobals \
201-
= OSL_NAMESPACE::BatchedShaderGlobals<WIDTH_OF_OSL_DATA>;
200+
using BatchedShaderGlobals = OSL::BatchedShaderGlobals<WIDTH_OF_OSL_DATA>;
202201

203202
#undef OSL_USING_DATA_WIDTH
204203
#ifdef __OSL_USING_BATCHED_TEXTURE
@@ -212,4 +211,4 @@ template<int WidthT> struct alignas(64) BatchedShaderGlobals {
212211
__OSL_USING_SHADERGLOBALS(WIDTH_OF_OSL_DATA)
213212
#endif
214213

215-
OSL_NAMESPACE_EXIT
214+
OSL_NAMESPACE_END

src/include/OSL/batched_texture.h

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
#include <OSL/wide.h>
88

9-
OSL_NAMESPACE_ENTER
9+
OSL_NAMESPACE_BEGIN
1010

1111
namespace Tex {
1212

@@ -279,11 +279,10 @@ template<int WidthT> class BatchedTextureOutputs {
279279
Mask<WidthT> m_mask;
280280
};
281281

282-
#define __OSL_USING_BATCHED_TEXTURE(WIDTH_OF_OSL_DATA) \
283-
using BatchedTextureOutputs \
284-
= OSL_NAMESPACE::BatchedTextureOutputs<WIDTH_OF_OSL_DATA>; \
285-
using BatchedTextureOptions \
286-
= OSL_NAMESPACE::BatchedTextureOptions<WIDTH_OF_OSL_DATA>;
282+
#define __OSL_USING_BATCHED_TEXTURE(WIDTH_OF_OSL_DATA) \
283+
using BatchedTextureOutputs \
284+
= OSL::BatchedTextureOutputs<WIDTH_OF_OSL_DATA>; \
285+
using BatchedTextureOptions = OSL::BatchedTextureOptions<WIDTH_OF_OSL_DATA>;
287286

288287
#undef OSL_USING_DATA_WIDTH
289288
#ifdef __OSL_USING_SHADERGLOBALS
@@ -297,4 +296,4 @@ template<int WidthT> class BatchedTextureOutputs {
297296
__OSL_USING_BATCHED_TEXTURE(WIDTH_OF_OSL_DATA)
298297
#endif
299298

300-
OSL_NAMESPACE_EXIT
299+
OSL_NAMESPACE_END

src/include/OSL/device_ptr.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99

1010

11-
OSL_NAMESPACE_ENTER
11+
OSL_NAMESPACE_BEGIN
1212

1313

1414
/// Wrapper class for holding a "device" pointer -- GPU or whatnot. It
@@ -54,4 +54,4 @@ template<class T> class device_ptr {
5454

5555

5656

57-
OSL_NAMESPACE_EXIT
57+
OSL_NAMESPACE_END

src/include/OSL/dual.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#include <OpenImageIO/fmath.h>
1414

1515

16-
OSL_NAMESPACE_ENTER
16+
OSL_NAMESPACE_BEGIN
1717

1818

1919
// Shortcut notation for enable_if trickery
@@ -1367,4 +1367,4 @@ ifloor (const Dual<T,P> &x)
13671367
}
13681368

13691369

1370-
OSL_NAMESPACE_EXIT
1370+
OSL_NAMESPACE_END

src/include/OSL/dual_vec.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#include <OSL/dual.h>
2727
#include <OSL/Imathx/Imathx.h>
2828

29-
OSL_NAMESPACE_ENTER
29+
OSL_NAMESPACE_BEGIN
3030

3131
#if 0 // appears unused
3232
/// Templated trick to be able to derive what type we use to represent
@@ -559,4 +559,4 @@ distance (const Vec3 &a, const Dual<Vec3,P> &b)
559559
return length (a - b);
560560
}
561561

562-
OSL_NAMESPACE_EXIT
562+
OSL_NAMESPACE_END

0 commit comments

Comments
 (0)