Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ struct Param
bool isOpenBSD; // generate code for OpenBSD
bool isSolaris; // generate code for Solaris
bool mscoff; // for Win32: write COFF object files instead of OMF
bool objc; // for OSX (for now): support for Objective-C methods
char useDeprecated; // 0: don't allow use of deprecated features
// 1: silently allow use of deprecated features
// 2: warn about the use of deprecated features
Expand Down
4 changes: 1 addition & 3 deletions src/magicport.json
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,7 @@
"function objc_FuncDeclaration_semantic_setSelector",
"function objc_isUdaSelector",
"function objc_FuncDeclaration_semantic_validateSelector",
"function objc_FuncDeclaration_semantic_checkLinkage",
"function objc_tryMain_dObjc",
"function objc_tryMain_init"
"function objc_FuncDeclaration_semantic_checkLinkage"
],
"extra" : [
"extern(C++) void objc_initSymbols();"
Expand Down
16 changes: 14 additions & 2 deletions src/mars.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ void parseConfFile(StringTable *environment, const char *path, size_t len, unsig
void genObjFile(Module *m, bool multiobj);
void genhelpers(Module *m, bool iscomdat);

// in objc_glue.c
void objc_initSymbols();

/** Normalize path by turning forward slashes into backslashes */
const char * toWinPath(const char *src)
{
Expand Down Expand Up @@ -1066,6 +1069,8 @@ Language changes listed by -transition=id:\n\
global.params.debuglibname = global.params.defaultlibname;

#if TARGET_OSX
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Objective-C support is enabled if the makefile variable D_OBJC is enabled.

if (global.params.is64bit)
global.params.objc = true;
global.params.pic = 1;
#endif

Expand Down Expand Up @@ -1194,7 +1199,9 @@ Language changes listed by -transition=id:\n\
VersionCondition::addPredefinedGlobalIdent("D_NoBoundsChecks");

VersionCondition::addPredefinedGlobalIdent("D_HardFloat");
objc_tryMain_dObjc();

if (global.params.objc)
VersionCondition::addPredefinedGlobalIdent("D_ObjectiveC");

// Initialization
Lexer::initLexer();
Expand All @@ -1203,11 +1210,16 @@ Language changes listed by -transition=id:\n\
Module::init();
Target::init();
Expression::init();
objc_tryMain_init();
initPrecedence();
builtin_init();
initTraitsStringTable();

if (global.params.objc)
{
objc_initSymbols();
ObjcSelector::init();
}

if (global.params.verbose)
{ fprintf(global.stdmsg, "binary %s\n", global.params.argv0);
fprintf(global.stdmsg, "version %s\n", global.version);
Expand Down
14 changes: 0 additions & 14 deletions src/objc.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#include "visitor.h"

void mangleToBuffer(Type *t, OutBuffer *buf);
void objc_initSymbols();

// MARK: Objc_ClassDeclaration

Expand Down Expand Up @@ -140,19 +139,6 @@ void objc_FuncDeclaration_semantic_checkLinkage(FuncDeclaration *fd)
fd->error("must have Objective-C linkage to attach a selector");
}

// MARK: init

void objc_tryMain_dObjc()
{
VersionCondition::addPredefinedGlobalIdent("D_ObjectiveC");
}

void objc_tryMain_init()
{
objc_initSymbols();
ObjcSelector::init();
}

// MARK: Selector

StringTable ObjcSelector::stringtable;
Expand Down
2 changes: 0 additions & 2 deletions src/objc.di
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,3 @@ extern (C++) void objc_FuncDeclaration_semantic_setSelector(FuncDeclaration fd,
extern (C++) bool objc_isUdaSelector(StructDeclaration sd);
extern (C++) void objc_FuncDeclaration_semantic_validateSelector(FuncDeclaration fd);
extern (C++) void objc_FuncDeclaration_semantic_checkLinkage(FuncDeclaration fd);
extern (C++) void objc_tryMain_dObjc();
extern (C++) void objc_tryMain_init();
2 changes: 0 additions & 2 deletions src/objc.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,5 @@ bool objc_isUdaSelector(StructDeclaration *sd);
void objc_FuncDeclaration_semantic_validateSelector(FuncDeclaration *fd);
void objc_FuncDeclaration_semantic_checkLinkage(FuncDeclaration *fd);

void objc_tryMain_dObjc();
void objc_tryMain_init();

#endif /* DMD_OBJC_H */
5 changes: 5 additions & 0 deletions src/objc_glue_stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ class Type;
class TypeFunction;
struct elem;

void objc_initSymbols()
{
// noop
}

void objc_callfunc_setupEp(elem *esel, elem **ep, int reverse)
{
// noop
Expand Down
15 changes: 6 additions & 9 deletions src/objc_stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ ObjcSelector::ObjcSelector(const char *sv, size_t len, size_t pcount)
assert(0);
}

void ObjcSelector::init()
{
printf("Should never be called when D_OBJC is false\n");
assert(0);
}

ObjcSelector *ObjcSelector::lookup(const char *s)
{
printf("Should never be called when D_OBJC is false\n");
Expand Down Expand Up @@ -107,12 +113,3 @@ void objc_FuncDeclaration_semantic_checkLinkage(FuncDeclaration *fd)
// noop
}

void objc_tryMain_dObjc()
{
// noop
}

void objc_tryMain_init()
{
// noop
}
9 changes: 0 additions & 9 deletions src/objc_stubs.d
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,3 @@ extern (C++) void objc_FuncDeclaration_semantic_checkLinkage(FuncDeclaration fd)
// noop
}

extern (C++) void objc_tryMain_dObjc()
{
// noop
}

extern (C++) void objc_tryMain_init()
{
// noop
}