Commit 55d3f8352a499f9d79e82e61a0d0b1675768664b

sammy 2008-04-15T09:53:27

* Added ftglDestroyFont() destructor for the C bindings. * Remove useless "#ifdef __cplusplus" constructs from .cpp files.

diff --git a/include/FTFont.h b/include/FTFont.h
index 2c0ff8c..49d7ee1 100644
--- a/include/FTFont.h
+++ b/include/FTFont.h
@@ -372,6 +372,8 @@ namespace C {
 
 typedef struct FTGLfont FTGLfont;
 
+FTGL_EXPORT void ftglDestroyFont(FTGLfont*);
+
 FTGL_EXPORT int ftglAttachFile (FTGLfont*, const char*);
 FTGL_EXPORT int ftglAttachData (FTGLfont*, const unsigned char *, size_t);
 
diff --git a/include/FTGLBitmapFont.h b/include/FTGLBitmapFont.h
index c81dba5..34d1ba8 100644
--- a/include/FTGLBitmapFont.h
+++ b/include/FTGLBitmapFont.h
@@ -104,7 +104,7 @@ class FTGL_EXPORT FTGLBitmapFont : public FTFont
 extern "C" {
 namespace C {
 #endif
-FTGL_EXPORT FTGLfont *ftglBitmapFontMake(const char *fontname);
+FTGL_EXPORT FTGLfont *ftglCreateBitmapFont(const char *fontname);
 #ifdef __cplusplus
 }
 }
diff --git a/include/FTGLExtrdFont.h b/include/FTGLExtrdFont.h
index 54c4a9d..51fcefc 100644
--- a/include/FTGLExtrdFont.h
+++ b/include/FTGLExtrdFont.h
@@ -101,7 +101,7 @@ class FTGL_EXPORT FTGLExtrdFont : public FTFont
 extern "C" {
 namespace C {
 #endif
-FTGL_EXPORT FTGLfont *ftglExtrdFontMake(const char *fontname);
+FTGL_EXPORT FTGLfont *ftglCreateExtrdFont(const char *fontname);
 #ifdef __cplusplus
 }
 }
diff --git a/include/FTGLOutlineFont.h b/include/FTGLOutlineFont.h
index a89e0fb..cea153e 100644
--- a/include/FTGLOutlineFont.h
+++ b/include/FTGLOutlineFont.h
@@ -104,7 +104,7 @@ namespace C {
 extern "C" {
 #endif
 
-FTGL_EXPORT FTGLfont *ftglOutlineFontMake(const char *fontname);
+FTGL_EXPORT FTGLfont *ftglCreateOutlineFont(const char *fontname);
 
 #ifdef __cplusplus
 }
diff --git a/include/FTGLPixmapFont.h b/include/FTGLPixmapFont.h
index dacbbe9..577000b 100644
--- a/include/FTGLPixmapFont.h
+++ b/include/FTGLPixmapFont.h
@@ -104,7 +104,7 @@ class FTGL_EXPORT FTGLPixmapFont : public FTFont
 extern "C" {
 namespace C {
 #endif
-FTGL_EXPORT FTGLfont *ftglPixmapFontMake(const char *fontname);
+FTGL_EXPORT FTGLfont *ftglCreatePixmapFont(const char *fontname);
 #ifdef __cplusplus
 }
 }
diff --git a/include/FTGLPolygonFont.h b/include/FTGLPolygonFont.h
index 25fa4ea..8abfaa0 100644
--- a/include/FTGLPolygonFont.h
+++ b/include/FTGLPolygonFont.h
@@ -89,7 +89,7 @@ class FTGL_EXPORT FTGLPolygonFont : public FTFont
 extern "C" {
 namespace C {
 #endif
-FTGL_EXPORT FTGLfont *ftglPolygonFontMake(const char *fontname);
+FTGL_EXPORT FTGLfont *ftglCreatePolygonFont(const char *fontname);
 #ifdef __cplusplus
 }
 }
diff --git a/include/FTGLTextureFont.h b/include/FTGLTextureFont.h
index e537b6b..0c4f9e2 100644
--- a/include/FTGLTextureFont.h
+++ b/include/FTGLTextureFont.h
@@ -187,7 +187,7 @@ class  FTGL_EXPORT FTGLTextureFont : public FTFont
 extern "C" {
 namespace C {
 #endif
-FTGL_EXPORT FTGLfont *ftglTextureFontMake(const char *fontname);
+FTGL_EXPORT FTGLfont *ftglCreateTextureFont(const char *fontname);
 #ifdef __cplusplus
 }
 }
diff --git a/src/FTGLBitmapFont.cpp b/src/FTGLBitmapFont.cpp
index 86d9c79..5ec1c7a 100644
--- a/src/FTGLBitmapFont.cpp
+++ b/src/FTGLBitmapFont.cpp
@@ -102,17 +102,13 @@ void FTGLBitmapFont::Render( const wchar_t* string)
     glPopClientAttrib();
 }
 
-#ifdef __cplusplus
-extern "C" {
-namespace C {
-#endif
-extern "C" FTGLfont* ftglBitmapFontMake(const char *fontname)
+
+namespace C
 {
-    FTGLfont *ftgl = createFTFont(Bitmap, fontname);
-    return ftgl;
-}
-#ifdef __cplusplus
-}
+    extern "C" FTGLfont* ftglCreateBitmapFont(const char *fontname)
+    {
+        FTGLfont *ftgl = createFTFont(Bitmap, fontname);
+        return ftgl;
+    }
 }
-#endif
 
diff --git a/src/FTGLExtrdFont.cpp b/src/FTGLExtrdFont.cpp
index 84a4862..9a2b3f5 100644
--- a/src/FTGLExtrdFont.cpp
+++ b/src/FTGLExtrdFont.cpp
@@ -70,17 +70,13 @@ FTGlyph* FTGLExtrdFont::MakeGlyph( unsigned int glyphIndex)
     return NULL;
 }
 
