Ejemplo n.º 1
0
// BindHeader attaches the header to a libsass context ensuring
// gc does not delete the pointers necessary to make this happen.
func BindHeader(opts SassOptions, entries []ImportEntry) *string {

	idx := globalHeaders.set(entries)
	ptr := unsafe.Pointer(idx)

	imper := C.sass_make_importer(
		C.Sass_Importer_Fn(C.SassHeaders),
		C.double(0),
		ptr,
	)
	impers := C.sass_make_importer_list(1)
	C.sass_importer_set_list_entry(impers, 0, imper)

	C.sass_option_set_c_headers(
		(*C.struct_Sass_Options)(unsafe.Pointer(opts)),
		impers)
	return idx
}
Ejemplo n.º 2
0
func (ctx *Context) SetHeaders(opts *C.struct_Sass_Options) {
	// Push the headers into the local array
	for _, gh := range globalHeaders {
		ctx.Headers.Add(gh)
	}

	cheads := C.sass_make_importer_list(1)
	hdr := reflect.SliceHeader{
		Data: uintptr(unsafe.Pointer(cheads)),
		Len:  1, Cap: 1,
	}
	goheads := *(*[]C.Sass_Importer_Entry)(unsafe.Pointer(&hdr))

	imper := C.sass_make_importer(
		C.Sass_Importer_Fn(C.SassHeaders),
		C.double(0),
		unsafe.Pointer(ctx))

	goheads[0] = imper

	C.sass_option_set_c_headers(opts, cheads)
}
Ejemplo n.º 3
0
// SassOptionSetCHeaders adds custom C headers to a SassOptions
func SassOptionSetCHeaders(gofc SassOptions, goimp SassImporterList) {
	C.sass_option_set_c_headers(gofc, goimp)
}