├── .editorconfig
├── .gitattributes
├── .github
├── FUNDING.yml
└── workflows
│ └── ci.yml
├── .gitignore
├── .gitmodules
├── changelog.md
├── img
├── SharpScss.png
└── SharpScss.svg
├── license.txt
├── readme.md
└── src
├── Directory.Packages.props
├── LibSassGen
├── LibSassGen.csproj
└── Program.cs
├── SharpScss.Tests
├── SharpScss.Tests.csproj
├── TestScss.cs
└── files
│ ├── subfolder
│ └── foo.scss
│ └── test.scss
├── SharpScss.sln
├── SharpScss.sln.DotSettings
├── SharpScss
├── LibSass.Generated.cs
├── LibSass.cs
├── Scss.cs
├── ScssException.cs
├── ScssOptions.cs
├── ScssOutputStyle.cs
├── ScssResult.cs
├── SharpScss.csproj
├── SharpScss.xproj.DotSettings
├── build
│ └── net20-35-40
│ │ └── SharpScss.targets
├── key.snk
└── runtimes
│ ├── linux-arm
│ └── native
│ │ └── libsass.so
│ ├── linux-arm64
│ └── native
│ │ └── libsass.so
│ ├── linux-musl-arm64
│ └── native
│ │ └── libsass.so
│ ├── linux-musl-x64
│ └── native
│ │ └── libsass.so
│ ├── linux-x64
│ └── native
│ │ └── libsass.so
│ ├── osx-arm64
│ └── native
│ │ └── libsass.dylib
│ ├── osx-x64
│ └── native
│ │ └── libsass.dylib
│ ├── win-arm
│ └── native
│ │ └── libsass.dll
│ ├── win-arm64
│ └── native
│ │ └── libsass.dll
│ ├── win-x64
│ └── native
│ │ └── libsass.dll
│ └── win-x86
│ └── native
│ └── libsass.dll
├── dotnet-releaser.toml
└── global.json
/.editorconfig:
--------------------------------------------------------------------------------
1 | # EditorConfig is awesome:http://EditorConfig.org
2 |
3 | # top-most EditorConfig file
4 | root = true
5 |
6 | # All Files
7 | [*]
8 | charset = utf-8
9 | #end_of_line = crlf
10 | indent_style = space
11 | indent_size = 4
12 | insert_final_newline = false
13 | trim_trailing_whitespace = true
14 |
15 | # Solution Files
16 | [*.sln]
17 | indent_style = tab
18 |
19 | # XML Project Files
20 | [*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}]
21 | indent_size = 2
22 |
23 | # Configuration Files
24 | [*.{json,xml,yml,config,props,targets,nuspec,resx,ruleset}]
25 | indent_size = 2
26 |
27 | # Markdown Files
28 | [*.md]
29 | trim_trailing_whitespace = false
30 |
31 | # Web Files
32 | [*.{htm,html,js,ts,css,scss,less}]
33 | indent_size = 2
34 | insert_final_newline = true
35 |
36 | # Bash Files
37 | [*.sh]
38 | end_of_line = lf
39 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Set default behavior to automatically normalize line endings.
2 | * text=auto
3 |
4 | # shell files should always be LF
5 | *.sh text eol=lf
6 |
7 |
--------------------------------------------------------------------------------
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | # These are supported funding model platforms
2 |
3 | github: [xoofx] # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
4 | patreon: # Replace with a single Patreon username
5 | open_collective: # Replace with a single Open Collective username
6 | ko_fi: # Replace with a single Ko-fi username
7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9 | liberapay: # Replace with a single Liberapay username
10 | issuehunt: # Replace with a single IssueHunt username
11 | otechie: # Replace with a single Otechie username
12 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
13 |
--------------------------------------------------------------------------------
/.github/workflows/ci.yml:
--------------------------------------------------------------------------------
1 | name: ci
2 |
3 | on:
4 | push:
5 | paths-ignore:
6 | - 'doc/**'
7 | - 'img/**'
8 | - 'readme.md'
9 | pull_request:
10 |
11 | jobs:
12 | build:
13 | runs-on: 'windows-latest'
14 | steps:
15 | - name: "Build, Test and Pack common"
16 | uses: xoofx/.github/.github/actions/dotnet-releaser-action@main
17 | with:
18 | NUGET_TOKEN: ${{ secrets.NUGET_TOKEN }}
19 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.userosscache
8 | *.sln.docstates
9 |
10 | # User-specific files (MonoDevelop/Xamarin Studio)
11 | *.userprefs
12 |
13 | # Build results
14 | [Dd]ebug/
15 | [Dd]ebugPublic/
16 | [Rr]elease/
17 | [Rr]eleases/
18 | x64/
19 | x86/
20 | build/
21 | bld/
22 | [Bb]in/
23 | [Oo]bj/
24 |
25 | # Visual Studio 2015 cache/options directory
26 | .vs/
27 | # Uncomment if you have tasks that create the project's static files in wwwroot
28 | #wwwroot/
29 |
30 | # MSTest test Results
31 | [Tt]est[Rr]esult*/
32 | [Bb]uild[Ll]og.*
33 |
34 | # NUNIT
35 | *.VisualState.xml
36 | TestResult.xml
37 |
38 | # Build Results of an ATL Project
39 | [Dd]ebugPS/
40 | [Rr]eleasePS/
41 | dlldata.c
42 |
43 | # DNX
44 | project.lock.json
45 | artifacts/
46 |
47 | *_i.c
48 | *_p.c
49 | *_i.h
50 | *.ilk
51 | *.meta
52 | *.obj
53 | *.pch
54 | *.pdb
55 | *.pgc
56 | *.pgd
57 | *.rsp
58 | *.sbr
59 | *.tlb
60 | *.tli
61 | *.tlh
62 | *.tmp
63 | *.tmp_proj
64 | *.log
65 | *.vspscc
66 | *.vssscc
67 | .builds
68 | *.pidb
69 | *.svclog
70 | *.scc
71 |
72 | # Chutzpah Test files
73 | _Chutzpah*
74 |
75 | # Visual C++ cache files
76 | ipch/
77 | *.aps
78 | *.ncb
79 | *.opensdf
80 | *.sdf
81 | *.cachefile
82 |
83 | # Visual Studio profiler
84 | *.psess
85 | *.vsp
86 | *.vspx
87 |
88 | # TFS 2012 Local Workspace
89 | $tf/
90 |
91 | # Guidance Automation Toolkit
92 | *.gpState
93 |
94 | # ReSharper is a .NET coding add-in
95 | _ReSharper*/
96 | *.[Rr]e[Ss]harper
97 | *.DotSettings.user
98 |
99 | # JustCode is a .NET coding add-in
100 | .JustCode
101 |
102 | # TeamCity is a build add-in
103 | _TeamCity*
104 |
105 | # DotCover is a Code Coverage Tool
106 | *.dotCover
107 |
108 | # NCrunch
109 | _NCrunch_*
110 | .*crunch*.local.xml
111 | nCrunchTemp_*
112 |
113 | # MightyMoose
114 | *.mm.*
115 | AutoTest.Net/
116 |
117 | # Web workbench (sass)
118 | .sass-cache/
119 |
120 | # Installshield output folder
121 | [Ee]xpress/
122 |
123 | # DocProject is a documentation generator add-in
124 | DocProject/buildhelp/
125 | DocProject/Help/*.HxT
126 | DocProject/Help/*.HxC
127 | DocProject/Help/*.hhc
128 | DocProject/Help/*.hhk
129 | DocProject/Help/*.hhp
130 | DocProject/Help/Html2
131 | DocProject/Help/html
132 |
133 | # Click-Once directory
134 | publish/
135 |
136 | # Publish Web Output
137 | *.[Pp]ublish.xml
138 | *.azurePubxml
139 | # TODO: Comment the next line if you want to checkin your web deploy settings
140 | # but database connection strings (with potential passwords) will be unencrypted
141 | *.pubxml
142 | *.publishproj
143 |
144 | # NuGet Packages
145 | *.nupkg
146 | # The packages folder can be ignored because of Package Restore
147 | **/packages/*
148 | # except build/, which is used as an MSBuild target.
149 | !**/packages/build/
150 | # Uncomment if necessary however generally it will be regenerated when needed
151 | #!**/packages/repositories.config
152 |
153 | # Windows Azure Build Output
154 | csx/
155 | *.build.csdef
156 |
157 | # Windows Store app package directory
158 | AppPackages/
159 |
160 | # Visual Studio cache files
161 | # files ending in .cache can be ignored
162 | *.[Cc]ache
163 | # but keep track of directories ending in .cache
164 | !*.[Cc]ache/
165 |
166 | # Others
167 | ClientBin/
168 | [Ss]tyle[Cc]op.*
169 | ~$*
170 | *~
171 | *.dbmdl
172 | *.dbproj.schemaview
173 | *.pfx
174 | *.publishsettings
175 | node_modules/
176 | orleans.codegen.cs
177 |
178 | # RIA/Silverlight projects
179 | Generated_Code/
180 |
181 | # Backup & report files from converting an old project file
182 | # to a newer Visual Studio version. Backup files are not needed,
183 | # because we have git ;-)
184 | _UpgradeReport_Files/
185 | Backup*/
186 | UpgradeLog*.XML
187 | UpgradeLog*.htm
188 |
189 | # SQL Server files
190 | *.mdf
191 | *.ldf
192 |
193 | # Business Intelligence projects
194 | *.rdl.data
195 | *.bim.layout
196 | *.bim_*.settings
197 |
198 | # Microsoft Fakes
199 | FakesAssemblies/
200 |
201 | # Node.js Tools for Visual Studio
202 | .ntvs_analysis.dat
203 |
204 | # Visual Studio 6 build log
205 | *.plg
206 |
207 | # Visual Studio 6 workspace options file
208 | *.opt
209 |
210 | # Visual Studio LightSwitch build output
211 | **/*.HTMLClient/GeneratedArtifacts
212 | **/*.DesktopClient/GeneratedArtifacts
213 | **/*.DesktopClient/ModelManifest.xml
214 | **/*.Server/GeneratedArtifacts
215 | **/*.Server/ModelManifest.xml
216 | _Pvt_Extensions
217 |
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "libsass"]
2 | path = libsass
3 | url = https://github.com/xoofx/libsass.git
4 | branch = develop
5 |
--------------------------------------------------------------------------------
/changelog.md:
--------------------------------------------------------------------------------
1 | # Changelog for SharpScss
2 |
3 | ## 2.0.0 (28 Jun 2020)
4 | - Breaking change of ScssOptions.TryImport delegate. The file parameter is now passed by ref in order to provide the resolved file path.
5 |
6 | ## 1.5.0 (2 May 2020)
7 | - Update libsass to 3.6.4
8 | - Support only .NET Standard 2.0+
9 |
10 | ## 1.4.0 (25 June 2018)
11 | - Update libsass to 3.5.4
12 |
13 | ## 1.3.8
14 | - Fix runtime for MacOSX
15 |
16 | ## 1.3.7
17 | - Improve detection of x86 runtime on Windows for net20, net35, net40+
18 |
19 | ## 1.3.6
20 | - Fix native library on Windows x86/x64 to return the correct version `Scss.Version`
21 |
22 | ## 1.3.5
23 | - Better support for NET20, NET35, NET40 by copying by default the win7-x64 libsass.dll to the folder.
24 | The platform runtime can be changed in your project by using the SharpScssRuntime variable set by default to `win7-x64`
25 |
26 | The possible values for SharpScssRuntime are:
27 | - `win7-x86`
28 | - `win7-x64`
29 | - `osx.10.10-x64`
30 | - `ubuntu.14.04-x64`
31 |
32 | For the netstandard1.3+ platforms (.NET Core), it is based on the RID of your `netcoreapp` project
33 |
34 | ## 1.3.4
35 | - upgrade to libsass 3.4.4
--------------------------------------------------------------------------------
/img/SharpScss.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xoofx/SharpScss/ebf2cb0dc6fb1e2c69b8a661c274c1039e2ee5ca/img/SharpScss.png
--------------------------------------------------------------------------------
/img/SharpScss.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
72 |
--------------------------------------------------------------------------------
/license.txt:
--------------------------------------------------------------------------------
1 | Copyright (c) 2016-2020, Alexandre Mutel
2 | All rights reserved.
3 |
4 | Redistribution and use in source and binary forms, with or without modification
5 | , are permitted provided that the following conditions are met:
6 |
7 | 1. Redistributions of source code must retain the above copyright notice, this
8 | list of conditions and the following disclaimer.
9 |
10 | 2. Redistributions in binary form must reproduce the above copyright notice,
11 | this list of conditions and the following disclaimer in the documentation
12 | and/or other materials provided with the distribution.
13 |
14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
15 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
18 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
21 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
22 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--------------------------------------------------------------------------------
/readme.md:
--------------------------------------------------------------------------------
1 | # SharpScss [](https://github.com/xoofx/SharpScss/actions/workflows/ci.yml) [](https://www.nuget.org/packages/SharpScss/)
2 |
3 |
4 |
5 | SharpScss is a P/Invoke .NET wrapper around [libsass](https://github.com/sass/libsass) to convert SCSS to CSS.
6 |
7 | > Based on the version of `libsass 3.6.6`
8 |
9 | ## Features
10 |
11 | - Pure P/Invoke .NET wrapper, no C++/CLI involved
12 | - Supports converting from a string or from a file
13 | - Supports include paths
14 | - Supports for source maps
15 | - Supports for `libsass` user custom importer callback in `ScssOptions.TryImport`
16 | - Supports for `netstandard2.0` and `net8.0`+
17 | - Supports the following platforms:
18 | - `win-x86`
19 | - `win-x64`
20 | - `win-arm`
21 | - `win-arm64`
22 | - `linux-x64`
23 | - `linux-arm`
24 | - `linux-arm64`
25 | - `linux-musl-x64`
26 | - `linux-musl-arm`
27 | - `linux-musl-arm64`
28 | - `osx-x64`
29 | - `osx-arm64`
30 |
31 | For older .NET2.0, .NET3.5, .NET4.x+ and `netstandard1.3`, you need to download the `1.4.0` version.
32 |
33 | ## Download
34 |
35 | SharpScss is available on [](https://www.nuget.org/packages/SharpScss/)
36 |
37 | ## Usage
38 |
39 | SharpScss API is simply composed of a main `Scss` class:
40 |
41 | - `Scss.ConvertToCss`: to convert a `SCSS` string to a `CSS`
42 |
43 | ```
44 | var result = Scss.ConvertToCss("div {color: #FFF;}")
45 | Console.WriteLine(result.Css);
46 | ```
47 |
48 | - `Scss.ConvertFileToCss`: to convert a `SCSS` file to a `CSS`
49 |
50 | ```
51 | var result = Scss.ConvertFileToCss("test.scss")
52 | Console.WriteLine(result.Css);
53 | ```
54 |
55 | Using the `ScssOptions` you can specify additional parameters:
56 |
57 | ```
58 | var result = Scss.ConvertToCss(@"div {color: #FFF;}", new ScssOptions()
59 | {
60 | InputFile = "Test.scss",
61 | OutputFile = "Test.css", // Note: It will not generate the file,
62 | // only used for exception reporting
63 | // includes and source maps
64 | GenerateSourceMap = true
65 | });
66 | Console.WriteLine(result.Css);
67 | Console.WriteLine(result.SourceMap);
68 | ```
69 |
70 | You can use also custom dynamic import through the delegate `ScssOptions.TryImport`. Note that in that cases `ScssOptions.IncludePaths` is not used
71 | and it is the responsability of the `TryImport` to perform the resolution (e.g on a virtual file system):
72 |
73 | ```
74 | var result = Scss.ConvertToCss(@"@import ""foo"";", new ScssOptions()
75 | {
76 | InputFile = "test.scss",
77 | TryImport = (ref string file, string path, out string scss, out string map) =>
78 | {
79 | // Add resolve the file
80 | // file = resolvedFilePath; // Can change the file resolved
81 | scss = ...; // TODO: handle the loading of scss for the specified file
82 | map = null;
83 | return true;
84 | }
85 | });
86 | ```
87 |
88 | ## Runtime
89 |
90 | SharpScss depends on the native runtime `libsass`. This runtime is compiled for the following platform/runtime:
91 |
92 | - `win-x86`
93 | - `win-x64`
94 | - `win-arm`
95 | - `win-arm64`
96 | - `linux-x64`
97 | - `linux-arm`
98 | - `linux-arm64`
99 | - `linux-musl-x64`
100 | - `linux-musl-arm`
101 | - `linux-musl-arm64`
102 | - `osx-x64`
103 | - `osx-arm64`
104 |
105 | On .NET Core (`net8.0`), the runtime is selected based on the [Runtime Identifier - RID](https://docs.microsoft.com/en-us/dotnet/articles/core/rid-catalog) of your project.
106 |
107 | - You can add to your csproj the specific targeting runtimes your `net8.0` with `win-x86;linux-x64` or `` if you have only one runtime to target (See [Additions to the csproj format for .NET Core](https://docs.microsoft.com/en-us/dotnet/articles/core/tools/csproj))
108 |
109 | ## Build
110 |
111 | Currently, the compiled version of libsass shipped with SharpScss is a custom build from the fork [xoofx/libsass](https://github.com/xoofx/libsass)
112 |
113 | This fork is mainly allowing to compile libsass without the MSVC C/C++ Runtime on Windows and provide a GitHub CI action to compile all different platforms.
114 |
115 | ## License
116 |
117 | This software is released under the [BSD-Clause 2 license](http://opensource.org/licenses/BSD-2-Clause).
118 |
119 | ## Author
120 |
121 | Alexandre Mutel aka [xoofx](https://xoofx.github.io)
122 |
--------------------------------------------------------------------------------
/src/Directory.Packages.props:
--------------------------------------------------------------------------------
1 |
2 |
3 | true
4 | false
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/src/LibSassGen/LibSassGen.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net8.0
6 | win-x64
7 | 7.3
8 | false
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/src/LibSassGen/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Diagnostics;
4 | using System.IO;
5 | using System.Linq;
6 | using System.Text;
7 | using CppAst;
8 | using CppAst.CodeGen.Common;
9 | using CppAst.CodeGen.CSharp;
10 | using Zio;
11 | using Zio.FileSystems;
12 |
13 | namespace LibSassGen
14 | {
15 | ///
16 | /// Generates a C# file from api.h
17 | /// Runs only on Windows
18 | ///
19 | internal class Program
20 | {
21 | static void Main(string[] args)
22 | {
23 | var program = new Program();
24 | program.Run();
25 | }
26 |
27 | public void Run()
28 | {
29 | var srcFolder = Path.GetFullPath(Path.Combine(Environment.CurrentDirectory, @"..\..\..\..\..\..\libsass\include"));
30 | var destFolder = Path.GetFullPath(Path.Combine(Environment.CurrentDirectory, @"..\..\..\..\..\SharpScss"));
31 |
32 | if (!Directory.Exists(srcFolder))
33 | {
34 | throw new DirectoryNotFoundException($"The source folder `{srcFolder}` doesn't exist");
35 | }
36 | if (!Directory.Exists(destFolder))
37 | {
38 | throw new DirectoryNotFoundException($"The destination folder `{destFolder}` doesn't exist");
39 | }
40 |
41 |
42 | var marshalNoFreeNative = new CSharpMarshalAttribute(CSharpUnmanagedKind.CustomMarshaler) {MarshalTypeRef = "typeof(UTF8MarshallerNoFree)"};
43 |
44 | var csOptions = new CSharpConverterOptions()
45 | {
46 | DefaultClassLib = "LibSass",
47 | DefaultNamespace = "SharpScss",
48 | DefaultOutputFilePath = "/LibSass.generated.cs",
49 | DefaultDllImportNameAndArguments = "LibSassDll",
50 | GenerateAsInternal = true,
51 | DispatchOutputPerInclude = false,
52 | DefaultMarshalForString = new CSharpMarshalAttribute(CSharpUnmanagedKind.CustomMarshaler) { MarshalTypeRef = "typeof(UTF8MarshallerNoFree)" },
53 |
54 | MappingRules =
55 | {
56 | // Change Sass_Value to be a struct instead of an union
57 | e => e.Map( "Sass_Value").CppAction((converter, element) => ((CppClass)element).ClassKind = CppClassKind.Struct),
58 | e => e.Map("sass_make_import_entry::source").Type("const char*"),
59 | e => e.Map("sass_make_import_entry::srcmap").Type("const char*"),
60 | e => e.Map("sass_make_import::source").Type("const char*"),
61 | e => e.Map("sass_make_import::srcmap").Type("const char*"),
62 | e => e.Map("sass_make_data_context::source_string").Type("const char*"),
63 |
64 | e => e.Map("libsass_version").MarshalAs(marshalNoFreeNative),
65 | e => e.Map("libsass_language_version").MarshalAs(marshalNoFreeNative),
66 | e => e.Map("sass_context_get_output_string").MarshalAs(marshalNoFreeNative),
67 | e => e.Map("sass_context_get_source_map_string").MarshalAs(marshalNoFreeNative),
68 | }
69 | };
70 | csOptions.IncludeFolders.Add(srcFolder);
71 | var files = new List()
72 | {
73 | Path.Combine(srcFolder, "sass.h"),
74 | };
75 |
76 | var csCompilation = CSharpConverter.Convert(files, csOptions);
77 |
78 | if (csCompilation.HasErrors)
79 | {
80 | foreach (var message in csCompilation.Diagnostics.Messages)
81 | {
82 | Console.Error.WriteLine(message);
83 | }
84 | Console.Error.WriteLine("Unexpected parsing errors");
85 | Environment.Exit(1);
86 | }
87 |
88 |
89 | var libClass = (CSharpClass) ((CSharpNamespace) ((CSharpGeneratedFile) csCompilation.Members[0]).Members.First(x => x is CSharpNamespace)).Members.FirstOrDefault(x => x is CSharpClass);
90 |
91 | var member = libClass.Members.OfType().FirstOrDefault(x => x.Name == "SASS2SCSS_FIND_WHITESPACE");
92 | if (member != null)
93 | {
94 | libClass.Members.Remove(member);
95 | }
96 |
97 | var fs = new PhysicalFileSystem();
98 |
99 | {
100 | var subfs = new SubFileSystem(fs, fs.ConvertPathFromInternal(destFolder));
101 | var codeWriter = new CodeWriter(new CodeWriterOptions(subfs));
102 | csCompilation.DumpTo(codeWriter);
103 | }
104 | }
105 | }
106 | }
107 |
--------------------------------------------------------------------------------
/src/SharpScss.Tests/SharpScss.Tests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net8.0
4 | false
5 |
6 |
7 |
8 |
9 | PreserveNewest
10 |
11 |
12 | PreserveNewest
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 | runtimes\%(RecursiveDir)%(FileName)%(Extension)
27 | Always
28 | False
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/src/SharpScss.Tests/TestScss.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Alexandre Mutel. All rights reserved.
2 | // This file is licensed under the BSD-Clause 2 license.
3 | // See the license.txt file in the project root for more information.
4 |
5 | using System;
6 | using System.Collections.Generic;
7 | using System.IO;
8 | using System.Runtime.InteropServices;
9 | using Microsoft.VisualStudio.TestTools.UnitTesting;
10 |
11 |
12 | namespace SharpScss.Tests;
13 |
14 | ///
15 | /// Basic test for and .
16 | ///
17 | [TestClass]
18 | public class TestScss
19 | {
20 | public TestScss()
21 | {
22 | // Custom loading of native library
23 | //string arch;
24 | //switch (System.Runtime.InteropServices.RuntimeInformation.ProcessArchitecture)
25 | //{
26 | // case Architecture.X64:
27 | // arch = "x64";
28 | // break;
29 | // case Architecture.X86:
30 | // arch = "x86";
31 | // break;
32 | // case Architecture.Arm:
33 | // arch = "arm";
34 | // break;
35 | // case Architecture.Arm64:
36 | // arch = "arm64";
37 | // break;
38 | // default:
39 | // throw new ArgumentOutOfRangeException();
40 | //}
41 |
42 | var test = RuntimeInformation.RuntimeIdentifier;
43 |
44 | string rid = RuntimeInformation.RuntimeIdentifier;
45 | string sharedObjectPostExtension;
46 | if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
47 | {
48 | //rid = $"win-{arch}";
49 | sharedObjectPostExtension = "dll";
50 | }
51 | else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
52 | {
53 | //rid = $"linux-{arch}";
54 | sharedObjectPostExtension = "so";
55 | }
56 | else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
57 | {
58 | //rid = $"osx-{arch}";
59 | sharedObjectPostExtension = "dylib";
60 | }
61 | else
62 | {
63 | throw new PlatformNotSupportedException();
64 | }
65 |
66 | var fullPath = Path.Combine(AppContext.BaseDirectory, "runtimes", rid, "native", $"libsass.{sharedObjectPostExtension}");
67 | var libraryPointer = NativeLibrary.Load(fullPath);
68 | Assert.AreNotEqual(nint.Zero, libraryPointer, $"Unable to load library {fullPath}");
69 | }
70 |
71 | [TestMethod]
72 | public void TestVersion()
73 | {
74 | var version = Scss.Version;
75 | StringAssert.StartsWith("3.6.6", version);
76 | }
77 |
78 | [TestMethod]
79 | public void TestConvertToCss()
80 | {
81 | var result = Scss.ConvertToCss(@"div {color: #FFF;}");
82 | Assert.IsNotNull(result.Css);
83 | Assert.IsNull(result.SourceMap);
84 | Assert.IsNull(result.IncludedFiles);
85 | var css = result.Css.Replace("\n","").Replace(" ", "").Trim();
86 | Assert.AreEqual("div{color:#FFF;}", css);
87 | }
88 |
89 | [TestMethod]
90 | public void TestConvertToCssMemory()
91 | {
92 | Scss.ConvertToCss(@"div {color: #FFF;}");
93 | var start = GC.GetTotalMemory(true);
94 | for (int i = 0; i < 10000; i++)
95 | {
96 | Scss.ConvertToCss(@"div {color: #FFF;}");
97 | }
98 | GC.Collect();
99 | GC.WaitForFullGCComplete();
100 | var end = GC.GetTotalMemory(true);
101 | Console.WriteLine($"Total allocated: {end - start} bytes");
102 | }
103 |
104 | [TestMethod]
105 | public void TestConvertToCssCompressed()
106 | {
107 | var result = Scss.ConvertToCss(@"div {color: #FFF;}", new ScssOptions() { OutputStyle = ScssOutputStyle.Compressed});
108 | Assert.IsNotNull(result.Css);
109 | Assert.IsNull(result.SourceMap);
110 | Assert.IsNull(result.IncludedFiles);
111 | var css = result.Css.Trim();
112 | Assert.AreEqual("div{color:#FFF}", css);
113 | }
114 |
115 | [TestMethod]
116 | public void TestConvertToCssAndSourceMap()
117 | {
118 | var result = Scss.ConvertToCss(@"div {color: #FFF;}", new ScssOptions()
119 | {
120 | InputFile = "Test.scss",
121 | OutputFile = "Test.css",
122 | GenerateSourceMap = true
123 | });
124 | Assert.IsNotNull(result.Css);
125 | Assert.IsNotNull(result.SourceMap);
126 | Assert.IsNull(result.IncludedFiles);
127 | var css = result.Css.Replace("\n", "").Replace(" ", "").Trim();
128 | Assert.AreEqual("div{color:#FFF;}/*#sourceMappingURL=Test.css.map*/", css);
129 | }
130 |
131 | [TestMethod]
132 | public void TestConvertToCssWithTryImport()
133 | {
134 | var result = Scss.ConvertToCss(@"@import ""foo"";", new ScssOptions()
135 | {
136 | OutputStyle = ScssOutputStyle.Compressed,
137 | InputFile = "test.scss",
138 | TryImport = (ref string file, string path, out string scss, out string map) =>
139 | {
140 | Assert.AreEqual("foo", file);
141 | Assert.AreEqual(Path.Combine(Environment.CurrentDirectory, "test.scss"), new FileInfo(path).FullName);
142 | scss = "div {color: #FFF;}";
143 | map = null;
144 | return true;
145 | }
146 | });
147 | Assert.IsNotNull(result.Css);
148 | Assert.IsNull(result.SourceMap);
149 | Assert.IsNotNull(result.IncludedFiles);
150 | Assert.AreEqual(1, result.IncludedFiles.Count);
151 | Assert.AreEqual("foo", result.IncludedFiles[0]);
152 | var css = result.Css.Trim();
153 | Assert.AreEqual("div{color:#FFF}", css);
154 | }
155 |
156 | [TestMethod]
157 | public void TestConvertFileToCssWithIncludes()
158 | {
159 | var result = Scss.ConvertFileToCss(Path.Combine("files", "test.scss"), new ScssOptions()
160 | {
161 | OutputStyle = ScssOutputStyle.Compressed,
162 | IncludePaths =
163 | {
164 | Path.Combine("files", "subfolder")
165 | }
166 | });
167 | Assert.IsNotNull(result.Css);
168 | Assert.IsNull(result.SourceMap);
169 | Assert.IsNotNull(result.IncludedFiles);
170 | Assert.AreEqual(2, result.IncludedFiles.Count);
171 | Assert.AreEqual(Path.Combine(Environment.CurrentDirectory, "files", "test.scss"), new FileInfo(result.IncludedFiles[0]).FullName);
172 | Assert.AreEqual(Path.Combine(Environment.CurrentDirectory, "files", "subfolder", "foo.scss"), new FileInfo(result.IncludedFiles[1]).FullName);
173 | var css = result.Css.Trim();
174 | Assert.AreEqual("div{color:#FFF}", css);
175 | }
176 |
177 | [TestMethod]
178 | public void TestParsingException()
179 | {
180 | var exception = Assert.ThrowsException(() => Scss.ConvertToCss(@"div {"));
181 | Assert.AreEqual(5, exception.Column);
182 | Assert.AreEqual(1, exception.Line);
183 | Assert.IsTrue(exception.ErrorText.Contains("expected"));
184 | }
185 |
186 | [TestMethod]
187 | public void TestExceptionWithTryImport()
188 | {
189 | var exception = Assert.ThrowsException(() => Scss.ConvertToCss(@"@import ""foo"";", new ScssOptions()
190 | {
191 | InputFile = "test.scss",
192 | TryImport = (ref string file, string path, out string scss, out string map) =>
193 | {
194 | scss = null;
195 | map = null;
196 | return false;
197 | }
198 | }));
199 | Assert.AreEqual(1, exception.Line);
200 | Assert.AreEqual(9, exception.Column);
201 | Assert.IsTrue(exception.ErrorText.StartsWith("Unable to find include file for @import"));
202 | }
203 |
204 |
205 | [TestMethod]
206 | public void TestTryImportFromMemory()
207 | {
208 | var collectPaths = new List();
209 | var result = Scss.ConvertToCss(@"@import ""foo"";", new ScssOptions()
210 | {
211 | InputFile = "/test.scss",
212 | OutputStyle = ScssOutputStyle.Compressed,
213 | TryImport = (ref string file, string path, out string scss, out string map) =>
214 | {
215 | collectPaths.Add(path);
216 | if (file == "foo")
217 | {
218 | file = "/this/is/a/sub/folder/" + file + ".scss";
219 | scss = "@import 'local/bar';";
220 | }
221 | else
222 | {
223 | file = "/this/is/a/sub/folder/" + file + ".css";
224 | scss = ".foo { color: red; }";
225 | }
226 | map = null;
227 | return true;
228 | }
229 | });
230 | Assert.AreEqual(".foo{color:red}", result.Css.TrimEnd());
231 |
232 | Assert.AreEqual(2, collectPaths.Count);
233 | Assert.AreEqual("/test.scss", collectPaths[0]);
234 | Assert.AreEqual("/this/is/a/sub/folder/foo.scss", collectPaths[1]);
235 |
236 | Assert.AreEqual(2, result.IncludedFiles.Count);
237 | Assert.AreEqual("/this/is/a/sub/folder/foo.scss", result.IncludedFiles[0]);
238 | Assert.AreEqual("/this/is/a/sub/folder/local/bar.css", result.IncludedFiles[1]);
239 | }
240 | }
--------------------------------------------------------------------------------
/src/SharpScss.Tests/files/subfolder/foo.scss:
--------------------------------------------------------------------------------
1 | // This file is included by ..\test.scss
2 | div {
3 | color: #FFF;
4 | }
--------------------------------------------------------------------------------
/src/SharpScss.Tests/files/test.scss:
--------------------------------------------------------------------------------
1 | // This is a test file
2 | @import "foo";
3 |
--------------------------------------------------------------------------------
/src/SharpScss.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.11.35222.181
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{061866E2-005C-4D13-A338-EA464BBEC60F}"
7 | ProjectSection(SolutionItems) = preProject
8 | ..\libsass\.github\workflows\build_libsass.yml = ..\libsass\.github\workflows\build_libsass.yml
9 | ..\changelog.md = ..\changelog.md
10 | ..\.github\workflows\ci.yml = ..\.github\workflows\ci.yml
11 | Directory.Packages.props = Directory.Packages.props
12 | dotnet-releaser.toml = dotnet-releaser.toml
13 | global.json = global.json
14 | ..\license.txt = ..\license.txt
15 | ..\readme.md = ..\readme.md
16 | EndProjectSection
17 | EndProject
18 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SharpScss", "SharpScss\SharpScss.csproj", "{2FD6B6F5-89E4-4D15-B7F9-19327640225D}"
19 | EndProject
20 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SharpScss.Tests", "SharpScss.Tests\SharpScss.Tests.csproj", "{8AD83F92-2E0C-4C60-B2A4-83C7BCDF099E}"
21 | EndProject
22 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LibSassGen", "LibSassGen\LibSassGen.csproj", "{C4A1E522-4883-4E70-A822-DC877DEA2D82}"
23 | EndProject
24 | Global
25 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
26 | Debug|Any CPU = Debug|Any CPU
27 | Release|Any CPU = Release|Any CPU
28 | EndGlobalSection
29 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
30 | {2FD6B6F5-89E4-4D15-B7F9-19327640225D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
31 | {2FD6B6F5-89E4-4D15-B7F9-19327640225D}.Debug|Any CPU.Build.0 = Debug|Any CPU
32 | {2FD6B6F5-89E4-4D15-B7F9-19327640225D}.Release|Any CPU.ActiveCfg = Release|Any CPU
33 | {2FD6B6F5-89E4-4D15-B7F9-19327640225D}.Release|Any CPU.Build.0 = Release|Any CPU
34 | {8AD83F92-2E0C-4C60-B2A4-83C7BCDF099E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
35 | {8AD83F92-2E0C-4C60-B2A4-83C7BCDF099E}.Debug|Any CPU.Build.0 = Debug|Any CPU
36 | {8AD83F92-2E0C-4C60-B2A4-83C7BCDF099E}.Release|Any CPU.ActiveCfg = Release|Any CPU
37 | {8AD83F92-2E0C-4C60-B2A4-83C7BCDF099E}.Release|Any CPU.Build.0 = Release|Any CPU
38 | {C4A1E522-4883-4E70-A822-DC877DEA2D82}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
39 | {C4A1E522-4883-4E70-A822-DC877DEA2D82}.Debug|Any CPU.Build.0 = Debug|Any CPU
40 | {C4A1E522-4883-4E70-A822-DC877DEA2D82}.Release|Any CPU.ActiveCfg = Release|Any CPU
41 | {C4A1E522-4883-4E70-A822-DC877DEA2D82}.Release|Any CPU.Build.0 = Release|Any CPU
42 | EndGlobalSection
43 | GlobalSection(SolutionProperties) = preSolution
44 | HideSolutionNode = FALSE
45 | EndGlobalSection
46 | GlobalSection(ExtensibilityGlobals) = postSolution
47 | SolutionGuid = {E447DB53-0DA7-4320-8F60-A772E03736F6}
48 | EndGlobalSection
49 | EndGlobal
50 |
--------------------------------------------------------------------------------
/src/SharpScss.sln.DotSettings:
--------------------------------------------------------------------------------
1 |
2 | Copyright (c) Alexandre Mutel. All rights reserved.
3 | This file is licensed under the BSD-Clause 2 license.
4 | See the license.txt file in the project root for more information.
5 | True
--------------------------------------------------------------------------------
/src/SharpScss/LibSass.Generated.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | //
5 | // Changes to this file may cause incorrect behavior and will be lost if
6 | // the code is regenerated.
7 | //
8 | //------------------------------------------------------------------------------
9 | using System;
10 |
11 | #pragma warning disable CS8981
12 |
13 | namespace SharpScss
14 | {
15 | using System.Runtime.InteropServices;
16 |
17 | internal static partial class LibSass
18 | {
19 | ///
20 | /// Different render styles
21 | ///
22 | public enum Sass_Output_Style : int
23 | {
24 | SASS_STYLE_NESTED,
25 |
26 | SASS_STYLE_EXPANDED,
27 |
28 | SASS_STYLE_COMPACT,
29 |
30 | SASS_STYLE_COMPRESSED,
31 |
32 | ///
33 | /// only used internaly
34 | ///
35 | SASS_STYLE_INSPECT,
36 |
37 | ///
38 | /// only used internaly
39 | ///
40 | SASS_STYLE_TO_SASS,
41 |
42 | ///
43 | /// only used internaly
44 | ///
45 | SASS_STYLE_TO_CSS,
46 | }
47 |
48 | public const LibSass.Sass_Output_Style SASS_STYLE_NESTED = Sass_Output_Style.SASS_STYLE_NESTED;
49 |
50 | public const LibSass.Sass_Output_Style SASS_STYLE_EXPANDED = Sass_Output_Style.SASS_STYLE_EXPANDED;
51 |
52 | public const LibSass.Sass_Output_Style SASS_STYLE_COMPACT = Sass_Output_Style.SASS_STYLE_COMPACT;
53 |
54 | public const LibSass.Sass_Output_Style SASS_STYLE_COMPRESSED = Sass_Output_Style.SASS_STYLE_COMPRESSED;
55 |
56 | ///
57 | /// only used internaly
58 | ///
59 | public const LibSass.Sass_Output_Style SASS_STYLE_INSPECT = Sass_Output_Style.SASS_STYLE_INSPECT;
60 |
61 | ///
62 | /// only used internaly
63 | ///
64 | public const LibSass.Sass_Output_Style SASS_STYLE_TO_SASS = Sass_Output_Style.SASS_STYLE_TO_SASS;
65 |
66 | ///
67 | /// only used internaly
68 | ///
69 | public const LibSass.Sass_Output_Style SASS_STYLE_TO_CSS = Sass_Output_Style.SASS_STYLE_TO_CSS;
70 |
71 | ///
72 | /// Type for Sass values
73 | ///
74 | public enum Sass_Tag : int
75 | {
76 | SASS_BOOLEAN,
77 |
78 | SASS_NUMBER,
79 |
80 | SASS_COLOR,
81 |
82 | SASS_STRING,
83 |
84 | SASS_LIST,
85 |
86 | SASS_MAP,
87 |
88 | SASS_NULL,
89 |
90 | SASS_ERROR,
91 |
92 | SASS_WARNING,
93 | }
94 |
95 | public const LibSass.Sass_Tag SASS_BOOLEAN = Sass_Tag.SASS_BOOLEAN;
96 |
97 | public const LibSass.Sass_Tag SASS_NUMBER = Sass_Tag.SASS_NUMBER;
98 |
99 | public const LibSass.Sass_Tag SASS_COLOR = Sass_Tag.SASS_COLOR;
100 |
101 | public const LibSass.Sass_Tag SASS_STRING = Sass_Tag.SASS_STRING;
102 |
103 | public const LibSass.Sass_Tag SASS_LIST = Sass_Tag.SASS_LIST;
104 |
105 | public const LibSass.Sass_Tag SASS_MAP = Sass_Tag.SASS_MAP;
106 |
107 | public const LibSass.Sass_Tag SASS_NULL = Sass_Tag.SASS_NULL;
108 |
109 | public const LibSass.Sass_Tag SASS_ERROR = Sass_Tag.SASS_ERROR;
110 |
111 | public const LibSass.Sass_Tag SASS_WARNING = Sass_Tag.SASS_WARNING;
112 |
113 | ///
114 | /// Tags for denoting Sass list separators
115 | ///
116 | public enum Sass_Separator : int
117 | {
118 | SASS_COMMA,
119 |
120 | SASS_SPACE,
121 |
122 | ///
123 | /// only used internally to represent a hash map before evaluation
124 | /// otherwise we would be too early to check for duplicate keys
125 | ///
126 | SASS_HASH,
127 | }
128 |
129 | public const LibSass.Sass_Separator SASS_COMMA = Sass_Separator.SASS_COMMA;
130 |
131 | public const LibSass.Sass_Separator SASS_SPACE = Sass_Separator.SASS_SPACE;
132 |
133 | ///
134 | /// only used internally to represent a hash map before evaluation
135 | /// otherwise we would be too early to check for duplicate keys
136 | ///
137 | public const LibSass.Sass_Separator SASS_HASH = Sass_Separator.SASS_HASH;
138 |
139 | ///
140 | /// Value Operators
141 | ///
142 | public enum Sass_OP : int
143 | {
144 | ///
145 | /// logical connectives
146 | ///
147 | AND,
148 |
149 | ///
150 | /// logical connectives
151 | ///
152 | OR,
153 |
154 | ///
155 | /// arithmetic relations
156 | ///
157 | EQ,
158 |
159 | ///
160 | /// arithmetic relations
161 | ///
162 | NEQ,
163 |
164 | ///
165 | /// arithmetic relations
166 | ///
167 | GT,
168 |
169 | ///
170 | /// arithmetic relations
171 | ///
172 | GTE,
173 |
174 | ///
175 | /// arithmetic relations
176 | ///
177 | LT,
178 |
179 | ///
180 | /// arithmetic relations
181 | ///
182 | LTE,
183 |
184 | ///
185 | /// arithmetic functions
186 | ///
187 | ADD,
188 |
189 | ///
190 | /// arithmetic functions
191 | ///
192 | SUB,
193 |
194 | ///
195 | /// arithmetic functions
196 | ///
197 | MUL,
198 |
199 | ///
200 | /// arithmetic functions
201 | ///
202 | DIV,
203 |
204 | ///
205 | /// arithmetic functions
206 | ///
207 | MOD,
208 |
209 | ///
210 | /// so we know how big to make the op table
211 | ///
212 | NUM_OPS,
213 | }
214 |
215 | ///
216 | /// logical connectives
217 | ///
218 | public const LibSass.Sass_OP AND = Sass_OP.AND;
219 |
220 | ///
221 | /// logical connectives
222 | ///
223 | public const LibSass.Sass_OP OR = Sass_OP.OR;
224 |
225 | ///
226 | /// arithmetic relations
227 | ///
228 | public const LibSass.Sass_OP EQ = Sass_OP.EQ;
229 |
230 | ///
231 | /// arithmetic relations
232 | ///
233 | public const LibSass.Sass_OP NEQ = Sass_OP.NEQ;
234 |
235 | ///
236 | /// arithmetic relations
237 | ///
238 | public const LibSass.Sass_OP GT = Sass_OP.GT;
239 |
240 | ///
241 | /// arithmetic relations
242 | ///
243 | public const LibSass.Sass_OP GTE = Sass_OP.GTE;
244 |
245 | ///
246 | /// arithmetic relations
247 | ///
248 | public const LibSass.Sass_OP LT = Sass_OP.LT;
249 |
250 | ///
251 | /// arithmetic relations
252 | ///
253 | public const LibSass.Sass_OP LTE = Sass_OP.LTE;
254 |
255 | ///
256 | /// arithmetic functions
257 | ///
258 | public const LibSass.Sass_OP ADD = Sass_OP.ADD;
259 |
260 | ///
261 | /// arithmetic functions
262 | ///
263 | public const LibSass.Sass_OP SUB = Sass_OP.SUB;
264 |
265 | ///
266 | /// arithmetic functions
267 | ///
268 | public const LibSass.Sass_OP MUL = Sass_OP.MUL;
269 |
270 | ///
271 | /// arithmetic functions
272 | ///
273 | public const LibSass.Sass_OP DIV = Sass_OP.DIV;
274 |
275 | ///
276 | /// arithmetic functions
277 | ///
278 | public const LibSass.Sass_OP MOD = Sass_OP.MOD;
279 |
280 | ///
281 | /// so we know how big to make the op table
282 | ///
283 | public const LibSass.Sass_OP NUM_OPS = Sass_OP.NUM_OPS;
284 |
285 | ///
286 | /// Type of function calls
287 | ///
288 | public enum Sass_Callee_Type : int
289 | {
290 | SASS_CALLEE_MIXIN,
291 |
292 | SASS_CALLEE_FUNCTION,
293 |
294 | SASS_CALLEE_C_FUNCTION,
295 | }
296 |
297 | public const LibSass.Sass_Callee_Type SASS_CALLEE_MIXIN = Sass_Callee_Type.SASS_CALLEE_MIXIN;
298 |
299 | public const LibSass.Sass_Callee_Type SASS_CALLEE_FUNCTION = Sass_Callee_Type.SASS_CALLEE_FUNCTION;
300 |
301 | public const LibSass.Sass_Callee_Type SASS_CALLEE_C_FUNCTION = Sass_Callee_Type.SASS_CALLEE_C_FUNCTION;
302 |
303 | ///
304 | /// Compiler states
305 | ///
306 | public enum Sass_Compiler_State : int
307 | {
308 | SASS_COMPILER_CREATED,
309 |
310 | SASS_COMPILER_PARSED,
311 |
312 | SASS_COMPILER_EXECUTED,
313 | }
314 |
315 | public const LibSass.Sass_Compiler_State SASS_COMPILER_CREATED = Sass_Compiler_State.SASS_COMPILER_CREATED;
316 |
317 | public const LibSass.Sass_Compiler_State SASS_COMPILER_PARSED = Sass_Compiler_State.SASS_COMPILER_PARSED;
318 |
319 | public const LibSass.Sass_Compiler_State SASS_COMPILER_EXECUTED = Sass_Compiler_State.SASS_COMPILER_EXECUTED;
320 |
321 | ///
322 | /// Forward declaration
323 | ///
324 | [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
325 | public readonly partial struct Sass_Value : IEquatable
326 | {
327 | private readonly IntPtr _handle;
328 |
329 | public Sass_Value(IntPtr handle) => _handle = handle;
330 |
331 | public IntPtr Handle => _handle;
332 |
333 | public bool Equals(Sass_Value other) => _handle.Equals(other._handle);
334 |
335 | public override bool Equals(object obj) => obj is Sass_Value other && Equals(other);
336 |
337 | public override int GetHashCode() => _handle.GetHashCode();
338 |
339 | public override string ToString() => "0x" + (IntPtr.Size == 8 ? _handle.ToString("X16") : _handle.ToString("X8"));
340 |
341 | public static bool operator ==(Sass_Value left, Sass_Value right) => left.Equals(right);
342 |
343 | public static bool operator !=(Sass_Value left, Sass_Value right) => !left.Equals(right);
344 | }
345 |
346 | ///
347 | /// Forward declaration
348 | ///
349 | [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
350 | public readonly partial struct Sass_Env : IEquatable
351 | {
352 | private readonly IntPtr _handle;
353 |
354 | public Sass_Env(IntPtr handle) => _handle = handle;
355 |
356 | public IntPtr Handle => _handle;
357 |
358 | public bool Equals(Sass_Env other) => _handle.Equals(other._handle);
359 |
360 | public override bool Equals(object obj) => obj is Sass_Env other && Equals(other);
361 |
362 | public override int GetHashCode() => _handle.GetHashCode();
363 |
364 | public override string ToString() => "0x" + (IntPtr.Size == 8 ? _handle.ToString("X16") : _handle.ToString("X8"));
365 |
366 | public static bool operator ==(Sass_Env left, Sass_Env right) => left.Equals(right);
367 |
368 | public static bool operator !=(Sass_Env left, Sass_Env right) => !left.Equals(right);
369 | }
370 |
371 | [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
372 | public readonly partial struct Sass_Callee : IEquatable
373 | {
374 | private readonly IntPtr _handle;
375 |
376 | public Sass_Callee(IntPtr handle) => _handle = handle;
377 |
378 | public IntPtr Handle => _handle;
379 |
380 | public bool Equals(Sass_Callee other) => _handle.Equals(other._handle);
381 |
382 | public override bool Equals(object obj) => obj is Sass_Callee other && Equals(other);
383 |
384 | public override int GetHashCode() => _handle.GetHashCode();
385 |
386 | public override string ToString() => "0x" + (IntPtr.Size == 8 ? _handle.ToString("X16") : _handle.ToString("X8"));
387 |
388 | public static bool operator ==(Sass_Callee left, Sass_Callee right) => left.Equals(right);
389 |
390 | public static bool operator !=(Sass_Callee left, Sass_Callee right) => !left.Equals(right);
391 | }
392 |
393 | [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
394 | public readonly partial struct Sass_Import : IEquatable
395 | {
396 | private readonly IntPtr _handle;
397 |
398 | public Sass_Import(IntPtr handle) => _handle = handle;
399 |
400 | public IntPtr Handle => _handle;
401 |
402 | public bool Equals(Sass_Import other) => _handle.Equals(other._handle);
403 |
404 | public override bool Equals(object obj) => obj is Sass_Import other && Equals(other);
405 |
406 | public override int GetHashCode() => _handle.GetHashCode();
407 |
408 | public override string ToString() => "0x" + (IntPtr.Size == 8 ? _handle.ToString("X16") : _handle.ToString("X8"));
409 |
410 | public static bool operator ==(Sass_Import left, Sass_Import right) => left.Equals(right);
411 |
412 | public static bool operator !=(Sass_Import left, Sass_Import right) => !left.Equals(right);
413 | }
414 |
415 | ///
416 | /// Forward declaration
417 | ///
418 | [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
419 | public readonly partial struct Sass_Options : IEquatable
420 | {
421 | private readonly IntPtr _handle;
422 |
423 | public Sass_Options(IntPtr handle) => _handle = handle;
424 |
425 | public IntPtr Handle => _handle;
426 |
427 | public bool Equals(Sass_Options other) => _handle.Equals(other._handle);
428 |
429 | public override bool Equals(object obj) => obj is Sass_Options other && Equals(other);
430 |
431 | public override int GetHashCode() => _handle.GetHashCode();
432 |
433 | public override string ToString() => "0x" + (IntPtr.Size == 8 ? _handle.ToString("X16") : _handle.ToString("X8"));
434 |
435 | public static bool operator ==(Sass_Options left, Sass_Options right) => left.Equals(right);
436 |
437 | public static bool operator !=(Sass_Options left, Sass_Options right) => !left.Equals(right);
438 | }
439 |
440 | ///
441 | /// Forward declaration
442 | ///
443 | [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
444 | public readonly partial struct Sass_Compiler : IEquatable
445 | {
446 | private readonly IntPtr _handle;
447 |
448 | public Sass_Compiler(IntPtr handle) => _handle = handle;
449 |
450 | public IntPtr Handle => _handle;
451 |
452 | public bool Equals(Sass_Compiler other) => _handle.Equals(other._handle);
453 |
454 | public override bool Equals(object obj) => obj is Sass_Compiler other && Equals(other);
455 |
456 | public override int GetHashCode() => _handle.GetHashCode();
457 |
458 | public override string ToString() => "0x" + (IntPtr.Size == 8 ? _handle.ToString("X16") : _handle.ToString("X8"));
459 |
460 | public static bool operator ==(Sass_Compiler left, Sass_Compiler right) => left.Equals(right);
461 |
462 | public static bool operator !=(Sass_Compiler left, Sass_Compiler right) => !left.Equals(right);
463 | }
464 |
465 | [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
466 | public readonly partial struct Sass_Importer : IEquatable
467 | {
468 | private readonly IntPtr _handle;
469 |
470 | public Sass_Importer(IntPtr handle) => _handle = handle;
471 |
472 | public IntPtr Handle => _handle;
473 |
474 | public bool Equals(Sass_Importer other) => _handle.Equals(other._handle);
475 |
476 | public override bool Equals(object obj) => obj is Sass_Importer other && Equals(other);
477 |
478 | public override int GetHashCode() => _handle.GetHashCode();
479 |
480 | public override string ToString() => "0x" + (IntPtr.Size == 8 ? _handle.ToString("X16") : _handle.ToString("X8"));
481 |
482 | public static bool operator ==(Sass_Importer left, Sass_Importer right) => left.Equals(right);
483 |
484 | public static bool operator !=(Sass_Importer left, Sass_Importer right) => !left.Equals(right);
485 | }
486 |
487 | [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
488 | public readonly partial struct Sass_Function : IEquatable
489 | {
490 | private readonly IntPtr _handle;
491 |
492 | public Sass_Function(IntPtr handle) => _handle = handle;
493 |
494 | public IntPtr Handle => _handle;
495 |
496 | public bool Equals(Sass_Function other) => _handle.Equals(other._handle);
497 |
498 | public override bool Equals(object obj) => obj is Sass_Function other && Equals(other);
499 |
500 | public override int GetHashCode() => _handle.GetHashCode();
501 |
502 | public override string ToString() => "0x" + (IntPtr.Size == 8 ? _handle.ToString("X16") : _handle.ToString("X8"));
503 |
504 | public static bool operator ==(Sass_Function left, Sass_Function right) => left.Equals(right);
505 |
506 | public static bool operator !=(Sass_Function left, Sass_Function right) => !left.Equals(right);
507 | }
508 |
509 | [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
510 | public readonly partial struct Sass_Context : IEquatable
511 | {
512 | private readonly IntPtr _handle;
513 |
514 | public Sass_Context(IntPtr handle) => _handle = handle;
515 |
516 | public IntPtr Handle => _handle;
517 |
518 | public bool Equals(Sass_Context other) => _handle.Equals(other._handle);
519 |
520 | public override bool Equals(object obj) => obj is Sass_Context other && Equals(other);
521 |
522 | public override int GetHashCode() => _handle.GetHashCode();
523 |
524 | public override string ToString() => "0x" + (IntPtr.Size == 8 ? _handle.ToString("X16") : _handle.ToString("X8"));
525 |
526 | public static bool operator ==(Sass_Context left, Sass_Context right) => left.Equals(right);
527 |
528 | public static bool operator !=(Sass_Context left, Sass_Context right) => !left.Equals(right);
529 | }
530 |
531 | [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
532 | public readonly partial struct Sass_File_Context : IEquatable
533 | {
534 | private readonly IntPtr _handle;
535 |
536 | public Sass_File_Context(IntPtr handle) => _handle = handle;
537 |
538 | public IntPtr Handle => _handle;
539 |
540 | public bool Equals(Sass_File_Context other) => _handle.Equals(other._handle);
541 |
542 | public override bool Equals(object obj) => obj is Sass_File_Context other && Equals(other);
543 |
544 | public override int GetHashCode() => _handle.GetHashCode();
545 |
546 | public override string ToString() => "0x" + (IntPtr.Size == 8 ? _handle.ToString("X16") : _handle.ToString("X8"));
547 |
548 | public static bool operator ==(Sass_File_Context left, Sass_File_Context right) => left.Equals(right);
549 |
550 | public static bool operator !=(Sass_File_Context left, Sass_File_Context right) => !left.Equals(right);
551 | }
552 |
553 | [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
554 | public readonly partial struct Sass_Data_Context : IEquatable
555 | {
556 | private readonly IntPtr _handle;
557 |
558 | public Sass_Data_Context(IntPtr handle) => _handle = handle;
559 |
560 | public IntPtr Handle => _handle;
561 |
562 | public bool Equals(Sass_Data_Context other) => _handle.Equals(other._handle);
563 |
564 | public override bool Equals(object obj) => obj is Sass_Data_Context other && Equals(other);
565 |
566 | public override int GetHashCode() => _handle.GetHashCode();
567 |
568 | public override string ToString() => "0x" + (IntPtr.Size == 8 ? _handle.ToString("X16") : _handle.ToString("X8"));
569 |
570 | public static bool operator ==(Sass_Data_Context left, Sass_Data_Context right) => left.Equals(right);
571 |
572 | public static bool operator !=(Sass_Data_Context left, Sass_Data_Context right) => !left.Equals(right);
573 | }
574 |
575 | ///
576 | /// Typedef helpers for callee lists
577 | ///
578 | [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
579 | public readonly partial struct Sass_Env_Frame : IEquatable
580 | {
581 | public Sass_Env_Frame(LibSass.Sass_Env value) => this.Value = value;
582 |
583 | public readonly LibSass.Sass_Env Value;
584 |
585 | public bool Equals(Sass_Env_Frame other) => Value.Equals(other.Value);
586 |
587 | public override bool Equals(object obj) => obj is Sass_Env_Frame other && Equals(other);
588 |
589 | public override int GetHashCode() => Value.GetHashCode();
590 |
591 | public override string ToString() => Value.ToString();
592 |
593 | public static implicit operator LibSass.Sass_Env(Sass_Env_Frame from) => from.Value;
594 |
595 | public static implicit operator Sass_Env_Frame(LibSass.Sass_Env from) => new Sass_Env_Frame(from);
596 |
597 | public static bool operator ==(Sass_Env_Frame left, Sass_Env_Frame right) => left.Equals(right);
598 |
599 | public static bool operator !=(Sass_Env_Frame left, Sass_Env_Frame right) => !left.Equals(right);
600 | }
601 |
602 | ///
603 | /// Typedef helpers for callee lists
604 | ///
605 | [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
606 | public readonly partial struct Sass_Callee_Entry : IEquatable
607 | {
608 | public Sass_Callee_Entry(LibSass.Sass_Callee value) => this.Value = value;
609 |
610 | public readonly LibSass.Sass_Callee Value;
611 |
612 | public bool Equals(Sass_Callee_Entry other) => Value.Equals(other.Value);
613 |
614 | public override bool Equals(object obj) => obj is Sass_Callee_Entry other && Equals(other);
615 |
616 | public override int GetHashCode() => Value.GetHashCode();
617 |
618 | public override string ToString() => Value.ToString();
619 |
620 | public static implicit operator LibSass.Sass_Callee(Sass_Callee_Entry from) => from.Value;
621 |
622 | public static implicit operator Sass_Callee_Entry(LibSass.Sass_Callee from) => new Sass_Callee_Entry(from);
623 |
624 | public static bool operator ==(Sass_Callee_Entry left, Sass_Callee_Entry right) => left.Equals(right);
625 |
626 | public static bool operator !=(Sass_Callee_Entry left, Sass_Callee_Entry right) => !left.Equals(right);
627 | }
628 |
629 | ///
630 | /// Typedef helpers for import lists
631 | ///
632 | [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
633 | public readonly partial struct Sass_Import_Entry : IEquatable
634 | {
635 | public Sass_Import_Entry(LibSass.Sass_Import value) => this.Value = value;
636 |
637 | public readonly LibSass.Sass_Import Value;
638 |
639 | public bool Equals(Sass_Import_Entry other) => Value.Equals(other.Value);
640 |
641 | public override bool Equals(object obj) => obj is Sass_Import_Entry other && Equals(other);
642 |
643 | public override int GetHashCode() => Value.GetHashCode();
644 |
645 | public override string ToString() => Value.ToString();
646 |
647 | public static implicit operator LibSass.Sass_Import(Sass_Import_Entry from) => from.Value;
648 |
649 | public static implicit operator Sass_Import_Entry(LibSass.Sass_Import from) => new Sass_Import_Entry(from);
650 |
651 | public static bool operator ==(Sass_Import_Entry left, Sass_Import_Entry right) => left.Equals(right);
652 |
653 | public static bool operator !=(Sass_Import_Entry left, Sass_Import_Entry right) => !left.Equals(right);
654 | }
655 |
656 | [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
657 | public readonly partial struct Sass_Import_List : IEquatable
658 | {
659 | public Sass_Import_List(IntPtr value) => this.Value = value;
660 |
661 | public readonly IntPtr Value;
662 |
663 | public bool Equals(Sass_Import_List other) => Value.Equals(other.Value);
664 |
665 | public override bool Equals(object obj) => obj is Sass_Import_List other && Equals(other);
666 |
667 | public override int GetHashCode() => Value.GetHashCode();
668 |
669 | public override string ToString() => Value.ToString();
670 |
671 | public static implicit operator IntPtr(Sass_Import_List from) => from.Value;
672 |
673 | public static implicit operator Sass_Import_List(IntPtr from) => new Sass_Import_List(from);
674 |
675 | public static bool operator ==(Sass_Import_List left, Sass_Import_List right) => left.Equals(right);
676 |
677 | public static bool operator !=(Sass_Import_List left, Sass_Import_List right) => !left.Equals(right);
678 | }
679 |
680 | ///
681 | /// Typedef helpers for custom importer lists
682 | ///
683 | [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
684 | public readonly partial struct Sass_Importer_Entry : IEquatable
685 | {
686 | public Sass_Importer_Entry(LibSass.Sass_Importer value) => this.Value = value;
687 |
688 | public readonly LibSass.Sass_Importer Value;
689 |
690 | public bool Equals(Sass_Importer_Entry other) => Value.Equals(other.Value);
691 |
692 | public override bool Equals(object obj) => obj is Sass_Importer_Entry other && Equals(other);
693 |
694 | public override int GetHashCode() => Value.GetHashCode();
695 |
696 | public override string ToString() => Value.ToString();
697 |
698 | public static implicit operator LibSass.Sass_Importer(Sass_Importer_Entry from) => from.Value;
699 |
700 | public static implicit operator Sass_Importer_Entry(LibSass.Sass_Importer from) => new Sass_Importer_Entry(from);
701 |
702 | public static bool operator ==(Sass_Importer_Entry left, Sass_Importer_Entry right) => left.Equals(right);
703 |
704 | public static bool operator !=(Sass_Importer_Entry left, Sass_Importer_Entry right) => !left.Equals(right);
705 | }
706 |
707 | [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
708 | public readonly partial struct Sass_Importer_List : IEquatable
709 | {
710 | public Sass_Importer_List(IntPtr value) => this.Value = value;
711 |
712 | public readonly IntPtr Value;
713 |
714 | public bool Equals(Sass_Importer_List other) => Value.Equals(other.Value);
715 |
716 | public override bool Equals(object obj) => obj is Sass_Importer_List other && Equals(other);
717 |
718 | public override int GetHashCode() => Value.GetHashCode();
719 |
720 | public override string ToString() => Value.ToString();
721 |
722 | public static implicit operator IntPtr(Sass_Importer_List from) => from.Value;
723 |
724 | public static implicit operator Sass_Importer_List(IntPtr from) => new Sass_Importer_List(from);
725 |
726 | public static bool operator ==(Sass_Importer_List left, Sass_Importer_List right) => left.Equals(right);
727 |
728 | public static bool operator !=(Sass_Importer_List left, Sass_Importer_List right) => !left.Equals(right);
729 | }
730 |
731 | [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
732 | public delegate LibSass.Sass_Import_List Sass_Importer_Fn([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8MarshallerNoFree))] string url, LibSass.Sass_Importer_Entry cb, LibSass.Sass_Compiler compiler);
733 |
734 | ///
735 | /// Typedef helpers for custom functions lists
736 | ///
737 | [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
738 | public readonly partial struct Sass_Function_Entry : IEquatable
739 | {
740 | public Sass_Function_Entry(LibSass.Sass_Function value) => this.Value = value;
741 |
742 | public readonly LibSass.Sass_Function Value;
743 |
744 | public bool Equals(Sass_Function_Entry other) => Value.Equals(other.Value);
745 |
746 | public override bool Equals(object obj) => obj is Sass_Function_Entry other && Equals(other);
747 |
748 | public override int GetHashCode() => Value.GetHashCode();
749 |
750 | public override string ToString() => Value.ToString();
751 |
752 | public static implicit operator LibSass.Sass_Function(Sass_Function_Entry from) => from.Value;
753 |
754 | public static implicit operator Sass_Function_Entry(LibSass.Sass_Function from) => new Sass_Function_Entry(from);
755 |
756 | public static bool operator ==(Sass_Function_Entry left, Sass_Function_Entry right) => left.Equals(right);
757 |
758 | public static bool operator !=(Sass_Function_Entry left, Sass_Function_Entry right) => !left.Equals(right);
759 | }
760 |
761 | [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
762 | public readonly partial struct Sass_Function_List : IEquatable
763 | {
764 | public Sass_Function_List(IntPtr value) => this.Value = value;
765 |
766 | public readonly IntPtr Value;
767 |
768 | public bool Equals(Sass_Function_List other) => Value.Equals(other.Value);
769 |
770 | public override bool Equals(object obj) => obj is Sass_Function_List other && Equals(other);
771 |
772 | public override int GetHashCode() => Value.GetHashCode();
773 |
774 | public override string ToString() => Value.ToString();
775 |
776 | public static implicit operator IntPtr(Sass_Function_List from) => from.Value;
777 |
778 | public static implicit operator Sass_Function_List(IntPtr from) => new Sass_Function_List(from);
779 |
780 | public static bool operator ==(Sass_Function_List left, Sass_Function_List right) => left.Equals(right);
781 |
782 | public static bool operator !=(Sass_Function_List left, Sass_Function_List right) => !left.Equals(right);
783 | }
784 |
785 | [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
786 | public delegate LibSass.Sass_Value Sass_Function_Fn(in LibSass.Sass_Value arg0, LibSass.Sass_Function_Entry cb, LibSass.Sass_Compiler compiler);
787 |
788 | ///
789 | /// to allocate buffer to be filled
790 | ///
791 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
792 | public static extern IntPtr sass_alloc_memory(LibSass.size_t size);
793 |
794 | [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
795 | public readonly partial struct size_t : IEquatable
796 | {
797 | public size_t(IntPtr value) => this.Value = value;
798 |
799 | public readonly IntPtr Value;
800 |
801 | public bool Equals(size_t other) => Value.Equals(other.Value);
802 |
803 | public override bool Equals(object obj) => obj is size_t other && Equals(other);
804 |
805 | public override int GetHashCode() => Value.GetHashCode();
806 |
807 | public override string ToString() => Value.ToString();
808 |
809 | public static implicit operator IntPtr(size_t from) => from.Value;
810 |
811 | public static implicit operator size_t(IntPtr from) => new size_t(from);
812 |
813 | public static bool operator ==(size_t left, size_t right) => left.Equals(right);
814 |
815 | public static bool operator !=(size_t left, size_t right) => !left.Equals(right);
816 | }
817 |
818 | ///
819 | /// to allocate a buffer from existing string
820 | ///
821 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
822 | public static extern IntPtr sass_copy_c_string([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8MarshallerNoFree))] string str);
823 |
824 | ///
825 | /// to free overtaken memory when done
826 | ///
827 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
828 | public static extern void sass_free_memory(IntPtr ptr);
829 |
830 | ///
831 | /// Some convenient string helper function
832 | ///
833 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
834 | public static extern IntPtr sass_string_quote([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8MarshallerNoFree))] string str, sbyte quote_mark);
835 |
836 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
837 | public static extern IntPtr sass_string_unquote([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8MarshallerNoFree))] string str);
838 |
839 | ///
840 | /// Implemented sass language version
841 | /// Hardcoded version 3.4 for time being
842 | ///
843 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
844 | [return:MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8MarshallerNoFree))]
845 | public static extern string libsass_version();
846 |
847 | ///
848 | /// Get compiled libsass language
849 | ///
850 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
851 | [return:MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8MarshallerNoFree))]
852 | public static extern string libsass_language_version();
853 |
854 | ///
855 | /// Creator functions for all value types
856 | ///
857 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
858 | public static extern LibSass.Sass_Value sass_make_null();
859 |
860 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
861 | public static extern LibSass.Sass_Value sass_make_boolean([MarshalAs(UnmanagedType.U1)] bool val);
862 |
863 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
864 | public static extern LibSass.Sass_Value sass_make_string([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8MarshallerNoFree))] string val);
865 |
866 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
867 | public static extern LibSass.Sass_Value sass_make_qstring([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8MarshallerNoFree))] string val);
868 |
869 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
870 | public static extern LibSass.Sass_Value sass_make_number(double val, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8MarshallerNoFree))] string unit);
871 |
872 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
873 | public static extern LibSass.Sass_Value sass_make_color(double r, double g, double b, double a);
874 |
875 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
876 | public static extern LibSass.Sass_Value sass_make_list(LibSass.size_t len, LibSass.Sass_Separator sep, [MarshalAs(UnmanagedType.U1)] bool is_bracketed);
877 |
878 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
879 | public static extern LibSass.Sass_Value sass_make_map(LibSass.size_t len);
880 |
881 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
882 | public static extern LibSass.Sass_Value sass_make_error([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8MarshallerNoFree))] string msg);
883 |
884 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
885 | public static extern LibSass.Sass_Value sass_make_warning([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8MarshallerNoFree))] string msg);
886 |
887 | ///
888 | /// Generic destructor function for all types
889 | /// Will release memory of all associated Sass_Values
890 | /// Means we will delete recursively for lists and maps
891 | ///
892 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
893 | public static extern void sass_delete_value(LibSass.Sass_Value val);
894 |
895 | ///
896 | /// Make a deep cloned copy of the given sass value
897 | ///
898 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
899 | public static extern LibSass.Sass_Value sass_clone_value(in LibSass.Sass_Value val);
900 |
901 | ///
902 | /// Execute an operation for two Sass_Values and return the result as a Sass_Value too
903 | ///
904 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
905 | public static extern LibSass.Sass_Value sass_value_op(LibSass.Sass_OP op, in LibSass.Sass_Value a, in LibSass.Sass_Value b);
906 |
907 | ///
908 | /// Stringify a Sass_Values and also return the result as a Sass_Value (of type STRING)
909 | ///
910 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
911 | public static extern LibSass.Sass_Value sass_value_stringify(in LibSass.Sass_Value a, [MarshalAs(UnmanagedType.U1)] bool compressed, int precision);
912 |
913 | ///
914 | /// Return the sass tag for a generic sass value
915 | /// Check is needed before accessing specific values!
916 | ///
917 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
918 | public static extern LibSass.Sass_Tag sass_value_get_tag(in LibSass.Sass_Value v);
919 |
920 | ///
921 | /// Check value to be of a specific type
922 | /// Can also be used before accessing properties!
923 | ///
924 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
925 | [return:MarshalAs(UnmanagedType.U1)]
926 | public static extern bool sass_value_is_null(in LibSass.Sass_Value v);
927 |
928 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
929 | [return:MarshalAs(UnmanagedType.U1)]
930 | public static extern bool sass_value_is_number(in LibSass.Sass_Value v);
931 |
932 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
933 | [return:MarshalAs(UnmanagedType.U1)]
934 | public static extern bool sass_value_is_string(in LibSass.Sass_Value v);
935 |
936 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
937 | [return:MarshalAs(UnmanagedType.U1)]
938 | public static extern bool sass_value_is_boolean(in LibSass.Sass_Value v);
939 |
940 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
941 | [return:MarshalAs(UnmanagedType.U1)]
942 | public static extern bool sass_value_is_color(in LibSass.Sass_Value v);
943 |
944 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
945 | [return:MarshalAs(UnmanagedType.U1)]
946 | public static extern bool sass_value_is_list(in LibSass.Sass_Value v);
947 |
948 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
949 | [return:MarshalAs(UnmanagedType.U1)]
950 | public static extern bool sass_value_is_map(in LibSass.Sass_Value v);
951 |
952 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
953 | [return:MarshalAs(UnmanagedType.U1)]
954 | public static extern bool sass_value_is_error(in LibSass.Sass_Value v);
955 |
956 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
957 | [return:MarshalAs(UnmanagedType.U1)]
958 | public static extern bool sass_value_is_warning(in LibSass.Sass_Value v);
959 |
960 | ///
961 | /// Getters and setters for Sass_Number
962 | ///
963 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
964 | public static extern double sass_number_get_value(in LibSass.Sass_Value v);
965 |
966 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
967 | public static extern void sass_number_set_value(LibSass.Sass_Value v, double value);
968 |
969 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
970 | [return:MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8MarshallerNoFree))]
971 | public static extern string sass_number_get_unit(in LibSass.Sass_Value v);
972 |
973 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
974 | public static extern void sass_number_set_unit(LibSass.Sass_Value v, IntPtr unit);
975 |
976 | ///
977 | /// Getters and setters for Sass_String
978 | ///
979 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
980 | [return:MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8MarshallerNoFree))]
981 | public static extern string sass_string_get_value(in LibSass.Sass_Value v);
982 |
983 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
984 | public static extern void sass_string_set_value(LibSass.Sass_Value v, IntPtr value);
985 |
986 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
987 | [return:MarshalAs(UnmanagedType.U1)]
988 | public static extern bool sass_string_is_quoted(in LibSass.Sass_Value v);
989 |
990 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
991 | public static extern void sass_string_set_quoted(LibSass.Sass_Value v, [MarshalAs(UnmanagedType.U1)] bool quoted);
992 |
993 | ///
994 | /// Getters and setters for Sass_Boolean
995 | ///
996 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
997 | [return:MarshalAs(UnmanagedType.U1)]
998 | public static extern bool sass_boolean_get_value(in LibSass.Sass_Value v);
999 |
1000 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1001 | public static extern void sass_boolean_set_value(LibSass.Sass_Value v, [MarshalAs(UnmanagedType.U1)] bool value);
1002 |
1003 | ///
1004 | /// Getters and setters for Sass_Color
1005 | ///
1006 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1007 | public static extern double sass_color_get_r(in LibSass.Sass_Value v);
1008 |
1009 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1010 | public static extern void sass_color_set_r(LibSass.Sass_Value v, double r);
1011 |
1012 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1013 | public static extern double sass_color_get_g(in LibSass.Sass_Value v);
1014 |
1015 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1016 | public static extern void sass_color_set_g(LibSass.Sass_Value v, double g);
1017 |
1018 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1019 | public static extern double sass_color_get_b(in LibSass.Sass_Value v);
1020 |
1021 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1022 | public static extern void sass_color_set_b(LibSass.Sass_Value v, double b);
1023 |
1024 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1025 | public static extern double sass_color_get_a(in LibSass.Sass_Value v);
1026 |
1027 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1028 | public static extern void sass_color_set_a(LibSass.Sass_Value v, double a);
1029 |
1030 | ///
1031 | /// Getter for the number of items in list
1032 | ///
1033 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1034 | public static extern LibSass.size_t sass_list_get_length(in LibSass.Sass_Value v);
1035 |
1036 | ///
1037 | /// Getters and setters for Sass_List
1038 | ///
1039 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1040 | public static extern LibSass.Sass_Separator sass_list_get_separator(in LibSass.Sass_Value v);
1041 |
1042 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1043 | public static extern void sass_list_set_separator(LibSass.Sass_Value v, LibSass.Sass_Separator value);
1044 |
1045 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1046 | [return:MarshalAs(UnmanagedType.U1)]
1047 | public static extern bool sass_list_get_is_bracketed(in LibSass.Sass_Value v);
1048 |
1049 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1050 | public static extern void sass_list_set_is_bracketed(LibSass.Sass_Value v, [MarshalAs(UnmanagedType.U1)] bool value);
1051 |
1052 | ///
1053 | /// Getters and setters for Sass_List values
1054 | ///
1055 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1056 | public static extern LibSass.Sass_Value sass_list_get_value(in LibSass.Sass_Value v, LibSass.size_t i);
1057 |
1058 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1059 | public static extern void sass_list_set_value(LibSass.Sass_Value v, LibSass.size_t i, LibSass.Sass_Value value);
1060 |
1061 | ///
1062 | /// Getter for the number of items in map
1063 | ///
1064 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1065 | public static extern LibSass.size_t sass_map_get_length(in LibSass.Sass_Value v);
1066 |
1067 | ///
1068 | /// Getters and setters for Sass_Map keys and values
1069 | ///
1070 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1071 | public static extern LibSass.Sass_Value sass_map_get_key(in LibSass.Sass_Value v, LibSass.size_t i);
1072 |
1073 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1074 | public static extern void sass_map_set_key(LibSass.Sass_Value v, LibSass.size_t i, LibSass.Sass_Value arg2);
1075 |
1076 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1077 | public static extern LibSass.Sass_Value sass_map_get_value(in LibSass.Sass_Value v, LibSass.size_t i);
1078 |
1079 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1080 | public static extern void sass_map_set_value(LibSass.Sass_Value v, LibSass.size_t i, LibSass.Sass_Value arg2);
1081 |
1082 | ///
1083 | /// Getters and setters for Sass_Error
1084 | ///
1085 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1086 | public static extern IntPtr sass_error_get_message(in LibSass.Sass_Value v);
1087 |
1088 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1089 | public static extern void sass_error_set_message(LibSass.Sass_Value v, IntPtr msg);
1090 |
1091 | ///
1092 | /// Getters and setters for Sass_Warning
1093 | ///
1094 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1095 | public static extern IntPtr sass_warning_get_message(in LibSass.Sass_Value v);
1096 |
1097 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1098 | public static extern void sass_warning_set_message(LibSass.Sass_Value v, IntPtr msg);
1099 |
1100 | ///
1101 | /// Creator for sass custom importer return argument list
1102 | ///
1103 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1104 | public static extern LibSass.Sass_Importer_List sass_make_importer_list(LibSass.size_t length);
1105 |
1106 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1107 | public static extern LibSass.Sass_Importer_Entry sass_importer_get_list_entry(LibSass.Sass_Importer_List list, LibSass.size_t idx);
1108 |
1109 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1110 | public static extern void sass_importer_set_list_entry(LibSass.Sass_Importer_List list, LibSass.size_t idx, LibSass.Sass_Importer_Entry entry);
1111 |
1112 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1113 | public static extern void sass_delete_importer_list(LibSass.Sass_Importer_List list);
1114 |
1115 | ///
1116 | /// Creators for custom importer callback (with some additional pointer)
1117 | /// The pointer is mostly used to store the callback into the actual binding
1118 | ///
1119 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1120 | public static extern LibSass.Sass_Importer_Entry sass_make_importer(LibSass.Sass_Importer_Fn importer, double priority, IntPtr cookie);
1121 |
1122 | ///
1123 | /// Getters for import function descriptors
1124 | ///
1125 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1126 | public static extern LibSass.Sass_Importer_Fn sass_importer_get_function(LibSass.Sass_Importer_Entry cb);
1127 |
1128 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1129 | public static extern double sass_importer_get_priority(LibSass.Sass_Importer_Entry cb);
1130 |
1131 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1132 | public static extern IntPtr sass_importer_get_cookie(LibSass.Sass_Importer_Entry cb);
1133 |
1134 | ///
1135 | /// Deallocator for associated memory
1136 | ///
1137 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1138 | public static extern void sass_delete_importer(LibSass.Sass_Importer_Entry cb);
1139 |
1140 | ///
1141 | /// Creator for sass custom importer return argument list
1142 | ///
1143 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1144 | public static extern LibSass.Sass_Import_List sass_make_import_list(LibSass.size_t length);
1145 |
1146 | ///
1147 | /// Creator for a single import entry returned by the custom importer inside the list
1148 | ///
1149 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1150 | public static extern LibSass.Sass_Import_Entry sass_make_import_entry([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8MarshallerNoFree))] string path, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8MarshallerNoFree))] string source, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8MarshallerNoFree))] string srcmap);
1151 |
1152 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1153 | public static extern LibSass.Sass_Import_Entry sass_make_import([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8MarshallerNoFree))] string imp_path, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8MarshallerNoFree))] string abs_base, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8MarshallerNoFree))] string source, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8MarshallerNoFree))] string srcmap);
1154 |
1155 | ///
1156 | /// set error message to abort import and to print out a message (path from existing object is used in output)
1157 | ///
1158 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1159 | public static extern LibSass.Sass_Import_Entry sass_import_set_error(LibSass.Sass_Import_Entry import, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8MarshallerNoFree))] string message, LibSass.size_t line, LibSass.size_t col);
1160 |
1161 | ///
1162 | /// Setters to insert an entry into the import list (you may also use [] access directly)
1163 | /// Since we are dealing with pointers they should have a guaranteed and fixed size
1164 | ///
1165 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1166 | public static extern void sass_import_set_list_entry(LibSass.Sass_Import_List list, LibSass.size_t idx, LibSass.Sass_Import_Entry entry);
1167 |
1168 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1169 | public static extern LibSass.Sass_Import_Entry sass_import_get_list_entry(LibSass.Sass_Import_List list, LibSass.size_t idx);
1170 |
1171 | ///
1172 | /// Getters for callee entry
1173 | ///
1174 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1175 | [return:MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8MarshallerNoFree))]
1176 | public static extern string sass_callee_get_name(LibSass.Sass_Callee_Entry arg0);
1177 |
1178 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1179 | [return:MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8MarshallerNoFree))]
1180 | public static extern string sass_callee_get_path(LibSass.Sass_Callee_Entry arg0);
1181 |
1182 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1183 | public static extern LibSass.size_t sass_callee_get_line(LibSass.Sass_Callee_Entry arg0);
1184 |
1185 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1186 | public static extern LibSass.size_t sass_callee_get_column(LibSass.Sass_Callee_Entry arg0);
1187 |
1188 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1189 | public static extern LibSass.Sass_Callee_Type sass_callee_get_type(LibSass.Sass_Callee_Entry arg0);
1190 |
1191 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1192 | public static extern LibSass.Sass_Env_Frame sass_callee_get_env(LibSass.Sass_Callee_Entry arg0);
1193 |
1194 | ///
1195 | /// Getters and Setters for environments (lexical, local and global)
1196 | ///
1197 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1198 | public static extern LibSass.Sass_Value sass_env_get_lexical(LibSass.Sass_Env_Frame arg0, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8MarshallerNoFree))] string arg1);
1199 |
1200 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1201 | public static extern void sass_env_set_lexical(LibSass.Sass_Env_Frame arg0, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8MarshallerNoFree))] string arg1, LibSass.Sass_Value arg2);
1202 |
1203 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1204 | public static extern LibSass.Sass_Value sass_env_get_local(LibSass.Sass_Env_Frame arg0, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8MarshallerNoFree))] string arg1);
1205 |
1206 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1207 | public static extern void sass_env_set_local(LibSass.Sass_Env_Frame arg0, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8MarshallerNoFree))] string arg1, LibSass.Sass_Value arg2);
1208 |
1209 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1210 | public static extern LibSass.Sass_Value sass_env_get_global(LibSass.Sass_Env_Frame arg0, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8MarshallerNoFree))] string arg1);
1211 |
1212 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1213 | public static extern void sass_env_set_global(LibSass.Sass_Env_Frame arg0, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8MarshallerNoFree))] string arg1, LibSass.Sass_Value arg2);
1214 |
1215 | ///
1216 | /// Getters for import entry
1217 | ///
1218 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1219 | [return:MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8MarshallerNoFree))]
1220 | public static extern string sass_import_get_imp_path(LibSass.Sass_Import_Entry arg0);
1221 |
1222 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1223 | [return:MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8MarshallerNoFree))]
1224 | public static extern string sass_import_get_abs_path(LibSass.Sass_Import_Entry arg0);
1225 |
1226 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1227 | [return:MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8MarshallerNoFree))]
1228 | public static extern string sass_import_get_source(LibSass.Sass_Import_Entry arg0);
1229 |
1230 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1231 | [return:MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8MarshallerNoFree))]
1232 | public static extern string sass_import_get_srcmap(LibSass.Sass_Import_Entry arg0);
1233 |
1234 | ///
1235 | /// Explicit functions to take ownership of these items
1236 | /// The property on our struct will be reset to NULL
1237 | ///
1238 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1239 | public static extern IntPtr sass_import_take_source(LibSass.Sass_Import_Entry arg0);
1240 |
1241 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1242 | public static extern IntPtr sass_import_take_srcmap(LibSass.Sass_Import_Entry arg0);
1243 |
1244 | ///
1245 | /// Getters from import error entry
1246 | ///
1247 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1248 | public static extern LibSass.size_t sass_import_get_error_line(LibSass.Sass_Import_Entry arg0);
1249 |
1250 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1251 | public static extern LibSass.size_t sass_import_get_error_column(LibSass.Sass_Import_Entry arg0);
1252 |
1253 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1254 | [return:MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8MarshallerNoFree))]
1255 | public static extern string sass_import_get_error_message(LibSass.Sass_Import_Entry arg0);
1256 |
1257 | ///
1258 | /// Deallocator for associated memory (incl. entries)
1259 | ///
1260 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1261 | public static extern void sass_delete_import_list(LibSass.Sass_Import_List arg0);
1262 |
1263 | ///
1264 | /// Just in case we have some stray import structs
1265 | ///
1266 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1267 | public static extern void sass_delete_import(LibSass.Sass_Import_Entry arg0);
1268 |
1269 | ///
1270 | /// Creators for sass function list and function descriptors
1271 | ///
1272 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1273 | public static extern LibSass.Sass_Function_List sass_make_function_list(LibSass.size_t length);
1274 |
1275 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1276 | public static extern LibSass.Sass_Function_Entry sass_make_function([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8MarshallerNoFree))] string signature, LibSass.Sass_Function_Fn cb, IntPtr cookie);
1277 |
1278 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1279 | public static extern void sass_delete_function(LibSass.Sass_Function_Entry entry);
1280 |
1281 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1282 | public static extern void sass_delete_function_list(LibSass.Sass_Function_List list);
1283 |
1284 | ///
1285 | /// Setters and getters for callbacks on function lists
1286 | ///
1287 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1288 | public static extern LibSass.Sass_Function_Entry sass_function_get_list_entry(LibSass.Sass_Function_List list, LibSass.size_t pos);
1289 |
1290 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1291 | public static extern void sass_function_set_list_entry(LibSass.Sass_Function_List list, LibSass.size_t pos, LibSass.Sass_Function_Entry cb);
1292 |
1293 | ///
1294 | /// Getters for custom function descriptors
1295 | ///
1296 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1297 | [return:MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8MarshallerNoFree))]
1298 | public static extern string sass_function_get_signature(LibSass.Sass_Function_Entry cb);
1299 |
1300 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1301 | public static extern LibSass.Sass_Function_Fn sass_function_get_function(LibSass.Sass_Function_Entry cb);
1302 |
1303 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1304 | public static extern IntPtr sass_function_get_cookie(LibSass.Sass_Function_Entry cb);
1305 |
1306 | ///
1307 | /// Create and initialize an option struct
1308 | ///
1309 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1310 | public static extern LibSass.Sass_Options sass_make_options();
1311 |
1312 | ///
1313 | /// Create and initialize a specific context
1314 | ///
1315 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1316 | public static extern LibSass.Sass_File_Context sass_make_file_context([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8MarshallerNoFree))] string input_path);
1317 |
1318 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1319 | public static extern LibSass.Sass_Data_Context sass_make_data_context([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8MarshallerNoFree))] string source_string);
1320 |
1321 | ///
1322 | /// Call the compilation step for the specific context
1323 | ///
1324 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1325 | public static extern int sass_compile_file_context(LibSass.Sass_File_Context ctx);
1326 |
1327 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1328 | public static extern int sass_compile_data_context(LibSass.Sass_Data_Context ctx);
1329 |
1330 | ///
1331 | /// Create a sass compiler instance for more control
1332 | ///
1333 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1334 | public static extern LibSass.Sass_Compiler sass_make_file_compiler(LibSass.Sass_File_Context file_ctx);
1335 |
1336 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1337 | public static extern LibSass.Sass_Compiler sass_make_data_compiler(LibSass.Sass_Data_Context data_ctx);
1338 |
1339 | ///
1340 | /// Execute the different compilation steps individually
1341 | /// Useful if you only want to query the included files
1342 | ///
1343 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1344 | public static extern int sass_compiler_parse(LibSass.Sass_Compiler compiler);
1345 |
1346 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1347 | public static extern int sass_compiler_execute(LibSass.Sass_Compiler compiler);
1348 |
1349 | ///
1350 | /// Release all memory allocated with the compiler
1351 | /// This does _not_ include any contexts or options
1352 | ///
1353 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1354 | public static extern void sass_delete_compiler(LibSass.Sass_Compiler compiler);
1355 |
1356 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1357 | public static extern void sass_delete_options(LibSass.Sass_Options options);
1358 |
1359 | ///
1360 | /// Release all memory allocated and also ourself
1361 | ///
1362 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1363 | public static extern void sass_delete_file_context(LibSass.Sass_File_Context ctx);
1364 |
1365 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1366 | public static extern void sass_delete_data_context(LibSass.Sass_Data_Context ctx);
1367 |
1368 | ///
1369 | /// Getters for context from specific implementation
1370 | ///
1371 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1372 | public static extern LibSass.Sass_Context sass_file_context_get_context(LibSass.Sass_File_Context file_ctx);
1373 |
1374 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1375 | public static extern LibSass.Sass_Context sass_data_context_get_context(LibSass.Sass_Data_Context data_ctx);
1376 |
1377 | ///
1378 | /// Getters for Context_Options from Sass_Context
1379 | ///
1380 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1381 | public static extern LibSass.Sass_Options sass_context_get_options(LibSass.Sass_Context ctx);
1382 |
1383 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1384 | public static extern LibSass.Sass_Options sass_file_context_get_options(LibSass.Sass_File_Context file_ctx);
1385 |
1386 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1387 | public static extern LibSass.Sass_Options sass_data_context_get_options(LibSass.Sass_Data_Context data_ctx);
1388 |
1389 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1390 | public static extern void sass_file_context_set_options(LibSass.Sass_File_Context file_ctx, LibSass.Sass_Options opt);
1391 |
1392 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1393 | public static extern void sass_data_context_set_options(LibSass.Sass_Data_Context data_ctx, LibSass.Sass_Options opt);
1394 |
1395 | ///
1396 | /// Getters for Context_Option values
1397 | ///
1398 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1399 | public static extern int sass_option_get_precision(LibSass.Sass_Options options);
1400 |
1401 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1402 | public static extern LibSass.Sass_Output_Style sass_option_get_output_style(LibSass.Sass_Options options);
1403 |
1404 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1405 | [return:MarshalAs(UnmanagedType.U1)]
1406 | public static extern bool sass_option_get_source_comments(LibSass.Sass_Options options);
1407 |
1408 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1409 | [return:MarshalAs(UnmanagedType.U1)]
1410 | public static extern bool sass_option_get_source_map_embed(LibSass.Sass_Options options);
1411 |
1412 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1413 | [return:MarshalAs(UnmanagedType.U1)]
1414 | public static extern bool sass_option_get_source_map_contents(LibSass.Sass_Options options);
1415 |
1416 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1417 | [return:MarshalAs(UnmanagedType.U1)]
1418 | public static extern bool sass_option_get_source_map_file_urls(LibSass.Sass_Options options);
1419 |
1420 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1421 | [return:MarshalAs(UnmanagedType.U1)]
1422 | public static extern bool sass_option_get_omit_source_map_url(LibSass.Sass_Options options);
1423 |
1424 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1425 | [return:MarshalAs(UnmanagedType.U1)]
1426 | public static extern bool sass_option_get_is_indented_syntax_src(LibSass.Sass_Options options);
1427 |
1428 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1429 | [return:MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8MarshallerNoFree))]
1430 | public static extern string sass_option_get_indent(LibSass.Sass_Options options);
1431 |
1432 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1433 | [return:MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8MarshallerNoFree))]
1434 | public static extern string sass_option_get_linefeed(LibSass.Sass_Options options);
1435 |
1436 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1437 | [return:MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8MarshallerNoFree))]
1438 | public static extern string sass_option_get_input_path(LibSass.Sass_Options options);
1439 |
1440 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1441 | [return:MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8MarshallerNoFree))]
1442 | public static extern string sass_option_get_output_path(LibSass.Sass_Options options);
1443 |
1444 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1445 | [return:MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8MarshallerNoFree))]
1446 | public static extern string sass_option_get_source_map_file(LibSass.Sass_Options options);
1447 |
1448 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1449 | [return:MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8MarshallerNoFree))]
1450 | public static extern string sass_option_get_source_map_root(LibSass.Sass_Options options);
1451 |
1452 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1453 | public static extern LibSass.Sass_Importer_List sass_option_get_c_headers(LibSass.Sass_Options options);
1454 |
1455 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1456 | public static extern LibSass.Sass_Importer_List sass_option_get_c_importers(LibSass.Sass_Options options);
1457 |
1458 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1459 | public static extern LibSass.Sass_Function_List sass_option_get_c_functions(LibSass.Sass_Options options);
1460 |
1461 | ///
1462 | /// Setters for Context_Option values
1463 | ///
1464 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1465 | public static extern void sass_option_set_precision(LibSass.Sass_Options options, int precision);
1466 |
1467 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1468 | public static extern void sass_option_set_output_style(LibSass.Sass_Options options, LibSass.Sass_Output_Style output_style);
1469 |
1470 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1471 | public static extern void sass_option_set_source_comments(LibSass.Sass_Options options, [MarshalAs(UnmanagedType.U1)] bool source_comments);
1472 |
1473 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1474 | public static extern void sass_option_set_source_map_embed(LibSass.Sass_Options options, [MarshalAs(UnmanagedType.U1)] bool source_map_embed);
1475 |
1476 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1477 | public static extern void sass_option_set_source_map_contents(LibSass.Sass_Options options, [MarshalAs(UnmanagedType.U1)] bool source_map_contents);
1478 |
1479 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1480 | public static extern void sass_option_set_source_map_file_urls(LibSass.Sass_Options options, [MarshalAs(UnmanagedType.U1)] bool source_map_file_urls);
1481 |
1482 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1483 | public static extern void sass_option_set_omit_source_map_url(LibSass.Sass_Options options, [MarshalAs(UnmanagedType.U1)] bool omit_source_map_url);
1484 |
1485 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1486 | public static extern void sass_option_set_is_indented_syntax_src(LibSass.Sass_Options options, [MarshalAs(UnmanagedType.U1)] bool is_indented_syntax_src);
1487 |
1488 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1489 | public static extern void sass_option_set_indent(LibSass.Sass_Options options, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8MarshallerNoFree))] string indent);
1490 |
1491 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1492 | public static extern void sass_option_set_linefeed(LibSass.Sass_Options options, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8MarshallerNoFree))] string linefeed);
1493 |
1494 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1495 | public static extern void sass_option_set_input_path(LibSass.Sass_Options options, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8MarshallerNoFree))] string input_path);
1496 |
1497 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1498 | public static extern void sass_option_set_output_path(LibSass.Sass_Options options, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8MarshallerNoFree))] string output_path);
1499 |
1500 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1501 | public static extern void sass_option_set_plugin_path(LibSass.Sass_Options options, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8MarshallerNoFree))] string plugin_path);
1502 |
1503 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1504 | public static extern void sass_option_set_include_path(LibSass.Sass_Options options, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8MarshallerNoFree))] string include_path);
1505 |
1506 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1507 | public static extern void sass_option_set_source_map_file(LibSass.Sass_Options options, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8MarshallerNoFree))] string source_map_file);
1508 |
1509 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1510 | public static extern void sass_option_set_source_map_root(LibSass.Sass_Options options, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8MarshallerNoFree))] string source_map_root);
1511 |
1512 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1513 | public static extern void sass_option_set_c_headers(LibSass.Sass_Options options, LibSass.Sass_Importer_List c_headers);
1514 |
1515 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1516 | public static extern void sass_option_set_c_importers(LibSass.Sass_Options options, LibSass.Sass_Importer_List c_importers);
1517 |
1518 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1519 | public static extern void sass_option_set_c_functions(LibSass.Sass_Options options, LibSass.Sass_Function_List c_functions);
1520 |
1521 | ///
1522 | /// Getters for Sass_Context values
1523 | ///
1524 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1525 | [return:MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8MarshallerNoFree))]
1526 | public static extern string sass_context_get_output_string(LibSass.Sass_Context ctx);
1527 |
1528 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1529 | public static extern int sass_context_get_error_status(LibSass.Sass_Context ctx);
1530 |
1531 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1532 | [return:MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8MarshallerNoFree))]
1533 | public static extern string sass_context_get_error_json(LibSass.Sass_Context ctx);
1534 |
1535 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1536 | [return:MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8MarshallerNoFree))]
1537 | public static extern string sass_context_get_error_text(LibSass.Sass_Context ctx);
1538 |
1539 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1540 | [return:MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8MarshallerNoFree))]
1541 | public static extern string sass_context_get_error_message(LibSass.Sass_Context ctx);
1542 |
1543 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1544 | [return:MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8MarshallerNoFree))]
1545 | public static extern string sass_context_get_error_file(LibSass.Sass_Context ctx);
1546 |
1547 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1548 | [return:MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8MarshallerNoFree))]
1549 | public static extern string sass_context_get_error_src(LibSass.Sass_Context ctx);
1550 |
1551 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1552 | public static extern LibSass.size_t sass_context_get_error_line(LibSass.Sass_Context ctx);
1553 |
1554 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1555 | public static extern LibSass.size_t sass_context_get_error_column(LibSass.Sass_Context ctx);
1556 |
1557 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1558 | [return:MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8MarshallerNoFree))]
1559 | public static extern string sass_context_get_source_map_string(LibSass.Sass_Context ctx);
1560 |
1561 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1562 | public static extern IntPtr sass_context_get_included_files(LibSass.Sass_Context ctx);
1563 |
1564 | ///
1565 | /// Getters for options include path array
1566 | ///
1567 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1568 | public static extern LibSass.size_t sass_option_get_include_path_size(LibSass.Sass_Options options);
1569 |
1570 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1571 | [return:MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8MarshallerNoFree))]
1572 | public static extern string sass_option_get_include_path(LibSass.Sass_Options options, LibSass.size_t i);
1573 |
1574 | ///
1575 | /// Plugin paths to load dynamic libraries work the same
1576 | ///
1577 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1578 | public static extern LibSass.size_t sass_option_get_plugin_path_size(LibSass.Sass_Options options);
1579 |
1580 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1581 | [return:MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8MarshallerNoFree))]
1582 | public static extern string sass_option_get_plugin_path(LibSass.Sass_Options options, LibSass.size_t i);
1583 |
1584 | ///
1585 | /// Calculate the size of the stored null terminated array
1586 | ///
1587 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1588 | public static extern LibSass.size_t sass_context_get_included_files_size(LibSass.Sass_Context ctx);
1589 |
1590 | ///
1591 | /// Take ownership of memory (value on context is set to 0)
1592 | ///
1593 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1594 | public static extern IntPtr sass_context_take_error_json(LibSass.Sass_Context ctx);
1595 |
1596 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1597 | public static extern IntPtr sass_context_take_error_text(LibSass.Sass_Context ctx);
1598 |
1599 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1600 | public static extern IntPtr sass_context_take_error_message(LibSass.Sass_Context ctx);
1601 |
1602 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1603 | public static extern IntPtr sass_context_take_error_file(LibSass.Sass_Context ctx);
1604 |
1605 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1606 | public static extern IntPtr sass_context_take_error_src(LibSass.Sass_Context ctx);
1607 |
1608 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1609 | public static extern IntPtr sass_context_take_output_string(LibSass.Sass_Context ctx);
1610 |
1611 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1612 | public static extern IntPtr sass_context_take_source_map_string(LibSass.Sass_Context ctx);
1613 |
1614 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1615 | public static extern IntPtr sass_context_take_included_files(LibSass.Sass_Context ctx);
1616 |
1617 | ///
1618 | /// Getters for Sass_Compiler options
1619 | ///
1620 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1621 | public static extern LibSass.Sass_Compiler_State sass_compiler_get_state(LibSass.Sass_Compiler compiler);
1622 |
1623 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1624 | public static extern LibSass.Sass_Context sass_compiler_get_context(LibSass.Sass_Compiler compiler);
1625 |
1626 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1627 | public static extern LibSass.Sass_Options sass_compiler_get_options(LibSass.Sass_Compiler compiler);
1628 |
1629 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1630 | public static extern LibSass.size_t sass_compiler_get_import_stack_size(LibSass.Sass_Compiler compiler);
1631 |
1632 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1633 | public static extern LibSass.Sass_Import_Entry sass_compiler_get_last_import(LibSass.Sass_Compiler compiler);
1634 |
1635 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1636 | public static extern LibSass.Sass_Import_Entry sass_compiler_get_import_entry(LibSass.Sass_Compiler compiler, LibSass.size_t idx);
1637 |
1638 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1639 | public static extern LibSass.size_t sass_compiler_get_callee_stack_size(LibSass.Sass_Compiler compiler);
1640 |
1641 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1642 | public static extern LibSass.Sass_Callee_Entry sass_compiler_get_last_callee(LibSass.Sass_Compiler compiler);
1643 |
1644 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1645 | public static extern LibSass.Sass_Callee_Entry sass_compiler_get_callee_entry(LibSass.Sass_Compiler compiler, LibSass.size_t idx);
1646 |
1647 | ///
1648 | /// Push function for paths (no manipulation support for now)
1649 | ///
1650 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1651 | public static extern void sass_option_push_plugin_path(LibSass.Sass_Options options, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8MarshallerNoFree))] string path);
1652 |
1653 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1654 | public static extern void sass_option_push_include_path(LibSass.Sass_Options options, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8MarshallerNoFree))] string path);
1655 |
1656 | ///
1657 | /// Resolve a file via the given include paths in the sass option struct
1658 | /// find_file looks for the exact file name while find_include does a regular sass include
1659 | ///
1660 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1661 | public static extern IntPtr sass_find_file([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8MarshallerNoFree))] string path, LibSass.Sass_Options opt);
1662 |
1663 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1664 | public static extern IntPtr sass_find_include([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8MarshallerNoFree))] string path, LibSass.Sass_Options opt);
1665 |
1666 | ///
1667 | /// Resolve a file relative to last import or include paths in the sass option struct
1668 | /// find_file looks for the exact file name while find_include does a regular sass include
1669 | ///
1670 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1671 | public static extern IntPtr sass_compiler_find_file([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8MarshallerNoFree))] string path, LibSass.Sass_Compiler compiler);
1672 |
1673 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1674 | public static extern IntPtr sass_compiler_find_include([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8MarshallerNoFree))] string path, LibSass.Sass_Compiler compiler);
1675 |
1676 | ///
1677 | /// available to c and c++ code
1678 | ///
1679 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1680 | public static extern IntPtr sass2scss([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8MarshallerNoFree))] string sass, int options);
1681 |
1682 | ///
1683 | /// Get compiled sass2scss version
1684 | ///
1685 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1686 | [return:MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8MarshallerNoFree))]
1687 | public static extern string sass2scss_version();
1688 |
1689 | ///
1690 | /// converter struct
1691 | /// holding all states
1692 | ///
1693 | [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
1694 | public partial struct converter
1695 | {
1696 | ///
1697 | /// bit options
1698 | ///
1699 | public int options;
1700 |
1701 | ///
1702 | /// is selector
1703 | ///
1704 | [MarshalAs(UnmanagedType.U1)]
1705 | public bool selector;
1706 |
1707 | ///
1708 | /// concat lists
1709 | ///
1710 | [MarshalAs(UnmanagedType.U1)]
1711 | public bool comma;
1712 |
1713 | ///
1714 | /// has property
1715 | ///
1716 | [MarshalAs(UnmanagedType.U1)]
1717 | public bool property;
1718 |
1719 | ///
1720 | /// has semicolon
1721 | ///
1722 | [MarshalAs(UnmanagedType.U1)]
1723 | public bool semicolon;
1724 |
1725 | ///
1726 | /// comment context
1727 | ///
1728 | public LibSass.converter.basic_string comment;
1729 |
1730 | [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
1731 | public partial struct basic_string
1732 | {
1733 | }
1734 |
1735 | ///
1736 | /// flag end of file
1737 | ///
1738 | [MarshalAs(UnmanagedType.U1)]
1739 | public bool end_of_file;
1740 |
1741 | ///
1742 | /// whitespace buffer
1743 | ///
1744 | public LibSass.converter.basic_string whitespace;
1745 |
1746 | ///
1747 | /// context/block stack
1748 | ///
1749 | public LibSass.converter.stack indents;
1750 |
1751 | [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
1752 | public partial struct stack
1753 | {
1754 | }
1755 | }
1756 |
1757 | ///
1758 | /// pretty print options
1759 | ///
1760 | public const int SASS2SCSS_PRETTIFY_0 = 0;
1761 |
1762 | public const int SASS2SCSS_PRETTIFY_1 = 1;
1763 |
1764 | public const int SASS2SCSS_PRETTIFY_2 = 2;
1765 |
1766 | public const int SASS2SCSS_PRETTIFY_3 = 3;
1767 |
1768 | ///
1769 | /// remove one-line comment
1770 | ///
1771 | public const int SASS2SCSS_KEEP_COMMENT = 32;
1772 |
1773 | ///
1774 | /// remove multi-line comments
1775 | ///
1776 | public const int SASS2SCSS_STRIP_COMMENT = 64;
1777 |
1778 | ///
1779 | /// convert one-line to multi-line
1780 | ///
1781 | public const int SASS2SCSS_CONVERT_COMMENT = 128;
1782 |
1783 | ///
1784 | /// function only available in c++ code
1785 | ///
1786 | [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)]
1787 | public static extern IntPtr sass2scss(ref LibSass.converter.basic_string sass, int options);
1788 | }
1789 | }
1790 |
--------------------------------------------------------------------------------
/src/SharpScss/LibSass.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Alexandre Mutel. All rights reserved.
2 | // This file is licensed under the BSD-Clause 2 license.
3 | // See the license.txt file in the project root for more information.
4 |
5 | using System;
6 | using System.Collections.Generic;
7 | using System.IO;
8 | using System.Runtime.InteropServices;
9 | using System.Text;
10 |
11 | namespace SharpScss;
12 |
13 | ///
14 | /// Struct and functions of libsass used manually. All other functions/types are defined in LibSass.Generated.cs
15 | ///
16 | internal static partial class LibSass
17 | {
18 | private const string LibSassDll = "libsass";
19 |
20 | [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
21 | public delegate Sass_Import_List sass_importer_delegate(LibSass.StringUtf8 cur_path, LibSass.Sass_Importer_Entry cb, LibSass.Sass_Compiler compiler);
22 |
23 | public partial struct Sass_File_Context
24 | {
25 | public static implicit operator Sass_Context(Sass_File_Context context)
26 | {
27 | return new Sass_Context(context.Handle);
28 | }
29 | public static explicit operator Sass_File_Context(Sass_Context context)
30 | {
31 | return new Sass_File_Context(context.Handle);
32 | }
33 | }
34 |
35 | public partial struct Sass_Data_Context
36 | {
37 | public static implicit operator Sass_Context(Sass_Data_Context context)
38 | {
39 | return new Sass_Context(context.Handle);
40 | }
41 | public static explicit operator Sass_Data_Context(Sass_Context context)
42 | {
43 | return new Sass_Data_Context(context.Handle);
44 | }
45 | }
46 | public partial struct size_t
47 | {
48 | public size_t(int value)
49 | {
50 | Value = new IntPtr(value);
51 | }
52 |
53 | public size_t(long value)
54 | {
55 | Value = new IntPtr(value);
56 | }
57 |
58 |
59 | public static implicit operator long(size_t size)
60 | {
61 | return size.Value.ToInt64();
62 | }
63 |
64 | public static implicit operator int(size_t size)
65 | {
66 | return size.Value.ToInt32();
67 | }
68 |
69 | public static implicit operator size_t(long size)
70 | {
71 | return new size_t(size);
72 | }
73 |
74 | public static implicit operator size_t(int size)
75 | {
76 | return new size_t(size);
77 | }
78 | }
79 |
80 | public struct StringUtf8
81 | {
82 | public StringUtf8(IntPtr pointer)
83 | {
84 | this.pointer = pointer;
85 | }
86 |
87 | private readonly IntPtr pointer;
88 |
89 | public bool IsEmpty => pointer == IntPtr.Zero;
90 |
91 | public static implicit operator string?(StringUtf8 stringUtf8)
92 | {
93 | if (stringUtf8.pointer != IntPtr.Zero)
94 | {
95 | return Utf8ToString(stringUtf8.pointer);
96 | }
97 | return null;
98 | }
99 |
100 | public static unsafe implicit operator StringUtf8(string? text)
101 | {
102 | if (text == null)
103 | {
104 | return new StringUtf8(IntPtr.Zero);
105 | }
106 |
107 | var length = Encoding.UTF8.GetByteCount(text);
108 | var pointer = sass_alloc_memory(length+1);
109 | fixed (char* pText = text)
110 | Encoding.UTF8.GetBytes(pText, text.Length, (byte*) pointer, length);
111 | ((byte*)pointer)[length] = 0;
112 | return new StringUtf8(pointer);
113 | }
114 |
115 | private static unsafe string Utf8ToString(IntPtr utfString)
116 | {
117 | var pText = (byte*)utfString;
118 | // find the end of the string
119 | while (*pText != 0)
120 | {
121 | pText++;
122 | }
123 | int length = (int)(pText - (byte*)utfString);
124 | var text = Encoding.UTF8.GetString((byte*)utfString, length);
125 | return text;
126 | }
127 | }
128 |
129 | private sealed class UTF8EncodingRelaxed : UTF8Encoding
130 | {
131 | public new static readonly UTF8EncodingRelaxed Default = new UTF8EncodingRelaxed();
132 |
133 | public UTF8EncodingRelaxed() : base(false, false)
134 | {
135 | }
136 | }
137 |
138 | internal abstract class SassAllocator
139 | {
140 | [ThreadStatic]
141 | private static List? PointersToFree;
142 |
143 | public static void FreeNative()
144 | {
145 | var pointersToFree = PointersToFree;
146 | if (pointersToFree == null) return;
147 | try
148 | {
149 | foreach (var pData in pointersToFree)
150 | {
151 | sass_free_memory(pData);
152 | }
153 |
154 | }
155 | finally
156 | {
157 | pointersToFree.Clear();
158 | }
159 | }
160 |
161 | public static void RecordFreeNative(IntPtr pNativeData)
162 | {
163 | if (pNativeData == IntPtr.Zero) return;
164 | if (PointersToFree == null)
165 | {
166 | PointersToFree = new List();
167 | }
168 |
169 | var pointersToFree = PointersToFree;
170 | pointersToFree.Add(pNativeData);
171 | }
172 | }
173 |
174 | private class UTF8MarshallerBase : SassAllocator, ICustomMarshaler where T : Encoding, new()
175 | {
176 | private static readonly Encoding EncodingUsed = new T();
177 |
178 | private readonly bool _freeNative;
179 |
180 | protected UTF8MarshallerBase(bool freeNative)
181 | {
182 | _freeNative = freeNative;
183 | }
184 |
185 | public static unsafe string FromNative(IntPtr pNativeData)
186 | {
187 | var pBuffer = (byte*)pNativeData;
188 | if (pBuffer == null) return string.Empty;
189 | int length = 0;
190 | while (pBuffer[length] != 0)
191 | {
192 | length++;
193 | }
194 | return EncodingUsed.GetString((byte*)pNativeData, length);
195 | }
196 |
197 | public static unsafe IntPtr ToNative(string text, bool strict = false)
198 | {
199 | if (text == null) return IntPtr.Zero;
200 |
201 | var length = EncodingUsed.GetByteCount(text);
202 | var pBuffer = (byte*)sass_alloc_memory(length + 1);
203 | if (pBuffer == null) return IntPtr.Zero;
204 |
205 | if (length > 0)
206 | {
207 | fixed (char* ptr = text)
208 | {
209 | EncodingUsed.GetBytes(ptr, text.Length, pBuffer, length);
210 | }
211 | }
212 |
213 | pBuffer[length] = 0;
214 |
215 | return new IntPtr(pBuffer);
216 | }
217 |
218 | public virtual object MarshalNativeToManaged(IntPtr pNativeData)
219 | {
220 | return FromNative(pNativeData);
221 | }
222 |
223 | public virtual IntPtr MarshalManagedToNative(object managedObj)
224 | {
225 | var text = (string)managedObj;
226 | return ToNative(text);
227 | }
228 |
229 | public virtual void CleanUpNativeData(IntPtr pNativeData)
230 | {
231 | if (!_freeNative) return;
232 | RecordFreeNative(pNativeData);
233 | }
234 |
235 | public virtual void CleanUpManagedData(object ManagedObj)
236 | {
237 | }
238 |
239 | public int GetNativeDataSize()
240 | {
241 | return -1;
242 | }
243 | }
244 |
245 | private sealed class UTF8MarshallerNoFree : UTF8MarshallerBase
246 | {
247 | private static readonly UTF8MarshallerNoFree Instance = new UTF8MarshallerNoFree(false);
248 |
249 | public UTF8MarshallerNoFree(bool freeNative) : base(freeNative)
250 | {
251 | }
252 |
253 | public static ICustomMarshaler GetInstance(string cookie)
254 | {
255 | return Instance;
256 | }
257 | }
258 | }
--------------------------------------------------------------------------------
/src/SharpScss/Scss.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Alexandre Mutel. All rights reserved.
2 | // This file is licensed under the BSD-Clause 2 license.
3 | // See the license.txt file in the project root for more information.
4 |
5 | using System;
6 | using System.Collections.Generic;
7 | using System.IO;
8 | using System.Runtime.InteropServices;
9 |
10 | namespace SharpScss;
11 |
12 | ///
13 | /// Scss to css converter using libsass from https://github.com/sass/libsass.
14 | ///
15 | public static class Scss
16 | {
17 | // NOTE: It is important to keep allocated delegate importer function, so that it will not be garbage collected
18 | private static readonly LibSass.Sass_Importer_Fn ScssImporterLock;
19 | private static string? version;
20 | private static string? languageVersion;
21 | private static readonly ScssOptions DefaultOptions = new ScssOptions();
22 |
23 | static Scss()
24 | {
25 | // We must store the delegate so GetFunctionPointerForDelegate will not be orphaned
26 | ScssImporterLock = CustomScssImporter;
27 | }
28 |
29 | ///
30 | /// Gets the libsass version.
31 | ///
32 | public static string Version
33 | {
34 | get { return version ??= LibSass.libsass_version(); }
35 | }
36 |
37 | ///
38 | /// Gets the libsass language version.
39 | ///
40 | public static string LanguageVersion
41 | {
42 | get { return languageVersion = languageVersion ?? LibSass.libsass_language_version(); }
43 | }
44 |
45 | ///
46 | /// Converts the specified scss content string.
47 | ///
48 | /// A scss content.
49 | /// The options.
50 | /// The result of the conversion
51 | /// if scss is null
52 | public static ScssResult ConvertToCss(string scss, ScssOptions? options = null)
53 | {
54 | if (scss == null) throw new ArgumentNullException(nameof(scss));
55 | return FromCore(scss, false, options);
56 | }
57 |
58 | ///
59 | /// Converts a scss content from the specified scss file.
60 | ///
61 | /// A scss file.
62 | /// The options.
63 | /// The result of the conversion
64 | /// if scss is null
65 | public static ScssResult ConvertFileToCss(string scssFile, ScssOptions? options = null)
66 | {
67 | if (scssFile == null) throw new ArgumentNullException(nameof(scssFile));
68 | return FromCore(scssFile, true, options);
69 | }
70 |
71 | ///
72 | /// Shared conversion method.
73 | ///
74 | /// From string or file.
75 | /// if set to true is a scss file; otherwise it is a scss content.
76 | /// The options.
77 | /// The result of the conversion
78 | private static ScssResult FromCore(string fromStringOrFile, bool fromFile, ScssOptions? options = null)
79 | {
80 | var compiler = new LibSass.Sass_Compiler();
81 | GCHandle? tryImportHandle = null;
82 | var context = new LibSass.Sass_Context();
83 | try
84 | {
85 | options = options ?? DefaultOptions;
86 | if (fromFile)
87 | {
88 | var fileContext = LibSass.sass_make_file_context(fromStringOrFile);
89 | context = fileContext;
90 | var inputFile = options.InputFile ?? fromStringOrFile;
91 | tryImportHandle = MarshalOptions(fileContext, options, inputFile);
92 | compiler = LibSass.sass_make_file_compiler(fileContext);
93 | }
94 | else
95 | {
96 | var dataContext = LibSass.sass_make_data_context(fromStringOrFile);
97 | context = dataContext;
98 | tryImportHandle = MarshalOptions(dataContext, options, options.InputFile);
99 | compiler = LibSass.sass_make_data_compiler(dataContext);
100 | }
101 |
102 | LibSass.sass_compiler_parse(compiler);
103 | CheckStatus(context);
104 |
105 | LibSass.sass_compiler_execute(compiler);
106 | CheckStatus(context);
107 |
108 | // Gets the result of the conversion
109 | var css = LibSass.sass_context_get_output_string(context);
110 |
111 | // Gets the map if it was enabled
112 | string? map = null;
113 | if (options.GenerateSourceMap)
114 | {
115 | map = LibSass.sass_context_get_source_map_string(context);
116 | }
117 |
118 | // Gets the list of included files
119 | var includedFiles = GetIncludedFiles(context);
120 |
121 | // Returns the result
122 | return new ScssResult(css, map, includedFiles);
123 | }
124 | finally
125 | {
126 | // Free any allocations that happened during the compilation
127 | LibSass.SassAllocator.FreeNative();
128 |
129 | // Release the cookie handle if any
130 | if (tryImportHandle.HasValue && tryImportHandle.Value.IsAllocated)
131 | {
132 | tryImportHandle.Value.Free();
133 | }
134 |
135 | if (compiler.Handle != IntPtr.Zero)
136 | {
137 | LibSass.sass_delete_compiler(compiler);
138 | }
139 |
140 | if (context.Handle != IntPtr.Zero)
141 | {
142 | if (fromFile)
143 | {
144 | LibSass.sass_delete_file_context((LibSass.Sass_File_Context)context);
145 | }
146 | else
147 | {
148 | LibSass.sass_delete_data_context((LibSass.Sass_Data_Context)context);
149 | }
150 | }
151 | }
152 | }
153 |
154 | private static unsafe List? GetIncludedFiles(LibSass.Sass_Context context)
155 | {
156 | var filesCount = (int)LibSass.sass_context_get_included_files_size(context);
157 | var files = (LibSass.StringUtf8*)LibSass.sass_context_get_included_files(context);
158 | List? list = null;
159 | for(int i = 0; i < filesCount; i++)
160 | {
161 | if (!files->IsEmpty)
162 | {
163 | list ??= new List();
164 | var fileAsString = (string)(*files)!;
165 | list.Add(fileAsString);
166 | }
167 | files++;
168 | }
169 | return list;
170 | }
171 |
172 | private static void CheckStatus(LibSass.Sass_Context context)
173 | {
174 | int status = LibSass.sass_context_get_error_status(context);
175 | if (status != 0)
176 | {
177 | var column = LibSass.sass_context_get_error_column(context);
178 | var line = LibSass.sass_context_get_error_line(context);
179 | var file = (string) LibSass.sass_context_get_error_file(context);
180 | var message = (string) LibSass.sass_context_get_error_message(context);
181 | var errorText = (string) LibSass.sass_context_get_error_text(context);
182 |
183 | throw new ScssException((int) line, (int) column, file, message, errorText);
184 | }
185 | }
186 |
187 | private static GCHandle? MarshalOptions(LibSass.Sass_Context context, ScssOptions options, string? inputFile)
188 | {
189 | var nativeOptions = LibSass.sass_context_get_options(context);
190 |
191 | // TODO: The C function is not working?
192 | //LibSass.sass_option_set_precision(nativeOptions, options.Precision);
193 | LibSass.sass_option_set_output_style(nativeOptions, (LibSass.Sass_Output_Style)(int)options.OutputStyle);
194 | LibSass.sass_option_set_source_comments(nativeOptions, options.SourceComments);
195 | LibSass.sass_option_set_source_map_embed(nativeOptions, options.SourceMapEmbed);
196 | LibSass.sass_option_set_source_map_contents(nativeOptions, options.SourceMapContents);
197 | LibSass.sass_option_set_omit_source_map_url(nativeOptions, options.OmitSourceMapUrl);
198 | LibSass.sass_option_set_is_indented_syntax_src(nativeOptions, options.IsIndentedSyntaxSource);
199 |
200 | // Handle TryImport
201 | GCHandle? cookieHandle = null;
202 | if (options.TryImport != null)
203 | {
204 | unsafe
205 | {
206 | var importerList = LibSass.sass_make_importer_list(1);
207 | cookieHandle = GCHandle.Alloc(options.TryImport, GCHandleType.Normal);
208 | var cookie = GCHandle.ToIntPtr(cookieHandle.Value);
209 |
210 | var importer = LibSass.sass_make_importer(ScssImporterLock, 0, cookie);
211 | LibSass.sass_importer_set_list_entry(importerList, 0, importer);
212 | LibSass.sass_option_set_c_importers(nativeOptions, importerList);
213 | // TODO: Should we deallocate with sass_delete_importer at some point?
214 | }
215 | }
216 |
217 | if (options.Indent != null)
218 | {
219 | LibSass.sass_option_set_indent(nativeOptions, options.Indent);
220 | }
221 | if (options.Linefeed != null)
222 | {
223 | LibSass.sass_option_set_linefeed(nativeOptions, options.Linefeed);
224 | }
225 | if (inputFile != null)
226 | {
227 | inputFile = GetRootedPath(inputFile);
228 | LibSass.sass_option_set_input_path(nativeOptions, inputFile);
229 | }
230 | string? outputFile = options.OutputFile;
231 | if (outputFile != null)
232 | {
233 | outputFile = GetRootedPath(outputFile);
234 | LibSass.sass_option_set_output_path(nativeOptions, outputFile);
235 | }
236 | if (options.IncludePaths.Count > 0)
237 | {
238 | foreach (var path in options.IncludePaths)
239 | {
240 | var fullPath = GetRootedPath(path);
241 | LibSass.sass_option_push_include_path(nativeOptions, fullPath);
242 | }
243 | }
244 | if (options.GenerateSourceMap)
245 | {
246 | var sourceMapFile = GetRootedPath(options.SourceMapFile ?? (outputFile ?? "result.css") + ".map");
247 | LibSass.sass_option_set_source_map_file(nativeOptions, sourceMapFile);
248 | }
249 | if (options.SourceMapRoot != null)
250 | {
251 | LibSass.sass_option_set_source_map_root(nativeOptions, options.SourceMapRoot);
252 | }
253 |
254 | return cookieHandle;
255 | }
256 |
257 | private static string GetRootedPath(string path)
258 | {
259 | return !Path.IsPathRooted(path) ? Path.Combine(Directory.GetCurrentDirectory(), path) : path;
260 | }
261 |
262 | private static unsafe LibSass.Sass_Import_List CustomScssImporter(string currentPath, LibSass.Sass_Importer_Entry cb, LibSass.Sass_Compiler compiler)
263 | {
264 | var cookie = LibSass.sass_importer_get_cookie(cb);
265 |
266 | var previous = LibSass.sass_compiler_get_last_import(compiler);
267 | string previousPath = LibSass.sass_import_get_abs_path(previous);
268 |
269 | var cookieHandle = GCHandle.FromIntPtr(cookie);
270 | var tryImport = (ScssOptions.TryImportDelegate?)cookieHandle.Target;
271 |
272 | var file = (string)currentPath;
273 | var importList = LibSass.sass_make_import_list(1);
274 | uint line = 0;
275 | uint column = 0;
276 | string? errorMessage = null;
277 | if (tryImport != null)
278 | {
279 | try
280 | {
281 | string scss;
282 | string? map;
283 | if (tryImport(ref file, previousPath, out scss, out map))
284 | {
285 | var entry = LibSass.sass_make_import(currentPath, file, scss, map ?? "");
286 | *(LibSass.Sass_Import_Entry*)importList.Value = entry;
287 | return importList;
288 | }
289 | }
290 | catch (ScssException ex)
291 | {
292 | errorMessage = ex.Message;
293 | line = (uint)ex.Line;
294 | column = (uint)ex.Column;
295 | }
296 | catch (Exception ex)
297 | {
298 | errorMessage = ex.ToString();
299 | }
300 | }
301 |
302 | if (errorMessage == null)
303 | {
304 | errorMessage = $"Unable to find include file for @import \"{file}\" with dynamic import";
305 | }
306 | {
307 | var entry = LibSass.sass_make_import(file, "","", "");
308 | *(LibSass.Sass_Import_Entry*)importList.Value = entry;
309 |
310 | LibSass.sass_import_set_error(entry, errorMessage, line, column);
311 | }
312 | return importList;
313 | }
314 | }
--------------------------------------------------------------------------------
/src/SharpScss/ScssException.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Alexandre Mutel. All rights reserved.
2 | // This file is licensed under the BSD-Clause 2 license.
3 | // See the license.txt file in the project root for more information.
4 |
5 | using System;
6 |
7 | namespace SharpScss;
8 |
9 | ///
10 | /// Exception used by to report errors from libsass.
11 | ///
12 | public class ScssException : Exception
13 | {
14 | ///
15 | /// Initializes a new instance of the class.
16 | ///
17 | /// The line.
18 | /// The column.
19 | /// The file.
20 | /// The message that describes the error.
21 | /// The error text.
22 | public ScssException(int line, int column, string file, string message, string errorText) : base(message)
23 | {
24 | Line = line;
25 | Column = column;
26 | File = file;
27 | ErrorText = errorText;
28 | }
29 |
30 | ///
31 | /// Gets the line the exception occured.
32 | ///
33 | public int Line { get; }
34 |
35 | ///
36 | /// Gets the column the exception occured.
37 | ///
38 | public int Column { get; }
39 |
40 | ///
41 | /// Gets the file the exception occured.
42 | ///
43 | public string File { get; }
44 |
45 | ///
46 | /// Gets a short error message describing the error. For a full message use the property.
47 | ///
48 | public string ErrorText { get; set; }
49 | }
--------------------------------------------------------------------------------
/src/SharpScss/ScssOptions.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Alexandre Mutel. All rights reserved.
2 | // This file is licensed under the BSD-Clause 2 license.
3 | // See the license.txt file in the project root for more information.
4 |
5 | using System.Collections.Generic;
6 |
7 | namespace SharpScss;
8 |
9 | ///
10 | /// Options used by and .
11 | ///
12 | public class ScssOptions
13 | {
14 | ///
15 | /// Delegates that tries to import the specified file.
16 | ///
17 | /// The file to import. The fully resolved path can be modified by this delegate by re-assigning the to the path fully resolved.
18 | /// The path of the parent file that is trying to import .
19 | /// The output scss if import was found.
20 | /// The output map if import was found. May be null
21 | /// true if import was found; false otherwise
22 | public delegate bool TryImportDelegate(ref string file, string parentPath, out string scss, out string? map);
23 |
24 | ///
25 | /// Initializes a new instance of the class.
26 | ///
27 | public ScssOptions()
28 | {
29 | //Precision = 5;
30 | OutputStyle = ScssOutputStyle.Nested;
31 | IncludePaths = new List();
32 | Indent = " ";
33 | Linefeed = "\n";
34 | }
35 |
36 | /////
37 | ///// Gets or sets the maximum number of digits after the decimal. Default is 5.
38 | ///// TODO: the C function is not working
39 | /////
40 | //public int Precision { get; set; }
41 |
42 | ///
43 | /// Gets or sets the output style. Default is
44 | ///
45 | public ScssOutputStyle OutputStyle { get; set; }
46 |
47 | ///
48 | /// Gets or sets a value indicating whether to generate source map (result in
49 | ///
50 | ///
51 | /// Note that should be setup. will then automatically
52 | /// map to + ".map" unless specified.
53 | ///
54 | public bool GenerateSourceMap { get; set; }
55 |
56 | ///
57 | /// Gets or sets a value indicating whether to enable additional debugging information in the output file as CSS comments. Default is false
58 | ///
59 | public bool SourceComments { get; set; }
60 |
61 | ///
62 | /// Gets or sets a value indicating whether to embed the source map as a data URI. Default is false
63 | ///
64 | public bool SourceMapEmbed { get; set; }
65 |
66 | ///
67 | /// Gets or sets a value indicating whether to include the contents in the source map information. Default is false
68 | ///
69 | public bool SourceMapContents { get; set; }
70 |
71 | ///
72 | /// Gets or sets a value indicating whether to enable or disable the inclusion of source map information in the output file. Default is false
73 | ///
74 | ///
75 | /// If this is set to true, the must be setup to avoid unexpected behavior.
76 | ///
77 | public bool OmitSourceMapUrl { get; set; }
78 |
79 | ///
80 | /// Gets or sets a value indicating whether the scss content to transform is using indented syntax.
81 | ///
82 | public bool IsIndentedSyntaxSource { get; set; }
83 |
84 | ///
85 | /// Gets or sets the indent string. Default is 2 spaces.
86 | ///
87 | public string? Indent { get; set; }
88 |
89 | ///
90 | /// Gets or sets the linefeed. Default is LF (\n)
91 | ///
92 | public string? Linefeed { get; set; }
93 |
94 | ///
95 | /// Gets or sets the name of the input file. See remarks for more information.
96 | ///
97 | ///
98 | /// This is recommended when so that they can properly refer back to their intended files.
99 | /// Note also that this is not used to load the data from a file. Use instead.
100 | ///
101 | public string? InputFile { get; set; }
102 |
103 | ///
104 | /// Gets or sets the location of the output file. This is recommended when so that they can properly refer back to their intended files.
105 | ///
106 | public string? OutputFile { get; set; }
107 |
108 | ///
109 | /// Gets or sets the intended location of the source map file. Note that is used when is set. By default, if this property is not set,
110 | /// the + ".map" extension will be used. Default is null
111 | ///
112 | public string? SourceMapFile { get; set; }
113 |
114 | ///
115 | /// Gets or sets the value that will be emitted as sourceRoot in the source map information. Default is null.
116 | ///
117 | public string? SourceMapRoot { get; set; }
118 |
119 | ///
120 | /// Gets the include paths that will be used to search for @import directives in scss content.
121 | ///
122 | public List IncludePaths { get; }
123 |
124 | ///
125 | /// Gets or sets a dynamic delegate used to resolve imports dynamically.
126 | ///
127 | public TryImportDelegate? TryImport { get; set; }
128 | }
--------------------------------------------------------------------------------
/src/SharpScss/ScssOutputStyle.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Alexandre Mutel. All rights reserved.
2 | // This file is licensed under the BSD-Clause 2 license.
3 | // See the license.txt file in the project root for more information.
4 | namespace SharpScss;
5 |
6 | ///
7 | /// Determines the output format of the final CSS style used by and .
8 | ///
9 | public enum ScssOutputStyle
10 | {
11 | ///
12 | /// Nested format.
13 | ///
14 | Nested = 0,
15 |
16 | ///
17 | /// Expanded format.
18 | ///
19 | Expanded = 1,
20 |
21 | ///
22 | /// Compact format.
23 | ///
24 | Compact = 2,
25 |
26 | ///
27 | /// Compressed format.
28 | ///
29 | Compressed = 3,
30 |
31 | ///
32 | /// TODO: No documentation.
33 | ///
34 | Inspect = 4,
35 |
36 | ///
37 | /// TODO: No documentation.
38 | ///
39 | Sass = 5
40 | }
--------------------------------------------------------------------------------
/src/SharpScss/ScssResult.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Alexandre Mutel. All rights reserved.
2 | // This file is licensed under the BSD-Clause 2 license.
3 | // See the license.txt file in the project root for more information.
4 |
5 | using System.Collections.Generic;
6 |
7 | namespace SharpScss;
8 |
9 | ///
10 | /// The result of CSS rendering by and .
11 | ///
12 | public struct ScssResult
13 | {
14 | ///
15 | /// Initializes a new instance of the struct.
16 | ///
17 | /// The Css.
18 | /// The source SourceMap.
19 | /// The included files.
20 | public ScssResult(string css, string? sourceMap, List? includedFiles)
21 | {
22 | Css = css;
23 | SourceMap = sourceMap;
24 | IncludedFiles = includedFiles;
25 | }
26 |
27 | ///
28 | /// Gets the generated CSS.
29 | ///
30 | public string Css { get; }
31 |
32 | ///
33 | /// Gets the source map (may be null if was false.
34 | ///
35 | public string? SourceMap { get; }
36 |
37 | ///
38 | /// Gets the included files used to generate this result when converting the input scss content.
39 | ///
40 | public List? IncludedFiles { get; }
41 | }
--------------------------------------------------------------------------------
/src/SharpScss/SharpScss.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Library
5 | netstandard2.0;net8.0
6 | true
7 | enable
8 | 11.0
9 |
10 |
11 | True
12 | true
13 |
14 |
15 |
16 | A P/Invoke .NET wrapper around libsass to convert SCSS to CSS for .NET
17 | Alexandre Mutel
18 | en-US
19 | Alexandre Mutel
20 | libsass;SCSS;SASS;CSS
21 | readme.md
22 | SharpScss.png
23 | https://github.com/xoofx/SharpScss
24 | BSD-2-Clause
25 |
26 | true
27 | true
28 | snupkg
29 |
30 |
31 |
32 |
33 | %(Identity)
34 | true
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 | true
45 | key.snk
46 | true
47 | true
48 |
49 |
50 |
51 |
52 | all
53 | runtime; build; native; contentfiles; analyzers; buildtransitive
54 |
55 |
56 |
57 |
58 |
59 | all
60 | runtime; build; native; contentfiles; analyzers; buildtransitive
61 |
62 |
63 |
64 |
--------------------------------------------------------------------------------
/src/SharpScss/SharpScss.xproj.DotSettings:
--------------------------------------------------------------------------------
1 |
2 | False
--------------------------------------------------------------------------------
/src/SharpScss/build/net20-35-40/SharpScss.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | win-x86
5 | linux-x64
6 | win-x64
7 |
8 |
9 |
10 | %(Filename)%(Extension)
11 | Always
12 | False
13 |
14 |
15 |
--------------------------------------------------------------------------------
/src/SharpScss/key.snk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xoofx/SharpScss/ebf2cb0dc6fb1e2c69b8a661c274c1039e2ee5ca/src/SharpScss/key.snk
--------------------------------------------------------------------------------
/src/SharpScss/runtimes/linux-arm/native/libsass.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xoofx/SharpScss/ebf2cb0dc6fb1e2c69b8a661c274c1039e2ee5ca/src/SharpScss/runtimes/linux-arm/native/libsass.so
--------------------------------------------------------------------------------
/src/SharpScss/runtimes/linux-arm64/native/libsass.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xoofx/SharpScss/ebf2cb0dc6fb1e2c69b8a661c274c1039e2ee5ca/src/SharpScss/runtimes/linux-arm64/native/libsass.so
--------------------------------------------------------------------------------
/src/SharpScss/runtimes/linux-musl-arm64/native/libsass.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xoofx/SharpScss/ebf2cb0dc6fb1e2c69b8a661c274c1039e2ee5ca/src/SharpScss/runtimes/linux-musl-arm64/native/libsass.so
--------------------------------------------------------------------------------
/src/SharpScss/runtimes/linux-musl-x64/native/libsass.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xoofx/SharpScss/ebf2cb0dc6fb1e2c69b8a661c274c1039e2ee5ca/src/SharpScss/runtimes/linux-musl-x64/native/libsass.so
--------------------------------------------------------------------------------
/src/SharpScss/runtimes/linux-x64/native/libsass.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xoofx/SharpScss/ebf2cb0dc6fb1e2c69b8a661c274c1039e2ee5ca/src/SharpScss/runtimes/linux-x64/native/libsass.so
--------------------------------------------------------------------------------
/src/SharpScss/runtimes/osx-arm64/native/libsass.dylib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xoofx/SharpScss/ebf2cb0dc6fb1e2c69b8a661c274c1039e2ee5ca/src/SharpScss/runtimes/osx-arm64/native/libsass.dylib
--------------------------------------------------------------------------------
/src/SharpScss/runtimes/osx-x64/native/libsass.dylib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xoofx/SharpScss/ebf2cb0dc6fb1e2c69b8a661c274c1039e2ee5ca/src/SharpScss/runtimes/osx-x64/native/libsass.dylib
--------------------------------------------------------------------------------
/src/SharpScss/runtimes/win-arm/native/libsass.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xoofx/SharpScss/ebf2cb0dc6fb1e2c69b8a661c274c1039e2ee5ca/src/SharpScss/runtimes/win-arm/native/libsass.dll
--------------------------------------------------------------------------------
/src/SharpScss/runtimes/win-arm64/native/libsass.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xoofx/SharpScss/ebf2cb0dc6fb1e2c69b8a661c274c1039e2ee5ca/src/SharpScss/runtimes/win-arm64/native/libsass.dll
--------------------------------------------------------------------------------
/src/SharpScss/runtimes/win-x64/native/libsass.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xoofx/SharpScss/ebf2cb0dc6fb1e2c69b8a661c274c1039e2ee5ca/src/SharpScss/runtimes/win-x64/native/libsass.dll
--------------------------------------------------------------------------------
/src/SharpScss/runtimes/win-x86/native/libsass.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xoofx/SharpScss/ebf2cb0dc6fb1e2c69b8a661c274c1039e2ee5ca/src/SharpScss/runtimes/win-x86/native/libsass.dll
--------------------------------------------------------------------------------
/src/dotnet-releaser.toml:
--------------------------------------------------------------------------------
1 | # configuration file for dotnet-releaser
2 | # Disable default packs - It will only publish NuGet and the Changelog
3 | [msbuild]
4 | project = "SharpScss.sln"
5 | [github]
6 | user = "xoofx"
7 | repo = "SharpScss"
--------------------------------------------------------------------------------
/src/global.json:
--------------------------------------------------------------------------------
1 | {
2 | "sdk": {
3 | "version": "8.0.100",
4 | "rollForward": "latestMinor",
5 | "allowPrerelease": false
6 | }
7 | }
--------------------------------------------------------------------------------