-#ifdef __cplusplus
-extern "C" {
-namespace C {
-#endif
-extern "C" FTGLfont* ftglExtrdFontMake(const char *fontname)
+
+namespace C
 {
-    FTGLfont *ftgl = createFTFont(Extrude, fontname);
-    return ftgl;
-}
-#ifdef __cplusplus
-}
+    extern "C" FTGLfont* ftglCreateExtrdFont(const char *fontname)
+    {
+        FTGLfont *ftgl = createFTFont(Extrude, fontname);
+        return ftgl;
+    }
 }
-#endif
 
diff --git a/src/FTGLOutlineFont.cpp b/src/FTGLOutlineFont.cpp
index c17ece0..cd78435 100644
--- a/src/FTGLOutlineFont.cpp
+++ b/src/FTGLOutlineFont.cpp
@@ -102,16 +102,13 @@ void FTGLOutlineFont::Render( const wchar_t* string)
     glPopAttrib();
 }
 
-#ifdef __cplusplus
-extern "C" {
-namespace C {
-#endif
-extern "C" FTGLfont* ftglOutlineFontMake(const char *fontname)
+
+namespace C
 {
-    FTGLfont *ftgl = createFTFont(Outline, fontname);
-    return ftgl;
-}
-#ifdef __cplusplus
-}
+    extern "C" FTGLfont* ftglCreateOutlineFont(const char *fontname)
+    {
+        FTGLfont *ftgl = createFTFont(Outline, fontname);
+        return ftgl;
+    }
 }
-#endif
+
diff --git a/src/FTGLPixmapFont.cpp b/src/FTGLPixmapFont.cpp
index 96159fe..71253ae 100644
--- a/src/FTGLPixmapFont.cpp
+++ b/src/FTGLPixmapFont.cpp
@@ -118,17 +118,13 @@ void FTGLPixmapFont::Render( const wchar_t* string)
     glPopAttrib();
 }
 
