/* Generated from "/Users/hww3/devel/pike/src/post_modules/_Sass/sass.cmod" by precompile.pike running Pike v8.0 release 709
 *
 * Do NOT edit this file.
 */

#undef PRECOMPILE_API_VERSION
#define PRECOMPILE_API_VERSION 6

#undef PRECOMPILE_SUB_PIKEVARS
#define PRECOMPILE_SUB_PIKEVARS 1

#undef PRECOMPILE_DYNAMIC_TYPES
#define PRECOMPILE_DYNAMIC_TYPES 1



#undef cmod___CMOD__
#define cmod___CMOD__ 1
#line 1 "/Users/hww3/devel/pike/src/post_modules/_Sass/sass.cmod"
#line 1 "/Users/hww3/devel/pike/src/post_modules/_Sass/sass.cmod"
#line 1 "/Users/hww3/devel/pike/src/post_modules/_Sass/sass.cmod"
#line 3003 "/Users/hww3/devel/pike/lib/modules/Tools.pmod/Standalone.pmod/precompile.pike"







#line 3010 "/Users/hww3/devel/pike/lib/modules/Tools.pmod/Standalone.pmod/precompile.pike"
#line 1 "/Users/hww3/devel/pike/src/post_modules/_Sass/sass.cmod"
#line 1 "/Users/hww3/devel/pike/src/post_modules/_Sass/sass.cmod"
/*
|| This file is part of Pike. For copyright information see COPYRIGHT.
|| Pike is distributed under GPL, LGPL and MPL. See the file COPYING
|| for more information.
*/

#include "global.h"
#include "interpret.h"
#include "module.h"
#include "stralloc.h"
#include "mapping.h"
#include "array.h"
#include "builtin_functions.h"
#include "svalue.h"
#include "pike_types.h"
#include "module_support.h"

#include "config.h"



#ifndef PIKE_UNUSED_ATTRIBUTE
#define PIKE_UNUSED_ATTRIBUTE
#endif
#define CMOD_MAP_PROGRAM_IDS_DEFINED 1
static int ___cmod_map_program_ids(int id) PIKE_UNUSED_ATTRIBUTE;
#ifndef TYPEOF
/* Compat with older Pikes. */
#define TYPEOF(SVAL)	((SVAL).type)
#define SUBTYPEOF(SVAL)	((SVAL).subtype)
#define SET_SVAL_TYPE(SVAL, TYPE)	(TYPEOF(SVAL) = TYPE)
#define SET_SVAL_SUBTYPE(SVAL, TYPE)	(SUBTYPEOF(SVAL) = TYPE)
#define SET_SVAL(SVAL, TYPE, SUBTYPE, FIELD, EXPR) do {	\
    /* Set the type afterwards to avoid a clobbered	\
     * svalue in case EXPR throws. */			\
    (SVAL).u.FIELD = (EXPR);				\
    SET_SVAL_TYPE((SVAL), (TYPE));			\
    SET_SVAL_SUBTYPE((SVAL), (SUBTYPE));		\
  } while(0)
#endif /* !TYPEOF */
#ifndef PIKE_UNUSED
/* Compat with Pike 7.8 and earlier. */
/* NB: Not strictly correct; PIKE_UNUSED was added the
 *     day after set_program_id_to_id(), but good enough.
 */
#ifndef UNUSED
#define UNUSED(X)	X
#endif
#ifndef set_program_id_to_id
/* NB: Recent Pike 7.8 has a #define that conflicts with
 *     the following declaration.
 */
static void set_program_id_to_id(void*UNUSED(id)){}
#endif
#else /* */
PMOD_EXPORT void set_program_id_to_id( int (*to)(int) );
#endif /* !PIKE_UNUSED */


#ifndef DEFAULT_CMOD_STORAGE
#define CMOD_COND_USED
#define DEFAULT_CMOD_STORAGE static
#endif
#define module_strings_declared
static struct pike_string *module_strings[1] = {
  NULL,
};
#ifndef CMOD_COND_USED
# define f_Sass_Api_compile_file_fun_num_used 1
#else
#undef f_Sass_Api_compile_file_fun_num_used
#endif
#ifndef CMOD_COND_USED
# define Sass_Api_program_fun_num_used 1
#else
#undef Sass_Api_program_fun_num_used
#endif
#ifndef CMOD_COND_USED
# define f_Sass_sass2scss_fun_num_used 1
#else
#undef f_Sass_sass2scss_fun_num_used
#endif
#ifndef CMOD_COND_USED
# define f_Sass_libsass_version_fun_num_used 1
#else
#undef f_Sass_libsass_version_fun_num_used
#endif
#ifndef CMOD_COND_USED
# define f_Sass_Api_handle_sass_import_fun_num_used 1
#else
#undef f_Sass_Api_handle_sass_import_fun_num_used
#endif
#ifndef CMOD_COND_USED
# define f_Sass_libsass_language_version_fun_num_used 1
#else
#undef f_Sass_libsass_language_version_fun_num_used
#endif
#ifndef CMOD_COND_USED
# define f_Sass_Api_compile_string_fun_num_used 1
#else
#undef f_Sass_Api_compile_string_fun_num_used
#endif
#ifndef CMOD_COND_USED
# define f_Sass_sass2scss_version_fun_num_used 1
#else
#undef f_Sass_sass2scss_version_fun_num_used
#endif
#line 22 "/Users/hww3/devel/pike/src/post_modules/_Sass/sass.cmod"
#ifdef HAVE_LIBSASS

#include "pike_sass.h"
#include <sass.h>

#ifndef HAVE_LIBSASS_COPY_C_STRING
static char *sass_copy_c_string(const char *str)
{
size_t len = strlen(str);
char *res = malloc(len+1);
if (!res) return NULL;
memcpy(res, str, len+1);
return res;
}
#endif /* !HAVE_LIBSASS_COPY_C_STRING */

/*! @module Web
 */
/*! @module Sass
 */
