]> git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - gmqcc.h
Make compiler and virtual-machine compile as C++ code, also removed gmqcc_voidptr...
[xonotic/gmqcc.git] / gmqcc.h
diff --git a/gmqcc.h b/gmqcc.h
index 30a27fea4f1bfea88ffaab525828bd7e42236559..949559442021428f8555b8ce672dbb38c9d02330 100644 (file)
--- a/gmqcc.h
+++ b/gmqcc.h
@@ -37,7 +37,6 @@
 #ifdef _MSC_VER
 #   pragma warning(disable : 4244 ) /* conversion from 'int' to 'float', possible loss of data */
 #   pragma warning(disable : 4018 ) /* signed/unsigned mismatch                                */
-#   pragma warning(disable : 4996 ) /* This function or variable may be unsafe                 */
 #endif
 
 #define GMQCC_VERSION_MAJOR 0
@@ -261,54 +260,28 @@ size_t util_strtononcmd (const char *, char *, size_t);
 
 uint16_t util_crc16(uint16_t crc, const char *data, size_t len);
 
-/*
- * If we're compiling as C++ code we need to fix some subtle issues regarding casts between mem_a/mem_d
- * since C++ doesn't allow implicit conversions between void*
- */
-#ifdef __cplusplus
-        /*
-         * void * will be implicitally converted to gmqcc_voidptr using gmqcc_voidptr(void*).  This is what
-         * essentially allows us to allow implicit conversion to whatever pointer type we're trying to assign
-         * to because it acks as a default assignment constructor.
-         */
-        class gmqcc_voidptr {
-            void *m_pointer;
-        public:
-            gmqcc_voidptr(void *pointer) :
-                m_pointer(pointer)
-            { };
-
-            template <typename T>
-            GMQCC_INLINE operator T *() {
-                return m_pointer;
-            }
-        };
-
-#      define GMQCC_IMPLICIT_POINTER(X) (gmqcc_voidptr(X))
-#else
-#      define GMQCC_IMPLICIT_POINTER(X) (X)
-#endif
-
 #ifdef NOTRACK
-#    define mem_a(x)    GMQCC_IMPLICIT_POINTER(malloc (x))
+#    define mem_a(x)    malloc (x)
 #    define mem_d(x)    free   ((void*)x)
 #    define mem_r(x, n) realloc((void*)x, n)
 #else
-#    define mem_a(x)    GMQCC_IMPLICIT_POINTER(util_memory_a((x), __LINE__, __FILE__))
+#    define mem_a(x)    util_memory_a((x), __LINE__, __FILE__)
 #    define mem_d(x)    util_memory_d((void*)(x),      __LINE__, __FILE__)
 #    define mem_r(x, n) util_memory_r((void*)(x), (n), __LINE__, __FILE__)
 #endif
 
 /*
  * A flexible vector implementation: all vector pointers contain some
- * data baout themselfs exactly - sizeof(vector_t) behind the pointer
+ * data about themselfs exactly - sizeof(vector_t) behind the pointer
  * this data is represented in the structure below.  Doing this allows
- * use to use the array [] to access individual data from the vector
+ * us to use the array [] to access individual elements from the vector
  * opposed to using set/get methods.
  */     
 typedef struct {
     size_t  allocated;
     size_t  used;
+
+    /* can be extended now! whoot */
 } vector_t;
 
 /* hidden interface */
@@ -370,29 +343,27 @@ typedef struct hash_table_t {
  */
 hash_table_t *util_htnew (size_t size);
 void          util_htset (hash_table_t *ht, const char *key, void *value);
-void         *util_htget (hash_table_t *ht, const char *key);
 void          util_htdel (hash_table_t *ht);
 size_t        util_hthash(hash_table_t *ht, const char *key);
-void         *util_htgeth(hash_table_t *ht, const char *key, size_t hash);
 void          util_htseth(hash_table_t *ht, const char *key, size_t hash, void *value);
 
+void         *util_htget (hash_table_t *ht, const char *key);
+void         *util_htgeth(hash_table_t *ht, const char *key, size_t hash);
 /*===================================================================*/
 /*============================ file.c ===============================*/
 /*===================================================================*/
-void   GMQCC_INLINE file_close  (FILE *);
+GMQCC_INLINE void    file_close  (FILE *);
+GMQCC_INLINE int     file_error  (FILE *);
+GMQCC_INLINE int     file_getc   (FILE *);
+GMQCC_INLINE int     file_printf (FILE *, const char *, ...);
+GMQCC_INLINE int     file_puts   (FILE *, const char *);
+GMQCC_INLINE int     file_seek   (FILE *, long int, int);
 
-int    GMQCC_INLINE file_error  (FILE *);
-int    GMQCC_INLINE file_getc   (FILE *);
-int    GMQCC_INLINE file_printf (FILE *, const char *, ...);
-int    GMQCC_INLINE file_puts   (FILE *, const char *);
-int    GMQCC_INLINE file_seek   (FILE *, long int, int);
+GMQCC_INLINE size_t  file_read   (void *,        size_t, size_t, FILE *);
+GMQCC_INLINE size_t  file_write  (const void *,  size_t, size_t, FILE *);
 
-size_t GMQCC_INLINE file_read   (void *,        size_t, size_t, FILE *);
-size_t GMQCC_INLINE file_write  (const void *,  size_t, size_t, FILE *);
-
-FILE*  GMQCC_INLINE file_open   (const char *, const char *);
-
-int   /*NO_INLINE*/ file_getline(char  **, size_t *, FILE *);
+GMQCC_INLINE FILE   *file_open   (const char *, const char *);
+/*NOINLINE*/ int     file_getline(char  **, size_t *, FILE *);
 
 
 /*===================================================================*/
@@ -920,15 +891,11 @@ qcint             prog_tempstring(qc_program *prog, const char *_str);
 /*===================================================================*/
 
 bool parser_init          ();
-bool parser_compile_file  (const char *filename);
-bool parser_compile_string(const char *name, const char *str);
-bool parser_finish        (const char *output);
+bool parser_compile_file  (const char *);
+bool parser_compile_string(const char *, const char *, size_t);
+bool parser_finish        (const char *);
 void parser_cleanup       ();
 
-/* TODO: make compile_string accept len and remove this */
-/* There's really no need to strlen() preprocessed files */
-bool parser_compile_string_len(const char *name, const char *str, size_t len);
-
 /*===================================================================*/
 /*====================== ftepp.c commandline ========================*/
 /*===================================================================*/