Cleanup: Remove C++ ifdef checks in C++ headers

Pull Request: https://projects.blender.org/blender/blender/pulls/119900
This commit is contained in:
Hans Goudey 2024-03-26 04:56:03 +01:00 committed by Hans Goudey
parent 893130e6fe
commit fc0d8ba012
21 changed files with 14 additions and 128 deletions

@ -10,10 +10,6 @@
#include "GHOST_Types.h"
#ifdef __cplusplus
extern "C" {
#endif
GHOST_DECLARE_HANDLE(GHOST_SystemPathsHandle);
/**
@ -63,7 +59,3 @@ extern const char *GHOST_getBinaryDir();
* Add the file to the operating system most recently used files
*/
extern void GHOST_addToSystemRecentFiles(const char *filepath);
#ifdef __cplusplus
}
#endif

@ -8,15 +8,13 @@
#pragma once
#ifdef __cplusplus
# undef wl_array_for_each
#undef wl_array_for_each
/**
* This macro causes a warning for C++ code, define our own.
* See: https://gitlab.freedesktop.org/wayland/wayland/-/issues/34
*/
# define WL_ARRAY_FOR_EACH(pos, array) \
for (pos = (decltype(pos))((array)->data); \
reinterpret_cast<const char *>(pos) < \
(reinterpret_cast<const char *>((array)->data) + (array)->size); \
(pos)++)
#endif
#define WL_ARRAY_FOR_EACH(pos, array) \
for (pos = (decltype(pos))((array)->data); \
reinterpret_cast<const char *>(pos) < \
(reinterpret_cast<const char *>((array)->data) + (array)->size); \
(pos)++)