/*! @class Api
 *!
 *! Low-level Sass/SCSS compiler.
 *!
 *! You probably want to use @[Compiler] instead of this class.
 *!
 *! @seealso
 *!   @[Compiler]
 */

#undef class_Sass_Api_defined
#define class_Sass_Api_defined
DEFAULT_CMOD_STORAGE struct program *Sass_Api_program=NULL;

#ifdef Sass_Api_program_fun_num_used
DEFAULT_CMOD_STORAGE int Sass_Api_program_fun_num=-1;
#endif /* Sass_Api_program_fun_num_used */
/*! @decl int(0..3) output_style = 0
   *!
   *! Determines the level of compression on the generated output.
   *!
   *! @seealso
   *!  @[STYLE_NESTED], @[STYLE_EXPANDED], @[STYLE_COMPACT] and
   *!  @[STYLE_COMPRESSED].
   */

#undef var_output_style_Sass_Api_defined
#define var_output_style_Sass_Api_defined
/*! @decl string(8bit) source_map_file = UNDEFINED
   *!
   *! Set the path of the source map file.
   */

#undef var_source_map_file_Sass_Api_defined
#define var_source_map_file_Sass_Api_defined
/*! @decl string(8bit) source_map_root
   *!
   *! Set the root path of the source files, relative to where the source.map
   *! file is written.
   */

#undef var_source_map_root_Sass_Api_defined
#define var_source_map_root_Sass_Api_defined
/*! @decl string(8bit) include_path
   *!
   *! The base path of @tt{@@import@}s. Note! This needs to be set when
   *! @[compile_string()] is used.
   */

#undef var_include_path_Sass_Api_defined
#define var_include_path_Sass_Api_defined
/*! @decl int precision
   *!
   *! Set the precision of fractional numbers. Default is @tt{5@}.
   */

#undef var_precision_Sass_Api_defined
#define var_precision_Sass_Api_defined
/*! @decl bool source_comments
   *!
   *! Emit comments in the generated CSS indicating the corresponding source
   *! line. Default is @tt{false@}.
   */

#undef var_source_comments_Sass_Api_defined
#define var_source_comments_Sass_Api_defined
/*! @decl bool source_map_embed
   *!
   *! Set whether embedding @tt{sourceMappingUrl=#@} as data uri or not.
   */

#undef var_source_map_embed_Sass_Api_defined
#define var_source_map_embed_Sass_Api_defined
/*! @decl bool omit_source_map_url
   *!
   *! Set whether writing the @tt{sourceMappingUrl=#@} or not.
   */

#undef var_omit_source_map_url_Sass_Api_defined
#define var_omit_source_map_url_Sass_Api_defined
/*! @decl bool sass_syntax
   *!
   *! Set whether the code is Sass syntax, i.e. indented syntax or not. Only
   *! necessary when using @[compile_string()]
   */

#undef var_sass_syntax_Sass_Api_defined
#define var_sass_syntax_Sass_Api_defined
/* Documented in the pmod */
#define f_Sass_Api_handle_sass_import_defined

#ifdef f_Sass_Api_handle_sass_import_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_Sass_Api_handle_sass_import_fun_num = 0;

#endif /* f_Sass_Api_handle_sass_import_fun_num_used */
DEFAULT_CMOD_STORAGE void f_Sass_Api_handle_sass_import(INT32 args) {
#line 117 "/Users/hww3/devel/pike/src/post_modules/_Sass/sass.cmod"
struct pike_string * path;
struct pike_string * absolute_path;
struct pike_string * relative_path;
#line 116 "/Users/hww3/devel/pike/src/post_modules/_Sass/sass.cmod"
if(args < 1) wrong_number_of_args_error("handle_sass_import",args,1);
#line 116 "/Users/hww3/devel/pike/src/post_modules/_Sass/sass.cmod"
if(args > 3) wrong_number_of_args_error("handle_sass_import",args,3);
if(TYPEOF(Pike_sp[0-args]) != PIKE_T_STRING) SIMPLE_ARG_TYPE_ERROR("handle_sass_import",1,"string(0..255)");
#line 117 "/Users/hww3/devel/pike/src/post_modules/_Sass/sass.cmod"
debug_malloc_pass(path=Pike_sp[0-args].u.string);
if (args > 1 &&
    (TYPEOF(Pike_sp[1-args]) != PIKE_T_INT ||
     Pike_sp[1-args].u.integer)) {
#line 118 "/Users/hww3/devel/pike/src/post_modules/_Sass/sass.cmod"
if(TYPEOF(Pike_sp[1-args]) != PIKE_T_STRING) SIMPLE_ARG_TYPE_ERROR("handle_sass_import",2,"void|string(0..255)");
#line 118 "/Users/hww3/devel/pike/src/post_modules/_Sass/sass.cmod"
debug_malloc_pass(absolute_path=Pike_sp[1-args].u.string);
#line 118 "/Users/hww3/devel/pike/src/post_modules/_Sass/sass.cmod"
} else absolute_path = NULL;
if (args > 2 &&
    (TYPEOF(Pike_sp[2-args]) != PIKE_T_INT ||
     Pike_sp[2-args].u.integer)) {
#line 119 "/Users/hww3/devel/pike/src/post_modules/_Sass/sass.cmod"
if(TYPEOF(Pike_sp[2-args]) != PIKE_T_STRING) SIMPLE_ARG_TYPE_ERROR("handle_sass_import",3,"void|string(0..255)");
#line 119 "/Users/hww3/devel/pike/src/post_modules/_Sass/sass.cmod"
debug_malloc_pass(relative_path=Pike_sp[2-args].u.string);
#line 119 "/Users/hww3/devel/pike/src/post_modules/_Sass/sass.cmod"
} else relative_path = NULL;
{
/* This method is overridden in module.pmod, but if someone would inherit */
/* this base class directly (it really isn't exposed though) and don't */
/* implement this method we by returning UNDEFINED leave the import */
/* resolution back to libsass. */
push_undefined ();
}

}
/* Identifier ID of handle_sass_import */

