From 624fd74f830e21473b31d15b006337550c3f9fe4 Mon Sep 17 00:00:00 2001 From: DX-MON Date: Tue, 10 Jun 2014 18:54:10 +0100 Subject: [PATCH] Added C header samples from https://github.com/MiJyn/nightmare/ to fix the misclassifications as C++ that were occuring --- lib/linguist/samples.json | 392 +++++++++++++++++++++++++++++++------- samples/C/NWMan.h | 99 ++++++++++ samples/C/Nightmare.h | 27 +++ 3 files changed, 449 insertions(+), 69 deletions(-) create mode 100644 samples/C/NWMan.h create mode 100644 samples/C/Nightmare.h diff --git a/lib/linguist/samples.json b/lib/linguist/samples.json index 8e0c5465..e3f1b605 100644 --- a/lib/linguist/samples.json +++ b/lib/linguist/samples.json @@ -560,8 +560,8 @@ ".gitconfig" ] }, - "tokens_total": 454619, - "languages_total": 558, + "tokens_total": 460663, + "languages_total": 561, "tokens": { "IDL": { ";": 59, @@ -41660,50 +41660,50 @@ "After": 1 }, "C": { - "#include": 159, + "#include": 186, "": 5, - "": 2, + "": 3, "": 3, "": 3, "": 5, "": 2, - "#ifndef": 90, + "#ifndef": 93, "ULLONG_MAX": 10, - "#endif": 246, + "#endif": 264, "MIN": 3, - "#if": 92, + "#if": 105, "HTTP_PARSER_DEBUG": 4, - "#define": 921, + "#define": 927, "SET_ERRNO": 47, - "(": 6249, + "(": 6533, "e": 4, - ")": 6251, + ")": 6543, "do": 21, - "{": 1532, + "{": 1616, "parser": 334, - "-": 1803, + "-": 1856, "http_errno": 11, - ";": 5468, + ";": 5833, "error_lineno": 3, "__LINE__": 50, - "}": 1548, + "}": 1632, "while": 70, - "#else": 95, + "#else": 107, "CALLBACK_NOTIFY_": 3, "FOR": 11, "ER": 4, "assert": 41, "HTTP_PARSER_ERRNO": 10, "HPE_OK": 10, - "if": 1015, + "if": 1018, "settings": 6, "on_##FOR": 4, "HPE_CB_##FOR": 2, - "return": 529, + "return": 584, "CALLBACK_NOTIFY": 10, "p": 60, "data": 69, - "+": 551, + "+": 696, "CALLBACK_NOTIFY_NOADVANCE": 2, "CALLBACK_DATA_": 4, "LEN": 2, @@ -41720,12 +41720,12 @@ "CHUNKED": 4, "KEEP_ALIVE": 4, "CLOSE": 4, - "static": 457, - "const": 368, - "char": 530, + "static": 551, + "const": 369, + "char": 531, "*method_strings": 1, - "[": 603, - "]": 603, + "[": 1377, + "]": 1377, "XX": 63, "num": 24, "name": 28, @@ -41741,7 +41741,7 @@ "normal_url_char": 3, "T": 3, "enum": 30, - "state": 104, + "state": 106, "s_dead": 10, "s_start_req_or_res": 4, "s_res_or_resp_H": 3, @@ -41828,7 +41828,7 @@ "h_connection_keep_alive": 4, "h_connection_close": 4, "Macros": 1, - "for": 88, + "for": 92, "character": 11, "classes": 1, "depends": 1, @@ -41839,19 +41839,19 @@ "CR": 18, "r": 58, "LF": 21, - "n": 70, + "n": 74, "LOWER": 7, "c": 252, "unsigned": 140, "0x20": 1, "IS_ALPHA": 5, "&&": 248, - "z": 47, + "z": 64, "IS_NUM": 14, "9": 1, "IS_ALPHANUM": 3, "IS_HEX": 2, - "f": 184, + "f": 287, "TOKEN": 4, "IS_URL_CHAR": 6, "IS_HOST_CHAR": 4, @@ -41860,7 +41860,7 @@ "_": 3, "endif": 6, "start_state": 1, - "type": 36, + "type": 38, "HTTP_REQUEST": 7, "cond": 1, "HPE_STRICT": 1, @@ -41869,12 +41869,12 @@ "HTTP_STRERROR_GEN": 3, "s": 154, "#n": 1, - "struct": 360, + "struct": 362, "*name": 12, "*description": 1, "http_strerror_tab": 7, "HTTP_ERRNO_MAP": 3, - "int": 446, + "int": 459, "http_message_needs_eof": 4, "http_parser": 13, "*parser": 9, @@ -41885,7 +41885,7 @@ "case": 273, "break": 244, "default": 33, - "size_t": 52, + "size_t": 64, "http_parser_execute": 2, "http_parser_settings": 5, "*settings": 2, @@ -41916,10 +41916,10 @@ "HTTP_HEAD": 2, "index": 58, "STRICT_CHECK": 15, - "<": 219, + "<": 223, "HPE_INVALID_VERSION": 12, "http_major": 11, - "*": 262, + "*": 505, "http_minor": 11, "HPE_INVALID_STATUS": 3, "status_code": 8, @@ -41969,7 +41969,7 @@ "F_CONNECTION_KEEP_ALIVE": 3, "F_CONNECTION_CLOSE": 3, "F_CHUNKED": 11, - "&": 442, + "&": 465, "F_TRAILING": 3, "NEW_MESSAGE": 6, "upgrade": 3, @@ -41994,11 +41994,11 @@ "end": 48, "of": 44, "message": 3, - "/": 9, + "/": 27, "http_should_keep_alive": 2, "http_method_str": 1, - "m": 8, - "void": 289, + "m": 84, + "void": 299, "http_parser_init": 2, "http_parser_type": 3, "memset": 4, @@ -42017,7 +42017,7 @@ "http_parser_url_fields": 2, "uf": 14, "old_uf": 4, - "u": 18, + "u": 21, "port": 7, "field_set": 5, "UF_MAX": 3, @@ -42034,7 +42034,7 @@ ".off": 2, "<<": 56, "long": 105, - "v": 11, + "v": 25, "strtoul": 2, "xffff": 1, "uint16_t": 12, @@ -42042,7 +42042,7 @@ "paused": 3, "HPE_PAUSED": 2, "BLOB_H": 2, - "extern": 38, + "extern": 41, "*blob_type": 2, "blob": 6, "object": 41, @@ -42056,9 +42056,9 @@ "": 2, "": 2, "": 1, - "": 3, + "": 4, "": 2, - "//": 262, + "//": 267, "local": 5, "stack": 6, "memory": 4, @@ -42077,21 +42077,21 @@ "LOG_ERROR": 64, "RE_STRING_INIT_FAILURE": 8, "buffAllocated": 11, - "true": 73, + "true": 74, "free": 62, "ret": 142, "RF_MALLOC": 47, "RF_String": 27, "bytes": 225, "memcpy": 35, - "#ifdef": 68, + "#ifdef": 70, "i_NVrfString_Create": 3, "i_rfString_CreateLocal1": 3, "RF_OPTION_SOURCE_ENCODING": 30, "RF_UTF8": 8, "characterLength": 16, "*codepoints": 2, - "i": 410, + "i": 434, "j": 206, "rfLMS_MacroEvalPtr": 2, "RF_LMS": 6, @@ -42141,7 +42141,7 @@ "sequence": 6, "could": 2, "not": 6, - "be": 6, + "be": 7, "properly": 2, "encoded": 2, "RE_UTF8_ENCODING": 2, @@ -42222,7 +42222,7 @@ "strcpy": 4, "rfString_Init_i": 2, "rfString_Create_f": 2, - "float": 26, + "float": 231, "rfString_Init_f": 2, "rfString_Create_UTF16": 2, "endianess": 40, @@ -42343,7 +42343,7 @@ "srcP": 6, "src": 16, "rfString_Copy_IN": 2, - "dst": 15, + "dst": 16, "rfString_Copy_chars": 2, "bytePos": 23, "terminate": 1, @@ -42701,7 +42701,7 @@ "prefix.size": 1, "git_buf_detach": 1, "git_buf_free": 4, - "bool": 6, + "bool": 19, "diff_pathspec_is_interesting": 2, "*str": 1, "diff_path_matches_pathspec": 3, @@ -42940,10 +42940,15 @@ "diff_delta__merge_like_cgit": 1, "git_vector_swap": 1, "git_pool_swap": 1, + "_NMEX_NIGHTMARE_H": 2, + "//#define": 1, + "NMEX": 1, + "START_HEAD": 2, + "END_HEAD": 2, "REFU_IO_H": 2, "": 2, "": 8, - "__cplusplus": 20, + "__cplusplus": 22, "opening": 2, "bracket": 4, "calling": 4, @@ -43009,7 +43014,7 @@ "wglext.h": 1, "included": 2, "wglew.h": 1, - "defined": 42, + "defined": 55, "WINAPI": 119, "": 1, "GLEW_STATIC": 1, @@ -43074,7 +43079,7 @@ "GLenum": 8, "filter": 1, "PFNWGLCREATEASSOCIATEDCONTEXTAMDPROC": 2, - "id": 13, + "id": 14, "PFNWGLCREATEASSOCIATEDCONTEXTATTRIBSAMDPROC": 2, "hShareContext": 2, "int*": 22, @@ -43124,8 +43129,8 @@ "PFNWGLDELETEBUFFERREGIONARBPROC": 2, "hRegion": 3, "PFNWGLRESTOREBUFFERREGIONARBPROC": 2, - "x": 57, - "y": 14, + "x": 70, + "y": 29, "width": 3, "height": 3, "xSrc": 1, @@ -44271,7 +44276,7 @@ "close": 13, "oom": 3, "REDIS_WARNING": 19, - "sleep": 1, + "sleep": 2, "abort": 1, "ustime": 7, "*1000000": 1, @@ -44315,7 +44320,7 @@ "o2": 7, "dictObjHash": 2, "*key": 5, - "key": 9, + "key": 10, "dictGenHashFunction": 5, "dictSdsHash": 4, "dictSdsCaseHash": 2, @@ -44954,6 +44959,58 @@ "aeSetBeforeSleepProc": 1, "aeMain": 1, "aeDeleteEventLoop": 1, + "_NME_WMAN_H": 2, + "NTS": 1, + "NWMan_event": 3, + "NSTRUCT": 2, + "NWMan": 2, + "init": 1, + "destroy": 1, + "create_window": 1, + "destroy_window": 1, + "swap_buffers": 1, + "next_event": 1, + "NWMan_event*": 1, + "event": 1, + "uint": 2, + "get_millis": 1, + "millis": 1, + "rshift_key": 1, + "lshift_key": 1, + "left_key": 1, + "right_key": 1, + "NENUM": 1, + "NWMan_event_type": 3, + "N_WMAN_MOUSE_MOVE": 1, + "N_WMAN_MOUSE_BUTTON": 1, + "N_WMAN_MOUSE_WHEEL": 1, + "N_WMAN_KEYBOARD": 1, + "N_WMAN_QUIT": 1, + "N_WMAN_RESIZE": 1, + "N_WMAN_FOCUS": 1, + "N_WMAN_MOUSE_LEFT": 1, + "N_WMAN_MOUSE_RIGHT": 1, + "N_WMAN_MOUSE_MIDDLE": 1, + "union": 1, + "NPos2i": 2, + "mouse_pos": 1, + "short": 7, + "mouse_button": 1, + "signed": 6, + "mouse_wheel": 1, + "up": 1, + "down": 1, + "keyboard": 1, + "window_quit": 1, + "Will": 1, + "always": 3, + "WM_QUIT": 1, + "window_size": 1, + "window_focus": 1, + "NWMan_event_new": 1, + "NWMan_init": 1, + "NWMan_destroy": 1, + "N_WMan": 1, "_WIN32": 3, "strncasecmp": 2, "_strnicmp": 1, @@ -44970,7 +45027,7 @@ "sd_markdown": 6, "tag": 1, "tag_len": 3, - "w": 6, + "w": 9, "is_empty": 4, "htmlblock_end": 3, "*curtag": 2, @@ -45092,7 +45149,6 @@ "Functions": 1, "convert": 1, "but": 1, - "always": 2, "Once": 1, "been": 1, "created": 1, @@ -45130,7 +45186,7 @@ "@endcpp": 1, "@endinternal": 1, "*/": 1, - "#pragma": 2, + "#pragma": 8, "pop": 1, "i_rfString_CreateLocal": 2, "__VA_ARGS__": 66, @@ -45652,7 +45708,7 @@ "PYREX_WITHOUT_ASSERTIONS": 1, "CYTHON_WITHOUT_ASSERTIONS": 1, "CYTHON_INLINE": 65, - "__inline__": 1, + "__inline__": 95, "__inline": 1, "__STDC_VERSION__": 2, "L": 1, @@ -46010,12 +46066,10 @@ "cabs": 1, "cpow": 1, "__Pyx_PyInt_AsUnsignedChar": 1, - "short": 6, "__Pyx_PyInt_AsUnsignedShort": 1, "__Pyx_PyInt_AsUnsignedInt": 1, "__Pyx_PyInt_AsChar": 1, "__Pyx_PyInt_AsShort": 1, - "signed": 5, "__Pyx_PyInt_AsSignedChar": 1, "__Pyx_PyInt_AsSignedShort": 1, "__Pyx_PyInt_AsSignedInt": 1, @@ -46377,7 +46431,7 @@ "**__pyx_pyargnames": 3, "__pyx_n_s__p": 6, "__pyx_n_s__y": 6, - "values": 30, + "values": 67, "__pyx_kwds": 15, "kw_args": 15, "pos_args": 12, @@ -46501,7 +46555,7 @@ "pp_remainder": 1, "indent": 1, "*pop_most_recent_commit": 1, - "mark": 3, + "mark": 9, "*pop_commit": 1, "**stack": 1, "clear_commit_marks": 1, @@ -46976,6 +47030,207 @@ "*http_method_str": 1, "*http_errno_name": 1, "*http_errno_description": 1, + "__GLK_MATRIX_4_H": 2, + "": 1, + "__ARM_NEON__": 13, + "": 1, + "": 1, + "": 1, + "": 1, + "": 1, + "Prototypes": 1, + "GLKMatrix4": 183, + "GLKMatrix4Identity": 3, + "GLKMatrix4Make": 2, + "m00": 6, + "m01": 6, + "m02": 6, + "m03": 6, + "m10": 6, + "m11": 6, + "m12": 6, + "m13": 6, + "m20": 6, + "m21": 6, + "m22": 6, + "m23": 6, + "m30": 6, + "m31": 6, + "m32": 6, + "m33": 6, + "GLKMatrix4MakeAndTranspose": 2, + "GLKMatrix4MakeWithArray": 2, + "GLKMatrix4MakeWithArrayAndTranspose": 2, + "GLKMatrix4MakeWithRows": 2, + "GLKVector4": 44, + "row0": 2, + "row1": 2, + "row2": 2, + "row3": 2, + "GLKMatrix4MakeWithColumns": 2, + "column0": 2, + "column1": 2, + "column2": 2, + "column3": 2, + "GLKMatrix4MakeWithQuaternion": 2, + "GLKQuaternion": 2, + "quaternion": 4, + "GLKMatrix4MakeTranslation": 2, + "tx": 8, + "ty": 8, + "tz": 8, + "GLKMatrix4MakeScale": 2, + "sx": 10, + "sy": 10, + "sz": 10, + "GLKMatrix4MakeRotation": 5, + "radians": 34, + "GLKMatrix4MakeXRotation": 3, + "GLKMatrix4MakeYRotation": 3, + "GLKMatrix4MakeZRotation": 3, + "GLKMatrix4MakePerspective": 2, + "fovyRadians": 3, + "aspect": 3, + "nearZ": 17, + "farZ": 15, + "GLKMatrix4MakeFrustum": 2, + "left": 8, + "right": 8, + "bottom": 8, + "top": 8, + "GLKMatrix4MakeOrtho": 2, + "GLKMatrix4MakeLookAt": 2, + "eyeX": 3, + "eyeY": 3, + "eyeZ": 3, + "centerX": 3, + "centerY": 3, + "centerZ": 3, + "upX": 3, + "upY": 3, + "upZ": 3, + "GLKMatrix3": 3, + "GLKMatrix4GetMatrix3": 2, + "matrix": 64, + "GLKMatrix2": 3, + "GLKMatrix4GetMatrix2": 2, + "GLKMatrix4GetRow": 2, + "row": 12, + "GLKMatrix4GetColumn": 2, + "column": 14, + "GLKMatrix4SetRow": 2, + "vector": 4, + "GLKMatrix4SetColumn": 2, + "GLKMatrix4Transpose": 2, + "GLKMatrix4Invert": 1, + "*isInvertible": 2, + "GLKMatrix4InvertAndTranspose": 1, + "GLKMatrix4Multiply": 8, + "matrixLeft": 21, + "matrixRight": 9, + "GLKMatrix4Add": 2, + "GLKMatrix4Subtract": 2, + "GLKMatrix4Translate": 2, + "GLKMatrix4TranslateWithVector3": 2, + "GLKVector3": 31, + "translationVector": 4, + "GLKMatrix4TranslateWithVector4": 2, + "GLKMatrix4Scale": 2, + "GLKMatrix4ScaleWithVector3": 2, + "scaleVector": 4, + "GLKMatrix4ScaleWithVector4": 2, + "GLKMatrix4Rotate": 2, + "GLKMatrix4RotateWithVector3": 2, + "axisVector": 4, + "GLKMatrix4RotateWithVector4": 2, + "GLKMatrix4RotateX": 2, + "GLKMatrix4RotateY": 2, + "GLKMatrix4RotateZ": 2, + "GLKMatrix4MultiplyVector3": 3, + "vectorRight": 8, + "GLKMatrix4MultiplyVector3WithTranslation": 3, + "GLKMatrix4MultiplyAndProjectVector3": 3, + "GLKMatrix4MultiplyVector3Array": 2, + "*vectors": 8, + "vectorCount": 12, + "GLKMatrix4MultiplyVector3ArrayWithTranslation": 2, + "GLKMatrix4MultiplyAndProjectVector3Array": 2, + "GLKMatrix4MultiplyVector4": 6, + "GLKMatrix4MultiplyVector4Array": 2, + "Implementations": 1, + "float32x4x4_t": 29, + "vld4q_f32": 2, + "row0.v": 4, + "row1.v": 4, + "row2.v": 4, + "row3.v": 4, + "m.val": 52, + "vld1q_f32": 6, + "column0.v": 5, + "column1.v": 5, + "column2.v": 5, + "column3.v": 5, + "GLKQuaternionNormalize": 1, + "quaternion.q": 4, + "_2x": 7, + "_2y": 5, + "_2z": 3, + "_2w": 7, + "m.m": 54, + "GLKVector3Normalize": 3, + "GLKVector3Make": 4, + "cos": 14, + "cosf": 4, + "cosp": 10, + "sin": 16, + "sinf": 4, + "v.v": 27, + "cotan": 3, + "tanf": 1, + "ral": 4, + "rsl": 6, + "tsb": 6, + "tab": 4, + "fan": 4, + "fsn": 6, + "ev": 7, + "cv": 2, + "uv": 2, + "GLKVector3Add": 1, + "GLKVector3Negate": 4, + "GLKVector3CrossProduct": 2, + "u.v": 3, + "n.v": 3, + "GLKVector3DotProduct": 3, + "matrix.m": 171, + "float32x4_t": 2, + "vector.v": 9, + "*dst": 1, + "vst1q_f32": 1, + "iMatrixLeft": 3, + "iMatrixRight": 3, + "vmulq_n_f32": 17, + "iMatrixLeft.val": 24, + "vgetq_lane_f32": 16, + "iMatrixRight.val": 24, + "vmlaq_n_f32": 12, + "matrixLeft.m": 112, + "matrixRight.m": 96, + "vaddq_f32": 7, + "vsubq_f32": 4, + "translationVector.v": 18, + "iMatrix": 4, + "iMatrix.val": 28, + "float32_t": 13, + "scaleVector.v": 30, + "rm": 12, + "axisVector.v": 6, + "v4": 3, + "GLKVector4Make": 3, + "vectorRight.v": 29, + "v4.v": 10, + "GLKVector3MultiplyScalar": 1, + "vectors": 8, "syscalldef": 1, "syscalldefs": 1, "SYSCALL_OR_NUM": 3, @@ -47334,7 +47589,6 @@ "EINTR": 1, "ev_child_init": 1, "ev_child_start": 1, - "ev": 2, "child_watcher.data": 1, "uv__set_sys_error": 2, "uv_process_kill": 1, @@ -49264,7 +49518,7 @@ "AsciiDoc": 103, "Protocol Buffer": 63, "Common Lisp": 103, - "C": 59137, + "C": 65181, "XQuery": 801, "RobotFramework": 483, "Gosu": 410, @@ -49411,7 +49665,7 @@ "AsciiDoc": 3, "Protocol Buffer": 1, "Common Lisp": 1, - "C": 31, + "C": 34, "XQuery": 1, "RobotFramework": 3, "Gosu": 4, @@ -49423,5 +49677,5 @@ "GLSL": 3, "Xtend": 2 }, - "md5": "5b3ac3847ff456b82cf95a19d03449a4" + "md5": "ffe9f7427856f37d6cd0e305a22630c6" } \ No newline at end of file diff --git a/samples/C/NWMan.h b/samples/C/NWMan.h new file mode 100644 index 00000000..abcd2ddb --- /dev/null +++ b/samples/C/NWMan.h @@ -0,0 +1,99 @@ +#ifndef _NME_WMAN_H +#define _NME_WMAN_H + +// Internal window manager API + +#include "NCompat.h" + +START_HEAD + +#include "NPos.h" +#include "NUtil.h" +#include "NTypes.h" + +NTS(NWMan_event); + +NSTRUCT(NWMan, { + // Init stuff + bool (*init)(); + bool (*destroy)(); + + // Window stuff + bool (*create_window)(); + bool (*destroy_window)(); + + void (*swap_buffers)(); + + // Event stuff + bool (*next_event)(NWMan_event* event); + + // Time stuff + uint (*get_millis)(); + void (*sleep)(uint millis); + + // Info + int rshift_key; + int lshift_key; + int left_key; + int right_key; +}); + +NENUM(NWMan_event_type, { + N_WMAN_MOUSE_MOVE = 0, + N_WMAN_MOUSE_BUTTON = 1, + N_WMAN_MOUSE_WHEEL = 2, + + N_WMAN_KEYBOARD = 10, + + N_WMAN_QUIT = 20, + N_WMAN_RESIZE = 21, + N_WMAN_FOCUS = 22 +}); + +#define N_WMAN_MOUSE_LEFT 0 +#define N_WMAN_MOUSE_RIGHT 1 +#define N_WMAN_MOUSE_MIDDLE 2 + +NSTRUCT(NWMan_event, { + NWMan_event_type type; + + union { + // Mouse + + NPos2i mouse_pos; + + struct { + short id; + bool state; + } mouse_button; + + signed char mouse_wheel; // 1 if up, -1 if down + + // Keyboard + + struct { + int key; + bool state; + } keyboard; + + // Window + + bool window_quit; // Will always be true if WM_QUIT + + NPos2i window_size; + + bool window_focus; + }; +}); + +NWMan_event NWMan_event_new(NWMan_event_type type); + + +bool NWMan_init(); +bool NWMan_destroy(); + +extern NWMan N_WMan; + +END_HEAD + +#endif diff --git a/samples/C/Nightmare.h b/samples/C/Nightmare.h new file mode 100644 index 00000000..3b639c20 --- /dev/null +++ b/samples/C/Nightmare.h @@ -0,0 +1,27 @@ +#ifndef _NMEX_NIGHTMARE_H +#define _NMEX_NIGHTMARE_H + +//#define NMEX + +#include "../src/NCompat.h" + +START_HEAD + +#include "../src/NTypes.h" +#include "../src/NUtil.h" +#include "../src/NPorting.h" +#include "../src/NGlobals.h" +#include "../src/NLog.h" +#include "../src/NWMan.h" +#include "../src/NRsc.h" +#include "../src/NShader.h" +#include "../src/NSquare.h" +#include "../src/NImage.h" +#include "../src/NSprite.h" +#include "../src/NSpritesheet.h" +#include "../src/NEntity.h" +#include "../src/Game.h" + +END_HEAD + +#endif