Skip to content

Commit

Permalink
Make public headers C++-compatible
Browse files Browse the repository at this point in the history
Allow `#include <SheenBidi.h>` in C++ without having
to wrap it in `extern "C"`.
  • Loading branch information
glebm committed Feb 28, 2025
1 parent c44eb11 commit 5d1135d
Show file tree
Hide file tree
Showing 25 changed files with 106 additions and 21 deletions.
8 changes: 8 additions & 0 deletions Headers/SBAlgorithm.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
#include "SBCodepointSequence.h"
#include "SBParagraph.h"

#ifdef __cplusplus
extern "C" {
#endif

typedef struct _SBAlgorithm *SBAlgorithmRef;

/**
Expand Down Expand Up @@ -116,4 +120,8 @@ SBAlgorithmRef SBAlgorithmRetain(SBAlgorithmRef algorithm);
*/
void SBAlgorithmRelease(SBAlgorithmRef algorithm);

#ifdef __cplusplus
}
#endif

#endif
8 changes: 8 additions & 0 deletions Headers/SBBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
#include <stddef.h>
#include <stdint.h>

#ifdef __cplusplus
extern "C" {
#endif

/**
* A type to represent an 8-bit signed integer.
*/
Expand Down Expand Up @@ -116,4 +120,8 @@ typedef SBUInt8 SBLevel;
*/
#define SBLevelDefaultRTL 0xFD

#ifdef __cplusplus
}
#endif

#endif
8 changes: 8 additions & 0 deletions Headers/SBBidiType.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@

#include "SBBase.h"

#ifdef __cplusplus
extern "C" {
#endif

/**
* Constants that specify the bidirectional types of a character.
*/
Expand Down Expand Up @@ -78,4 +82,8 @@ typedef SBUInt8 SBBidiType;
*/
#define SBBidiTypeIsFormat(t) SBUInt8InRange(t, SBBidiTypeLRI, SBBidiTypePDF)

#ifdef __cplusplus
}
#endif

#endif
8 changes: 8 additions & 0 deletions Headers/SBCodepoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
#include "SBGeneralCategory.h"
#include "SBScript.h"