#undef var_id_handle_import_Sass_Api_defined
#define var_id_handle_import_Sass_Api_defined

#undef THIS
#define THIS ((struct Sass_Api_struct *)(Pike_interpreter.frame_pointer->current_storage))

#undef THIS_SASS_API
#define THIS_SASS_API ((struct Sass_Api_struct *)(Pike_interpreter.frame_pointer->current_storage))

#undef OBJ2_SASS_API
#define OBJ2_SASS_API(o) ((struct Sass_Api_struct *)(o->storage+Sass_Api_storage_offset))

#undef GET_SASS_API_STORAGE
#define GET_SASS_API_STORAGE(o) ((struct Sass_Api_struct *)(o->storage+Sass_Api_storage_offset)
static ptrdiff_t Sass_Api_storage_offset;
struct Sass_Api_struct {

#ifdef var_output_style_Sass_Api_defined
  INT_TYPE output_style;

#endif /* var_output_style_Sass_Api_defined */

#ifdef var_source_map_file_Sass_Api_defined
  struct pike_string * source_map_file;

#endif /* var_source_map_file_Sass_Api_defined */

#ifdef var_source_map_root_Sass_Api_defined
  struct pike_string * source_map_root;

#endif /* var_source_map_root_Sass_Api_defined */

#ifdef var_include_path_Sass_Api_defined
  struct pike_string * include_path;

#endif /* var_include_path_Sass_Api_defined */

#ifdef var_precision_Sass_Api_defined
  INT_TYPE precision;

#endif /* var_precision_Sass_Api_defined */

#ifdef var_source_comments_Sass_Api_defined
  INT_TYPE source_comments;

#endif /* var_source_comments_Sass_Api_defined */

#ifdef var_source_map_embed_Sass_Api_defined
  INT_TYPE source_map_embed;

#endif /* var_source_map_embed_Sass_Api_defined */

#ifdef var_omit_source_map_url_Sass_Api_defined
  INT_TYPE omit_source_map_url;

#endif /* var_omit_source_map_url_Sass_Api_defined */

#ifdef var_sass_syntax_Sass_Api_defined
  INT_TYPE sass_syntax;

#endif /* var_sass_syntax_Sass_Api_defined */

#ifdef var_id_handle_import_Sass_Api_defined
#line 129 "/Users/hww3/devel/pike/src/post_modules/_Sass/sass.cmod"
int id_handle_import;
#endif /* var_id_handle_import_Sass_Api_defined */
};
#ifdef PIKE_DEBUG
/* Ensure the struct is used in a variable declaration, or else gdb might not see it. */
static struct Sass_Api_struct *Sass_Api_gdb_dummy_ptr;
#endif
#line 131 "/Users/hww3/devel/pike/src/post_modules/_Sass/sass.cmod"
void set_options (struct Sass_Context *ctx)
{
struct Sass_Options *s_opts = sass_context_get_options (ctx);

sass_option_set_precision (s_opts, THIS->precision);
sass_option_set_output_style (s_opts, THIS->output_style);

if (THIS->include_path) {
sass_option_set_include_path (
s_opts, sass_copy_c_string (THIS->include_path->str));
}

sass_option_set_is_indented_syntax_src (s_opts, THIS->sass_syntax);
sass_option_set_omit_source_map_url (s_opts, THIS->omit_source_map_url);
sass_option_set_source_comments (s_opts, THIS->source_comments);

if (THIS->source_map_file != NULL) {
sass_option_set_source_map_file (
s_opts, sass_copy_c_string (THIS->source_map_file->str));
sass_option_set_omit_source_map_url (s_opts, false);
sass_option_set_source_map_contents (s_opts, true);
}
else {
sass_option_set_source_map_embed (s_opts, THIS->source_map_embed);
}

if (THIS->source_map_root != NULL) {
sass_option_set_source_map_root (
s_opts, sass_copy_c_string (THIS->source_map_root->str));
}
}


/* Libsass import callback. This will be called for every @import directive */
/* in the Sass files. See the doc comment for __importer_cb. */
Sass_Import_List pike_sass_importer (const char *path,
Sass_Importer_Entry UNUSED(cb),
struct Sass_Compiler *comp)
{
if (THIS->id_handle_import > -1) {
JMP_BUF recovery;
Sass_Import_Entry last_imp = sass_compiler_get_last_import (comp);
const char *abs_path = sass_import_get_abs_path (last_imp);
const char *imp_path = sass_import_get_imp_path (last_imp);
Sass_Import_List list = sass_make_import_list(1);

push_text (path);

push_text (abs_path);
push_text (imp_path);

if (SETJMP(recovery)) {
list[0] = sass_make_import_entry(path, 0, 0);
sass_import_set_error(list[0],
sass_copy_c_string("Importer error."), 0, 0);
if (!IS_UNDEFINED(&throw_value)) {
push_svalue(&throw_value);
}
UNSETJMP(recovery);
return list;
}

apply_low (Pike_fp->current_object, THIS->id_handle_import, 3);

if (TYPEOF (Pike_sp[-1]) == T_STRING) {
if (Pike_sp[-1].u.string->size_shift != eightbit) {
Pike_error ("Widestring returned from sass importer.\n");
}

UNSETJMP(recovery);

list[0] = sass_make_import_entry (
path,
sass_copy_c_string (Pike_sp[-1].u.string->str),
0);

pop_stack();

return list;
}
/* FIXME: I'm not 100% sure about the code below since it took me some */
/*        Pike source code browsing to come up with it. */
else if (TYPEOF (Pike_sp[-1]) == T_ARRAY) {
struct array *v = Pike_sp[-1].u.array;

if (v->size != 2) {
Pike_error("Arrays returned from handle_sass_import() must "
"contain two indices: source and absolute path.\n");
}

if (TYPEOF (ITEM(v)[0]) == T_STRING &&
TYPEOF (ITEM(v)[1]) == T_STRING)
{
/* Contents of the imported file. */
struct pike_string *_data = ITEM(v)[0].u.string;
/* Absolute path of the imported file. */
struct pike_string *_absp = ITEM(v)[1].u.string;

if (_data->size_shift != eightbit) {
Pike_error ("Widestring returned in array index one from "
"importer function.\n");
}

if (_absp->size_shift != eightbit) {
Pike_error ("Widestring returned in array index two from "
"importer function.\n");
}

UNSETJMP(recovery);

list[0] = sass_make_import (path, _absp->str,
/* libsass takes ownership of _data->str */
/* and will free it when the context */
/* is destroyd, hence the copy. */
sass_copy_c_string(_data->str),
0);

pop_stack();

return list;
}
}

/* FIXME: Complain about unsupported return-value? */
pop_stack();

UNSETJMP(recovery);
}

return NULL;
}


