[vlc-commits] Clean up integer type name checks (e.g. uint16_t) with typedefs

Cheng Sun git at videolan.org
Wed Nov 30 22:05:42 CET 2011


npapi-vlc | branch: master | Cheng Sun <chengsun9 at gmail.com> | Wed Nov 30 20:33:30 2011 +0000| [31b539dde8b170896bc9cd7d22fc4dd7808f0362] | committer: Jean-Baptiste Kempf

Clean up integer type name checks (e.g. uint16_t) with typedefs

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/npapi-vlc.git/?a=commit;h=31b539dde8b170896bc9cd7d22fc4dd7808f0362
---

 npapi/vlcplugin.cpp |    6 +-----
 npapi/vlcplugin.h   |   22 ++++++++++++----------
 npapi/vlcshell.cpp  |   27 +++++----------------------
 npapi/vlcshell.h    |   36 ++++++++++--------------------------
 4 files changed, 28 insertions(+), 63 deletions(-)

diff --git a/npapi/vlcplugin.cpp b/npapi/vlcplugin.cpp
index b27f97c..a25466f 100644
--- a/npapi/vlcplugin.cpp
+++ b/npapi/vlcplugin.cpp
@@ -382,11 +382,7 @@ void EventObj::unhook_manager( void *userdata )
 /*****************************************************************************
  * VlcPlugin constructor and destructor
  *****************************************************************************/
-#if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
-VlcPlugin::VlcPlugin( NPP instance, uint16 mode ) :
-#else
-VlcPlugin::VlcPlugin( NPP instance, uint16_t mode ) :
-#endif
+VlcPlugin::VlcPlugin( NPP instance, NPuint16_t mode ) :
     i_npmode(mode),
     b_stream(0),
     b_autoplay(1),
diff --git a/npapi/vlcplugin.h b/npapi/vlcplugin.h
index 4e80603..b20accf 100644
--- a/npapi/vlcplugin.h
+++ b/npapi/vlcplugin.h
@@ -94,6 +94,16 @@
 
 #include "control/nporuntime.h"
 
