Skip to content

Commit c33911b

Browse files
committed
builders now accept StaticString names
The const char* version of name is node [[deprecated]]. This change is only cosmetic, no implementation is changed. This is a first step toward eliminating non literal tags.
1 parent 4e4459e commit c33911b

17 files changed

+154
-1
lines changed

filament/include/filament/BufferObject.h

+13
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <backend/BufferDescriptor.h>
2626

2727
#include <utils/compiler.h>
28+
#include <utils/StaticString.h>
2829

2930
#include <stdint.h>
3031
#include <stddef.h>
@@ -90,9 +91,21 @@ class UTILS_PUBLIC BufferObject : public FilamentAPI {
9091
* @param name A string to identify this BufferObject
9192
* @param len Length of name, should be less than or equal to 128
9293
* @return This Builder, for chaining calls.
94+
* @deprecated Use name(utils::StaticString const&) instead.
9395
*/
96+
UTILS_DEPRECATED
9497
Builder& name(const char* UTILS_NONNULL name, size_t len) noexcept;
9598

99+
/**
100+
* Associate an optional name with this BufferObject for debugging purposes.
101+
*
102+
* name will show in error messages and should be kept as short as possible.
103+
*
104+
* @param name A string literal to identify this BufferObject
105+
* @return This Builder, for chaining calls.
106+
*/
107+
Builder& name(utils::StaticString const& name) noexcept;
108+
96109
/**
97110
* Creates the BufferObject and returns a pointer to it. After creation, the buffer
98111
* object is uninitialized. Use BufferObject::setBuffer() to initialize it.

filament/include/filament/FilamentAPI.h

+7
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <utils/compiler.h>
2121
#include <utils/PrivateImplementation.h>
2222
#include <utils/CString.h>
23+
#include <utils/StaticString.h>
2324

2425
#include <stddef.h>
2526

@@ -61,11 +62,17 @@ UTILS_PUBLIC void builderMakeName(utils::CString& outName, const char* name, siz
6162
template <typename Builder>
6263
class UTILS_PUBLIC BuilderNameMixin {
6364
public:
65+
UTILS_DEPRECATED
6466
Builder& name(const char* name, size_t len) noexcept {
6567
builderMakeName(mName, name, len);
6668
return static_cast<Builder&>(*this);
6769
}
6870

71+
Builder& name(utils::StaticString const& name) noexcept {
72+
builderMakeName(mName, name.data(), name.size());
73+
return static_cast<Builder&>(*this);
74+
}
75+
6976
utils::CString const& getName() const noexcept { return mName; }
7077

7178
private:

filament/include/filament/IndexBuffer.h

+13
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <backend/BufferDescriptor.h>
2727

2828
#include <utils/compiler.h>
29+
#include <utils/StaticString.h>
2930

3031
#include <stdint.h>
3132
#include <stddef.h>
@@ -95,9 +96,21 @@ class UTILS_PUBLIC IndexBuffer : public FilamentAPI {
9596
* @param name A string to identify this IndexBuffer
9697
* @param len Length of name, should be less than or equal to 128
9798
* @return This Builder, for chaining calls.
99+
* @deprecated Use name(utils::StaticString const&) instead.
98100
*/
101+
UTILS_DEPRECATED
99102
Builder& name(const char* UTILS_NONNULL name, size_t len) noexcept;
100103

104+
/**
105+
* Associate an optional name with this IndexBuffer for debugging purposes.
106+
*
107+
* name will show in error messages and should be kept as short as possible.
108+
*
109+
* @param name A string literal to identify this IndexBuffer
110+
* @return This Builder, for chaining calls.
111+
*/
112+
Builder& name(utils::StaticString const& name) noexcept;
113+
101114
/**
102115
* Creates the IndexBuffer object and returns a pointer to it. After creation, the index
103116
* buffer is uninitialized. Use IndexBuffer::setBuffer() to initialize the IndexBuffer.

filament/include/filament/InstanceBuffer.h

+13
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <filament/Engine.h>
2222

2323
#include <utils/compiler.h>
24+
#include <utils/StaticString.h>
2425

2526
#include <math/mathfwd.h>
2627

@@ -82,9 +83,21 @@ class UTILS_PUBLIC InstanceBuffer : public FilamentAPI {
8283
* @param name A string to identify this InstanceBuffer
8384
* @param len Length of name, should be less than or equal to 128
8485
* @return This Builder, for chaining calls.
86+
* @deprecated Use name(utils::StaticString const&) instead.
8587
*/
88+
UTILS_DEPRECATED
8689
Builder& name(const char* UTILS_NONNULL name, size_t len) noexcept;
8790

91+
/**
92+
* Associate an optional name with this InstanceBuffer for debugging purposes.
93+
*
94+
* name will show in error messages and should be kept as short as possible.
95+
*
96+
* @param name A string literal to identify this InstanceBuffer
97+
* @return This Builder, for chaining calls.
98+
*/
99+
Builder& name(utils::StaticString const& name) noexcept;
100+
88101
/**
89102
* Creates the InstanceBuffer object and returns a pointer to it.
90103
*/

filament/include/filament/MorphTargetBuffer.h

+13
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <filament/Engine.h>
2323

2424
#include <utils/compiler.h>
25+
#include <utils/StaticString.h>
2526

2627
#include <math/mathfwd.h>
2728

@@ -75,9 +76,21 @@ class UTILS_PUBLIC MorphTargetBuffer : public FilamentAPI {
7576
* @param name A string to identify this MorphTargetBuffer
7677
* @param len Length of name, should be less than or equal to 128
7778
* @return This Builder, for chaining calls.
79+
* @deprecated Use name(utils::StaticString const&) instead.
7880
*/
81+
UTILS_DEPRECATED
7982
Builder& name(const char* UTILS_NONNULL name, size_t len) noexcept;
8083

84+
/**
85+
* Associate an optional name with this MorphTargetBuffer for debugging purposes.
86+
*
87+
* name will show in error messages and should be kept as short as possible.
88+
*
89+
* @param name A string literal to identify this MorphTargetBuffer
90+
* @return This Builder, for chaining calls.
91+
*/
92+
Builder& name(utils::StaticString const& name) noexcept;
93+
8194
/**
8295
* Creates the MorphTargetBuffer object and returns a pointer to it.
8396
*

filament/include/filament/SkinningBuffer.h

+13
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <filament/RenderableManager.h>
2323

2424
#include <utils/compiler.h>
25+
#include <utils/StaticString.h>
2526

2627
#include <math/mathfwd.h>
2728

@@ -81,9 +82,21 @@ class UTILS_PUBLIC SkinningBuffer : public FilamentAPI {
8182
* @param name A string to identify this SkinningBuffer
8283
* @param len Length of name, should be less than or equal to 128
8384
* @return This Builder, for chaining calls.
85+
* @deprecated Use name(utils::StaticString const&) instead.
8486
*/
87+
UTILS_DEPRECATED
8588
Builder& name(const char* UTILS_NONNULL name, size_t len) noexcept;
8689

90+
/**
91+
* Associate an optional name with this SkinningBuffer for debugging purposes.
92+
*
93+
* name will show in error messages and should be kept as short as possible.
94+
*
95+
* @param name A string literal to identify this SkinningBuffer
96+
* @return This Builder, for chaining calls.
97+
*/
98+
Builder& name(utils::StaticString const& name) noexcept;
99+
87100
/**
88101
* Creates the SkinningBuffer object and returns a pointer to it.
89102
*

filament/include/filament/Stream.h

+13
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <backend/CallbackHandler.h>
2424

2525
#include <utils/compiler.h>
26+
#include <utils/StaticString.h>
2627

2728
#include <stdint.h>
2829

@@ -148,9 +149,21 @@ class UTILS_PUBLIC Stream : public FilamentAPI {
148149
* @param name A string to identify this Stream
149150
* @param len Length of name, should be less than or equal to 128
150151
* @return This Builder, for chaining calls.
152+
* @deprecated Use name(utils::StaticString const&) instead.
151153
*/
154+
UTILS_DEPRECATED
152155
Builder& name(const char* UTILS_NONNULL name, size_t len) noexcept;
153156

157+
/**
158+
* Associate an optional name with this Stream for debugging purposes.
159+
*
160+
* name will show in error messages and should be kept as short as possible.
161+
*
162+
* @param name A string literal to identify this Stream
163+
* @return This Builder, for chaining calls.
164+
*/
165+
Builder& name(utils::StaticString const& name) noexcept;
166+
154167
/**
155168
* Creates the Stream object and returns a pointer to it.
156169
*

filament/include/filament/Texture.h

+14-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <backend/Platform.h>
2727

2828
#include <utils/compiler.h>
29+
#include <utils/StaticString.h>
2930

3031
#include <utility>
3132

@@ -222,8 +223,20 @@ class UTILS_PUBLIC Texture : public FilamentAPI {
222223
* @param name A string to identify this Texture
223224
* @param len Length of name, should be less than or equal to 128
224225
* @return This Builder, for chaining calls.
226+
* @deprecated Use name(utils::StaticString const&) instead.
225227
*/
226-
Builder& name(const char* UTILS_NONNULL name, size_t len) noexcept;
228+
UTILS_DEPRECATED
229+
Builder& name(const char* UTILS_NONNULL name, size_t len) noexcept;
230+
231+
/**
232+
* Associate an optional name with this Texture for debugging purposes.
233+
*
234+
* name will show in error messages and should be kept as short as possible.
235+
*
236+
* @param name A string literal to identify this Texture
237+
* @return This Builder, for chaining calls.
238+
*/
239+
Builder& name(utils::StaticString const& name) noexcept;
227240

228241
/**
229242
* Creates an external texture. The content must be set using setExternalImage().

filament/include/filament/VertexBuffer.h

+13
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <backend/DriverEnums.h>
2727

2828
#include <utils/compiler.h>
29+
#include <utils/StaticString.h>
2930

3031
#include <stddef.h>
3132
#include <stdint.h>
@@ -170,9 +171,21 @@ class UTILS_PUBLIC VertexBuffer : public FilamentAPI {
170171
* @param name A string to identify this VertexBuffer
171172
* @param len Length of name, should be less than or equal to 128
172173
* @return This Builder, for chaining calls.
174+
* @deprecated Use name(utils::StaticString const&) instead.
173175
*/
176+
UTILS_DEPRECATED
174177
Builder& name(const char* UTILS_NONNULL name, size_t len) noexcept;
175178

179+
/**
180+
* Associate an optional name with this VertexBuffer for debugging purposes.
181+
*
182+
* name will show in error messages and should be kept as short as possible.
183+
*
184+
* @param name A string literal to identify this VertexBuffer
185+
* @return This Builder, for chaining calls.
186+
*/
187+
Builder& name(utils::StaticString const& name) noexcept;
188+
176189
/**
177190
* Creates the VertexBuffer object and returns a pointer to it.
178191
*

filament/src/details/BufferObject.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "FilamentAPI-impl.h"
2222

2323
#include <utils/CString.h>
24+
#include <utils/StaticString.h>
2425

2526
namespace filament {
2627

@@ -51,6 +52,10 @@ BufferObject::Builder& BufferObject::Builder::name(const char* name, size_t cons
5152
return BuilderNameMixin::name(name, len);
5253
}
5354

55+
BufferObject::Builder& BufferObject::Builder::name(utils::StaticString const& name) noexcept {
56+
return BuilderNameMixin::name(name);
57+
}
58+
5459
BufferObject* BufferObject::Builder::build(Engine& engine) {
5560
return downcast(engine).createBufferObject(*this);
5661
}

filament/src/details/IndexBuffer.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "FilamentAPI-impl.h"
2222

2323
#include <utils/CString.h>
24+
#include <utils/StaticString.h>
2425

2526
namespace filament {
2627

@@ -51,6 +52,10 @@ IndexBuffer::Builder& IndexBuffer::Builder::name(const char* name, size_t const
5152
return BuilderNameMixin::name(name, len);
5253
}
5354

55+
IndexBuffer::Builder& IndexBuffer::Builder::name(utils::StaticString const& name) noexcept {
56+
return BuilderNameMixin::name(name);
57+
}
58+
5459
IndexBuffer* IndexBuffer::Builder::build(Engine& engine) {
5560
return downcast(engine).createIndexBuffer(*this);
5661
}

filament/src/details/InstanceBuffer.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121

2222
#include "FilamentAPI-impl.h"
2323

24+
#include <utils/StaticString.h>
25+
2426
#include <math/mat3.h>
2527
#include <math/vec3.h>
2628

@@ -54,6 +56,10 @@ InstanceBuffer::Builder& InstanceBuffer::Builder::name(const char* name, size_t
5456
return BuilderNameMixin::name(name, len);
5557
}
5658

59+
InstanceBuffer::Builder& InstanceBuffer::Builder::name(utils::StaticString const& name) noexcept {
60+
return BuilderNameMixin::name(name);
61+
}
62+
5763
InstanceBuffer* InstanceBuffer::Builder::build(Engine& engine) {
5864
FILAMENT_CHECK_PRECONDITION(mImpl->mInstanceCount >= 1) << "instanceCount must be >= 1.";
5965
FILAMENT_CHECK_PRECONDITION(mImpl->mInstanceCount <= engine.getMaxAutomaticInstances())

filament/src/details/MorphTargetBuffer.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <math/norm.h>
2727

2828
#include <utils/CString.h>
29+
#include <utils/StaticString.h>
2930

3031
namespace filament {
3132

@@ -59,6 +60,10 @@ MorphTargetBuffer::Builder& MorphTargetBuffer::Builder::name(const char* name, s
5960
return BuilderNameMixin::name(name, len);
6061
}
6162

63+
MorphTargetBuffer::Builder& MorphTargetBuffer::Builder::name(utils::StaticString const& name) noexcept {
64+
return BuilderNameMixin::name(name);
65+
}
66+
6267
MorphTargetBuffer* MorphTargetBuffer::Builder::build(Engine& engine) {
6368
return downcast(engine).createMorphTargetBuffer(*this);
6469
}

filament/src/details/SkinningBuffer.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <math/mat4.h>
2727

2828
#include <utils/CString.h>
29+
#include <utils/StaticString.h>
2930

3031
#include <string.h>
3132
#include <stddef.h>
@@ -64,6 +65,10 @@ SkinningBuffer::Builder& SkinningBuffer::Builder::name(const char* name, size_t
6465
return BuilderNameMixin::name(name, len);
6566
}
6667

68+
SkinningBuffer::Builder& SkinningBuffer::Builder::name(utils::StaticString const& name) noexcept {
69+
return BuilderNameMixin::name(name);
70+
}
71+
6772
SkinningBuffer* SkinningBuffer::Builder::build(Engine& engine) {
6873
return downcast(engine).createSkinningBuffer(*this);
6974
}

filament/src/details/Stream.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <backend/PixelBufferDescriptor.h>
2525

2626
#include <utils/CString.h>
27+
#include <utils/StaticString.h>
2728
#include <utils/Panic.h>
2829
#include <filament/Stream.h>
2930

@@ -65,6 +66,10 @@ Stream::Builder& Stream::Builder::name(const char* name, size_t const len) noexc
6566
return BuilderNameMixin::name(name, len);
6667
}
6768

69+
Stream::Builder& Stream::Builder::name(utils::StaticString const& name) noexcept {
70+
return BuilderNameMixin::name(name);
71+
}
72+
6873
Stream* Stream::Builder::build(Engine& engine) {
6974
return downcast(engine).createStream(*this);
7075
}

0 commit comments

Comments
 (0)