void register_importer (struct Sass_Context *ctx)
{
struct Sass_Options *s_opts = sass_context_get_options (ctx);

Sass_Importer_Entry c_imp = sass_make_importer (pike_sass_importer, 0, 0);

Sass_Importer_List imp_list = sass_make_importer_list (1);
sass_importer_set_list_entry (imp_list, 0, c_imp);
sass_option_set_c_importers (s_opts, imp_list);
}


/* Compile the file input_file and return the result. */
/* This method is over ridden in the the pmod. */
#define f_Sass_Api_compile_file_defined

#ifdef f_Sass_Api_compile_file_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_Sass_Api_compile_file_fun_num = 0;

#endif /* f_Sass_Api_compile_file_fun_num_used */
DEFAULT_CMOD_STORAGE void f_Sass_Api_compile_file(INT32 args) {
#line 278 "/Users/hww3/devel/pike/src/post_modules/_Sass/sass.cmod"
struct pike_string * input_file;
#line 278 "/Users/hww3/devel/pike/src/post_modules/_Sass/sass.cmod"
if(args != 1) wrong_number_of_args_error("compile_file",args,1);
#line 278 "/Users/hww3/devel/pike/src/post_modules/_Sass/sass.cmod"
if(TYPEOF(Pike_sp[0-1]) != PIKE_T_STRING) SIMPLE_ARG_TYPE_ERROR("compile_file",1,"string");
#line 278 "/Users/hww3/devel/pike/src/post_modules/_Sass/sass.cmod"
debug_malloc_pass(input_file=Pike_sp[0-1].u.string);
{
struct Sass_File_Context *ctx;
struct Sass_Context *ctx_out;
int err;
const char *scss;
ONERROR uwp;

SASS_TRACE ("compile_file(%s)\n", input_file->str);

ctx = sass_make_file_context (sass_copy_c_string (input_file->str));
ctx_out = sass_file_context_get_context (ctx);

set_options (ctx_out);
register_importer (ctx_out);

/* Since the Pike layer can throw below we register a cleanup */
/* callback here so that we can free the context properly. */

/* Sentinel for holding Pike errors.
     *
     * Pike errors are caught by the low-level code and pushed
     * on the stack, so that we can rethrow them here.
     */
push_undefined();

SET_ONERROR(uwp, sass_delete_file_context, ctx);

err = sass_compile_file_context (ctx);

if (!IS_UNDEFINED(Pike_sp-1)) {
/* Sentinel has changed. Rethrow. */
f_throw(1);
}

if (err) {
const char *errstr = sass_context_get_error_message (ctx_out);
Pike_error("Sass compile error (code: %d):\n%s\n", err, errstr);
}

scss = sass_context_get_output_string (ctx_out);

if (scss) {
const char *smap = NULL;
struct Sass_Options *s_opts = sass_context_get_options (ctx_out);

if (sass_option_get_source_map_file (s_opts)) {
smap = sass_context_get_source_map_string (ctx_out);

if ((err = sass_context_get_error_status (ctx_out))) {
const char *errstr = sass_context_get_error_message (ctx_out);
Pike_error("Failed generating source map (code: %ld): %s\n",
err, errstr);
}
}

push_constant_text ("css"); push_text (scss);
push_constant_text ("map");

if (smap != NULL) {
push_text (smap);
}
else {
push_undefined ();
}

f_aggregate_mapping (4);
}
else {
push_undefined ();
}

CALL_AND_UNSET_ONERROR(uwp);
}


}
/*! @decl string(8bit) compile_string(string(8bit) source)
   *!
   *! Compiles the string @[source] and returns the generated CSS.
   *!
   *! @note
   *!  If the @[source] contain @tt{@@import@} directives you have to
   *!  explicitly set the include path via @[include_path].
   *!
   *! @param source
   *!  The string to compile
   */
#define f_Sass_Api_compile_string_defined

#ifdef f_Sass_Api_compile_string_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_Sass_Api_compile_string_fun_num = 0;