+#if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
+    typedef uint16 NPuint16_t;
+    typedef int16 NPint16_t;
+    typedef int32 NPint32_t;
+#else
+    typedef uint16_t NPuint16_t;
+    typedef int16_t NPint16_t;
+    typedef int32_t NPint32_t;
+#endif
+
 typedef struct {
 #if defined(XP_UNIX)
     pthread_mutex_t mutex;
@@ -198,11 +208,7 @@ HMODULE DllGetModule();
 class VlcPlugin
 {
 public:
-#if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
-             VlcPlugin( NPP, uint16 );
-#else
-             VlcPlugin( NPP, uint16_t );
-#endif
+    VlcPlugin( NPP, NPuint16_t );
     virtual ~VlcPlugin();
 
     NPError             init(int argc, char* const argn[], char* const argv[]);
@@ -254,11 +260,7 @@ public:
     vlc_toolbar_clicked_t getToolbarButtonClicked( int i_xpos, int i_ypos );
 #endif
 
-#if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
-    uint16    i_npmode; /* either NP_EMBED or NP_FULL */
-#else
-    uint16_t  i_npmode; /* either NP_EMBED or NP_FULL */
-#endif
+    NPuint16_t  i_npmode; /* either NP_EMBED or NP_FULL */
 
     /* plugin properties */
     int      b_stream;
diff --git a/npapi/vlcshell.cpp b/npapi/vlcshell.cpp
index f6d55a3..6efe3af 100644
--- a/npapi/vlcshell.cpp
+++ b/npapi/vlcshell.cpp
@@ -278,11 +278,7 @@ void NPP_Shutdown( void )
 }
 
 NPError NPP_New( NPMIMEType pluginType, NPP instance,
-#if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
-                 uint16 mode, int16 argc,
-#else
-                 uint16_t mode, int16_t argc,
-#endif
+                 NPuint16_t mode, NPint16_t argc,
                  char* argn[], char* argv[], NPSavedData* saved )
 {
     NPError status;
@@ -553,11 +549,7 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window )
 }
 
 NPError NPP_NewStream( NPP instance, NPMIMEType type, NPStream *stream,
-#if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
-                       NPBool seekable, uint16 *stype )
-#else
-                       NPBool seekable, uint16_t *stype )
-#endif
+                       NPBool seekable, NPuint16_t *stype )
 {
     if( NULL == instance  )
     {
@@ -586,23 +578,14 @@ NPError NPP_NewStream( NPP instance, NPMIMEType type, NPStream *stream,
     return NPERR_GENERIC_ERROR;
 }
 
-#if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
-int32 NPP_WriteReady( NPP instance, NPStream *stream )
-#else
-int32_t NPP_WriteReady( NPP instance, NPStream *stream )
-#endif
+NPint32_t NPP_WriteReady( NPP instance, NPStream *stream )
 {
     /* TODO */
     return 8*1024;
 }
 
-#if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
-int32 NPP_Write( NPP instance, NPStream *stream, int32 offset,
-                 int32 len, void *buffer )
-#else
-int32_t NPP_Write( NPP instance, NPStream *stream, int32_t offset,
-                 int32_t len, void *buffer )
-#endif
+NPint32_t NPP_Write( NPP instance, NPStream *stream, NPint32_t offset,
+                     NPint32_t len, void *buffer )
 {
     /* TODO */
     return len;
diff --git a/npapi/vlcshell.h b/npapi/vlcshell.h
index c8d471e..228e92c 100644
--- a/npapi/vlcshell.h
+++ b/npapi/vlcshell.h
@@ -28,6 +28,8 @@
 # include "config.h"
 #endif
 
+#include "vlcplugin.h"
+
 NPP_GET_MIME_CONST char * NPP_GetMIMEDescription( void );
 
 NPError NPP_Initialize( void );
@@ -37,13 +39,9 @@ jref NPP_GetJavaClass( void );
 #endif
 void NPP_Shutdown( void );
 
-#if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
-NPError NPP_New( NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc,
-                 char* argn[], char* argv[], NPSavedData* saved );
-#else
-NPError NPP_New( NPMIMEType pluginType, NPP instance, uint16_t mode, int16_t argc,
-                 char* argn[], char* argv[], NPSavedData* saved );
-#endif
+NPError NPP_New( NPMIMEType pluginType, NPP instance, NPuint16_t mode,
+                 NPint16_t argc, char* argn[], char* argv[],
+                 NPSavedData* saved );
 
 NPError NPP_Destroy( NPP instance, NPSavedData** save );
 
@@ -53,34 +51,20 @@ NPError NPP_SetValue( NPP instance, NPNVariable variable, void *value );
 NPError NPP_SetWindow( NPP instance, NPWindow* window );
 
 NPError NPP_NewStream( NPP instance, NPMIMEType type, NPStream *stream,
-#if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
-                       NPBool seekable, uint16 *stype );
-#else
-                       NPBool seekable, uint16_t *stype );
-#endif
+                       NPBool seekable, NPuint16_t *stype );
 NPError NPP_DestroyStream( NPP instance, NPStream *stream, NPError reason );
 void NPP_StreamAsFile( NPP instance, NPStream *stream, const char* fname );
 
-#if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
-int32 NPP_WriteReady( NPP instance, NPStream *stream );
-int32 NPP_Write( NPP instance, NPStream *stream, int32 offset,
-                 int32 len, void *buffer );
-#else
-int32_t NPP_WriteReady( NPP instance, NPStream *stream );
-int32_t NPP_Write( NPP instance, NPStream *stream, int32_t offset,
-                 int32_t len, void *buffer );
-#endif
+NPint32_t NPP_WriteReady( NPP instance, NPStream *stream );
+NPint32_t NPP_Write( NPP instance, NPStream *stream, NPint32_t offset,
+                 NPint32_t len, void *buffer );
 
 void NPP_URLNotify( NPP instance, const char* url,
                     NPReason reason, void* notifyData );
 void NPP_Print( NPP instance, NPPrint* printInfo );
 
 #ifdef XP_MACOSX
-#if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
-int16 NPP_HandleEvent( NPP instance, void * event );
-#else
-int16_t NPP_HandleEvent( NPP instance, void * event );
-#endif
+NPint16_t NPP_HandleEvent( NPP instance, void * event );
 #endif
 
 static char mimetype[] =



More information about the vlc-commits mailing list