gnustep-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Objective-C boilerplate header (sort of like boost)


From: Ivan Vučica
Subject: Re: Objective-C boilerplate header (sort of like boost)
Date: Fri, 14 Jun 2013 10:24:34 +0200

I never needed something like what you wrote. That stuff belongs in a framework. If a compiler doesn't support an attribute that I need (and I typically don't need attributes), then I don't support the compiler.

Objective-C modules also doesn't really need anything special to expose C functions to modules written in C, except perhaps an extern "C" in case a header defining C functions is included by a C++ module.

So no, I don't typically have things like what you wrote down there :-)

Regards,

Ivan Vučica
via phone

On 14. 6. 2013., at 08:58, Maxthon Chan <address@hidden> wrote:

I mean exposing a function or two from Objective-C code so that it can be accessed from other languages. There is no reason to prevent a function with signature CGIApplicationMain(int, const char **, const char *restrict, const char *restrict); from being exposed, right?

Also, the inline function wrapper for [NSString stringWithFormat:] can be really useful.

Sent from my iPhone

On 2013年6月14日, at 14:21, Jamie Ramone <address@hidden> wrote:

Why...would anyone want to do that? The whole point of OOP is to hide details so as to allow programmers to concentrate on one thing at a time (while giving us the bonus of modular, reusable, easily maintainable code). Why would you want/need to unhide details?


On Fri, Jun 14, 2013 at 2:59 AM, Maxthon Chan <address@hidden> wrote:
Copied from Xcode and Mail saved all formatting from code highlighting as RTF. The code boilerplate is what I always use as a start point of my code. It makes it possible to expose some Objective-C code as plain C/C++ as I did in CGIKit 5, and it detects compiler. I have a newer version that does easy string constant too.

Sent from my iPhone

On 2013年6月14日, at 13:51, Jamie Ramone <address@hidden> wrote:

Colorful text is colorful! So what is this "boilerplate" thing exactly? I've heard the _expression_ before but not quite sure what it refers to.


On Wed, Jun 12, 2013 at 12:25 PM, Maxthon Chan <address@hidden> wrote:
Do you guys have a boilerplate that you are very used to build code on top of? I have one like this (sans include guard which depend on header file name):

#include <sys/cdefs.h>
#include <stdarg.h>
#include <stdint.h>
#include <stddef.h>
#include <sys/types.h>

// Feature testers

#ifndef __has_feature
#define __has_feature(x) 0
#endif

#ifndef __has_builtin
#define __has_builtin(x) 0
#endif

#ifndef __has_extension
#define __has_extension(x) 0
#endif

#ifndef __has_attribute
#define __has_attribute(x) 0
#endif

// __inline

#if __has_attribute(always_inline)
#define __inline static inline __attribute__((always_inline))
#else // !__has_attribute(always_inline)
#define __inline static inline
#endif// __has_attribute(always_inline)

// __restrict

#ifndef __cplusplus
#ifndef __restrict
#if __STDC_VERSION__ >= 199901L
#define __restrict restrict
#else // __STDC_VERSION__ < 199901L
#define __restrict
#endif // __STDC_VERSION__ >= 199901L
#endif // !defined(__restrict)
#endif // !defined(__cplusplus)

// noreturn (__noreturn and unreachable())

#if __has_attribute(noreturn)
#define __noreturn __attribute__((noreturn))
#if __has_builtin(__builtin_unreachable)
#define unreachable() __builtin_unreachable()
#else // !__has_builtin(__builtin_unreachable)
#define unreachable() do {} while (0)
#endif // __has_builtin(unreachable)
#else // !__has_attribute(noreturn)
#define __noreturn
#define unreachable() do {} while (0)
#endif // __has_attribute(noreturn)

// Deprecated/unavalible with messages

#undef __deprecated
#undef __unavailable

#if __has_attribute(deprecated)
#if __has_extension(attribute_deprecated_with_message)
#define __deprecated(_msg) __attribute__((deprecated(_msg)))
#else // !__has_extension(attribute_deprecated_with_message)
#define __deprecated(_msg) __attribute__((deprecated))
#endif // __has_extension(attribute_deprecated_with_message)
#else // !__has_attribute(deprecated)
#define __deprecated(_msg)
#endif // __has_attribute(deprecated)

#if __has_attribute(unavailable)
#if __has_extension(attribute_unavailable_with_message)
#define __unavailable(_msg) __attribute__((unavailable(_msg)))
#else // !__has_extension(attribute_unavailable_with_message)
#define __unavailable(_msg) __attribute__((unavailable))
#endif // __has_extension(attribute_unavailable_with_message)
#else // !__has_attribute(unavailable)
#define __unavailable(_msg)
#endif // __has_attribute(unavailable)

#if __has_extension(enumerator_attributes)
#define __e_deprecated(_msg) __deprecated(_msg)
#define __e_unavailable(_msg) __unavailable(_msg)
#else // !__has_extension(enumerator_attributes)
#define __e_deprecated(_msg)
#define __e_unavailable(_msg)
#endif // __has_extension(enumerator_attributes)

// Format strings

#if __has_attribute(format)
#define __format(...) __attribute__((format(__VA_ARGS__)))
#else // __has_attribute(format)
#define __format(...)
_______________________________________________
Gnustep-dev mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/gnustep-dev

reply via email to

[Prev in Thread] Current Thread [Next in Thread]