#endif /* f_Sass_Api_compile_string_fun_num_used */
DEFAULT_CMOD_STORAGE void f_Sass_Api_compile_string(INT32 args) {
#line 366 "/Users/hww3/devel/pike/src/post_modules/_Sass/sass.cmod"
struct pike_string * source;
#line 365 "/Users/hww3/devel/pike/src/post_modules/_Sass/sass.cmod"
if(args != 1) wrong_number_of_args_error("compile_string",args,1);
if(TYPEOF(Pike_sp[0-1]) != PIKE_T_STRING) SIMPLE_ARG_TYPE_ERROR("compile_string",1,"string(0..255)");
#line 366 "/Users/hww3/devel/pike/src/post_modules/_Sass/sass.cmod"
debug_malloc_pass(source=Pike_sp[0-1].u.string);
{
struct Sass_Data_Context *ctx;
struct Sass_Context *ctx_out;
int err;
const char *out;
ONERROR uwp;

ctx = sass_make_data_context (sass_copy_c_string (source->str));
ctx_out = sass_data_context_get_context (ctx);

set_options (ctx_out);
register_importer (ctx_out);

/* Since the Pike layer can throw below we register a cleanup */
/* callback here so that we can free the context properly. */

/* Sentinel for holding Pike errors.
     *
     * Pike errors are caught by the low-level code and pushed
     * on the stack, so that we can rethrow them here.
     */
push_undefined();

SET_ONERROR(uwp, sass_delete_data_context, ctx);

sass_compile_data_context (ctx);

if (!IS_UNDEFINED(Pike_sp-1)) {
/* Sentinel has changed. Rethrow. */
f_throw(1);
}

err = sass_context_get_error_status (ctx_out);

if (err) {
const char *errstr = sass_context_get_error_message (ctx_out);
Pike_error("Sass compile error (code: %ld):\n%s\n", err, errstr);
}

out = sass_context_get_output_string (ctx_out);

if (out) {
const char *smap = NULL;
struct Sass_Options *s_opts = sass_context_get_options (ctx_out);

if (sass_option_get_source_map_file (s_opts)) {
smap = sass_context_get_source_map_string (ctx_out);

if ((err = sass_context_get_error_status (ctx_out))) {
const char *errstr = sass_context_get_error_message (ctx_out);
Pike_error("Failed generating source map (code: %ld): %s\n",
err, errstr);
}
}

push_constant_text ("css"); push_text (out);
push_constant_text ("map");

if (smap != NULL) {
push_text (smap);
}
else {
push_undefined ();
}

f_aggregate_mapping (4);
}
else {
push_undefined ();
}

CALL_AND_UNSET_ONERROR(uwp);
}

}

#undef internal_init_Sass_Api_defined
#define internal_init_Sass_Api_defined

#undef Sass_Api_event_handler_defined
#define Sass_Api_event_handler_defined
static void init_Sass_Api_struct(void)
#line 441 "/Users/hww3/devel/pike/src/post_modules/_Sass/sass.cmod"
{
SASS_TRACE ("INIT ___Sass.Api\n");
THIS->precision = 5;
THIS->output_style = SASS_STYLE_NESTED;
THIS->id_handle_import =
really_low_find_shared_string_identifier (module_strings[0] /* "handle_sass_import" */,
Pike_fp->current_object->prog,
SEE_PROTECTED|SEE_PRIVATE);

SASS_TRACE ("Handle Import ID: %d\n", THIS->id_handle_import);
}


#undef internal_exit_Sass_Api_defined
#define internal_exit_Sass_Api_defined

#undef Sass_Api_event_handler_defined
#define Sass_Api_event_handler_defined
static void exit_Sass_Api_struct(void)
#line 455 "/Users/hww3/devel/pike/src/post_modules/_Sass/sass.cmod"
{
SASS_TRACE ("EXIT ___Sass.Api\n");
}

#ifdef Sass_Api_event_handler_defined
static void Sass_Api_event_handler(int ev) {
  switch(ev) {

#ifdef internal_init_Sass_Api_defined
  case PROG_EVENT_INIT: init_Sass_Api_struct(); break;

#endif /* internal_init_Sass_Api_defined */

#ifdef internal_exit_Sass_Api_defined
  case PROG_EVENT_EXIT: exit_Sass_Api_struct(); break;

#endif /* internal_exit_Sass_Api_defined */
  default: break; 
  }
}

#endif /* Sass_Api_event_handler_defined */
/*! @endclass */


/*! @decl string(8bit) sass2scss(string(8bit) data)
 *! @decl string(8bit) sass2scss(string(8bit) data, int options)
 *!
 *! Convert Sass syntax (i.e. indented syntax) to SCSS syntax.
 *!
 *! @param data
 *!  Sass syntax text to convert to SCSS syntax.
 *!
 *! @param options
 *!  This is a bitwise union of compression level (@[STYLE_NESTED],
 *!  @[STYLE_EXPANDED], @[STYLE_COMPACT] and $[STYLE_COMPRESSED]) and the
 *!  @tt{SASS2SCSS_*@} constants @[SASS2SCSS_KEEP_COMMENT],
 *!  @[SASS2SCSS_STRIP_COMMENT] and @[SASS2SCSS_CONVERT_COMMENT].
 *!  It defaults to @expr{STYLE_NESTED|SASS2SCSS_KEEP_COMMENT@}.
 *!
 *! @returns
 *!  @[data] converted to SCSS syntax.
 */
#define f_Sass_sass2scss_defined

#ifdef f_Sass_sass2scss_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_Sass_sass2scss_fun_num = 0;

#endif /* f_Sass_sass2scss_fun_num_used */
DEFAULT_CMOD_STORAGE void f_Sass_sass2scss(INT32 args) {
#line 480 "/Users/hww3/devel/pike/src/post_modules/_Sass/sass.cmod"
struct pike_string * data;
#line 480 "/Users/hww3/devel/pike/src/post_modules/_Sass/sass.cmod"
struct svalue * options;
#line 480 "/Users/hww3/devel/pike/src/post_modules/_Sass/sass.cmod"
if(args < 1) wrong_number_of_args_error("sass2scss",args,1);
#line 480 "/Users/hww3/devel/pike/src/post_modules/_Sass/sass.cmod"
if(args > 2) wrong_number_of_args_error("sass2scss",args,2);
#line 480 "/Users/hww3/devel/pike/src/post_modules/_Sass/sass.cmod"
if(TYPEOF(Pike_sp[0-args]) != PIKE_T_STRING) SIMPLE_ARG_TYPE_ERROR("sass2scss",1,"string(0..255)");
#line 480 "/Users/hww3/devel/pike/src/post_modules/_Sass/sass.cmod"
debug_malloc_pass(data=Pike_sp[0-args].u.string);
#line 480 "/Users/hww3/devel/pike/src/post_modules/_Sass/sass.cmod"
if ((args > 1) &&
    ((TYPEOF(Pike_sp[1-args]) != PIKE_T_INT) ||
     (SUBTYPEOF(Pike_sp[1-args]) != NUMBER_UNDEFINED))) {
#line 480 "/Users/hww3/devel/pike/src/post_modules/_Sass/sass.cmod"
if(TYPEOF(Pike_sp[1-args]) != PIKE_T_INT) SIMPLE_ARG_TYPE_ERROR("sass2scss",2,"void|int");
#line 480 "/Users/hww3/devel/pike/src/post_modules/_Sass/sass.cmod"
options=Pike_sp+1-args; dmalloc_touch_svalue(Pike_sp+1-args);
#line 480 "/Users/hww3/devel/pike/src/post_modules/_Sass/sass.cmod"
} else options = NULL;
{
const char *conv;

/* NB: SASS2SCSS_PRETTIFY_1 is == SASS_STYLE_NESTED. */
int opts = SASS2SCSS_PRETTIFY_1 | SASS2SCSS_KEEP_COMMENT;

if (options && TYPEOF (*options) == T_INT) {
opts = options->u.integer;
}

conv = sass2scss (data->str, opts);
push_text (conv);
}


}
/*! @decl string libsass_version()
 *!
 *! Returns the @tt{libsass@} version this module was compiled against
 */
