Index: configure.ac ================================================================== --- configure.ac +++ configure.ac @@ -17,12 +17,14 @@ BUILDSYS_LIB AC_DEFINE_UNQUOTED(PLUGIN_SUFFIX, "$PLUGIN_SUFFIX", [Suffix for plugins]) if test x"$PLUGIN_SUFFIX" != "x"; then AC_SUBST(OFPLUGIN_M, "OFPlugin.m") - AC_SUBST(OFPLUGIN, "OFPlugin") - AC_SUBST(OFPLUGIN_DEF, "-DOF_PLUGINS") + AC_SUBST(PLUGIN_M, "plugin.m") + AC_SUBST(TESTPLUGIN, "plugin") + AC_DEFINE(OF_PLUGINS, 1, [Whether we have plugin support]) + AC_SUBST(OFPLUGINS_DEF, "-DOF_PLUGINS") fi AC_C_BIGENDIAN([ AC_DEFINE(OF_BIG_ENDIAN, 1, [Whether we are big endian]) AC_SUBST(ENDIANESS_DEF, "-DOF_BIG_ENDIAN") Index: extra.mk.in ================================================================== --- extra.mk.in +++ extra.mk.in @@ -1,8 +1,9 @@ ASPRINTF_C = @ASPRINTF_C@ OBJC_SYNC = @OBJC_SYNC@ OBJC_SYNC_M = @OBJC_SYNC_M@ -OFPLUGIN = @OFPLUGIN@ OFPLUGIN_M = @OFPLUGIN_M@ +PLUGIN_M = @PLUGIN_M@ +TESTPLUGIN = @TESTPLUGIN@ WS2_LIBS = @WS2_LIBS@ TESTS = @TESTS@ TEST_LAUNCHER = @TEST_LAUNCHER@ Index: objfw-config.in ================================================================== --- objfw-config.in +++ objfw-config.in @@ -2,11 +2,11 @@ prefix="@prefix@" exec_prefix="@exec_prefix@" libdir="@libdir@" CFLAGS="" CPPFLAGS="-I@includedir@ -DOF_CONFIGURED @ENDIANESS_DEF@ @ASPRINTF_DEF@" -CPPFLAGS="$CPPFLAGS @OFPLUGIN_DEF@" +CPPFLAGS="$CPPFLAGS @OFPLUGINS_DEF@" CXXFLAGS="" OBJCFLAGS="-fobjc-exceptions -fconstant-string-class=OFConstString" OBJCFLAGS="$OBJCFLAGS @NO_CONST_CFSTRINGS@" LDFLAGS="@RPATH_LDFLAGS@" LIBS="-L${libdir} -lobjfw @LIBS@" Index: tests/Makefile ================================================================== --- tests/Makefile +++ tests/Makefile @@ -1,8 +1,7 @@ include ../extra.mk -SUBDIRS = ${OFPLUGIN} \ - OFThread \ +SUBDIRS = OFThread \ OFXMLParser \ ${OBJC_SYNC} include ../buildsys.mk DELETED tests/OFPlugin/Makefile Index: tests/OFPlugin/Makefile ================================================================== --- tests/OFPlugin/Makefile +++ tests/OFPlugin/Makefile @@ -1,31 +0,0 @@ -SUBDIRS = TestPlugin - -PROG_NOINST = ofplugin${PROG_SUFFIX} -SRCS = OFPlugin.m - -include ../../buildsys.mk -include ../../extra.mk - -CPPFLAGS += -I../../src -I../.. -LIBS := -L../../src -lobjfw ${LIBS} - -.PHONY: run - -all: run -run: subdirs ${PROG_NOINST} - rm -f libobjfw.so.0 libobjfw.so.0.1 libobjfw.dll libobjfw.dylib - if test -f ../../src/libobjfw.so; then \ - ln -s ../../src/libobjfw.so libobjfw.so.0; \ - ln -s ../../src/libobjfw.so libobjfw.so.0.1; \ - fi - if test -f ../../src/libobjfw.dll; then \ - ln ../../src/libobjfw.dll libobjfw.dll; \ - fi - if test -f ../../src/libobjfw.dylib; then \ - ln -s ../../src/libobjfw.dylib libobjfw.dylib; \ - fi - LD_LIBRARY_PATH=.$${LD_LIBRARY_PATH+:}$$LD_LIBRARY_PATH \ - DYLD_LIBRARY_PATH=.$${DYLD_LIBRARY_PATH+:}$$DYLD_LIBRARY_PATH \ - ${TEST_LAUNCHER} ./${PROG_NOINST}; EXIT=$$?; \ - rm -f libobjfw.so.0 libobjfw.so.0.1 libobjfw.dll libobjfw.dylib; \ - exit $$EXIT DELETED tests/OFPlugin/OFPlugin.m Index: tests/OFPlugin/OFPlugin.m ================================================================== --- tests/OFPlugin/OFPlugin.m +++ tests/OFPlugin/OFPlugin.m @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2008 - 2009 - * Jonathan Schleifer - * - * All rights reserved. - * - * This file is part of libobjfw. It may be distributed under the terms of the - * Q Public License 1.0, which can be found in the file LICENSE included in - * the packaging of this file. - */ - -#include "config.h" - -#include - -#import "OFPlugin.h" -#import "TestPlugin/TestPlugin.h" - -int -main() -{ - TestPlugin *plugin; - - plugin = [OFPlugin pluginFromFile: @"TestPlugin/TestPlugin"]; - if ([plugin test: 1234] != 2468) { - puts("\033[K\033[1;31mTest 1/1 failed!\033[m"); - return 1; - } - - puts("\033[1;32mTests successful: 1/1\033[0m"); - return 0; -} DELETED tests/OFPlugin/TestPlugin/Makefile Index: tests/OFPlugin/TestPlugin/Makefile ================================================================== --- tests/OFPlugin/TestPlugin/Makefile +++ tests/OFPlugin/TestPlugin/Makefile @@ -1,9 +0,0 @@ -PLUGIN_NOINST = TestPlugin${PLUGIN_SUFFIX} -SRCS = TestPlugin.m - -include ../../../buildsys.mk -include ../../../extra.mk - -CPPFLAGS += ${PLUGIN_CPPFLAGS} -I../../.. -I../../../src -OBJCFLAGS += ${PLUGIN_CFLAGS} -LIBS := -L../../../src -lobjfw ${LIBS} DELETED tests/OFPlugin/TestPlugin/TestPlugin.h Index: tests/OFPlugin/TestPlugin/TestPlugin.h ================================================================== --- tests/OFPlugin/TestPlugin/TestPlugin.h +++ tests/OFPlugin/TestPlugin/TestPlugin.h @@ -1,16 +0,0 @@ -/* - * Copyright (c) 2008 - 2009 - * Jonathan Schleifer - * - * All rights reserved. - * - * This file is part of libobjfw. It may be distributed under the terms of the - * Q Public License 1.0, which can be found in the file LICENSE included in - * the packaging of this file. - */ - -#import "OFPlugin.h" - -@interface TestPlugin: OFPlugin -- (int)test: (int)num; -@end DELETED tests/OFPlugin/TestPlugin/TestPlugin.m Index: tests/OFPlugin/TestPlugin/TestPlugin.m ================================================================== --- tests/OFPlugin/TestPlugin/TestPlugin.m +++ tests/OFPlugin/TestPlugin/TestPlugin.m @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2008 - 2009 - * Jonathan Schleifer - * - * All rights reserved. - * - * This file is part of libobjfw. It may be distributed under the terms of the - * Q Public License 1.0, which can be found in the file LICENSE included in - * the packaging of this file. - */ - -#include "config.h" - -#import "TestPlugin.h" - -@implementation TestPlugin -- (int)test: (int)num -{ - return num * 2; -} -@end - -id -init_plugin() -{ - return [[TestPlugin alloc] init]; -} Index: tests_new/Makefile ================================================================== --- tests_new/Makefile +++ tests_new/Makefile @@ -1,27 +1,24 @@ +include ../extra.mk + +SUBDIRS = ${TESTPLUGIN} + PROG_NOINST = tests${PROG_SUFFIX} SRCS = array.m \ dataarray.m \ dictionary.m \ hashes.m \ list.m \ main.m \ object.m \ + ${PLUGIN_M} \ string.m \ tcpsocket.m \ xmlelement.m -include ../buildsys.mk -include ../extra.mk - -CPPFLAGS += -I../src -I.. -DSTDOUT -LIBS := -L../src -lobjfw ${LIBS} - .PHONY: run - -all: run -run: ${PROG_NOINST} +run: all rm -f libobjfw.so.0 libobjfw.so.0.1 libobjfw.dll libobjfw.dylib if test -f ../src/libobjfw.so; then \ ln -s ../src/libobjfw.so libobjfw.so.0; \ ln -s ../src/libobjfw.so libobjfw.so.0.1; \ fi @@ -34,5 +31,10 @@ LD_LIBRARY_PATH=.$${LD_LIBRARY_PATH+:}$$LD_LIBRARY_PATH \ DYLD_LIBRARY_PATH=.$${DYLD_LIBRARY_PATH+:}$$DYLD_LIBRARY_PATH \ ${TEST_LAUNCHER} ./${PROG_NOINST}; EXIT=$$?; \ rm -f libobjfw.so.0 libobjfw.so.0.1 libobjfw.dll libobjfw.dylib; \ exit $$EXIT + +include ../buildsys.mk + +CPPFLAGS += -I../src -I.. -DSTDOUT +LIBS := -L../src -lobjfw ${LIBS} Index: tests_new/main.m ================================================================== --- tests_new/main.m +++ tests_new/main.m @@ -23,10 +23,13 @@ extern void dataarray_tests(); extern void dictionary_tests(); extern void hashes_tests(); extern void list_tests(); extern void object_tests(); +#ifdef OF_PLUGINS +extern void plugin_tests(); +#endif extern void string_tests(); extern void tcpsocket_tests(); extern void xmlelement_tests(); static int fails = 0; @@ -99,8 +102,11 @@ array_tests(); dictionary_tests(); list_tests(); tcpsocket_tests(); xmlelement_tests(); +#ifdef OF_PLUGINS + plugin_tests(); +#endif return fails; } ADDED tests_new/plugin.m Index: tests_new/plugin.m ================================================================== --- tests_new/plugin.m +++ tests_new/plugin.m @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2008 - 2009 + * Jonathan Schleifer + * + * All rights reserved. + * + * This file is part of libobjfw. It may be distributed under the terms of the + * Q Public License 1.0, which can be found in the file LICENSE included in + * the packaging of this file. + */ + +#include "config.h" + +#import "OFPlugin.h" +#import "OFAutoreleasePool.h" +#import "OFString.h" +#import "OFExceptions.h" + +#import "main.h" + +#import "plugin/TestPlugin.h" + +static OFString *module = @"OFPlugin"; + +void +plugin_tests() +{ + OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; + TestPlugin *plugin; + + TEST(@"+[pluginFromFile:]", + (plugin = [OFPlugin pluginFromFile: @"plugin/TestPlugin"])) + + TEST(@"TestPlugin's -[test:]", [plugin test: 1234] == 2468) + + [pool release]; +} ADDED tests_new/plugin/Makefile Index: tests_new/plugin/Makefile ================================================================== --- tests_new/plugin/Makefile +++ tests_new/plugin/Makefile @@ -0,0 +1,9 @@ +PLUGIN_NOINST = TestPlugin${PLUGIN_SUFFIX} +SRCS = TestPlugin.m + +include ../../buildsys.mk +include ../../extra.mk + +CPPFLAGS += ${PLUGIN_CPPFLAGS} -I../.. -I../../src +OBJCFLAGS += ${PLUGIN_CFLAGS} +LIBS := -L../../src -lobjfw ${LIBS} ADDED tests_new/plugin/TestPlugin.h Index: tests_new/plugin/TestPlugin.h ================================================================== --- tests_new/plugin/TestPlugin.h +++ tests_new/plugin/TestPlugin.h @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2008 - 2009 + * Jonathan Schleifer + * + * All rights reserved. + * + * This file is part of libobjfw. It may be distributed under the terms of the + * Q Public License 1.0, which can be found in the file LICENSE included in + * the packaging of this file. + */ + +#import "OFPlugin.h" + +@interface TestPlugin: OFPlugin +- (int)test: (int)num; +@end ADDED tests_new/plugin/TestPlugin.m Index: tests_new/plugin/TestPlugin.m ================================================================== --- tests_new/plugin/TestPlugin.m +++ tests_new/plugin/TestPlugin.m @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2008 - 2009 + * Jonathan Schleifer + * + * All rights reserved. + * + * This file is part of libobjfw. It may be distributed under the terms of the + * Q Public License 1.0, which can be found in the file LICENSE included in + * the packaging of this file. + */ + +#include "config.h" + +#import "TestPlugin.h" + +@implementation TestPlugin +- (int)test: (int)num +{ + return num * 2; +} +@end + +id +init_plugin() +{ + return [[[TestPlugin alloc] init] autorelease]; +}