#ifdef __cplusplus
extern "C" {
#endif

/**
* A type to represent a unicode code point.
*/
Expand Down Expand Up @@ -160,4 +164,8 @@ SBCodepoint SBCodepointDecodeNextFromUTF16(const SBUInt16 *buffer, SBUInteger le
*/
SBCodepoint SBCodepointDecodePreviousFromUTF16(const SBUInt16 *buffer, SBUInteger length, SBUInteger *stringIndex);

#ifdef __cplusplus
}
#endif

#endif
8 changes: 8 additions & 0 deletions Headers/SBCodepointSequence.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
#include "SBBase.h"
#include "SBCodepoint.h"

#ifdef __cplusplus
extern "C" {
#endif

enum {
SBStringEncodingUTF8 = 0, /**< An 8-bit representation of Unicode code points. */
SBStringEncodingUTF16 = 1, /**< 16-bit UTF encoding in native endianness. */
Expand Down Expand Up @@ -63,4 +67,8 @@ SBCodepoint SBCodepointSequenceGetCodepointBefore(const SBCodepointSequence *cod
SBCodepoint SBCodepointSequenceGetCodepointAt(const SBCodepointSequence *codepointSequence,
SBUInteger *stringIndex);

#ifdef __cplusplus
}
#endif

#endif
8 changes: 8 additions & 0 deletions Headers/SBGeneralCategory.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@

#include "SBBase.h"

#ifdef __cplusplus
extern "C" {
#endif

/**
* Constants that specify the general category of a character.
*/
Expand Down Expand Up @@ -103,4 +107,8 @@ typedef SBUInt8 SBGeneralCategory;
*/
#define SBGeneralCategoryIsOther(gc) SBUInt8InRange(gc, SBGeneralCategoryCC, SBGeneralCategoryCN)

#ifdef __cplusplus
}
#endif

#endif
8 changes: 8 additions & 0 deletions Headers/SBLine.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
#include "SBBase.h"
#include "SBRun.h"

#ifdef __cplusplus
extern "C" {
#endif

typedef struct _SBLine *SBLineRef;

/**
Expand Down Expand Up @@ -81,4 +85,8 @@ SBLineRef SBLineRetain(SBLineRef line);
*/
void SBLineRelease(SBLineRef line);

#ifdef __cplusplus
}
#endif

#endif
8 changes: 8 additions & 0 deletions Headers/SBMirrorLocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
#include "SBCodepoint.h"
#include "SBLine.h"

#ifdef __cplusplus
extern "C" {
#endif

typedef struct _SBMirrorLocator *SBMirrorLocatorRef;

/**
Expand Down Expand Up @@ -100,4 +104,8 @@ SBMirrorLocatorRef SBMirrorLocatorRetain(SBMirrorLocatorRef locator);
*/
void SBMirrorLocatorRelease(SBMirrorLocatorRef locator);

#ifdef __cplusplus
}
#endif

#endif
8 changes: 8 additions & 0 deletions Headers/SBParagraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
#include "SBBase.h"
#include "SBLine.h"

#ifdef __cplusplus
extern "C" {
#endif

typedef struct _SBParagraph *SBParagraphRef;

/**
Expand Down Expand Up @@ -97,4 +101,8 @@ SBParagraphRef SBParagraphRetain(SBParagraphRef paragraph);
*/
void SBParagraphRelease(SBParagraphRef paragraph);

#ifdef __cplusplus
}
#endif

#endif
8 changes: 8 additions & 0 deletions Headers/SBRun.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@

#include "SBBase.h"

#ifdef __cplusplus
extern "C" {
#endif

/**
* A structure containing the information of a sequence of characters having the same embedding
* level.
Expand All @@ -29,4 +33,8 @@ typedef struct _SBRun {
SBLevel level; /**< The embedding level of the run. */
} SBRun;

#ifdef __cplusplus
}
#endif

#endif
8 changes: 8 additions & 0 deletions Headers/SBScript.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@

#include "SBBase.h"

#ifdef __cplusplus
extern "C" {
#endif

/**
* Constants that specify the script of a character.
*/
Expand Down Expand Up @@ -264,4 +268,8 @@ typedef SBUInt8 SBScript;
*/
SBUInt32 SBScriptGetOpenTypeTag(SBScript script);

#ifdef __cplusplus
}
#endif

#endif
8 changes: 8 additions & 0 deletions Headers/SBScriptLocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
#include "SBCodepointSequence.h"
#include "SBScript.h"

#ifdef __cplusplus
extern "C" {
#endif

typedef struct _SBScriptLocator *SBScriptLocatorRef;

/**
Expand Down Expand Up @@ -98,4 +102,8 @@ SBScriptLocatorRef SBScriptLocatorRetain(SBScriptLocatorRef locator);
*/
void SBScriptLocatorRelease(SBScriptLocatorRef locator);

#ifdef __cplusplus
}
#endif

#endif
2 changes: 0 additions & 2 deletions Tools/Tester/AlgorithmTester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@
#include <string>
#include <vector>

extern "C" {
#include <SheenBidi.h>
}

#include <Parser/BidiTest.h>
#include <Parser/BidiBrackets.h>
Expand Down
2 changes: 0 additions & 2 deletions Tools/Tester/AlgorithmTester.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@
#include <cstdint>
#include <vector>

extern "C" {
#include <SheenBidi.h>
}

#include <Parser/BidiTest.h>
#include <Parser/BidiCharacterTest.h>
Expand Down
3 changes: 2 additions & 1 deletion Tools/Tester/BidiTypeLookupTester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@
* limitations under the License.
*/

extern "C" {
#include <Headers/SBBase.h>
#include <Headers/SBBidiType.h>
#include <Headers/SBConfig.h>

extern "C" {
#include <Source/BidiTypeLookup.h>
}

Expand Down
3 changes: 2 additions & 1 deletion Tools/Tester/BracketLookupTester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
* limitations under the License.
*/

extern "C" {
#include <Headers/SBBase.h>
#include <Headers/SBConfig.h>

extern "C" {
#include <Source/BracketType.h>
#include <Source/PairingLookup.h>
}
Expand Down
2 changes: 0 additions & 2 deletions Tools/Tester/CodepointSequenceTester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@
* limitations under the License.
*/

extern "C" {
#include <SBBase.h>
#include <SBCodepointSequence.h>
}

#include <cassert>
#include <vector>
Expand Down
2 changes: 0 additions & 2 deletions Tools/Tester/Configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
* limitations under the License.
*/

extern "C" {
#include <SBConfig.h>
}

#include "Configuration.h"

Expand Down
3 changes: 2 additions & 1 deletion Tools/Tester/GeneralCategoryLookupTester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@
* limitations under the License.
*/

extern "C" {
#include <Headers/SBBase.h>
#include <Headers/SBConfig.h>
#include <Headers/SBGeneralCategory.h>

extern "C" {
#include <Source/GeneralCategoryLookup.h>
}

Expand Down
3 changes: 2 additions & 1 deletion Tools/Tester/MirrorLookupTester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
* limitations under the License.
*/

extern "C" {
#include <Headers/SBBase.h>
#include <Headers/SBConfig.h>

extern "C" {
#include <Source/PairingLookup.h>
}

Expand Down
2 changes: 0 additions & 2 deletions Tools/Tester/ScriptLocatorTester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@
* limitations under the License.
*/

extern "C" {
#include <Headers/SBBase.h>
#include <Headers/SBCodepointSequence.h>
#include <Headers/SBScript.h>
#include <Headers/SBScriptLocator.h>
}

#include <cassert>
#include <string>
Expand Down
3 changes: 2 additions & 1 deletion Tools/Tester/ScriptLookupTester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
* limitations under the License.
*/

extern "C" {
#include <Headers/SBBase.h>
#include <Headers/SBConfig.h>

extern "C" {
#include <Source/ScriptLookup.h>
}

Expand Down
2 changes: 0 additions & 2 deletions Tools/Tester/Utilities/Convert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@
* limitations under the License.
*/

extern "C" {
#include <Headers/SBBidiType.h>
#include <Headers/SBGeneralCategory.h>
#include <Headers/SBScript.h>
}

#include <cstdint>
#include <map>
Expand Down
2 changes: 0 additions & 2 deletions Tools/Tester/Utilities/Convert.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@
#include <cstdint>
#include <string>

extern "C" {
#include <Headers/SBBidiType.h>
#include <Headers/SBGeneralCategory.h>
#include <Headers/SBScript.h>
}

namespace SheenBidi {
namespace Tester {
Expand Down
2 changes: 0 additions & 2 deletions Tools/Tester/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
* limitations under the License.
*/

extern "C" {
#include <Headers/SheenBidi.h>
}

#include <iostream>

Expand Down

0 comments on commit 5d1135d

Please sign in to comment.