#define f_Sass_libsass_version_defined

#ifdef f_Sass_libsass_version_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_Sass_libsass_version_fun_num = 0;

#endif /* f_Sass_libsass_version_fun_num_used */
DEFAULT_CMOD_STORAGE void f_Sass_libsass_version(INT32 args) {
#line 500 "/Users/hww3/devel/pike/src/post_modules/_Sass/sass.cmod"
if(args != 0) wrong_number_of_args_error("libsass_version",args,0);
{
push_text (libsass_version ());
}


}
/*! @decl string sass2scss_version()
 *!
 *! Returns the @tt{sass2scss@} version this module was compiled against
 */
#define f_Sass_sass2scss_version_defined

#ifdef f_Sass_sass2scss_version_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_Sass_sass2scss_version_fun_num = 0;

#endif /* f_Sass_sass2scss_version_fun_num_used */
DEFAULT_CMOD_STORAGE void f_Sass_sass2scss_version(INT32 args) {
#line 510 "/Users/hww3/devel/pike/src/post_modules/_Sass/sass.cmod"
if(args != 0) wrong_number_of_args_error("sass2scss_version",args,0);
{
push_text (sass2scss_version ());
}


}
#line 516 "/Users/hww3/devel/pike/src/post_modules/_Sass/sass.cmod"
#if HAVE_LIBSASS_LANGUAGE_VERSION
/*! @decl string libsass_language_version()
 *!
 *! Returns the @tt{language@} version of Sass this module was compiled against
 */
#define f_Sass_libsass_language_version_defined

#ifdef f_Sass_libsass_language_version_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_Sass_libsass_language_version_fun_num = 0;

#endif /* f_Sass_libsass_language_version_fun_num_used */
DEFAULT_CMOD_STORAGE void f_Sass_libsass_language_version(INT32 args) {
#line 521 "/Users/hww3/devel/pike/src/post_modules/_Sass/sass.cmod"
if(args != 0) wrong_number_of_args_error("libsass_language_version",args,0);
{
push_text (libsass_language_version ());
}
}
#line 525 "/Users/hww3/devel/pike/src/post_modules/_Sass/sass.cmod"
#endif


