diff --git a/.gitignore b/.gitignore index 2252c407b9..41511b8ebd 100644 --- a/.gitignore +++ b/.gitignore @@ -39,6 +39,8 @@ libsass/* *.o *.lo +*.so +*.dll *.a a.out libsass.js @@ -46,6 +48,7 @@ libsass.js bin/* .deps/ .libs/ +win/bin # Final results diff --git a/Makefile b/Makefile index c6df9c8b88..885db5c382 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,26 @@ -CC ?= cc +CC ?= gcc CXX ?= g++ RM ?= rm -f +CP ?= cp -a MKDIR ?= mkdir -p -CFLAGS ?= -Wall -fPIC -O2 -CXXFLAGS ?= -Wall -fPIC -O2 -LDFLAGS ?= -Wall -fPIC -O2 +WINDRES ?= windres +CFLAGS ?= -Wall -O2 +CXXFLAGS ?= -Wall -O2 +LDFLAGS ?= -Wall -O2 + +ifneq (,$(findstring /cygdrive/,$(PATH))) + UNAME := Cygwin +else + ifneq (,$(findstring WINDOWS,$(PATH))) + UNAME := Windows + else + ifneq (,$(findstring mingw32,$(MAKE))) + UNAME := MinGW + else + UNAME := $(shell uname -s) + endif + endif +endif ifeq "$(LIBSASS_VERSION)" "" ifneq "$(wildcard ./.git/ )" "" @@ -18,8 +34,13 @@ ifneq "$(LIBSASS_VERSION)" "" endif # enable mandatory flag -CXXFLAGS += -std=c++0x -LDFLAGS += -std=c++0x +ifeq (MinGW,$(UNAME)) + CXXFLAGS += -std=gnu++0x + LDFLAGS += -std=gnu++0x +else + CXXFLAGS += -std=c++0x + LDFLAGS += -std=c++0x +endif ifneq "$(SASS_LIBSASS_PATH)" "" CFLAGS += -I $(SASS_LIBSASS_PATH) @@ -36,23 +57,14 @@ ifneq "$(EXTRA_LDFLAGS)" "" LDFLAGS += $(EXTRA_LDFLAGS) endif -ifneq (,$(findstring /cygdrive/,$(PATH))) - UNAME := Cygwin -else - ifneq (,$(findstring WINDOWS,$(PATH))) - UNAME := Windows - else - UNAME := $(shell uname -s) - endif -endif - LDLIBS = -lstdc++ -lm ifeq ($(UNAME),Darwin) CFLAGS += -stdlib=libc++ CXXFLAGS += -stdlib=libc++ + LDFLAGS += -stdlib=libc++ endif -ifneq ($(BUILD), shared) +ifneq ($(BUILD),shared) BUILD = static endif @@ -70,6 +82,13 @@ SASS_SPEC_SPEC_DIR ?= spec SASSC_BIN = $(SASS_SASSC_PATH)/bin/sassc RUBY_BIN = ruby +ifeq (MinGW,$(UNAME)) + SASSC_BIN = $(SASS_SASSC_PATH)/bin/sassc.exe +endif +ifeq (Windows,$(UNAME)) + SASSC_BIN = $(SASS_SASSC_PATH)/bin/sassc.exe +endif + SOURCES = \ ast.cpp \ base64vlq.cpp \ @@ -108,8 +127,26 @@ SOURCES = \ CSOURCES = cencode.c +RESOURCES = + +LIBRARIES = lib/libsass.so + +ifeq (MinGW,$(UNAME)) + ifeq (shared,$(BUILD)) + CFLAGS += -D ADD_EXPORTS + CXXFLAGS += -D ADD_EXPORTS + LIBRARIES += lib/libsass.dll + RESOURCES += res/resource.rc + endif +else + CFLAGS += -fPIC + CXXFLAGS += -fPIC + LDFLAGS += -fPIC +endif + OBJECTS = $(SOURCES:.cpp=.o) COBJECTS = $(CSOURCES:.c=.o) +RCOBJECTS = $(RESOURCES:.rc=.o) DEBUG_LVL ?= NONE @@ -128,19 +165,26 @@ debug-shared: CXXFLAGS := -g -DDEBUG -DDEBUG_LVL="$(DEBUG_LVL)" $(filter-out -O2 debug-shared: shared static: lib/libsass.a -shared: lib/libsass.so +shared: $(LIBRARIES) lib/libsass.a: $(COBJECTS) $(OBJECTS) $(MKDIR) lib - $(AR) rvs $@ $(COBJECTS) $(OBJECTS) + $(AR) rcvs $@ $(COBJECTS) $(OBJECTS) lib/libsass.so: $(COBJECTS) $(OBJECTS) $(MKDIR) lib $(CXX) -shared $(LDFLAGS) -o $@ $(COBJECTS) $(OBJECTS) $(LDLIBS) +lib/libsass.dll: $(COBJECTS) $(OBJECTS) $(RCOBJECTS) + $(MKDIR) lib + $(CXX) -shared $(LDFLAGS) -o $@ $(COBJECTS) $(OBJECTS) $(RCOBJECTS) $(LDLIBS) -s -Wl,--subsystem,windows,--out-implib,lib/libsass.a + %.o: %.c $(CC) $(CFLAGS) -c -o $@ $< +%.o: %.rc + $(WINDRES) -i $< -o $@ + %.o: %.cpp $(CXX) $(CXXFLAGS) -c -o $@ $< @@ -160,6 +204,9 @@ install-shared: lib/libsass.so $(SASSC_BIN): $(BUILD) cd $(SASS_SASSC_PATH) && $(MAKE) +sassc: $(SASSC_BIN) + $(SASSC_BIN) -v + test: $(SASSC_BIN) $(RUBY_BIN) $(SASS_SPEC_PATH)/sass-spec.rb -c $(SASSC_BIN) -s $(LOG_FLAGS) $(SASS_SPEC_PATH)/$(SASS_SPEC_SPEC_DIR) @@ -170,7 +217,7 @@ test_issues: $(SASSC_BIN) $(RUBY_BIN) $(SASS_SPEC_PATH)/sass-spec.rb -c $(SASSC_BIN) $(LOG_FLAGS) $(SASS_SPEC_PATH)/spec/issues clean: - $(RM) $(COBJECTS) $(OBJECTS) lib/*.a lib/*.la lib/*.so + $(RM) $(RCOBJECTS) $(COBJECTS) $(OBJECTS) $(LIBRARIES) lib/*.a lib/*.so lib/*.dll lib/*.la -.PHONY: all debug debug-static debug-shared static shared install install-static install-shared clean +.PHONY: all debug debug-static debug-shared static shared install install-static install-shared sassc clean diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 0000000000..761b260b56 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,69 @@ +environment: + CTEST_OUTPUT_ON_FAILURE: 1 + matrix: + - Compiler: mingw + Build: static + ruby_version: "21-x64" + - Compiler: mingw + Build: shared + ruby_version: "21-x64" + - Compiler: msvc + Config: Release + ruby_version: "21-x64" + - Compiler: msvc + Config: Debug + ruby_version: "21-x64" + +install: + - git clone https://github.com/mgreter/sassc.git --branch feature/build-dll-win-mingw + - git clone https://github.com/sass/sass-spec.git + - set PATH=C:\Ruby%ruby_version%\bin;%PATH% + - set SASS_LIBSASS_PATH=.. + - gem install minitest + - ps: | + if ($env:Compiler -eq "mingw") { + # Install MinGW. + $url = "http://sourceforge.net/projects/mingw-w64/files/" + $url += "Toolchains%20targetting%20Win64/Personal%20Builds/" + $url += "mingw-builds/4.9.2/threads-win32/seh/" + $url += "x86_64-4.9.2-release-win32-seh-rt_v3-rev0.7z/download" + Invoke-WebRequest -UserAgent wget -Uri $url -OutFile mingw.7z + &7z x -oC:\ mingw.7z > $null + } + - set PATH=C:\mingw64\bin;%PATH% + - set CC=gcc + +build_script: + - ps: | + if ($env:Compiler -eq "mingw") { + mingw32-make -j4 sassc + } else { + msbuild /m:4 /p:Configuration=$env:Config win\libsass.sln + } + - ps: | + if ($env:Compiler -eq "mingw") { + sassc\bin\sassc.exe -v + ruby -v + } else { + if ($env:Config -eq "Debug") { + win\bin\Debug\sassc.exe -v + ruby -v + } else { + win\bin\sassc.exe -v + ruby -v + } + } + +test_script: + - ps: | + if ($env:Compiler -eq "mingw") { + ruby sass-spec\sass-spec.rb -c sassc\bin\sassc.exe -s --ignore-todo sass-spec/spec + } else { + if ($env:Config -eq "Debug") { + echo test runner in debug mode build via msvc will throw debug assertions + echo ruby sass-spec\sass-spec.rb -c win\bin\Debug\sassc.exe -s --ignore-todo sass-spec/spec + } else { + ruby sass-spec\sass-spec.rb -c win\bin\sassc.exe -s --ignore-todo sass-spec/spec + } + } + diff --git a/functions.cpp b/functions.cpp index 53af939d01..fc21433454 100644 --- a/functions.cpp +++ b/functions.cpp @@ -22,6 +22,10 @@ #include #include +#ifdef __MINGW32__ +#include "windows.h" +#endif + #define ARG(argname, argtype) get_arg(argname, env, sig, path, position, backtrace) #define ARGR(argname, argtype, lo, hi) get_arg_r(argname, env, sig, path, position, lo, hi, backtrace) #define ARGM(argname, argtype, ctx) get_arg_m(argname, env, sig, path, position, backtrace, ctx) @@ -112,12 +116,33 @@ namespace Sass { return val; } +#ifdef __MINGW32__ + uint64_t GetSeed() + { + HCRYPTPROV hp = 0; + BYTE rb[8]; + CryptAcquireContext(&hp, 0, 0, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT); + CryptGenRandom(hp, sizeof(rb), rb); + CryptReleaseContext(hp, 0); + + uint64_t seed; + memcpy(&seed, &rb[0], sizeof(seed)); + + return seed; + } +#else + static random_device rd; + uint64_t GetSeed() + { + return rd(); + } +#endif + // note: the performance of many implementations of // random_device degrades sharply once the entropy pool // is exhausted. For practical use, random_device is // generally only used to seed a PRNG such as mt19937. - static random_device rd; - static mt19937 rand(rd()); + static mt19937 rand(GetSeed()); // features static set features; diff --git a/posix/getopt.c b/posix/getopt.c new file mode 100644 index 0000000000..ac1fda426e --- /dev/null +++ b/posix/getopt.c @@ -0,0 +1,562 @@ +/* $OpenBSD: getopt_long.c,v 1.23 2007/10/31 12:34:57 chl Exp $ */ +/* $NetBSD: getopt_long.c,v 1.15 2002/01/31 22:43:40 tv Exp $ */ + +/* + * Copyright (c) 2002 Todd C. Miller + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Sponsored in part by the Defense Advanced Research Projects + * Agency (DARPA) and Air Force Research Laboratory, Air Force + * Materiel Command, USAF, under agreement number F39502-99-1-0512. + */ +/*- + * Copyright (c) 2000 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Dieter Baron and Thomas Klausner. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include +#include +#include +#include +#include +#include + +#define REPLACE_GETOPT /* use this getopt as the system getopt(3) */ + +#ifdef REPLACE_GETOPT +int opterr = 1; /* if error message should be printed */ +int optind = 1; /* index into parent argv vector */ +int optopt = '?'; /* character checked for validity */ +#undef optreset /* see getopt.h */ +#define optreset __mingw_optreset +int optreset; /* reset getopt */ +char *optarg; /* argument associated with option */ +#endif + +#define PRINT_ERROR ((opterr) && (*options != ':')) + +#define FLAG_PERMUTE 0x01 /* permute non-options to the end of argv */ +#define FLAG_ALLARGS 0x02 /* treat non-options as args to option "-1" */ +#define FLAG_LONGONLY 0x04 /* operate as getopt_long_only */ + +/* return values */ +#define BADCH (int)'?' +#define BADARG ((*options == ':') ? (int)':' : (int)'?') +#define INORDER (int)1 + +#ifndef __CYGWIN__ +#define __progname __argv[0] +#else +extern char __declspec(dllimport) *__progname; +#endif + +#ifdef __CYGWIN__ +static char EMSG[] = ""; +#else +#define EMSG "" +#endif + +static int getopt_internal(int, char * const *, const char *, + const struct option *, int *, int); +static int parse_long_options(char * const *, const char *, + const struct option *, int *, int); +static int gcd(int, int); +static void permute_args(int, int, int, char * const *); + +static char *place = EMSG; /* option letter processing */ + +/* XXX: set optreset to 1 rather than these two */ +static int nonopt_start = -1; /* first non option argument (for permute) */ +static int nonopt_end = -1; /* first option after non options (for permute) */ + +/* Error messages */ +static const char recargchar[] = "option requires an argument -- %c"; +static const char recargstring[] = "option requires an argument -- %s"; +static const char ambig[] = "ambiguous option -- %.*s"; +static const char noarg[] = "option doesn't take an argument -- %.*s"; +static const char illoptchar[] = "unknown option -- %c"; +static const char illoptstring[] = "unknown option -- %s"; + +static void +_vwarnx(const char *fmt,va_list ap) +{ + (void)fprintf(stderr,"%s: ",__progname); + if (fmt != NULL) + (void)vfprintf(stderr,fmt,ap); + (void)fprintf(stderr,"\n"); +} + +static void +warnx(const char *fmt,...) +{ + va_list ap; + va_start(ap,fmt); + _vwarnx(fmt,ap); + va_end(ap); +} + +/* + * Compute the greatest common divisor of a and b. + */ +static int +gcd(int a, int b) +{ + int c; + + c = a % b; + while (c != 0) { + a = b; + b = c; + c = a % b; + } + + return (b); +} + +/* + * Exchange the block from nonopt_start to nonopt_end with the block + * from nonopt_end to opt_end (keeping the same order of arguments + * in each block). + */ +static void +permute_args(int panonopt_start, int panonopt_end, int opt_end, + char * const *nargv) +{ + int cstart, cyclelen, i, j, ncycle, nnonopts, nopts, pos; + char *swap; + + /* + * compute lengths of blocks and number and size of cycles + */ + nnonopts = panonopt_end - panonopt_start; + nopts = opt_end - panonopt_end; + ncycle = gcd(nnonopts, nopts); + cyclelen = (opt_end - panonopt_start) / ncycle; + + for (i = 0; i < ncycle; i++) { + cstart = panonopt_end+i; + pos = cstart; + for (j = 0; j < cyclelen; j++) { + if (pos >= panonopt_end) + pos -= nnonopts; + else + pos += nopts; + swap = nargv[pos]; + /* LINTED const cast */ + ((char **) nargv)[pos] = nargv[cstart]; + /* LINTED const cast */ + ((char **)nargv)[cstart] = swap; + } + } +} + +/* + * parse_long_options -- + * Parse long options in argc/argv argument vector. + * Returns -1 if short_too is set and the option does not match long_options. + */ +static int +parse_long_options(char * const *nargv, const char *options, + const struct option *long_options, int *idx, int short_too) +{ + char *current_argv, *has_equal; + size_t current_argv_len; + int i, ambiguous, match; + +#define IDENTICAL_INTERPRETATION(_x, _y) \ + (long_options[(_x)].has_arg == long_options[(_y)].has_arg && \ + long_options[(_x)].flag == long_options[(_y)].flag && \ + long_options[(_x)].val == long_options[(_y)].val) + + current_argv = place; + match = -1; + ambiguous = 0; + + optind++; + + if ((has_equal = strchr(current_argv, '=')) != NULL) { + /* argument found (--option=arg) */ + current_argv_len = has_equal - current_argv; + has_equal++; + } else + current_argv_len = strlen(current_argv); + + for (i = 0; long_options[i].name; i++) { + /* find matching long option */ + if (strncmp(current_argv, long_options[i].name, + current_argv_len)) + continue; + + if (strlen(long_options[i].name) == current_argv_len) { + /* exact match */ + match = i; + ambiguous = 0; + break; + } + /* + * If this is a known short option, don't allow + * a partial match of a single character. + */ + if (short_too && current_argv_len == 1) + continue; + + if (match == -1) /* partial match */ + match = i; + else if (!IDENTICAL_INTERPRETATION(i, match)) + ambiguous = 1; + } + if (ambiguous) { + /* ambiguous abbreviation */ + if (PRINT_ERROR) + warnx(ambig, (int)current_argv_len, + current_argv); + optopt = 0; + return (BADCH); + } + if (match != -1) { /* option found */ + if (long_options[match].has_arg == no_argument + && has_equal) { + if (PRINT_ERROR) + warnx(noarg, (int)current_argv_len, + current_argv); + /* + * XXX: GNU sets optopt to val regardless of flag + */ + if (long_options[match].flag == NULL) + optopt = long_options[match].val; + else + optopt = 0; + return (BADARG); + } + if (long_options[match].has_arg == required_argument || + long_options[match].has_arg == optional_argument) { + if (has_equal) + optarg = has_equal; + else if (long_options[match].has_arg == + required_argument) { + /* + * optional argument doesn't use next nargv + */ + optarg = nargv[optind++]; + } + } + if ((long_options[match].has_arg == required_argument) + && (optarg == NULL)) { + /* + * Missing argument; leading ':' indicates no error + * should be generated. + */ + if (PRINT_ERROR) + warnx(recargstring, + current_argv); + /* + * XXX: GNU sets optopt to val regardless of flag + */ + if (long_options[match].flag == NULL) + optopt = long_options[match].val; + else + optopt = 0; + --optind; + return (BADARG); + } + } else { /* unknown option */ + if (short_too) { + --optind; + return (-1); + } + if (PRINT_ERROR) + warnx(illoptstring, current_argv); + optopt = 0; + return (BADCH); + } + if (idx) + *idx = match; + if (long_options[match].flag) { + *long_options[match].flag = long_options[match].val; + return (0); + } else + return (long_options[match].val); +#undef IDENTICAL_INTERPRETATION +} + +/* + * getopt_internal -- + * Parse argc/argv argument vector. Called by user level routines. + */ +static int +getopt_internal(int nargc, char * const *nargv, const char *options, + const struct option *long_options, int *idx, int flags) +{ + char *oli; /* option letter list index */ + int optchar, short_too; + static int posixly_correct = -1; + + if (options == NULL) + return (-1); + + /* + * XXX Some GNU programs (like cvs) set optind to 0 instead of + * XXX using optreset. Work around this braindamage. + */ + if (optind == 0) + optind = optreset = 1; + + /* + * Disable GNU extensions if POSIXLY_CORRECT is set or options + * string begins with a '+'. + * + * CV, 2009-12-14: Check POSIXLY_CORRECT anew if optind == 0 or + * optreset != 0 for GNU compatibility. + */ + if (posixly_correct == -1 || optreset != 0) + posixly_correct = (getenv("POSIXLY_CORRECT") != NULL); + if (*options == '-') + flags |= FLAG_ALLARGS; + else if (posixly_correct || *options == '+') + flags &= ~FLAG_PERMUTE; + if (*options == '+' || *options == '-') + options++; + + optarg = NULL; + if (optreset) + nonopt_start = nonopt_end = -1; +start: + if (optreset || !*place) { /* update scanning pointer */ + optreset = 0; + if (optind >= nargc) { /* end of argument vector */ + place = EMSG; + if (nonopt_end != -1) { + /* do permutation, if we have to */ + permute_args(nonopt_start, nonopt_end, + optind, nargv); + optind -= nonopt_end - nonopt_start; + } + else if (nonopt_start != -1) { + /* + * If we skipped non-options, set optind + * to the first of them. + */ + optind = nonopt_start; + } + nonopt_start = nonopt_end = -1; + return (-1); + } + if (*(place = nargv[optind]) != '-' || + (place[1] == '\0' && strchr(options, '-') == NULL)) { + place = EMSG; /* found non-option */ + if (flags & FLAG_ALLARGS) { + /* + * GNU extension: + * return non-option as argument to option 1 + */ + optarg = nargv[optind++]; + return (INORDER); + } + if (!(flags & FLAG_PERMUTE)) { + /* + * If no permutation wanted, stop parsing + * at first non-option. + */ + return (-1); + } + /* do permutation */ + if (nonopt_start == -1) + nonopt_start = optind; + else if (nonopt_end != -1) { + permute_args(nonopt_start, nonopt_end, + optind, nargv); + nonopt_start = optind - + (nonopt_end - nonopt_start); + nonopt_end = -1; + } + optind++; + /* process next argument */ + goto start; + } + if (nonopt_start != -1 && nonopt_end == -1) + nonopt_end = optind; + + /* + * If we have "-" do nothing, if "--" we are done. + */ + if (place[1] != '\0' && *++place == '-' && place[1] == '\0') { + optind++; + place = EMSG; + /* + * We found an option (--), so if we skipped + * non-options, we have to permute. + */ + if (nonopt_end != -1) { + permute_args(nonopt_start, nonopt_end, + optind, nargv); + optind -= nonopt_end - nonopt_start; + } + nonopt_start = nonopt_end = -1; + return (-1); + } + } + + /* + * Check long options if: + * 1) we were passed some + * 2) the arg is not just "-" + * 3) either the arg starts with -- we are getopt_long_only() + */ + if (long_options != NULL && place != nargv[optind] && + (*place == '-' || (flags & FLAG_LONGONLY))) { + short_too = 0; + if (*place == '-') + place++; /* --foo long option */ + else if (*place != ':' && strchr(options, *place) != NULL) + short_too = 1; /* could be short option too */ + + optchar = parse_long_options(nargv, options, long_options, + idx, short_too); + if (optchar != -1) { + place = EMSG; + return (optchar); + } + } + + if ((optchar = (int)*place++) == (int)':' || + (optchar == (int)'-' && *place != '\0') || + (oli = strchr(options, optchar)) == NULL) { + /* + * If the user specified "-" and '-' isn't listed in + * options, return -1 (non-option) as per POSIX. + * Otherwise, it is an unknown option character (or ':'). + */ + if (optchar == (int)'-' && *place == '\0') + return (-1); + if (!*place) + ++optind; + if (PRINT_ERROR) + warnx(illoptchar, optchar); + optopt = optchar; + return (BADCH); + } + if (long_options != NULL && optchar == 'W' && oli[1] == ';') { + /* -W long-option */ + if (*place) /* no space */ + /* NOTHING */; + else if (++optind >= nargc) { /* no arg */ + place = EMSG; + if (PRINT_ERROR) + warnx(recargchar, optchar); + optopt = optchar; + return (BADARG); + } else /* white space */ + place = nargv[optind]; + optchar = parse_long_options(nargv, options, long_options, + idx, 0); + place = EMSG; + return (optchar); + } + if (*++oli != ':') { /* doesn't take argument */ + if (!*place) + ++optind; + } else { /* takes (optional) argument */ + optarg = NULL; + if (*place) /* no white space */ + optarg = place; + else if (oli[1] != ':') { /* arg not optional */ + if (++optind >= nargc) { /* no arg */ + place = EMSG; + if (PRINT_ERROR) + warnx(recargchar, optchar); + optopt = optchar; + return (BADARG); + } else + optarg = nargv[optind]; + } + place = EMSG; + ++optind; + } + /* dump back option letter */ + return (optchar); +} + +#ifdef REPLACE_GETOPT +/* + * getopt -- + * Parse argc/argv argument vector. + * + * [eventually this will replace the BSD getopt] + */ +int +getopt(int nargc, char * const *nargv, const char *options) +{ + + /* + * We don't pass FLAG_PERMUTE to getopt_internal() since + * the BSD getopt(3) (unlike GNU) has never done this. + * + * Furthermore, since many privileged programs call getopt() + * before dropping privileges it makes sense to keep things + * as simple (and bug-free) as possible. + */ + return (getopt_internal(nargc, nargv, options, NULL, NULL, 0)); +} +#endif /* REPLACE_GETOPT */ + +/* + * getopt_long -- + * Parse argc/argv argument vector. + */ +int +getopt_long(int nargc, char * const *nargv, const char *options, + const struct option *long_options, int *idx) +{ + + return (getopt_internal(nargc, nargv, options, long_options, idx, + FLAG_PERMUTE)); +} + +/* + * getopt_long_only -- + * Parse argc/argv argument vector. + */ +int +getopt_long_only(int nargc, char * const *nargv, const char *options, + const struct option *long_options, int *idx) +{ + + return (getopt_internal(nargc, nargv, options, long_options, idx, + FLAG_PERMUTE|FLAG_LONGONLY)); +} diff --git a/posix/getopt.h b/posix/getopt.h new file mode 100644 index 0000000000..260915b7f2 --- /dev/null +++ b/posix/getopt.h @@ -0,0 +1,95 @@ +#ifndef __GETOPT_H__ +/** + * DISCLAIMER + * This file has no copyright assigned and is placed in the Public Domain. + * This file is a part of the w64 mingw-runtime package. + * + * The w64 mingw-runtime package and its code is distributed in the hope that it + * will be useful but WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESSED OR + * IMPLIED ARE HEREBY DISCLAIMED. This includes but is not limited to + * warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + */ + +#define __GETOPT_H__ + +/* All the headers include this file. */ +#include + +#ifdef __cplusplus +extern "C" { +#endif + +extern int optind; /* index of first non-option in argv */ +extern int optopt; /* single option character, as parsed */ +extern int opterr; /* flag to enable built-in diagnostics... */ + /* (user may set to zero, to suppress) */ + +extern char *optarg; /* pointer to argument of current option */ + +extern int getopt(int nargc, char * const *nargv, const char *options); + +#ifdef _BSD_SOURCE +/* + * BSD adds the non-standard `optreset' feature, for reinitialisation + * of `getopt' parsing. We support this feature, for applications which + * proclaim their BSD heritage, before including this header; however, + * to maintain portability, developers are advised to avoid it. + */ +# define optreset __mingw_optreset +extern int optreset; +#endif +#ifdef __cplusplus +} +#endif +/* + * POSIX requires the `getopt' API to be specified in `unistd.h'; + * thus, `unistd.h' includes this header. However, we do not want + * to expose the `getopt_long' or `getopt_long_only' APIs, when + * included in this manner. Thus, close the standard __GETOPT_H__ + * declarations block, and open an additional __GETOPT_LONG_H__ + * specific block, only when *not* __UNISTD_H_SOURCED__, in which + * to declare the extended API. + */ +#endif /* !defined(__GETOPT_H__) */ + +#if !defined(__UNISTD_H_SOURCED__) && !defined(__GETOPT_LONG_H__) +#define __GETOPT_LONG_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +struct option /* specification for a long form option... */ +{ + const char *name; /* option name, without leading hyphens */ + int has_arg; /* does it take an argument? */ + int *flag; /* where to save its status, or NULL */ + int val; /* its associated status value */ +}; + +enum /* permitted values for its `has_arg' field... */ +{ + no_argument = 0, /* option never takes an argument */ + required_argument, /* option always requires an argument */ + optional_argument /* option may take an argument */ +}; + +extern int getopt_long(int nargc, char * const *nargv, const char *options, + const struct option *long_options, int *idx); +extern int getopt_long_only(int nargc, char * const *nargv, const char *options, + const struct option *long_options, int *idx); +/* + * Previous MinGW implementation had... + */ +#ifndef HAVE_DECL_GETOPT +/* + * ...for the long form API only; keep this for compatibility. + */ +# define HAVE_DECL_GETOPT 1 +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* !defined(__UNISTD_H_SOURCED__) && !defined(__GETOPT_LONG_H__) */ diff --git a/res/resource.rc b/res/resource.rc new file mode 100644 index 0000000000..1262b182c3 --- /dev/null +++ b/res/resource.rc @@ -0,0 +1,35 @@ +#include + +// DLL version information. +VS_VERSION_INFO VERSIONINFO +FILEVERSION 1,0,0,0 +PRODUCTVERSION 1,0,0,0 +FILEFLAGSMASK VS_FFI_FILEFLAGSMASK +#ifdef _DEBUG + FILEFLAGS VS_FF_DEBUG | VS_FF_PRERELEASE +#else + FILEFLAGS 0 +#endif +FILEOS VOS_NT_WINDOWS32 +FILETYPE VFT_DLL +FILESUBTYPE VFT2_UNKNOWN +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "080904b0" + BEGIN + VALUE "CompanyName", "Libsass Organization" + VALUE "FileDescription", "A C/C++ implementation of a Sass compiler" + VALUE "FileVersion", "0.9.0.0" + VALUE "InternalName", "libsass" + VALUE "LegalCopyright", "©2014 libsass.org" + VALUE "OriginalFilename", "libsass.dll" + VALUE "ProductName", "Libsass Library" + VALUE "ProductVersion", "0.9.0.0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x809, 1200 + END +END \ No newline at end of file diff --git a/sass.cpp b/sass.cpp index a5c5c9b58d..b58dd32ea5 100644 --- a/sass.cpp +++ b/sass.cpp @@ -10,7 +10,7 @@ extern "C" { using namespace std; // caller must free the returned memory - char* sass_string_quote (const char *str, const char quotemark) { + char* ADDCALL sass_string_quote (const char *str, const char quotemark) { string quoted = Sass::quote(str, quotemark); char *cstr = (char*) malloc(quoted.length() + 1); std::strcpy(cstr, quoted.c_str()); @@ -18,7 +18,7 @@ extern "C" { } // caller must free the returned memory - char* sass_string_unquote (const char *str) { + char* ADDCALL sass_string_unquote (const char *str) { string unquoted = Sass::unquote(str); char *cstr = (char*) malloc(unquoted.length() + 1); std::strcpy(cstr, unquoted.c_str()); @@ -26,7 +26,7 @@ extern "C" { } // Get compiled libsass version - const char* libsass_version(void) { + const char* ADDCALL libsass_version(void) { return LIBSASS_VERSION; } diff --git a/sass.h b/sass.h index 4ab1d733e4..90c76276c4 100644 --- a/sass.h +++ b/sass.h @@ -3,13 +3,35 @@ #include #include -#include "sass_values.h" -#include "sass_functions.h" + +#ifdef _WIN32 + + /* You should define ADD_EXPORTS *only* when building the DLL. */ + #ifdef ADD_EXPORTS + #define ADDAPI __declspec(dllexport) + #define ADDCALL __cdecl + #else + #define ADDAPI + #define ADDCALL + #endif + +#else /* _WIN32 not defined. */ + + /* Define with no value on non-Windows OSes. */ + #define ADDAPI + #define ADDCALL + +#endif #ifndef LIBSASS_VERSION #define LIBSASS_VERSION "[NA]" #endif +// include API headers +#include "sass_values.h" +#include "sass_functions.h" + +/* Make sure functions are exported with C linkage under C++ compilers. */ #ifdef __cplusplus extern "C" { #endif @@ -24,14 +46,15 @@ enum Sass_Output_Style { }; // Some convenient string helper function -char* sass_string_quote (const char *str, const char quotemark); -char* sass_string_unquote (const char *str); +ADDAPI char* ADDCALL sass_string_quote (const char *str, const char quotemark); +ADDAPI char* ADDCALL sass_string_unquote (const char *str); // Get compiled libsass version -const char* libsass_version(void); +ADDAPI const char* ADDCALL libsass_version(void); + #ifdef __cplusplus -} +} // __cplusplus defined. #endif #endif diff --git a/sass2scss.cpp b/sass2scss.cpp index 787aa1977a..6805f2075e 100644 --- a/sass2scss.cpp +++ b/sass2scss.cpp @@ -821,13 +821,13 @@ namespace Sass extern "C" { - char* sass2scss (const char* sass, const int options) + char* ADDCALL sass2scss (const char* sass, const int options) { return Sass::sass2scss(sass, options); } // Get compiled sass2scss version - const char* sass2scss_version(void) { + const char* ADDCALL sass2scss_version(void) { return SASS2SCSS_VERSION; } diff --git a/sass2scss.h b/sass2scss.h index 907d9ad058..280df4b292 100644 --- a/sass2scss.h +++ b/sass2scss.h @@ -1,3 +1,22 @@ +#ifdef _WIN32 + + /* You should define ADD_EXPORTS *only* when building the DLL. */ + #ifdef ADD_EXPORTS + #define ADDAPI __declspec(dllexport) + #define ADDCALL __cdecl + #else + #define ADDAPI + #define ADDCALL + #endif + +#else /* _WIN32 not defined. */ + + /* Define with no value on non-Windows OSes. */ + #define ADDAPI + #define ADDCALL + +#endif + #ifdef __cplusplus #include @@ -81,11 +100,11 @@ extern "C" { #define SASS2SCSS_CONVERT_COMMENT 128 // available to c and c++ code - char* sass2scss (const char* sass, const int options); + ADDAPI char* ADDCALL sass2scss (const char* sass, const int options); // Get compiled sass2scss version - const char* sass2scss_version(void); + ADDAPI const char* ADDCALL sass2scss_version(void); #ifdef __cplusplus -} +} // __cplusplus defined. #endif diff --git a/sass_context.cpp b/sass_context.cpp index df5acb1fc6..631f5ff2a3 100644 --- a/sass_context.cpp +++ b/sass_context.cpp @@ -155,19 +155,19 @@ extern "C" { #define IMPLEMENT_SASS_OPTION_ACCESSOR(type, option) \ - type sass_option_get_##option (struct Sass_Options* options) { return options->option; } \ - void sass_option_set_##option (struct Sass_Options* options, type option) { options->option = option; } + type ADDCALL sass_option_get_##option (struct Sass_Options* options) { return options->option; } \ + void ADDCALL sass_option_set_##option (struct Sass_Options* options, type option) { options->option = option; } #define IMPLEMENT_SASS_OPTION_STRING_ACCESSOR(type, option) \ - type sass_option_get_##option (struct Sass_Options* options) { return options->option; } \ - void sass_option_set_##option (struct Sass_Options* options, type option) \ + type ADDCALL sass_option_get_##option (struct Sass_Options* options) { return options->option; } \ + void ADDCALL sass_option_set_##option (struct Sass_Options* options, type option) \ { free(options->option); options->option = option ? strdup(option) : 0; } #define IMPLEMENT_SASS_CONTEXT_GETTER(type, option) \ - type sass_context_get_##option (struct Sass_Context* ctx) { return ctx->option; } + type ADDCALL sass_context_get_##option (struct Sass_Context* ctx) { return ctx->option; } #define IMPLEMENT_SASS_FILE_CONTEXT_SETTER(type, option) \ - void sass_file_context_set_##option (struct Sass_File_Context* ctx, type option) { ctx->option = option; } + void ADDCALL sass_file_context_set_##option (struct Sass_File_Context* ctx, type option) { ctx->option = option; } #define IMPLEMENT_SASS_DATA_CONTEXT_SETTER(type, option) \ - void sass_data_context_set_##option (struct Sass_Data_Context* ctx, type option) { ctx->option = option; } + void ADDCALL sass_data_context_set_##option (struct Sass_Data_Context* ctx, type option) { ctx->option = option; } // helper for safe access to c_ctx static const char* safe_str (const char* str) { @@ -430,12 +430,12 @@ extern "C" { return c_ctx->error_status; } - Sass_Options* sass_make_options (void) + Sass_Options* ADDCALL sass_make_options (void) { return (struct Sass_Options*) calloc(1, sizeof(struct Sass_Options)); } - Sass_File_Context* sass_make_file_context(const char* input_path) + Sass_File_Context* ADDCALL sass_make_file_context(const char* input_path) { struct Sass_File_Context* ctx = (struct Sass_File_Context*) calloc(1, sizeof(struct Sass_File_Context)); if (ctx == 0) return 0; @@ -444,7 +444,7 @@ extern "C" { return ctx; } - Sass_Data_Context* sass_make_data_context(char* source_string) + Sass_Data_Context* ADDCALL sass_make_data_context(char* source_string) { struct Sass_Data_Context* ctx = (struct Sass_Data_Context*) calloc(1, sizeof(struct Sass_Data_Context)); if (ctx == 0) return 0; @@ -453,7 +453,7 @@ extern "C" { return ctx; } - struct Sass_Compiler* sass_make_file_compiler (struct Sass_File_Context* c_ctx) + struct Sass_Compiler* ADDCALL sass_make_file_compiler (struct Sass_File_Context* c_ctx) { struct Sass_Compiler* compiler = (struct Sass_Compiler*) calloc(1, sizeof(struct Sass_Compiler)); if (compiler == 0) return 0; @@ -465,7 +465,7 @@ extern "C" { return compiler; } - struct Sass_Compiler* sass_make_data_compiler (struct Sass_Data_Context* c_ctx) + struct Sass_Compiler* ADDCALL sass_make_data_compiler (struct Sass_Data_Context* c_ctx) { struct Sass_Compiler* compiler = (struct Sass_Compiler*) calloc(1, sizeof(struct Sass_Compiler)); if (compiler == 0) return 0; @@ -477,7 +477,7 @@ extern "C" { return compiler; } - int sass_compile_data_context(Sass_Data_Context* data_ctx) + int ADDCALL sass_compile_data_context(Sass_Data_Context* data_ctx) { Sass_Context* c_ctx = data_ctx; Context::Data cpp_opt = Context::Data(); @@ -485,7 +485,7 @@ extern "C" { return sass_compile_context(c_ctx, cpp_opt); } - int sass_compile_file_context(Sass_File_Context* file_ctx) + int ADDCALL sass_compile_file_context(Sass_File_Context* file_ctx) { Sass_Context* c_ctx = file_ctx; Context::Data cpp_opt = Context::Data(); @@ -493,7 +493,7 @@ extern "C" { return sass_compile_context(c_ctx, cpp_opt); } - int sass_compiler_parse(struct Sass_Compiler* compiler) + int ADDCALL sass_compiler_parse(struct Sass_Compiler* compiler) { if (compiler->state == SASS_COMPILER_PARSED) return 0; if (compiler->state != SASS_COMPILER_CREATED) return -1; @@ -507,7 +507,7 @@ extern "C" { return 0; } - int sass_compiler_execute(struct Sass_Compiler* compiler) + int ADDCALL sass_compiler_execute(struct Sass_Compiler* compiler) { if (compiler == 0) return 0; if (compiler->state == SASS_COMPILER_EXECUTED) return 0; @@ -593,7 +593,7 @@ extern "C" { sass_clear_options(ctx); } - void sass_delete_compiler (struct Sass_Compiler* compiler) + void ADDCALL sass_delete_compiler (struct Sass_Compiler* compiler) { if (compiler == 0) return; Context* cpp_ctx = (Context*) compiler->cpp_ctx; @@ -603,19 +603,19 @@ extern "C" { } // Deallocate all associated memory with contexts - void sass_delete_file_context (struct Sass_File_Context* ctx) { sass_clear_context(ctx); free(ctx); } - void sass_delete_data_context (struct Sass_Data_Context* ctx) { sass_clear_context(ctx); free(ctx); } + void ADDCALL sass_delete_file_context (struct Sass_File_Context* ctx) { sass_clear_context(ctx); free(ctx); } + void ADDCALL sass_delete_data_context (struct Sass_Data_Context* ctx) { sass_clear_context(ctx); free(ctx); } // Getters for sass context from specific implementations - struct Sass_Context* sass_file_context_get_context(struct Sass_File_Context* ctx) { return ctx; } - struct Sass_Context* sass_data_context_get_context(struct Sass_Data_Context* ctx) { return ctx; } + struct Sass_Context* ADDCALL sass_file_context_get_context(struct Sass_File_Context* ctx) { return ctx; } + struct Sass_Context* ADDCALL sass_data_context_get_context(struct Sass_Data_Context* ctx) { return ctx; } // Getters for context options from Sass_Context - struct Sass_Options* sass_context_get_options(struct Sass_Context* ctx) { return ctx; } - struct Sass_Options* sass_file_context_get_options(struct Sass_File_Context* ctx) { return ctx; } - struct Sass_Options* sass_data_context_get_options(struct Sass_Data_Context* ctx) { return ctx; } - void sass_file_context_set_options (struct Sass_File_Context* ctx, struct Sass_Options* opt) { (Sass_Options) *ctx = *opt; } - void sass_data_context_set_options (struct Sass_Data_Context* ctx, struct Sass_Options* opt) { (Sass_Options) *ctx = *opt; } + struct Sass_Options* ADDCALL sass_context_get_options(struct Sass_Context* ctx) { return ctx; } + struct Sass_Options* ADDCALL sass_file_context_get_options(struct Sass_File_Context* ctx) { return ctx; } + struct Sass_Options* ADDCALL sass_data_context_get_options(struct Sass_Data_Context* ctx) { return ctx; } + void ADDCALL sass_file_context_set_options (struct Sass_File_Context* ctx, struct Sass_Options* opt) { (Sass_Options) *ctx = *opt; } + void ADDCALL sass_data_context_set_options (struct Sass_Data_Context* ctx, struct Sass_Options* opt) { (Sass_Options) *ctx = *opt; } // Create getter and setters for options IMPLEMENT_SASS_OPTION_ACCESSOR(int, precision); @@ -648,7 +648,7 @@ extern "C" { IMPLEMENT_SASS_DATA_CONTEXT_SETTER(char*, source_string); // Push function for include paths (no manipulation support for now) - void sass_option_push_include_path(struct Sass_Options* options, const char* path) + void ADDCALL sass_option_push_include_path(struct Sass_Options* options, const char* path) { struct string_list* include_path = (struct string_list*) calloc(1, sizeof(struct string_list)); diff --git a/sass_context.h b/sass_context.h index 1534c35d7d..0e6371b1b2 100644 --- a/sass_context.h +++ b/sass_context.h @@ -20,99 +20,99 @@ struct Sass_File_Context; // : Sass_Context struct Sass_Data_Context; // : Sass_Context // Create and initialize an option struct -struct Sass_Options* sass_make_options (void); +ADDAPI struct Sass_Options* ADDCALL sass_make_options (void); // Create and initialize a specific context -struct Sass_File_Context* sass_make_file_context (const char* input_path); -struct Sass_Data_Context* sass_make_data_context (char* source_string); +ADDAPI struct Sass_File_Context* ADDCALL sass_make_file_context (const char* input_path); +ADDAPI struct Sass_Data_Context* ADDCALL sass_make_data_context (char* source_string); // Call the compilation step for the specific context -int sass_compile_file_context (struct Sass_File_Context* ctx); -int sass_compile_data_context (struct Sass_Data_Context* ctx); +ADDAPI int ADDCALL sass_compile_file_context (struct Sass_File_Context* ctx); +ADDAPI int ADDCALL sass_compile_data_context (struct Sass_Data_Context* ctx); // Create a sass compiler instance for more control -struct Sass_Compiler* sass_make_file_compiler (struct Sass_File_Context* file_ctx); -struct Sass_Compiler* sass_make_data_compiler (struct Sass_Data_Context* data_ctx); +ADDAPI struct Sass_Compiler* ADDCALL sass_make_file_compiler (struct Sass_File_Context* file_ctx); +ADDAPI struct Sass_Compiler* ADDCALL sass_make_data_compiler (struct Sass_Data_Context* data_ctx); // Execute the different compilation steps individually // Usefull if you only want to query the included files -int sass_compiler_parse(struct Sass_Compiler* compiler); -int sass_compiler_execute(struct Sass_Compiler* compiler); +ADDAPI int ADDCALL sass_compiler_parse(struct Sass_Compiler* compiler); +ADDAPI int ADDCALL sass_compiler_execute(struct Sass_Compiler* compiler); // Release all memory allocated with the compiler // This does _not_ include any contexts or options -void sass_delete_compiler(struct Sass_Compiler* compiler); +ADDAPI void ADDCALL sass_delete_compiler(struct Sass_Compiler* compiler); // Release all memory allocated and also ourself -void sass_delete_file_context (struct Sass_File_Context* ctx); -void sass_delete_data_context (struct Sass_Data_Context* ctx); +ADDAPI void ADDCALL sass_delete_file_context (struct Sass_File_Context* ctx); +ADDAPI void ADDCALL sass_delete_data_context (struct Sass_Data_Context* ctx); // Getters for context from specific implementation -struct Sass_Context* sass_file_context_get_context (struct Sass_File_Context* file_ctx); -struct Sass_Context* sass_data_context_get_context (struct Sass_Data_Context* data_ctx); +ADDAPI struct Sass_Context* ADDCALL sass_file_context_get_context (struct Sass_File_Context* file_ctx); +ADDAPI struct Sass_Context* ADDCALL sass_data_context_get_context (struct Sass_Data_Context* data_ctx); // Getters for context options from Sass_Context -struct Sass_Options* sass_context_get_options (struct Sass_Context* ctx); -struct Sass_Options* sass_file_context_get_options (struct Sass_File_Context* file_ctx); -struct Sass_Options* sass_data_context_get_options (struct Sass_Data_Context* data_ctx); -void sass_file_context_set_options (struct Sass_File_Context* file_ctx, struct Sass_Options* opt); -void sass_data_context_set_options (struct Sass_Data_Context* data_ctx, struct Sass_Options* opt); +ADDAPI struct Sass_Options* ADDCALL sass_context_get_options (struct Sass_Context* ctx); +ADDAPI struct Sass_Options* ADDCALL sass_file_context_get_options (struct Sass_File_Context* file_ctx); +ADDAPI struct Sass_Options* ADDCALL sass_data_context_get_options (struct Sass_Data_Context* data_ctx); +ADDAPI void ADDCALL sass_file_context_set_options (struct Sass_File_Context* file_ctx, struct Sass_Options* opt); +ADDAPI void ADDCALL sass_data_context_set_options (struct Sass_Data_Context* data_ctx, struct Sass_Options* opt); // Getters for options -int sass_option_get_precision (struct Sass_Options* options); -enum Sass_Output_Style sass_option_get_output_style (struct Sass_Options* options); -bool sass_option_get_source_comments (struct Sass_Options* options); -bool sass_option_get_source_map_embed (struct Sass_Options* options); -bool sass_option_get_source_map_contents (struct Sass_Options* options); -bool sass_option_get_omit_source_map_url (struct Sass_Options* options); -bool sass_option_get_is_indented_syntax_src (struct Sass_Options* options); -const char* sass_option_get_input_path (struct Sass_Options* options); -const char* sass_option_get_output_path (struct Sass_Options* options); -const char* sass_option_get_image_path (struct Sass_Options* options); -const char* sass_option_get_include_path (struct Sass_Options* options); -const char* sass_option_get_source_map_file (struct Sass_Options* options); -Sass_C_Function_List sass_option_get_c_functions (struct Sass_Options* options); -Sass_C_Import_Callback sass_option_get_importer (struct Sass_Options* options); +ADDAPI int ADDCALL sass_option_get_precision (struct Sass_Options* options); +ADDAPI enum Sass_Output_Style ADDCALL sass_option_get_output_style (struct Sass_Options* options); +ADDAPI bool ADDCALL sass_option_get_source_comments (struct Sass_Options* options); +ADDAPI bool ADDCALL sass_option_get_source_map_embed (struct Sass_Options* options); +ADDAPI bool ADDCALL sass_option_get_source_map_contents (struct Sass_Options* options); +ADDAPI bool ADDCALL sass_option_get_omit_source_map_url (struct Sass_Options* options); +ADDAPI bool ADDCALL sass_option_get_is_indented_syntax_src (struct Sass_Options* options); +ADDAPI const char* ADDCALL sass_option_get_input_path (struct Sass_Options* options); +ADDAPI const char* ADDCALL sass_option_get_output_path (struct Sass_Options* options); +ADDAPI const char* ADDCALL sass_option_get_image_path (struct Sass_Options* options); +ADDAPI const char* ADDCALL sass_option_get_include_path (struct Sass_Options* options); +ADDAPI const char* ADDCALL sass_option_get_source_map_file (struct Sass_Options* options); +ADDAPI Sass_C_Function_List ADDCALL sass_option_get_c_functions (struct Sass_Options* options); +ADDAPI Sass_C_Import_Callback ADDCALL sass_option_get_importer (struct Sass_Options* options); // Setters for options -void sass_option_set_precision (struct Sass_Options* options, int precision); -void sass_option_set_output_style (struct Sass_Options* options, enum Sass_Output_Style output_style); -void sass_option_set_source_comments (struct Sass_Options* options, bool source_comments); -void sass_option_set_source_map_embed (struct Sass_Options* options, bool source_map_embed); -void sass_option_set_source_map_contents (struct Sass_Options* options, bool source_map_contents); -void sass_option_set_omit_source_map_url (struct Sass_Options* options, bool omit_source_map_url); -void sass_option_set_is_indented_syntax_src (struct Sass_Options* options, bool is_indented_syntax_src); -void sass_option_set_input_path (struct Sass_Options* options, const char* input_path); -void sass_option_set_output_path (struct Sass_Options* options, const char* output_path); -void sass_option_set_image_path (struct Sass_Options* options, const char* image_path); -void sass_option_set_include_path (struct Sass_Options* options, const char* include_path); -void sass_option_set_source_map_file (struct Sass_Options* options, const char* source_map_file); -void sass_option_set_c_functions (struct Sass_Options* options, Sass_C_Function_List c_functions); -void sass_option_set_importer (struct Sass_Options* options, Sass_C_Import_Callback importer); +ADDAPI void ADDCALL sass_option_set_precision (struct Sass_Options* options, int precision); +ADDAPI void ADDCALL sass_option_set_output_style (struct Sass_Options* options, enum Sass_Output_Style output_style); +ADDAPI void ADDCALL sass_option_set_source_comments (struct Sass_Options* options, bool source_comments); +ADDAPI void ADDCALL sass_option_set_source_map_embed (struct Sass_Options* options, bool source_map_embed); +ADDAPI void ADDCALL sass_option_set_source_map_contents (struct Sass_Options* options, bool source_map_contents); +ADDAPI void ADDCALL sass_option_set_omit_source_map_url (struct Sass_Options* options, bool omit_source_map_url); +ADDAPI void ADDCALL sass_option_set_is_indented_syntax_src (struct Sass_Options* options, bool is_indented_syntax_src); +ADDAPI void ADDCALL sass_option_set_input_path (struct Sass_Options* options, const char* input_path); +ADDAPI void ADDCALL sass_option_set_output_path (struct Sass_Options* options, const char* output_path); +ADDAPI void ADDCALL sass_option_set_image_path (struct Sass_Options* options, const char* image_path); +ADDAPI void ADDCALL sass_option_set_include_path (struct Sass_Options* options, const char* include_path); +ADDAPI void ADDCALL sass_option_set_source_map_file (struct Sass_Options* options, const char* source_map_file); +ADDAPI void ADDCALL sass_option_set_c_functions (struct Sass_Options* options, Sass_C_Function_List c_functions); +ADDAPI void ADDCALL sass_option_set_importer (struct Sass_Options* options, Sass_C_Import_Callback importer); // Getter for context -const char* sass_context_get_output_string (struct Sass_Context* ctx); -int sass_context_get_error_status (struct Sass_Context* ctx); -const char* sass_context_get_error_json (struct Sass_Context* ctx); -const char* sass_context_get_error_message (struct Sass_Context* ctx); -const char* sass_context_get_error_file (struct Sass_Context* ctx); -size_t sass_context_get_error_line (struct Sass_Context* ctx); -size_t sass_context_get_error_column (struct Sass_Context* ctx); -const char* sass_context_get_source_map_string (struct Sass_Context* ctx); -char** sass_context_get_included_files (struct Sass_Context* ctx); +ADDAPI const char* ADDCALL sass_context_get_output_string (struct Sass_Context* ctx); +ADDAPI int ADDCALL sass_context_get_error_status (struct Sass_Context* ctx); +ADDAPI const char* ADDCALL sass_context_get_error_json (struct Sass_Context* ctx); +ADDAPI const char* ADDCALL sass_context_get_error_message (struct Sass_Context* ctx); +ADDAPI const char* ADDCALL sass_context_get_error_file (struct Sass_Context* ctx); +ADDAPI size_t ADDCALL sass_context_get_error_line (struct Sass_Context* ctx); +ADDAPI size_t ADDCALL sass_context_get_error_column (struct Sass_Context* ctx); +ADDAPI const char* ADDCALL sass_context_get_source_map_string (struct Sass_Context* ctx); +ADDAPI char** ADDCALL sass_context_get_included_files (struct Sass_Context* ctx); // Setters for specific data context option // const char* sass_data_context_get_source_string (struct Sass_Data_Context* ctx); -void sass_data_context_set_source_string (struct Sass_Data_Context* ctx, char* source_string); +ADDAPI void ADDCALL sass_data_context_set_source_string (struct Sass_Data_Context* ctx, char* source_string); // Push function for include paths (no manipulation support for now) -void sass_option_push_include_path (struct Sass_Options* options, const char* path); +ADDAPI void ADDCALL sass_option_push_include_path (struct Sass_Options* options, const char* path); #ifdef __cplusplus -} +} // __cplusplus defined. #endif #endif \ No newline at end of file diff --git a/sass_functions.cpp b/sass_functions.cpp index 57ee33aa3b..bcc2e60b0e 100644 --- a/sass_functions.cpp +++ b/sass_functions.cpp @@ -17,12 +17,12 @@ extern "C" { void* cookie; }; - Sass_C_Function_List sass_make_function_list(size_t length) + Sass_C_Function_List ADDCALL sass_make_function_list(size_t length) { return (Sass_C_Function_List) calloc(length + 1, sizeof(Sass_C_Function_Callback)); } - Sass_C_Function_Callback sass_make_function(const char* signature, Sass_C_Function function, void* cookie) + Sass_C_Function_Callback ADDCALL sass_make_function(const char* signature, Sass_C_Function function, void* cookie) { Sass_C_Function_Callback cb = (Sass_C_Function_Callback) calloc(1, sizeof(Sass_C_Function_Descriptor)); if (cb == 0) return 0; @@ -33,12 +33,12 @@ extern "C" { } // Setters and getters for callbacks on function lists - Sass_C_Function_Callback sass_function_get_list_entry(Sass_C_Function_List* list, size_t pos) { return *list[pos]; } + Sass_C_Function_Callback ADDCALL sass_function_get_list_entry(Sass_C_Function_List* list, size_t pos) { return *list[pos]; } void sass_function_set_list_entry(Sass_C_Function_List* list, Sass_C_Function_Callback cb, size_t pos) { *list[pos] = cb; } - const char* sass_function_get_signature(Sass_C_Function_Callback fn) { return fn->signature; } - Sass_C_Function sass_function_get_function(Sass_C_Function_Callback fn) { return fn->function; } - void* sass_function_get_cookie(Sass_C_Function_Callback fn) { return fn->cookie; } + const char* ADDCALL sass_function_get_signature(Sass_C_Function_Callback fn) { return fn->signature; } + Sass_C_Function ADDCALL sass_function_get_function(Sass_C_Function_Callback fn) { return fn->function; } + void* ADDCALL sass_function_get_cookie(Sass_C_Function_Callback fn) { return fn->cookie; } // External import entry struct Sass_Import { @@ -54,7 +54,7 @@ extern "C" { void* cookie; }; - Sass_C_Import_Callback sass_make_importer(Sass_C_Import_Fn function, void* cookie) + Sass_C_Import_Callback ADDCALL sass_make_importer(Sass_C_Import_Fn function, void* cookie) { Sass_C_Import_Callback cb = (Sass_C_Import_Callback) calloc(1, sizeof(Sass_C_Import_Descriptor)); if (cb == 0) return 0; @@ -63,24 +63,24 @@ extern "C" { return cb; } - Sass_C_Import_Fn sass_import_get_function(Sass_C_Import_Callback fn) { return fn->function; } - void* sass_import_get_cookie(Sass_C_Import_Callback fn) { return fn->cookie; } + Sass_C_Import_Fn ADDCALL sass_import_get_function(Sass_C_Import_Callback fn) { return fn->function; } + void* ADDCALL sass_import_get_cookie(Sass_C_Import_Callback fn) { return fn->cookie; } // Just in case we have some stray import structs - void sass_delete_importer (Sass_C_Import_Callback fn) + void ADDCALL sass_delete_importer (Sass_C_Import_Callback fn) { free(fn); } // Creator for sass custom importer return argument list - struct Sass_Import** sass_make_import_list(size_t length) + struct Sass_Import** ADDCALL sass_make_import_list(size_t length) { return (Sass_Import**) calloc(length + 1, sizeof(Sass_Import*)); } // Creator for a single import entry returned by the custom importer inside the list // We take ownership of the memory for source and srcmap (freed when context is destroyd) - struct Sass_Import* sass_make_import(const char* path, const char* base, char* source, char* srcmap) + struct Sass_Import* ADDCALL sass_make_import(const char* path, const char* base, char* source, char* srcmap) { Sass_Import* v = (Sass_Import*) calloc(1, sizeof(Sass_Import)); if (v == 0) return 0; @@ -92,17 +92,17 @@ extern "C" { } // Older style, but somehow still valid - keep around or deprecate? - struct Sass_Import* sass_make_import_entry(const char* path, char* source, char* srcmap) + struct Sass_Import* ADDCALL sass_make_import_entry(const char* path, char* source, char* srcmap) { return sass_make_import(path, path, source, srcmap); } // Setters and getters for entries on the import list - void sass_import_set_list_entry(struct Sass_Import** list, size_t idx, struct Sass_Import* entry) { list[idx] = entry; } - struct Sass_Import* sass_import_get_list_entry(struct Sass_Import** list, size_t idx) { return list[idx]; } + void ADDCALL sass_import_set_list_entry(struct Sass_Import** list, size_t idx, struct Sass_Import* entry) { list[idx] = entry; } + struct Sass_Import* ADDCALL sass_import_get_list_entry(struct Sass_Import** list, size_t idx) { return list[idx]; } // Deallocator for the allocated memory - void sass_delete_import_list(struct Sass_Import** list) + void ADDCALL sass_delete_import_list(struct Sass_Import** list) { struct Sass_Import** it = list; if (list == 0) return; @@ -114,7 +114,7 @@ extern "C" { } // Just in case we have some stray import structs - void sass_delete_import(struct Sass_Import* import) + void ADDCALL sass_delete_import(struct Sass_Import* import) { free(import->path); free(import->base); @@ -124,14 +124,14 @@ extern "C" { } // Getter for import entry - const char* sass_import_get_path(struct Sass_Import* entry) { return entry->path; } - const char* sass_import_get_base(struct Sass_Import* entry) { return entry->base; } - const char* sass_import_get_source(struct Sass_Import* entry) { return entry->source; } - const char* sass_import_get_srcmap(struct Sass_Import* entry) { return entry->srcmap; } + const char* ADDCALL sass_import_get_path(struct Sass_Import* entry) { return entry->path; } + const char* ADDCALL sass_import_get_base(struct Sass_Import* entry) { return entry->base; } + const char* ADDCALL sass_import_get_source(struct Sass_Import* entry) { return entry->source; } + const char* ADDCALL sass_import_get_srcmap(struct Sass_Import* entry) { return entry->srcmap; } // Explicit functions to take ownership of the memory // Resets our own property since we do not know if it is still alive - char* sass_import_take_source(struct Sass_Import* entry) { char* ptr = entry->source; entry->source = 0; return ptr; } - char* sass_import_take_srcmap(struct Sass_Import* entry) { char* ptr = entry->srcmap; entry->srcmap = 0; return ptr; } + char* ADDCALL sass_import_take_source(struct Sass_Import* entry) { char* ptr = entry->source; entry->source = 0; return ptr; } + char* ADDCALL sass_import_take_srcmap(struct Sass_Import* entry) { char* ptr = entry->srcmap; entry->srcmap = 0; return ptr; } } diff --git a/sass_functions.h b/sass_functions.h index 43ff82f14b..0499ca29fa 100644 --- a/sass_functions.h +++ b/sass_functions.h @@ -3,6 +3,7 @@ #include #include +#include "sass.h" #ifdef __cplusplus extern "C" { @@ -22,40 +23,40 @@ typedef struct Sass_Import** (*Sass_C_Import_Fn) (const char* url, const char* p // Creators for custom importer callback (with some additional pointer) // The pointer is mostly used to store the callback into the actual binding -Sass_C_Import_Callback sass_make_importer (Sass_C_Import_Fn, void* cookie); +ADDAPI Sass_C_Import_Callback ADDCALL sass_make_importer (Sass_C_Import_Fn, void* cookie); // Getters for import function descriptors -Sass_C_Import_Fn sass_import_get_function (Sass_C_Import_Callback fn); -void* sass_import_get_cookie (Sass_C_Import_Callback fn); +ADDAPI Sass_C_Import_Fn ADDCALL sass_import_get_function (Sass_C_Import_Callback fn); +ADDAPI void* ADDCALL sass_import_get_cookie (Sass_C_Import_Callback fn); // Deallocator for associated memory -void sass_delete_importer (Sass_C_Import_Callback fn); +ADDAPI void ADDCALL sass_delete_importer (Sass_C_Import_Callback fn); // Creator for sass custom importer return argument list -struct Sass_Import** sass_make_import_list (size_t length); +ADDAPI struct Sass_Import** ADDCALL sass_make_import_list (size_t length); // Creator for a single import entry returned by the custom importer inside the list -struct Sass_Import* sass_make_import_entry (const char* path, char* source, char* srcmap); -struct Sass_Import* sass_make_import (const char* path, const char* base, char* source, char* srcmap); +ADDAPI struct Sass_Import* ADDCALL sass_make_import_entry (const char* path, char* source, char* srcmap); +ADDAPI struct Sass_Import* ADDCALL sass_make_import (const char* path, const char* base, char* source, char* srcmap); // Setters to insert an entry into the import list (you may also use [] access directly) // Since we are dealing with pointers they should have a guaranteed and fixed size -void sass_import_set_list_entry (struct Sass_Import** list, size_t idx, struct Sass_Import* entry); -struct Sass_Import* sass_import_get_list_entry (struct Sass_Import** list, size_t idx); +ADDAPI void ADDCALL sass_import_set_list_entry (struct Sass_Import** list, size_t idx, struct Sass_Import* entry); +ADDAPI struct Sass_Import* ADDCALL sass_import_get_list_entry (struct Sass_Import** list, size_t idx); // Getters for import entry -const char* sass_import_get_path (struct Sass_Import*); -const char* sass_import_get_base (struct Sass_Import*); -const char* sass_import_get_source (struct Sass_Import*); -const char* sass_import_get_srcmap (struct Sass_Import*); +ADDAPI const char* ADDCALL sass_import_get_path (struct Sass_Import*); +ADDAPI const char* ADDCALL sass_import_get_base (struct Sass_Import*); +ADDAPI const char* ADDCALL sass_import_get_source (struct Sass_Import*); +ADDAPI const char* ADDCALL sass_import_get_srcmap (struct Sass_Import*); // Explicit functions to take ownership of these items // The property on our struct will be reset to NULL -char* sass_import_take_source (struct Sass_Import*); -char* sass_import_take_srcmap (struct Sass_Import*); +ADDAPI char* ADDCALL sass_import_take_source (struct Sass_Import*); +ADDAPI char* ADDCALL sass_import_take_srcmap (struct Sass_Import*); // Deallocator for associated memory (incl. entries) -void sass_delete_import_list (struct Sass_Import**); +ADDAPI void ADDCALL sass_delete_import_list (struct Sass_Import**); // Just in case we have some stray import structs -void sass_delete_import (struct Sass_Import*); +ADDAPI void ADDCALL sass_delete_import (struct Sass_Import*); // Forward declaration @@ -69,21 +70,21 @@ typedef union Sass_Value*(*Sass_C_Function) (const union Sass_Value*, void* cook // Creators for sass function list and function descriptors -Sass_C_Function_List sass_make_function_list (size_t length); -Sass_C_Function_Callback sass_make_function (const char* signature, Sass_C_Function fn, void* cookie); +ADDAPI Sass_C_Function_List ADDCALL sass_make_function_list (size_t length); +ADDAPI Sass_C_Function_Callback ADDCALL sass_make_function (const char* signature, Sass_C_Function fn, void* cookie); // Setters and getters for callbacks on function lists -Sass_C_Function_Callback sass_function_get_list_entry(Sass_C_Function_List* list, size_t pos); -void sass_function_set_list_entry(Sass_C_Function_List* list, Sass_C_Function_Callback cb, size_t pos); +ADDAPI Sass_C_Function_Callback ADDCALL sass_function_get_list_entry(Sass_C_Function_List* list, size_t pos); +ADDAPI void ADDCALL sass_function_set_list_entry(Sass_C_Function_List* list, Sass_C_Function_Callback cb, size_t pos); // Getters for custom function descriptors -const char* sass_function_get_signature (Sass_C_Function_Callback fn); -Sass_C_Function sass_function_get_function (Sass_C_Function_Callback fn); -void* sass_function_get_cookie (Sass_C_Function_Callback fn); +ADDAPI const char* ADDCALL sass_function_get_signature (Sass_C_Function_Callback fn); +ADDAPI Sass_C_Function ADDCALL sass_function_get_function (Sass_C_Function_Callback fn); +ADDAPI void* ADDCALL sass_function_get_cookie (Sass_C_Function_Callback fn); #ifdef __cplusplus -} +} // __cplusplus defined. #endif #endif diff --git a/sass_values.cpp b/sass_values.cpp index 5124882dd7..bff7243b99 100644 --- a/sass_values.cpp +++ b/sass_values.cpp @@ -86,70 +86,70 @@ extern "C" { }; // Return the sass tag for a generic sass value - enum Sass_Tag sass_value_get_tag(const union Sass_Value* v) { return v->unknown.tag; } + enum Sass_Tag ADDCALL sass_value_get_tag(const union Sass_Value* v) { return v->unknown.tag; } // Check value for specified type - bool sass_value_is_null(const union Sass_Value* v) { return v->unknown.tag == SASS_NULL; } - bool sass_value_is_number(const union Sass_Value* v) { return v->unknown.tag == SASS_NUMBER; } - bool sass_value_is_string(const union Sass_Value* v) { return v->unknown.tag == SASS_STRING; } - bool sass_value_is_boolean(const union Sass_Value* v) { return v->unknown.tag == SASS_BOOLEAN; } - bool sass_value_is_color(const union Sass_Value* v) { return v->unknown.tag == SASS_COLOR; } - bool sass_value_is_list(const union Sass_Value* v) { return v->unknown.tag == SASS_LIST; } - bool sass_value_is_map(const union Sass_Value* v) { return v->unknown.tag == SASS_MAP; } - bool sass_value_is_error(const union Sass_Value* v) { return v->unknown.tag == SASS_ERROR; } - bool sass_value_is_warning(const union Sass_Value* v) { return v->unknown.tag == SASS_WARNING; } + bool ADDCALL sass_value_is_null(const union Sass_Value* v) { return v->unknown.tag == SASS_NULL; } + bool ADDCALL sass_value_is_number(const union Sass_Value* v) { return v->unknown.tag == SASS_NUMBER; } + bool ADDCALL sass_value_is_string(const union Sass_Value* v) { return v->unknown.tag == SASS_STRING; } + bool ADDCALL sass_value_is_boolean(const union Sass_Value* v) { return v->unknown.tag == SASS_BOOLEAN; } + bool ADDCALL sass_value_is_color(const union Sass_Value* v) { return v->unknown.tag == SASS_COLOR; } + bool ADDCALL sass_value_is_list(const union Sass_Value* v) { return v->unknown.tag == SASS_LIST; } + bool ADDCALL sass_value_is_map(const union Sass_Value* v) { return v->unknown.tag == SASS_MAP; } + bool ADDCALL sass_value_is_error(const union Sass_Value* v) { return v->unknown.tag == SASS_ERROR; } + bool ADDCALL sass_value_is_warning(const union Sass_Value* v) { return v->unknown.tag == SASS_WARNING; } // Getters and setters for Sass_Number - double sass_number_get_value(const union Sass_Value* v) { return v->number.value; } - void sass_number_set_value(union Sass_Value* v, double value) { v->number.value = value; } - const char* sass_number_get_unit(const union Sass_Value* v) { return v->number.unit; } - void sass_number_set_unit(union Sass_Value* v, char* unit) { v->number.unit = unit; } + double ADDCALL sass_number_get_value(const union Sass_Value* v) { return v->number.value; } + void ADDCALL sass_number_set_value(union Sass_Value* v, double value) { v->number.value = value; } + const char* ADDCALL sass_number_get_unit(const union Sass_Value* v) { return v->number.unit; } + void ADDCALL sass_number_set_unit(union Sass_Value* v, char* unit) { v->number.unit = unit; } // Getters and setters for Sass_String - const char* sass_string_get_value(const union Sass_Value* v) { return v->string.value; } - void sass_string_set_value(union Sass_Value* v, char* value) { v->string.value = value; } + const char* ADDCALL sass_string_get_value(const union Sass_Value* v) { return v->string.value; } + void ADDCALL sass_string_set_value(union Sass_Value* v, char* value) { v->string.value = value; } // Getters and setters for Sass_Boolean - bool sass_boolean_get_value(const union Sass_Value* v) { return v->boolean.value; } - void sass_boolean_set_value(union Sass_Value* v, bool value) { v->boolean.value = value; } + bool ADDCALL sass_boolean_get_value(const union Sass_Value* v) { return v->boolean.value; } + void ADDCALL sass_boolean_set_value(union Sass_Value* v, bool value) { v->boolean.value = value; } // Getters and setters for Sass_Color - double sass_color_get_r(const union Sass_Value* v) { return v->color.r; } - void sass_color_set_r(union Sass_Value* v, double r) { v->color.r = r; } - double sass_color_get_g(const union Sass_Value* v) { return v->color.g; } - void sass_color_set_g(union Sass_Value* v, double g) { v->color.g = g; } - double sass_color_get_b(const union Sass_Value* v) { return v->color.b; } - void sass_color_set_b(union Sass_Value* v, double b) { v->color.b = b; } - double sass_color_get_a(const union Sass_Value* v) { return v->color.a; } - void sass_color_set_a(union Sass_Value* v, double a) { v->color.a = a; } + double ADDCALL sass_color_get_r(const union Sass_Value* v) { return v->color.r; } + void ADDCALL sass_color_set_r(union Sass_Value* v, double r) { v->color.r = r; } + double ADDCALL sass_color_get_g(const union Sass_Value* v) { return v->color.g; } + void ADDCALL sass_color_set_g(union Sass_Value* v, double g) { v->color.g = g; } + double ADDCALL sass_color_get_b(const union Sass_Value* v) { return v->color.b; } + void ADDCALL sass_color_set_b(union Sass_Value* v, double b) { v->color.b = b; } + double ADDCALL sass_color_get_a(const union Sass_Value* v) { return v->color.a; } + void ADDCALL sass_color_set_a(union Sass_Value* v, double a) { v->color.a = a; } // Getters and setters for Sass_List - size_t sass_list_get_length(const union Sass_Value* v) { return v->list.length; } - enum Sass_Separator sass_list_get_separator(const union Sass_Value* v) { return v->list.separator; } - void sass_list_set_separator(union Sass_Value* v, enum Sass_Separator separator) { v->list.separator = separator; } + size_t ADDCALL sass_list_get_length(const union Sass_Value* v) { return v->list.length; } + enum Sass_Separator ADDCALL sass_list_get_separator(const union Sass_Value* v) { return v->list.separator; } + void ADDCALL sass_list_set_separator(union Sass_Value* v, enum Sass_Separator separator) { v->list.separator = separator; } // Getters and setters for Sass_List values - union Sass_Value* sass_list_get_value(const union Sass_Value* v, size_t i) { return v->list.values[i]; } - void sass_list_set_value(union Sass_Value* v, size_t i, union Sass_Value* value) { v->list.values[i] = value; } + union Sass_Value* ADDCALL sass_list_get_value(const union Sass_Value* v, size_t i) { return v->list.values[i]; } + void ADDCALL sass_list_set_value(union Sass_Value* v, size_t i, union Sass_Value* value) { v->list.values[i] = value; } // Getters and setters for Sass_Map - size_t sass_map_get_length(const union Sass_Value* v) { return v->map.length; } + size_t ADDCALL sass_map_get_length(const union Sass_Value* v) { return v->map.length; } // Getters and setters for Sass_List keys and values - union Sass_Value* sass_map_get_key(const union Sass_Value* v, size_t i) { return v->map.pairs[i].key; } - union Sass_Value* sass_map_get_value(const union Sass_Value* v, size_t i) { return v->map.pairs[i].value; } - void sass_map_set_key(union Sass_Value* v, size_t i, union Sass_Value* key) { v->map.pairs[i].key = key; } - void sass_map_set_value(union Sass_Value* v, size_t i, union Sass_Value* val) { v->map.pairs[i].value = val; } + union Sass_Value* ADDCALL sass_map_get_key(const union Sass_Value* v, size_t i) { return v->map.pairs[i].key; } + union Sass_Value* ADDCALL sass_map_get_value(const union Sass_Value* v, size_t i) { return v->map.pairs[i].value; } + void ADDCALL sass_map_set_key(union Sass_Value* v, size_t i, union Sass_Value* key) { v->map.pairs[i].key = key; } + void ADDCALL sass_map_set_value(union Sass_Value* v, size_t i, union Sass_Value* val) { v->map.pairs[i].value = val; } // Getters and setters for Sass_Error - char* sass_error_get_message(const union Sass_Value* v) { return v->error.message; }; - void sass_error_set_message(union Sass_Value* v, char* msg) { v->error.message = msg; }; + char* ADDCALL sass_error_get_message(const union Sass_Value* v) { return v->error.message; }; + void ADDCALL sass_error_set_message(union Sass_Value* v, char* msg) { v->error.message = msg; }; // Getters and setters for Sass_Warning - char* sass_warning_get_message(const union Sass_Value* v) { return v->warning.message; }; - void sass_warning_set_message(union Sass_Value* v, char* msg) { v->warning.message = msg; }; + char* ADDCALL sass_warning_get_message(const union Sass_Value* v) { return v->warning.message; }; + void ADDCALL sass_warning_set_message(union Sass_Value* v, char* msg) { v->warning.message = msg; }; // Creator functions for all value types - union Sass_Value* sass_make_boolean(bool val) + union Sass_Value* ADDCALL sass_make_boolean(bool val) { Sass_Value* v = (Sass_Value*) calloc(1, sizeof(Sass_Value)); if (v == 0) return 0; @@ -158,7 +158,7 @@ extern "C" { return v; } - union Sass_Value* sass_make_number(double val, const char* unit) + union Sass_Value* ADDCALL sass_make_number(double val, const char* unit) { Sass_Value* v = (Sass_Value*) calloc(1, sizeof(Sass_Value)); if (v == 0) return 0; @@ -169,7 +169,7 @@ extern "C" { return v; } - union Sass_Value* sass_make_color(double r, double g, double b, double a) + union Sass_Value* ADDCALL sass_make_color(double r, double g, double b, double a) { Sass_Value* v = (Sass_Value*) calloc(1, sizeof(Sass_Value)); if (v == 0) return 0; @@ -181,7 +181,7 @@ extern "C" { return v; } - union Sass_Value* sass_make_string(const char* val) + union Sass_Value* ADDCALL sass_make_string(const char* val) { Sass_Value* v = (Sass_Value*) calloc(1, sizeof(Sass_Value)); if (v == 0) return 0; @@ -191,7 +191,7 @@ extern "C" { return v; } - union Sass_Value* sass_make_list(size_t len, enum Sass_Separator sep) + union Sass_Value* ADDCALL sass_make_list(size_t len, enum Sass_Separator sep) { Sass_Value* v = (Sass_Value*) calloc(1, sizeof(Sass_Value)); if (v == 0) return 0; @@ -203,7 +203,7 @@ extern "C" { return v; } - union Sass_Value* sass_make_map(size_t len) + union Sass_Value* ADDCALL sass_make_map(size_t len) { Sass_Value* v = (Sass_Value*) calloc(1, sizeof(Sass_Value)); if (v == 0) return 0; @@ -214,7 +214,7 @@ extern "C" { return v; } - union Sass_Value* sass_make_null(void) + union Sass_Value* ADDCALL sass_make_null(void) { Sass_Value* v = (Sass_Value*) calloc(1, sizeof(Sass_Value)); if (v == 0) return 0; @@ -222,7 +222,7 @@ extern "C" { return v; } - union Sass_Value* sass_make_error(const char* msg) + union Sass_Value* ADDCALL sass_make_error(const char* msg) { Sass_Value* v = (Sass_Value*) calloc(1, sizeof(Sass_Value)); if (v == 0) return 0; @@ -232,7 +232,7 @@ extern "C" { return v; } - union Sass_Value* sass_make_warning(const char* msg) + union Sass_Value* ADDCALL sass_make_warning(const char* msg) { Sass_Value* v = (Sass_Value*) calloc(1, sizeof(Sass_Value)); if (v == 0) return 0; @@ -243,7 +243,7 @@ extern "C" { } // will free all associated sass values - void sass_delete_value(union Sass_Value* val) { + void ADDCALL sass_delete_value(union Sass_Value* val) { size_t i; if (val == 0) return; @@ -286,7 +286,7 @@ extern "C" { } // Make a deep cloned copy of the given sass value - union Sass_Value* sass_clone_value (const union Sass_Value* val) + union Sass_Value* ADDCALL sass_clone_value (const union Sass_Value* val) { size_t i; diff --git a/sass_values.h b/sass_values.h index 2df94d139c..e4b5ea0c1d 100644 --- a/sass_values.h +++ b/sass_values.h @@ -3,6 +3,7 @@ #include #include +#include "sass.h" #ifdef __cplusplus extern "C" { @@ -33,88 +34,88 @@ enum Sass_Separator { // Return the sass tag for a generic sass value // Check is needed before accessing specific values! -enum Sass_Tag sass_value_get_tag (const union Sass_Value* v); +ADDAPI enum Sass_Tag ADDCALL sass_value_get_tag (const union Sass_Value* v); // Check value to be of a specific type // Can also be used before accessing properties! -bool sass_value_is_null (const union Sass_Value* v); -bool sass_value_is_number (const union Sass_Value* v); -bool sass_value_is_string (const union Sass_Value* v); -bool sass_value_is_boolean (const union Sass_Value* v); -bool sass_value_is_color (const union Sass_Value* v); -bool sass_value_is_list (const union Sass_Value* v); -bool sass_value_is_map (const union Sass_Value* v); -bool sass_value_is_error (const union Sass_Value* v); -bool sass_value_is_warning (const union Sass_Value* v); +ADDAPI bool ADDCALL sass_value_is_null (const union Sass_Value* v); +ADDAPI bool ADDCALL sass_value_is_number (const union Sass_Value* v); +ADDAPI bool ADDCALL sass_value_is_string (const union Sass_Value* v); +ADDAPI bool ADDCALL sass_value_is_boolean (const union Sass_Value* v); +ADDAPI bool ADDCALL sass_value_is_color (const union Sass_Value* v); +ADDAPI bool ADDCALL sass_value_is_list (const union Sass_Value* v); +ADDAPI bool ADDCALL sass_value_is_map (const union Sass_Value* v); +ADDAPI bool ADDCALL sass_value_is_error (const union Sass_Value* v); +ADDAPI bool ADDCALL sass_value_is_warning (const union Sass_Value* v); // Getters and setters for Sass_Number -double sass_number_get_value (const union Sass_Value* v); -void sass_number_set_value (union Sass_Value* v, double value); -const char* sass_number_get_unit (const union Sass_Value* v); -void sass_number_set_unit (union Sass_Value* v, char* unit); +ADDAPI double ADDCALL sass_number_get_value (const union Sass_Value* v); +ADDAPI void ADDCALL sass_number_set_value (union Sass_Value* v, double value); +ADDAPI const char* ADDCALL sass_number_get_unit (const union Sass_Value* v); +ADDAPI void ADDCALL sass_number_set_unit (union Sass_Value* v, char* unit); // Getters and setters for Sass_String -const char* sass_string_get_value (const union Sass_Value* v); -void sass_string_set_value (union Sass_Value* v, char* value); +ADDAPI const char* ADDCALL sass_string_get_value (const union Sass_Value* v); +ADDAPI void ADDCALL sass_string_set_value (union Sass_Value* v, char* value); // Getters and setters for Sass_Boolean -bool sass_boolean_get_value (const union Sass_Value* v); -void sass_boolean_set_value (union Sass_Value* v, bool value); +ADDAPI bool ADDCALL sass_boolean_get_value (const union Sass_Value* v); +ADDAPI void ADDCALL sass_boolean_set_value (union Sass_Value* v, bool value); // Getters and setters for Sass_Color -double sass_color_get_r (const union Sass_Value* v); -void sass_color_set_r (union Sass_Value* v, double r); -double sass_color_get_g (const union Sass_Value* v); -void sass_color_set_g (union Sass_Value* v, double g); -double sass_color_get_b (const union Sass_Value* v); -void sass_color_set_b (union Sass_Value* v, double b); -double sass_color_get_a (const union Sass_Value* v); -void sass_color_set_a (union Sass_Value* v, double a); +ADDAPI double ADDCALL sass_color_get_r (const union Sass_Value* v); +ADDAPI void ADDCALL sass_color_set_r (union Sass_Value* v, double r); +ADDAPI double ADDCALL sass_color_get_g (const union Sass_Value* v); +ADDAPI void ADDCALL sass_color_set_g (union Sass_Value* v, double g); +ADDAPI double ADDCALL sass_color_get_b (const union Sass_Value* v); +ADDAPI void ADDCALL sass_color_set_b (union Sass_Value* v, double b); +ADDAPI double ADDCALL sass_color_get_a (const union Sass_Value* v); +ADDAPI void ADDCALL sass_color_set_a (union Sass_Value* v, double a); // Getter for the number of items in list -size_t sass_list_get_length (const union Sass_Value* v); +ADDAPI size_t ADDCALL sass_list_get_length (const union Sass_Value* v); // Getters and setters for Sass_List -enum Sass_Separator sass_list_get_separator (const union Sass_Value* v); -void sass_list_set_separator (union Sass_Value* v, enum Sass_Separator value); +ADDAPI enum Sass_Separator ADDCALL sass_list_get_separator (const union Sass_Value* v); +ADDAPI void ADDCALL sass_list_set_separator (union Sass_Value* v, enum Sass_Separator value); // Getters and setters for Sass_List values -union Sass_Value* sass_list_get_value (const union Sass_Value* v, size_t i); -void sass_list_set_value (union Sass_Value* v, size_t i, union Sass_Value* value); +ADDAPI union Sass_Value* ADDCALL sass_list_get_value (const union Sass_Value* v, size_t i); +ADDAPI void ADDCALL sass_list_set_value (union Sass_Value* v, size_t i, union Sass_Value* value); // Getter for the number of items in map -size_t sass_map_get_length (const union Sass_Value* v); +ADDAPI size_t ADDCALL sass_map_get_length (const union Sass_Value* v); // Getters and setters for Sass_List keys and values -union Sass_Value* sass_map_get_key (const union Sass_Value* v, size_t i); -void sass_map_set_key (union Sass_Value* v, size_t i, union Sass_Value*); -union Sass_Value* sass_map_get_value (const union Sass_Value* v, size_t i); -void sass_map_set_value (union Sass_Value* v, size_t i, union Sass_Value*); +ADDAPI union Sass_Value* ADDCALL sass_map_get_key (const union Sass_Value* v, size_t i); +ADDAPI void ADDCALL sass_map_set_key (union Sass_Value* v, size_t i, union Sass_Value*); +ADDAPI union Sass_Value* ADDCALL sass_map_get_value (const union Sass_Value* v, size_t i); +ADDAPI void ADDCALL sass_map_set_value (union Sass_Value* v, size_t i, union Sass_Value*); // Getters and setters for Sass_Error -char* sass_error_get_message (const union Sass_Value* v); -void sass_error_set_message (union Sass_Value* v, char* msg); +ADDAPI char* ADDCALL sass_error_get_message (const union Sass_Value* v); +ADDAPI void ADDCALL sass_error_set_message (union Sass_Value* v, char* msg); // Getters and setters for Sass_Warning -char* sass_warning_get_message (const union Sass_Value* v); -void sass_warning_set_message (union Sass_Value* v, char* msg); +ADDAPI char* ADDCALL sass_warning_get_message (const union Sass_Value* v); +ADDAPI void ADDCALL sass_warning_set_message (union Sass_Value* v, char* msg); // Creator functions for all value types -union Sass_Value* sass_make_null (void); -union Sass_Value* sass_make_boolean (bool val); -union Sass_Value* sass_make_string (const char* val); -union Sass_Value* sass_make_number (double val, const char* unit); -union Sass_Value* sass_make_color (double r, double g, double b, double a); -union Sass_Value* sass_make_list (size_t len, enum Sass_Separator sep); -union Sass_Value* sass_make_map (size_t len); -union Sass_Value* sass_make_error (const char* msg); -union Sass_Value* sass_make_warning (const char* msg); +ADDAPI union Sass_Value* ADDCALL sass_make_null (void); +ADDAPI union Sass_Value* ADDCALL sass_make_boolean (bool val); +ADDAPI union Sass_Value* ADDCALL sass_make_string (const char* val); +ADDAPI union Sass_Value* ADDCALL sass_make_number (double val, const char* unit); +ADDAPI union Sass_Value* ADDCALL sass_make_color (double r, double g, double b, double a); +ADDAPI union Sass_Value* ADDCALL sass_make_list (size_t len, enum Sass_Separator sep); +ADDAPI union Sass_Value* ADDCALL sass_make_map (size_t len); +ADDAPI union Sass_Value* ADDCALL sass_make_error (const char* msg); +ADDAPI union Sass_Value* ADDCALL sass_make_warning (const char* msg); // Generic destructor function for all types // Will release memory of all associated Sass_Values // Means we will delete recursively for lists and maps -void sass_delete_value (union Sass_Value* val); +ADDAPI void ADDCALL sass_delete_value (union Sass_Value* val); #ifdef __cplusplus -} +} // __cplusplus defined. #endif #endif diff --git a/win/libsass.filters b/win/libsass.filters new file mode 100644 index 0000000000..1ad9528ed0 --- /dev/null +++ b/win/libsass.filters @@ -0,0 +1,291 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + \ No newline at end of file diff --git a/win/libsass.sln b/win/libsass.sln new file mode 100644 index 0000000000..9354d85f53 --- /dev/null +++ b/win/libsass.sln @@ -0,0 +1,28 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.30723.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libsass", "libsass.vcxproj", "{E4030474-AFC9-4CC6-BEB6-D846F631502B}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|Win64 = Debug|Win64 + Release|Win32 = Release|Win32 + Release|Win64 = Release|Win64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E4030474-AFC9-4CC6-BEB6-D846F631502B}.Debug|Win32.ActiveCfg = Debug|Win32 + {E4030474-AFC9-4CC6-BEB6-D846F631502B}.Debug|Win32.Build.0 = Debug|Win32 + {E4030474-AFC9-4CC6-BEB6-D846F631502B}.Debug|Win64.ActiveCfg = Debug|x64 + {E4030474-AFC9-4CC6-BEB6-D846F631502B}.Debug|Win64.Build.0 = Debug|x64 + {E4030474-AFC9-4CC6-BEB6-D846F631502B}.Release|Win32.ActiveCfg = Release|Win32 + {E4030474-AFC9-4CC6-BEB6-D846F631502B}.Release|Win32.Build.0 = Release|Win32 + {E4030474-AFC9-4CC6-BEB6-D846F631502B}.Release|Win64.ActiveCfg = Release|x64 + {E4030474-AFC9-4CC6-BEB6-D846F631502B}.Release|Win64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/win/libsass.vcxproj b/win/libsass.vcxproj new file mode 100644 index 0000000000..6520e7ce6e --- /dev/null +++ b/win/libsass.vcxproj @@ -0,0 +1,255 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {E4030474-AFC9-4CC6-BEB6-D846F631502B} + Win32Proj + libsass + + + + Application + true + v120 + Unicode + + + Application + true + v120 + Unicode + + + Application + false + v120 + true + Unicode + + + Application + false + v120 + true + Unicode + + + + + + + + + + + + + + + + + + + true + sassc + $(SolutionDir)bin\Debug\ + $(SolutionDir)bin\Debug\obj\ + + + true + sassc + $(SolutionDir)bin\Debug\ + $(SolutionDir)bin\Debug\obj\ + + + false + sassc + $(SolutionDir)bin\ + $(SolutionDir)bin\obj + + + false + sassc + $(SolutionDir)bin\ + $(SolutionDir)bin\obj\ + + + + ..;..\posix;..\sassc;%(AdditionalIncludeDirectories) + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) + + + Console + true + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) + + + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) + + + Console + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) + + + Console + true + true + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file