-#ifdef __cplusplus
-extern "C" {
-namespace C {
-#endif
-extern "C" FTGLfont* ftglPixmapFontMake(const char *fontname)
+
+namespace C
 {
-    FTGLfont *ftgl = createFTFont(Pixmap, fontname);
-    return ftgl;
-}
-#ifdef __cplusplus
-}
+    extern "C" FTGLfont* ftglCreatePixmapFont(const char *fontname)
+    {
+        FTGLfont *ftgl = createFTFont(Pixmap, fontname);
+        return ftgl;
+    }
 }
-#endif
 
diff --git a/src/FTGLPolygonFont.cpp b/src/FTGLPolygonFont.cpp
index a50faeb..0e128ff 100644
--- a/src/FTGLPolygonFont.cpp
+++ b/src/FTGLPolygonFont.cpp
@@ -68,17 +68,13 @@ FTGlyph* FTGLPolygonFont::MakeGlyph( unsigned int g)
     return NULL;
 }
 
-#ifdef __cplusplus
-extern "C" {
-namespace C {
-#endif
-extern "C" FTGLfont* ftglPolygonFontMake(const char *fontname)
+
+namespace C
 {
-    FTGLfont *ftgl = createFTFont(Polygon, fontname);
-    return ftgl;
-}
-#ifdef __cplusplus
-}
+    extern "C" FTGLfont* ftglCreatePolygonFont(const char *fontname)
+    {
+        FTGLfont *ftgl = createFTFont(Polygon, fontname);
+        return ftgl;
+    }
 }
-#endif
 
diff --git a/src/FTGLTextureFont.cpp b/src/FTGLTextureFont.cpp
index 592e398..de967f0 100644
--- a/src/FTGLTextureFont.cpp
+++ b/src/FTGLTextureFont.cpp
@@ -218,17 +218,13 @@ void FTGLTextureFont::Render( const wchar_t* string)
     glPopAttrib();
 }
 
-#ifdef __cplusplus
-extern "C" {
-namespace C {
-#endif
-extern "C" FTGLfont* ftglTextureFontMake(const char *fontname)
+
+namespace C
 {
-    FTGLfont *ftgl = createFTFont(Texture, fontname);
-    return ftgl;
-}
-#ifdef __cplusplus
-}
+    extern "C" FTGLfont* ftglCreateTextureFont(const char *fontname)
+    {
+        FTGLfont *ftgl = createFTFont(Texture, fontname);
+        return ftgl;
+    }
 }
-#endif
 
diff --git a/src/FTGlue.cpp b/src/FTGlue.cpp
index cd0c9fb..30b56f4 100644
--- a/src/FTGlue.cpp
+++ b/src/FTGlue.cpp
@@ -37,10 +37,8 @@
 
 #include "FTInternals.h"
 
-#ifdef __cplusplus
-extern "C" {
-namespace C {
-#endif
+namespace C
+{
 
 #define C_FUN(cret, cname, cargs, cxxerr, cxxname, cxxarg) \
     cret cname cargs \
@@ -69,6 +67,9 @@ namespace C {
         cxxerr; \
     }
 
+// FTFont::~FTFont();
+C_FUN(void, ftglDestroyFont, (FTGLfont *f), return, ~FTFont, ());
+
 // bool FTFont::Attach(const char* fontFilePath);
 C_FUN(int, ftglAttachFile, (FTGLfont *f, const char* path),
       return 0, Attach, (path));
@@ -133,8 +134,5 @@ C_FUN(void, ftglRender, (FTGLfont *f, const char * s), return, Render, (s));
 // FT_Error FTFont::Error() const;
 C_FUN(FT_Error, ftglError, (FTGLfont *f), return -1, Error, ());
 
-#ifdef __cplusplus
-} // extern "C"
 } // namespace C
-#endif