PIKE_MODULE_INIT
{
/*! @decl constant LIBSASS_VERSION = ""
   *!
   *! The @tt{libsass@} version, as a string, this module was compiled agains.
   */

add_string_constant ("LIBSASS_VERSION", LIBSASS_VERSION, 0);

/*! @decl constant STYLE_NESTED = 1
   *! @decl constant STYLE_EXPANDED = 1
   *! @decl constant STYLE_COMPACT = 1
   *! @decl constant STYLE_COMPRESSED = 1
   *!
   *! Styling of output. Use as argument to @[Compiler.set_output_style()]
   *!
   *! @string
   *! @value STYLE_NESTED
   *! The default setting. The output will look like:
   *! @code
   *! a {
   *!   property: value;
   *!   other-property: value; }
   *!   a:hover {
   *!     property: value; }
   *! b {
   *!   property: value; }
   *! @endcode
   *!
   *! @value STYLE_EXPANDED
   *! Fully expanded output:
   *! @code
   *! a {
   *!   property: value;
   *!   other-property: value;
   *! }
   *! a:hover {
   *!   property: value;
   *! }
   *! b {
   *!   property: value;
   *! }
   *! @endcode
   *!
   *! @value STYLE_COMPACT
   *! Somewhat minified output:
   *! @code
   *! a { property: value; other-prop: value }
   *! a:hover { property: value; }
   *! b { property: value; }
   *! @endcode
   *!
   *! @value STYLE_COMPRESSED
   *! Minified output
   *! @code
   *! a{property:value;other-property:value}a:hover{property:value}b{property:value}
   *! @endcode
   *! @endstring
   */

add_integer_constant ("STYLE_NESTED", SASS_STYLE_NESTED, 0);
add_integer_constant ("STYLE_EXPANDED", SASS_STYLE_EXPANDED, 0);
add_integer_constant ("STYLE_COMPACT", SASS_STYLE_COMPACT, 0);
add_integer_constant ("STYLE_COMPRESSED", SASS_STYLE_COMPRESSED, 0);

/*! @decl constant HTTP_IMPORT_NONE = 0
   *! @decl constant HTTP_IMPORT_GREEDY = 1
   *! @decl constant HTTP_IMPORT_ANY = 2
   *!
   *! Description:
   *!
   *! @string
   *! @value HTTP_IMPORT_NONE
   *!  Default value of @[Compiler.http_import]. Prohibits imports over HTTP.
   *! @value HTTP_IMPORT_GREEDY
   *!  Allow imports over HTTP only if the returned content type is
   *!  @tt{text/scss@}.
   *! @value HTTP_IMPORT_ANY
   *!  Anything goes.
   *! @endstring
   */

add_integer_constant ("HTTP_IMPORT_NONE", 0, 0);
add_integer_constant ("HTTP_IMPORT_GREEDY", 1, 0);
add_integer_constant ("HTTP_IMPORT_ANY", 2, 0);

/**
   * @decl constant SASS2SCSS_KEEP_COMMENT = 32
   * @decl constant SASS2SCSS_STRIP_COMMENT = 64
   * @decl constant SASS2SCSS_CONVERT_COMMENT = 128
   *
   * Constants that can be given as option to @[sass2scss()].
   */

add_integer_constant ("SASS2SCSS_KEEP_COMMENT", SASS2SCSS_KEEP_COMMENT, 0);
add_integer_constant ("SASS2SCSS_STRIP_COMMENT", SASS2SCSS_STRIP_COMMENT, 0);
add_integer_constant ("SASS2SCSS_CONVERT_COMMENT", SASS2SCSS_CONVERT_COMMENT, 0);


#ifdef module_strings_declared
module_strings[0] = 
  make_shared_binary_string("handle_sass_import",
                            CONSTANT_STRLEN("handle_sass_import"));
#endif

#ifdef CMOD_MAP_PROGRAM_IDS_DEFINED
set_program_id_to_id( ___cmod_map_program_ids );

#endif /* CMOD_MAP_PROGRAM_IDS_DEFINED */

#ifdef class_Sass_Api_defined

#ifdef PROG_SASS_API_ID
#line 51 "/Users/hww3/devel/pike/src/post_modules/_Sass/sass.cmod"
  START_NEW_PROGRAM_ID(SASS_API);
#else
#line 51 "/Users/hww3/devel/pike/src/post_modules/_Sass/sass.cmod"
  start_new_program();

#endif /* PROG_SASS_API_ID */
#line 51 "/Users/hww3/devel/pike/src/post_modules/_Sass/sass.cmod"
  Sass_Api_program = Pike_compiler->new_program;

#ifndef tObjImpl_SASS_API

#undef tObjIs_SASS_API
#define tObjIs_SASS_API "\3\1\177\0\0\2"

#undef tObjImpl_SASS_API
#define tObjImpl_SASS_API "\3\0\177\0\0\2"

#endif /* tObjImpl_SASS_API */

#ifdef THIS_SASS_API
  Sass_Api_storage_offset = ADD_STORAGE(struct Sass_Api_struct);
#endif /* THIS_SASS_API */

#ifdef var_output_style_Sass_Api_defined
  PIKE_MAP_VARIABLE("output_style", Sass_Api_storage_offset + OFFSETOF(Sass_Api_struct, output_style),
                    "\10\0\0\0\0\0\0\0\3", PIKE_T_INT, 0);
#endif /* var_output_style_Sass_Api_defined */

#ifdef var_source_map_file_Sass_Api_defined
  PIKE_MAP_VARIABLE("source_map_file", Sass_Api_storage_offset + OFFSETOF(Sass_Api_struct, source_map_file),
                    tStr8, PIKE_T_STRING, 0);
#endif /* var_source_map_file_Sass_Api_defined */

#ifdef var_source_map_root_Sass_Api_defined
  PIKE_MAP_VARIABLE("source_map_root", Sass_Api_storage_offset + OFFSETOF(Sass_Api_struct, source_map_root),
                    tStr8, PIKE_T_STRING, 0);
#endif /* var_source_map_root_Sass_Api_defined */

#ifdef var_include_path_Sass_Api_defined
  PIKE_MAP_VARIABLE("include_path", Sass_Api_storage_offset + OFFSETOF(Sass_Api_struct, include_path),
                    tStr8, PIKE_T_STRING, 0);
#endif /* var_include_path_Sass_Api_defined */

#ifdef var_precision_Sass_Api_defined
  PIKE_MAP_VARIABLE("precision", Sass_Api_storage_offset + OFFSETOF(Sass_Api_struct, precision),
                    "\10\0\0\0\0\177\377\377\377", PIKE_T_INT, 0);
#endif /* var_precision_Sass_Api_defined */

#ifdef var_source_comments_Sass_Api_defined
  PIKE_MAP_VARIABLE("source_comments", Sass_Api_storage_offset + OFFSETOF(Sass_Api_struct, source_comments),
                    "\10\0\0\0\0\0\0\0\1", PIKE_T_INT, 0);
#endif /* var_source_comments_Sass_Api_defined */

#ifdef var_source_map_embed_Sass_Api_defined
  PIKE_MAP_VARIABLE("source_map_embed", Sass_Api_storage_offset + OFFSETOF(Sass_Api_struct, source_map_embed),
                    "\10\0\0\0\0\0\0\0\1", PIKE_T_INT, 0);
#endif /* var_source_map_embed_Sass_Api_defined */

#ifdef var_omit_source_map_url_Sass_Api_defined
  PIKE_MAP_VARIABLE("omit_source_map_url", Sass_Api_storage_offset + OFFSETOF(Sass_Api_struct, omit_source_map_url),
                    "\10\0\0\0\0\0\0\0\1", PIKE_T_INT, 0);
#endif /* var_omit_source_map_url_Sass_Api_defined */

#ifdef var_sass_syntax_Sass_Api_defined
  PIKE_MAP_VARIABLE("sass_syntax", Sass_Api_storage_offset + OFFSETOF(Sass_Api_struct, sass_syntax),
                    "\10\0\0\0\0\0\0\0\1", PIKE_T_INT, 0);
#endif /* var_sass_syntax_Sass_Api_defined */

#ifdef Sass_Api_event_handler_defined
  pike_set_prog_event_callback(Sass_Api_event_handler);

#ifndef Sass_Api_gc_live_obj
  Pike_compiler->new_program->flags &= ~PROGRAM_LIVE_OBJ;

#endif /* Sass_Api_gc_live_obj */

#endif /* Sass_Api_event_handler_defined */

#ifdef f_Sass_Api_handle_sass_import_defined

#ifdef f_Sass_Api_handle_sass_import_fun_num_used
  f_Sass_Api_handle_sass_import_fun_num =
#endif /* f_Sass_Api_handle_sass_import_fun_num_used */
#line 116 "/Users/hww3/devel/pike/src/post_modules/_Sass/sass.cmod"
    ADD_FUNCTION2("handle_sass_import", f_Sass_Api_handle_sass_import, tFunc(tStr8 tOr(tVoid,tStr8) tOr(tVoid,tStr8),tOr(tStr8,tArr(tStr8))), ID_PROTECTED, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_Sass_Api_handle_sass_import_defined */

#ifdef f_Sass_Api_compile_file_defined

#ifdef f_Sass_Api_compile_file_fun_num_used
  f_Sass_Api_compile_file_fun_num =
#endif /* f_Sass_Api_compile_file_fun_num_used */
#line 278 "/Users/hww3/devel/pike/src/post_modules/_Sass/sass.cmod"
    ADD_FUNCTION2("compile_file", f_Sass_Api_compile_file, tFunc(tStr,tMap(tStr8,tStr8)), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_Sass_Api_compile_file_defined */

#ifdef f_Sass_Api_compile_string_defined

#ifdef f_Sass_Api_compile_string_fun_num_used
  f_Sass_Api_compile_string_fun_num =
#endif /* f_Sass_Api_compile_string_fun_num_used */
#line 365 "/Users/hww3/devel/pike/src/post_modules/_Sass/sass.cmod"
    ADD_FUNCTION2("compile_string", f_Sass_Api_compile_string, tFunc(tStr8,tMap(tStr8,tStr8)), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_Sass_Api_compile_string_defined */
#line 51 "/Users/hww3/devel/pike/src/post_modules/_Sass/sass.cmod"
  Sass_Api_program=end_program();
#line 51 "/Users/hww3/devel/pike/src/post_modules/_Sass/sass.cmod"
#ifdef Sass_Api_program_fun_num_used
Sass_Api_program_fun_num=
#endif
 add_program_constant("Api",Sass_Api_program,0);

#endif /* class_Sass_Api_defined */

#ifdef f_Sass_sass2scss_defined

#ifdef f_Sass_sass2scss_fun_num_used
  f_Sass_sass2scss_fun_num =
#endif /* f_Sass_sass2scss_fun_num_used */
#line 480 "/Users/hww3/devel/pike/src/post_modules/_Sass/sass.cmod"
    ADD_FUNCTION2("sass2scss", f_Sass_sass2scss, tFunc(tStr8 tOr(tVoid,"\10\200\0\0\0\177\377\377\377"),tStr8), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_Sass_sass2scss_defined */

#ifdef f_Sass_libsass_version_defined

#ifdef f_Sass_libsass_version_fun_num_used
  f_Sass_libsass_version_fun_num =
#endif /* f_Sass_libsass_version_fun_num_used */
#line 500 "/Users/hww3/devel/pike/src/post_modules/_Sass/sass.cmod"
    ADD_FUNCTION2("libsass_version", f_Sass_libsass_version, tFunc(tNone,tStr), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_Sass_libsass_version_defined */

#ifdef f_Sass_sass2scss_version_defined

#ifdef f_Sass_sass2scss_version_fun_num_used
  f_Sass_sass2scss_version_fun_num =
#endif /* f_Sass_sass2scss_version_fun_num_used */
#line 510 "/Users/hww3/devel/pike/src/post_modules/_Sass/sass.cmod"
    ADD_FUNCTION2("sass2scss_version", f_Sass_sass2scss_version, tFunc(tNone,tStr), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_Sass_sass2scss_version_defined */

#ifdef f_Sass_libsass_language_version_defined

#ifdef f_Sass_libsass_language_version_fun_num_used
  f_Sass_libsass_language_version_fun_num =
#endif /* f_Sass_libsass_language_version_fun_num_used */
#line 521 "/Users/hww3/devel/pike/src/post_modules/_Sass/sass.cmod"
    ADD_FUNCTION2("libsass_language_version", f_Sass_libsass_language_version, tFunc(tNone,tStr), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_Sass_libsass_language_version_defined */

#ifdef CMOD_MAP_PROGRAM_IDS_DEFINED
set_program_id_to_id( 0 );
#endif /* CMOD_MAP_PROGRAM_IDS_DEFINED */
#line 627 "/Users/hww3/devel/pike/src/post_modules/_Sass/sass.cmod"
}


PIKE_MODULE_EXIT
{

#ifdef class_Sass_Api_defined
  if(Sass_Api_program) {
#line 51 "/Users/hww3/devel/pike/src/post_modules/_Sass/sass.cmod"
    free_program(Sass_Api_program);
    Sass_Api_program=0;
  }

#endif /* class_Sass_Api_defined */

#ifdef module_strings_declared
{
  int i;
  for(i=0; i < 1; i++) {
    if (module_strings[i]) free_string(module_strings[i]);
    module_strings[i] = NULL;
  }
}
#endif
#line 633 "/Users/hww3/devel/pike/src/post_modules/_Sass/sass.cmod"
}

/*! @endmodule
 */
/*! @endmodule
 */

#else  /* HAVE_LIBSASS */

PIKE_MODULE_INIT {
HIDE_MODULE();
}
PIKE_MODULE_EXIT {}

#endif /* HAVE_LIBSASS */


#ifdef CMOD_MAP_PROGRAM_IDS_DEFINED
static int ___cmod_map_program_ids(int id)
{
  int i = 0;
  if( (id&0x7f000000) != 0x7f000000 ) return id;
  id = id&0x00ffffff;
#ifdef class_Sass_Api_defined
if(id==2) return Sass_Api_program->id;
#endif
  return 0;
}
#endif /* CMOD_MAP_PROGRAM_IDS_DEFINED */