@ -254,8 +254,6 @@ void BKE_defvert_normalize_lock_map(MDeformVert *dvert,
void BKE_defvert_extract_vgroup_to_vertweights(
const MDeformVert *dvert, int defgroup, int verts_num, bool invert_vgroup, float *r_weights);
#ifdef __cplusplus
/**
* The following three make basic interpolation,
* using temp vert_weights array to avoid looking up same weight several times.
@ -283,7 +281,6 @@ void BKE_defvert_extract_vgroup_to_faceweights(const MDeformVert *dvert,
blender::OffsetIndices<int> faces,
bool invert_vgroup,
float *r_weights);
#endif
void BKE_defvert_weight_to_rgb(float r_rgb[3], float weight);

@ -86,7 +86,6 @@ typedef struct bNodeSocketTemplate {
/* Use `void *` for callbacks that require C++. This is rather ugly, but works well for now. This
* would not be necessary if we would use bNodeSocketType and bNodeType only in C++ code.
* However, achieving this requires quite a few changes currently. */
#ifdef __cplusplus
namespace blender {
class CPPType;
namespace nodes {
@ -106,7 +105,6 @@ class ShaderNode;
} // namespace realtime_compositor
} // namespace blender
using CPPTypeHandle = blender::CPPType;
using NodeMultiFunctionBuildFunction = void (*)(blender::nodes::NodeMultiFunctionBuilder &builder);
using NodeGeometryExecFunction = void (*)(blender::nodes::GeoNodeExecParams params);
using NodeDeclareFunction = void (*)(blender::nodes::NodeDeclarationBuilder &builder);
@ -130,23 +128,6 @@ using NodeGetCompositorShaderNodeFunction =
blender::realtime_compositor::ShaderNode *(*)(blender::nodes::DNode node);
using NodeExtraInfoFunction = void (*)(blender::nodes::NodeExtraInfoParams &params);
#else
typedef void *NodeGetCompositorOperationFunction;
typedef void *NodeGetCompositorShaderNodeFunction;
typedef void *NodeMultiFunctionBuildFunction;
typedef void *NodeGeometryExecFunction;
typedef void *NodeDeclareFunction;
typedef void *NodeDeclareDynamicFunction;
typedef void *NodeGatherSocketLinkOperationsFunction;
typedef void *NodeGatherAddOperationsFunction;
typedef void *SocketGetCPPTypeFunction;
typedef void *SocketGetGeometryNodesCPPTypeFunction;
typedef void *SocketGetGeometryNodesCPPValueFunction;
typedef void *SocketGetCPPValueFunction;
typedef void *NodeExtraInfoFunction;
typedef struct CPPTypeHandle CPPTypeHandle;
#endif
/**
* \brief Defines a socket type.
*
@ -201,11 +182,11 @@ typedef struct bNodeSocketType {
void (*free_self)(struct bNodeSocketType *stype);
/* Return the CPPType of this socket. */
const CPPTypeHandle *base_cpp_type;
const blender::CPPType *base_cpp_type;
/* Get the value of this socket in a generic way. */
SocketGetCPPValueFunction get_base_cpp_value;
/* Get geometry nodes cpp type. */
const CPPTypeHandle *geometry_nodes_cpp_type;
const blender::CPPType *geometry_nodes_cpp_type;
/* Get geometry nodes cpp value. */
SocketGetGeometryNodesCPPValueFunction get_geometry_nodes_cpp_value;
/* Default value for this socket type. */
@ -379,7 +360,7 @@ typedef struct bNodeType {
* the node. In this case, the static declaration is mostly just a hint, and does not have to
* match with the final node.
*/
NodeDeclarationHandle *static_declaration;
blender::nodes::NodeDeclaration *static_declaration;
/**
* Add to the list of search names and operations gathered by node link drag searching.

@ -186,7 +186,7 @@ class bNodeSocketRuntime : NonCopyable, NonMovable {
* data. It has to be updated when the node declaration changes. Access can be allowed by using
* #AllowUsingOutdatedInfo.
*/
const SocketDeclarationHandle *declaration = nullptr;
const nodes::SocketDeclaration *declaration = nullptr;
/** #eNodeTreeChangedFlag. */
uint32_t changed_flag = 0;
@ -253,7 +253,7 @@ class bNodeRuntime : NonCopyable, NonMovable {
* intended to change though. Especially when nodes become more dynamic with respect to how many
* sockets they have.
*/
NodeDeclarationHandle *declaration = nullptr;
nodes::NodeDeclaration *declaration = nullptr;
/** #eNodeTreeChangedFlag. */
uint32_t changed_flag = 0;

@ -12,10 +12,6 @@
#include "BLI_sys_types.h"
#ifdef __cplusplus
extern "C" {
#endif
/* Hardcoded for until GPU shaders are automatically generated, then we will have a more
* programmatic way of detecting this. */
#define MAX_GPU_SUBDIV_SSBOS 12
@ -96,7 +92,3 @@ Subdiv *BKE_subsurf_modifier_subdiv_descriptor_ensure(SubsurfRuntimeData *runtim
* which should be used to check if the modifier is enabled.
*/
int BKE_subsurf_modifier_eval_required_mode(bool is_final_render, bool is_edit_mode);
#ifdef __cplusplus
}
#endif

@ -463,11 +463,7 @@ enum {
/* Assignment from a void* to a typed pointer is not allowed in C++,
* casting the LHS to void works fine though.
*/
#ifdef __cplusplus
# define BM_CHECK_TYPE_ELEM_ASSIGN(ele) (BM_CHECK_TYPE_ELEM(ele)), *((void **)&ele)
#else
# define BM_CHECK_TYPE_ELEM_ASSIGN(ele) (BM_CHECK_TYPE_ELEM(ele)), ele
#endif
#define BM_CHECK_TYPE_ELEM_ASSIGN(ele) (BM_CHECK_TYPE_ELEM(ele)), *((void **)&ele)
/** #BMHeader.hflag (char) */
enum {

@ -219,8 +219,6 @@ void *BMO_iter_as_arrayN(BMOpSlot slot_args[BMO_OP_MAX_SLOTS],
void **stack_array,
int stack_array_size);
#ifdef __cplusplus
int BM_iter_mesh_bitmap_from_filter(char itype,
BMesh *bm,
blender::MutableBitSpan bitmap,
@ -234,8 +232,6 @@ int BM_iter_mesh_bitmap_from_filter_tessface(BMesh *bm,
bool (*test_fn)(BMFace *, void *user_data),
void *user_data);
#endif
/**
* \brief Elem Iter Flag Count
*

@ -20,10 +20,6 @@ struct TextLine;
struct bContext;
struct wmOperatorType;
#ifdef __cplusplus
extern "C" {
#endif
/* `text_draw.cc` */
void draw_text_main(SpaceText *st, ARegion *region);
@ -181,11 +177,7 @@ void TEXT_OT_autocomplete(wmOperatorType *ot);
/* `space_text.cc` */
extern const char *text_context_dir[]; /* doc access */
#ifdef __cplusplus
}
#endif
extern "C" const char *text_context_dir[]; /* doc access */
namespace blender::ed::text {
struct SpaceText_Runtime {

@ -12,9 +12,7 @@
#pragma once
#ifdef __cplusplus
# include <string>
#endif
#include <string>
#include "BLI_assert.h"
#include "BLI_utildefines.h"
@ -192,7 +190,6 @@ struct GPUSamplerState {
/** Specifies how the GPUSamplerState structure should be interpreted when passed around. */
GPUSamplerStateType type : 8;
#ifdef __cplusplus
/**
* Constructs a sampler state with default filtering and extended extend in both x and y axis.
* See the documentation on GPU_SAMPLER_FILTERING_DEFAULT and GPU_SAMPLER_EXTEND_MODE_EXTEND for
@ -387,18 +384,8 @@ struct GPUSamplerState {
this->extend_yz == rhs.extend_yz && this->custom_type == rhs.custom_type &&
this->type == rhs.type;
}
#endif
};
#ifndef __cplusplus
/** Identical to GPUSamplerState::default_sampler for non C++ users. */
static const GPUSamplerState GPU_SAMPLER_DEFAULT = {GPU_SAMPLER_FILTERING_DEFAULT,
GPU_SAMPLER_EXTEND_MODE_EXTEND,
GPU_SAMPLER_EXTEND_MODE_EXTEND,
GPU_SAMPLER_CUSTOM_COMPARE,
GPU_SAMPLER_STATE_TYPE_PARAMETERS};
#endif
/** \} */
/* -------------------------------------------------------------------- */

@ -10,10 +10,6 @@
#include "IMB_imbuf.hh"
#ifdef __cplusplus
extern "C" {
#endif
/* -------------------------------------------------------------------- */
/** \name Generic File Type
* \{ */
@ -297,7 +293,3 @@ ImBuf *imb_load_filepath_thumbnail_svg(const char *filepath,
size_t *r_height);
/** \} */
#ifdef __cplusplus
};
#endif

@ -14,8 +14,6 @@
OIIO_NAMESPACE_USING
using namespace blender::imbuf;
extern "C" {
bool imb_is_a_bmp(const uchar *mem, size_t size)
{
return imb_oiio_check(mem, size, "bmp");
@ -42,4 +40,3 @@ bool imb_save_bmp(ImBuf *ibuf, const char *filepath, int flags)
return imb_oiio_write(ctx, filepath, file_spec);
}
}

@ -28,10 +28,6 @@
OIIO_NAMESPACE_USING
using namespace blender::imbuf;
using std::unique_ptr;
extern "C" {
static void LoadDXTCImage(ImBuf *ibuf, Filesystem::IOMemReader &mem_reader);
void imb_init_dds()
@ -336,4 +332,3 @@ static void LoadDXTCImage(ImBuf *ibuf, Filesystem::IOMemReader &mem_reader)
FlipDXTCImage(ibuf);
}
}
}

@ -15,7 +15,6 @@
OIIO_NAMESPACE_USING
using namespace blender::imbuf;
extern "C" {
bool imb_is_a_dpx(const uchar *mem, size_t size)
{
return imb_oiio_check(mem, size, "dpx");
@ -85,4 +84,3 @@ bool imb_save_dpx(ImBuf *ibuf, const char *filepath, int flags)
return imb_oiio_write(ctx, filepath, file_spec);
}
}

@ -14,8 +14,6 @@
OIIO_NAMESPACE_USING
using namespace blender::imbuf;
extern "C" {
bool imb_is_a_hdr(const uchar *mem, size_t size)
{
return imb_oiio_check(mem, size, "hdr");
@ -53,4 +51,3 @@ bool imb_save_hdr(ImBuf *ibuf, const char *filepath, int flags)
return imb_oiio_write(ctx, filepath, file_spec);
}
}

@ -15,8 +15,6 @@
OIIO_NAMESPACE_USING
using namespace blender::imbuf;
extern "C" {
bool imb_is_a_png(const uchar *mem, size_t size)
{
return imb_oiio_check(mem, size, "png");
@ -67,4 +65,3 @@ bool imb_save_png(ImBuf *ibuf, const char *filepath, int flags)
return imb_oiio_write(ctx, filepath, file_spec);
}
}

@ -15,8 +15,6 @@
OIIO_NAMESPACE_USING
using namespace blender::imbuf;
extern "C" {
bool imb_is_a_psd(const uchar *mem, size_t size)
{
return imb_oiio_check(mem, size, "psd");
@ -34,4 +32,3 @@ ImBuf *imb_load_psd(const uchar *mem, size_t size, int flags, char colorspace[IM
return imb_oiio_read(ctx, config, colorspace, spec);
}
}

@ -14,8 +14,6 @@
OIIO_NAMESPACE_USING
using namespace blender::imbuf;
extern "C" {
bool imb_is_a_tga(const uchar *mem, size_t size)
{
return imb_oiio_check(mem, size, "tga");
@ -42,4 +40,3 @@ bool imb_save_tga(ImBuf *ibuf, const char *filepath, int flags)
return imb_oiio_write(ctx, filepath, file_spec);
}
}

@ -15,8 +15,6 @@
OIIO_NAMESPACE_USING
using namespace blender::imbuf;
extern "C" {
bool imb_is_a_tiff(const uchar *mem, size_t size)
{
return imb_oiio_check(mem, size, "tif");
@ -75,4 +73,3 @@ bool imb_save_tiff(ImBuf *ibuf, const char *filepath, int flags)
return imb_oiio_write(ctx, filepath, file_spec);
}
}

@ -43,15 +43,11 @@ class bNodeTreeZone;
namespace blender::bke {
struct RuntimeNodeEnumItems;
} // namespace blender::bke
using NodeDeclarationHandle = blender::nodes::NodeDeclaration;
using SocketDeclarationHandle = blender::nodes::SocketDeclaration;
using bNodeTreeRuntimeHandle = blender::bke::bNodeTreeRuntime;
using bNodeRuntimeHandle = blender::bke::bNodeRuntime;
using bNodeSocketRuntimeHandle = blender::bke::bNodeSocketRuntime;
using RuntimeNodeEnumItemsHandle = blender::bke::RuntimeNodeEnumItems;
#else
typedef struct NodeDeclarationHandle NodeDeclarationHandle;
typedef struct SocketDeclarationHandle SocketDeclarationHandle;
typedef struct bNodeTreeRuntimeHandle bNodeTreeRuntimeHandle;
typedef struct bNodeRuntimeHandle bNodeRuntimeHandle;
typedef struct bNodeSocketRuntimeHandle bNodeSocketRuntimeHandle;

@ -16,10 +16,6 @@
#include "RE_texture.h"
#ifdef __cplusplus
extern "C" {
#endif
struct bNodeThreadStack;
struct TexCallData {
@ -90,7 +86,3 @@ bNodeTreeExec *ntreeTexBeginExecTree_internal(bNodeExecContext *context,
bNodeTree *ntree,
bNodeInstanceKey parent_key);
void ntreeTexEndExecTree_internal(bNodeTreeExec *exec);
#ifdef __cplusplus
}
#endif