Example #1
0
func Compile(goCtx *Context) {
	// set up the underlying C context struct
	cCtx := C.sass_new_context()
	cCtx.source_string = C.CString(goCtx.SourceString)
	defer C.free(unsafe.Pointer(cCtx.source_string))
	cCtx.options.output_style = C.int(goCtx.Options.OutputStyle)
	if goCtx.Options.SourceComments {
		cCtx.options.source_comments = C.int(1)
	} else {
		cCtx.options.source_comments = C.int(0)
	}
	cCtx.options.include_paths = C.CString(strings.Join(goCtx.Options.IncludePaths, ":"))
	defer C.free(unsafe.Pointer(cCtx.options.include_paths))
	cCtx.options.image_path = C.CString(goCtx.Options.ImagePath)
	defer C.free(unsafe.Pointer(cCtx.options.image_path))
	// call the underlying C compile function to populate the C context
	C.sass_compile(cCtx)
	// extract values from the C context to populate the Go context object
	goCtx.OutputString = C.GoString(cCtx.output_string)
	goCtx.ErrorStatus = int(cCtx.error_status)
	goCtx.ErrorMessage = C.GoString(cCtx.error_message)
	// don't forget to free the C context!
	C.sass_free_context(cCtx)
}
Example #2
0
File: sass.go Project: pascalj/sass
func newSassCtx() *C.struct_sass_context {
	return C.sass_new_context()
}