@@ -269,7 +269,29 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
269269 var cKeywords = "auto if break case register continue return default do sizeof " +
270270 "static else struct switch extern typedef union for goto while enum const " +
271271 "volatile inline restrict asm fortran" ;
272- var cTypes = "int long char short double float unsigned signed void size_t ptrdiff_t" ;
272+
273+ // Do not use this. Use the cTypes function below. This is global just to avoid
274+ // excessive calls when cTypes is being called multiple times during a parse.
275+ var basicCTypes = words ( "int long char short double float unsigned signed " +
276+ "void bool" ) ;
277+
278+ // Do not use this. Use the objCTypes function below. This is global just to avoid
279+ // excessive calls when objCTypes is being called multiple times during a parse.
280+ var basicObjCTypes = words ( "SEL instancetype id Class Protocol BOOL" ) ;
281+
282+ // Returns true if identifier is a "C" type.
283+ // C type is defined as those that are reserved by the compiler (basicTypes),
284+ // and those that end in _t (Reserved by POSIX for types)
285+ // http://www.gnu.org/software/libc/manual/html_node/Reserved-Names.html
286+ function cTypes ( identifier ) {
287+ return contains ( basicCTypes , identifier ) || / .+ _ t / . test ( identifier ) ;
288+ }
289+
290+ // Returns true if identifier is a "Objective C" type.
291+ function objCTypes ( identifier ) {
292+ return cTypes ( identifier ) || contains ( basicObjCTypes , identifier ) ;
293+ }
294+
273295 var cBlockKeywords = "case do else for if switch while struct enum union" ;
274296 var cDefKeywords = "struct enum union" ;
275297
@@ -383,8 +405,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
383405 def ( [ "text/x-csrc" , "text/x-c" , "text/x-chdr" ] , {
384406 name : "clike" ,
385407 keywords : words ( cKeywords ) ,
386- types : words ( cTypes + " bool float_t double_t intptr_t intmax_t int8_t int16_t " +
387- "int32_t int64_t uintptr_t uintmax_t uint8_t uint16_t uint32_t uint64_t" ) ,
408+ types : cTypes ,
388409 blockKeywords : words ( cBlockKeywords ) ,
389410 defKeywords : words ( cDefKeywords ) ,
390411 typeFirstDefinitions : true ,
@@ -404,7 +425,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
404425 "this using const_cast public throw virtual delete mutable protected " +
405426 "alignas alignof constexpr decltype nullptr noexcept thread_local final " +
406427 "static_assert override" ) ,
407- types : words ( cTypes + " bool wchar_t" ) ,
428+ types : cTypes ,
408429 blockKeywords : words ( cBlockKeywords + " class try catch finally" ) ,
409430 defKeywords : words ( cDefKeywords + " class namespace" ) ,
410431 typeFirstDefinitions : true ,
@@ -532,7 +553,6 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
532553 def ( "text/x-scala" , {
533554 name : "clike" ,
534555 keywords : words (
535-
536556 /* scala */
537557 "abstract case catch class def do else extends final finally for forSome if " +
538558 "implicit import lazy match new null object override package private protected return " +
@@ -730,7 +750,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
730750 keywords : words ( cKeywords + " as atomic async call command component components configuration event generic " +
731751 "implementation includes interface module new norace nx_struct nx_union post provides " +
732752 "signal task uses abstract extends" ) ,
733- types : words ( cTypes ) ,
753+ types : cTypes ,
734754 blockKeywords : words ( cBlockKeywords ) ,
735755 atoms : words ( "null true false" ) ,
736756 hooks : { "#" : cppHook } ,
@@ -744,7 +764,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
744764 "@interface @implementation @end @protocol @encode @property @synthesize @dynamic @class " +
745765 "@public @package @private @protected @required @optional @try @catch @finally @import " +
746766 "@selector @encode @defs @synchronized @autoreleasepool @compatibility_alias @available" ) ,
747- types : words ( cTypes + " instancetype SEL id BOOL IMP Class" ) ,
767+ types : objCTypes ,
748768 builtin : words ( "FOUNDATION_EXPORT FOUNDATION_EXTERN NS_INLINE NS_FORMAT_FUNCTION NS_RETURNS_RETAINED " +
749769 "NS_ERROR_ENUM NS_RETURNS_NOT_RETAINED NS_RETURNS_INNER_POINTER NS_DESIGNATED_INITIALIZER " +
750770 "NS_ENUM NS_OPTIONS NS_REQUIRES_NIL_TERMINATION NS_ASSUME_NONNULL_BEGIN " +
@@ -753,7 +773,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
753773 defKeywords : words ( cDefKeywords + " @interface @implementation @protocol @class" ) ,
754774 dontIndentStatements : / ^ @ .* $ / ,
755775 typeFirstDefinitions : true ,
756- atoms : words ( "YES NO NULL Nil nil true false" ) ,
776+ atoms : words ( "YES NO NULL Nil nil true false nullptr " ) ,
757777 isReservedIdentifier : cIsReservedIdentifier ,
758778 hooks : {
759779 "#" : cppHook ,
@@ -766,7 +786,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
766786 name : "clike" ,
767787 keywords : words ( "base break clone continue const default delete enum extends function in class" +
768788 " foreach local resume return this throw typeof yield constructor instanceof static" ) ,
769- types : words ( cTypes ) ,
789+ types : cTypes ,
770790 blockKeywords : words ( "case catch class else for foreach if switch try while" ) ,
771791 defKeywords : words ( "function local class" ) ,
772792 typeFirstDefinitions : true ,
0 commit comments