sassc 2.0.0 → 2.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (260) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/.gitmodules +1 -1
  4. data/.travis.yml +9 -3
  5. data/CHANGELOG.md +36 -0
  6. data/CODE_OF_CONDUCT.md +1 -1
  7. data/README.md +1 -1
  8. data/Rakefile +43 -7
  9. data/ext/depend +4 -0
  10. data/ext/extconf.rb +92 -0
  11. data/ext/libsass/VERSION +1 -0
  12. data/ext/libsass/include/sass/base.h +9 -1
  13. data/ext/libsass/include/sass/context.h +5 -1
  14. data/ext/libsass/src/MurmurHash2.hpp +91 -0
  15. data/ext/libsass/src/ast.cpp +755 -2028
  16. data/ext/libsass/src/ast.hpp +492 -2477
  17. data/ext/libsass/src/{to_c.cpp → ast2c.cpp} +22 -16
  18. data/ext/libsass/src/ast2c.hpp +39 -0
  19. data/ext/libsass/src/ast_def_macros.hpp +70 -10
  20. data/ext/libsass/src/ast_fwd_decl.cpp +5 -3
  21. data/ext/libsass/src/ast_fwd_decl.hpp +107 -296
  22. data/ext/libsass/src/ast_helpers.hpp +292 -0
  23. data/ext/libsass/src/ast_sel_cmp.cpp +396 -0
  24. data/ext/libsass/src/ast_sel_super.cpp +539 -0
  25. data/ext/libsass/src/ast_sel_unify.cpp +275 -0
  26. data/ext/libsass/src/ast_sel_weave.cpp +616 -0
  27. data/ext/libsass/src/ast_selectors.cpp +1043 -0
  28. data/ext/libsass/src/ast_selectors.hpp +522 -0
  29. data/ext/libsass/src/ast_supports.cpp +114 -0
  30. data/ext/libsass/src/ast_supports.hpp +121 -0
  31. data/ext/libsass/src/ast_values.cpp +1154 -0
  32. data/ext/libsass/src/ast_values.hpp +498 -0
  33. data/ext/libsass/src/backtrace.cpp +11 -7
  34. data/ext/libsass/src/backtrace.hpp +5 -5
  35. data/ext/libsass/src/base64vlq.cpp +5 -2
  36. data/ext/libsass/src/base64vlq.hpp +1 -1
  37. data/ext/libsass/src/bind.cpp +35 -34
  38. data/ext/libsass/src/bind.hpp +3 -1
  39. data/ext/libsass/src/c2ast.cpp +64 -0
  40. data/ext/libsass/src/c2ast.hpp +14 -0
  41. data/ext/libsass/src/cencode.c +4 -6
  42. data/ext/libsass/src/check_nesting.cpp +83 -88
  43. data/ext/libsass/src/check_nesting.hpp +39 -34
  44. data/ext/libsass/src/color_maps.cpp +168 -164
  45. data/ext/libsass/src/color_maps.hpp +152 -160
  46. data/ext/libsass/src/constants.cpp +20 -0
  47. data/ext/libsass/src/constants.hpp +19 -0
  48. data/ext/libsass/src/context.cpp +104 -121
  49. data/ext/libsass/src/context.hpp +43 -55
  50. data/ext/libsass/src/cssize.cpp +103 -188
  51. data/ext/libsass/src/cssize.hpp +45 -51
  52. data/ext/libsass/src/dart_helpers.hpp +199 -0
  53. data/ext/libsass/src/debugger.hpp +524 -361
  54. data/ext/libsass/src/emitter.cpp +26 -26
  55. data/ext/libsass/src/emitter.hpp +20 -18
  56. data/ext/libsass/src/environment.cpp +41 -27
  57. data/ext/libsass/src/environment.hpp +33 -22
  58. data/ext/libsass/src/error_handling.cpp +92 -94
  59. data/ext/libsass/src/error_handling.hpp +73 -50
  60. data/ext/libsass/src/eval.cpp +380 -515
  61. data/ext/libsass/src/eval.hpp +64 -57
  62. data/ext/libsass/src/eval_selectors.cpp +75 -0
  63. data/ext/libsass/src/expand.cpp +322 -263
  64. data/ext/libsass/src/expand.hpp +55 -39
  65. data/ext/libsass/src/extender.cpp +1188 -0
  66. data/ext/libsass/src/extender.hpp +399 -0
  67. data/ext/libsass/src/extension.cpp +43 -0
  68. data/ext/libsass/src/extension.hpp +89 -0
  69. data/ext/libsass/src/file.cpp +134 -88
  70. data/ext/libsass/src/file.hpp +28 -37
  71. data/ext/libsass/src/fn_colors.cpp +596 -0
  72. data/ext/libsass/src/fn_colors.hpp +85 -0
  73. data/ext/libsass/src/fn_lists.cpp +285 -0
  74. data/ext/libsass/src/fn_lists.hpp +34 -0
  75. data/ext/libsass/src/fn_maps.cpp +94 -0
  76. data/ext/libsass/src/fn_maps.hpp +30 -0
  77. data/ext/libsass/src/fn_miscs.cpp +244 -0
  78. data/ext/libsass/src/fn_miscs.hpp +40 -0
  79. data/ext/libsass/src/fn_numbers.cpp +227 -0
  80. data/ext/libsass/src/fn_numbers.hpp +45 -0
  81. data/ext/libsass/src/fn_selectors.cpp +205 -0
  82. data/ext/libsass/src/fn_selectors.hpp +35 -0
  83. data/ext/libsass/src/fn_strings.cpp +268 -0
  84. data/ext/libsass/src/fn_strings.hpp +34 -0
  85. data/ext/libsass/src/fn_utils.cpp +158 -0
  86. data/ext/libsass/src/fn_utils.hpp +62 -0
  87. data/ext/libsass/src/inspect.cpp +253 -266
  88. data/ext/libsass/src/inspect.hpp +72 -74
  89. data/ext/libsass/src/json.cpp +2 -2
  90. data/ext/libsass/src/lexer.cpp +25 -84
  91. data/ext/libsass/src/lexer.hpp +5 -16
  92. data/ext/libsass/src/listize.cpp +27 -43
  93. data/ext/libsass/src/listize.hpp +14 -11
  94. data/ext/libsass/src/mapping.hpp +1 -0
  95. data/ext/libsass/src/memory.hpp +12 -0
  96. data/ext/libsass/src/memory/allocator.cpp +48 -0
  97. data/ext/libsass/src/memory/allocator.hpp +138 -0
  98. data/ext/libsass/src/memory/config.hpp +20 -0
  99. data/ext/libsass/src/memory/memory_pool.hpp +186 -0
  100. data/ext/libsass/src/memory/shared_ptr.cpp +33 -0
  101. data/ext/libsass/src/memory/shared_ptr.hpp +332 -0
  102. data/ext/libsass/src/operation.hpp +193 -143
  103. data/ext/libsass/src/operators.cpp +56 -29
  104. data/ext/libsass/src/operators.hpp +11 -11
  105. data/ext/libsass/src/ordered_map.hpp +112 -0
  106. data/ext/libsass/src/output.cpp +59 -75
  107. data/ext/libsass/src/output.hpp +15 -22
  108. data/ext/libsass/src/parser.cpp +662 -818
  109. data/ext/libsass/src/parser.hpp +96 -100
  110. data/ext/libsass/src/parser_selectors.cpp +189 -0
  111. data/ext/libsass/src/permutate.hpp +164 -0
  112. data/ext/libsass/src/plugins.cpp +12 -8
  113. data/ext/libsass/src/plugins.hpp +8 -8
  114. data/ext/libsass/src/position.cpp +10 -26
  115. data/ext/libsass/src/position.hpp +44 -21
  116. data/ext/libsass/src/prelexer.cpp +14 -8
  117. data/ext/libsass/src/prelexer.hpp +9 -9
  118. data/ext/libsass/src/remove_placeholders.cpp +59 -57
  119. data/ext/libsass/src/remove_placeholders.hpp +20 -18
  120. data/ext/libsass/src/sass.cpp +25 -18
  121. data/ext/libsass/src/sass.hpp +22 -14
  122. data/ext/libsass/src/sass2scss.cpp +49 -18
  123. data/ext/libsass/src/sass_context.cpp +104 -132
  124. data/ext/libsass/src/sass_context.hpp +2 -2
  125. data/ext/libsass/src/sass_functions.cpp +7 -4
  126. data/ext/libsass/src/sass_functions.hpp +1 -1
  127. data/ext/libsass/src/sass_values.cpp +26 -21
  128. data/ext/libsass/src/settings.hpp +19 -0
  129. data/ext/libsass/src/source.cpp +69 -0
  130. data/ext/libsass/src/source.hpp +95 -0
  131. data/ext/libsass/src/source_data.hpp +32 -0
  132. data/ext/libsass/src/source_map.cpp +27 -20
  133. data/ext/libsass/src/source_map.hpp +14 -11
  134. data/ext/libsass/src/stylesheet.cpp +22 -0
  135. data/ext/libsass/src/stylesheet.hpp +57 -0
  136. data/ext/libsass/src/to_value.cpp +24 -22
  137. data/ext/libsass/src/to_value.hpp +18 -22
  138. data/ext/libsass/src/units.cpp +28 -22
  139. data/ext/libsass/src/units.hpp +9 -8
  140. data/ext/libsass/src/utf8/checked.h +12 -10
  141. data/ext/libsass/src/utf8/core.h +3 -0
  142. data/ext/libsass/src/utf8_string.cpp +12 -10
  143. data/ext/libsass/src/utf8_string.hpp +7 -6
  144. data/ext/libsass/src/util.cpp +97 -107
  145. data/ext/libsass/src/util.hpp +74 -30
  146. data/ext/libsass/src/util_string.cpp +125 -0
  147. data/ext/libsass/src/util_string.hpp +73 -0
  148. data/ext/libsass/src/values.cpp +33 -24
  149. data/ext/libsass/src/values.hpp +2 -2
  150. data/lib/sassc.rb +24 -0
  151. data/lib/sassc/engine.rb +7 -5
  152. data/lib/sassc/functions_handler.rb +11 -13
  153. data/lib/sassc/native.rb +10 -9
  154. data/lib/sassc/native/native_functions_api.rb +0 -5
  155. data/lib/sassc/script.rb +4 -6
  156. data/lib/sassc/version.rb +1 -1
  157. data/sassc.gemspec +32 -12
  158. data/test/engine_test.rb +32 -2
  159. data/test/functions_test.rb +38 -1
  160. data/test/native_test.rb +4 -4
  161. metadata +95 -109
  162. data/ext/Rakefile +0 -3
  163. data/ext/libsass/.editorconfig +0 -15
  164. data/ext/libsass/.gitattributes +0 -2
  165. data/ext/libsass/.github/CONTRIBUTING.md +0 -65
  166. data/ext/libsass/.github/ISSUE_TEMPLATE.md +0 -54
  167. data/ext/libsass/.gitignore +0 -85
  168. data/ext/libsass/.travis.yml +0 -64
  169. data/ext/libsass/COPYING +0 -25
  170. data/ext/libsass/GNUmakefile.am +0 -88
  171. data/ext/libsass/INSTALL +0 -1
  172. data/ext/libsass/LICENSE +0 -25
  173. data/ext/libsass/Makefile +0 -351
  174. data/ext/libsass/Makefile.conf +0 -55
  175. data/ext/libsass/Readme.md +0 -104
  176. data/ext/libsass/SECURITY.md +0 -10
  177. data/ext/libsass/appveyor.yml +0 -91
  178. data/ext/libsass/configure.ac +0 -138
  179. data/ext/libsass/contrib/libsass.spec +0 -66
  180. data/ext/libsass/docs/README.md +0 -20
  181. data/ext/libsass/docs/api-context-example.md +0 -45
  182. data/ext/libsass/docs/api-context-internal.md +0 -163
  183. data/ext/libsass/docs/api-context.md +0 -295
  184. data/ext/libsass/docs/api-doc.md +0 -215
  185. data/ext/libsass/docs/api-function-example.md +0 -67
  186. data/ext/libsass/docs/api-function-internal.md +0 -8
  187. data/ext/libsass/docs/api-function.md +0 -74
  188. data/ext/libsass/docs/api-importer-example.md +0 -112
  189. data/ext/libsass/docs/api-importer-internal.md +0 -20
  190. data/ext/libsass/docs/api-importer.md +0 -86
  191. data/ext/libsass/docs/api-value-example.md +0 -55
  192. data/ext/libsass/docs/api-value-internal.md +0 -76
  193. data/ext/libsass/docs/api-value.md +0 -154
  194. data/ext/libsass/docs/build-on-darwin.md +0 -27
  195. data/ext/libsass/docs/build-on-gentoo.md +0 -55
  196. data/ext/libsass/docs/build-on-windows.md +0 -139
  197. data/ext/libsass/docs/build-shared-library.md +0 -35
  198. data/ext/libsass/docs/build-with-autotools.md +0 -78
  199. data/ext/libsass/docs/build-with-makefiles.md +0 -68
  200. data/ext/libsass/docs/build-with-mingw.md +0 -107
  201. data/ext/libsass/docs/build-with-visual-studio.md +0 -90
  202. data/ext/libsass/docs/build.md +0 -97
  203. data/ext/libsass/docs/compatibility-plan.md +0 -48
  204. data/ext/libsass/docs/contributing.md +0 -17
  205. data/ext/libsass/docs/custom-functions-internal.md +0 -122
  206. data/ext/libsass/docs/dev-ast-memory.md +0 -223
  207. data/ext/libsass/docs/implementations.md +0 -56
  208. data/ext/libsass/docs/plugins.md +0 -47
  209. data/ext/libsass/docs/setup-environment.md +0 -68
  210. data/ext/libsass/docs/source-map-internals.md +0 -51
  211. data/ext/libsass/docs/trace.md +0 -26
  212. data/ext/libsass/docs/triage.md +0 -17
  213. data/ext/libsass/docs/unicode.md +0 -39
  214. data/ext/libsass/extconf.rb +0 -6
  215. data/ext/libsass/include/sass/version.h.in +0 -12
  216. data/ext/libsass/m4/.gitkeep +0 -0
  217. data/ext/libsass/m4/m4-ax_cxx_compile_stdcxx_11.m4 +0 -167
  218. data/ext/libsass/res/resource.rc +0 -35
  219. data/ext/libsass/script/bootstrap +0 -13
  220. data/ext/libsass/script/branding +0 -10
  221. data/ext/libsass/script/ci-build-libsass +0 -134
  222. data/ext/libsass/script/ci-build-plugin +0 -62
  223. data/ext/libsass/script/ci-install-compiler +0 -6
  224. data/ext/libsass/script/ci-install-deps +0 -20
  225. data/ext/libsass/script/ci-report-coverage +0 -42
  226. data/ext/libsass/script/spec +0 -5
  227. data/ext/libsass/script/tap-driver +0 -652
  228. data/ext/libsass/script/tap-runner +0 -1
  229. data/ext/libsass/script/test-leaks.pl +0 -103
  230. data/ext/libsass/src/GNUmakefile.am +0 -54
  231. data/ext/libsass/src/extend.cpp +0 -2130
  232. data/ext/libsass/src/extend.hpp +0 -86
  233. data/ext/libsass/src/functions.cpp +0 -2234
  234. data/ext/libsass/src/functions.hpp +0 -198
  235. data/ext/libsass/src/memory/SharedPtr.cpp +0 -114
  236. data/ext/libsass/src/memory/SharedPtr.hpp +0 -206
  237. data/ext/libsass/src/node.cpp +0 -319
  238. data/ext/libsass/src/node.hpp +0 -118
  239. data/ext/libsass/src/paths.hpp +0 -71
  240. data/ext/libsass/src/sass_util.cpp +0 -149
  241. data/ext/libsass/src/sass_util.hpp +0 -256
  242. data/ext/libsass/src/subset_map.cpp +0 -55
  243. data/ext/libsass/src/subset_map.hpp +0 -76
  244. data/ext/libsass/src/support/libsass.pc.in +0 -11
  245. data/ext/libsass/src/to_c.hpp +0 -39
  246. data/ext/libsass/test/test_node.cpp +0 -94
  247. data/ext/libsass/test/test_paths.cpp +0 -28
  248. data/ext/libsass/test/test_selector_difference.cpp +0 -25
  249. data/ext/libsass/test/test_specificity.cpp +0 -25
  250. data/ext/libsass/test/test_subset_map.cpp +0 -472
  251. data/ext/libsass/test/test_superselector.cpp +0 -69
  252. data/ext/libsass/test/test_unification.cpp +0 -31
  253. data/ext/libsass/version.sh +0 -10
  254. data/ext/libsass/win/libsass.sln +0 -39
  255. data/ext/libsass/win/libsass.sln.DotSettings +0 -9
  256. data/ext/libsass/win/libsass.targets +0 -118
  257. data/ext/libsass/win/libsass.vcxproj +0 -188
  258. data/ext/libsass/win/libsass.vcxproj.filters +0 -357
  259. data/lib/sassc/native/lib_c.rb +0 -21
  260. data/lib/tasks/libsass.rb +0 -33
@@ -1,97 +0,0 @@
1
- `libsass` is only a library and does not do much on its own. You need an implementation that you can use from the [command line][6]. Or some [bindings|Implementations][9] to use it within your favorite programming language. You should be able to get [`sassc`][6] running by following the instructions in this guide.
2
-
3
- Before starting, see [setup dev environment](setup-environment.md).
4
-
5
- Building on different Operating Systems
6
- --
7
-
8
- We try to keep the code as OS independent and standard compliant as possible. Reading files from the file-system has some OS depending code, but will ultimately fall back to a posix compatible implementation. We do use some `C++11` features, but are so far only committed to use `unordered_map`. This means you will need a pretty recent compiler on most systems (gcc 4.5 seems to be the minimum).
9
-
10
- ### Building on Linux (and other *nix flavors)
11
-
12
- Linux is the main target for `libsass` and we support two ways to build `libsass` here. The old plain makefiles should still work on most systems (including MinGW), while the autotools build is preferred if you want to create a [system library] (experimental).
13
-
14
- - [Building with makefiles][1]
15
- - [Building with autotools][2]
16
-
17
- ### Building on Windows (experimental)
18
-
19
- Windows build support was added very recently and should be considered experimental. Credits go to @darrenkopp and @am11 for their work on getting `libsass` and `sassc` to compile with visual studio!
20
-
21
- - [Building with MinGW][3]
22
- - [Building with Visual Studio][11]
23
-
24
- ### Building on Max OS X (untested)
25
-
26
- Works the same as on linux, but you can also install LibSass via `homebrew`.
27
-
28
- - [Building on Mac OS X][10]
29
-
30
- ### Building a system library (experimental)
31
-
32
- Since `libsass` is a library, it makes sense to install it as a shared library on your system. On linux this means creating a `.so` library via autotools. This should work pretty well already, but we are not yet committed to keep the ABI 100% stable. This should be the case once we increase the version number for the library to 1.0.0 or higher. On Windows you should be able get a `dll` by creating a shared build with MinGW. There is currently no target in the MSVC project files to do this.
33
-
34
- - [Building shared system library][4]
35
-
36
- Compiling with clang instead of gcc
37
- --
38
-
39
- To use clang you just need to set the appropriate environment variables:
40
-
41
- ```bash
42
- export CC=/usr/bin/clang
43
- export CXX=/usr/bin/clang++
44
- ```
45
-
46
- Running the spec test-suite
47
- --
48
-
49
- We constantly and automatically test `libsass` against the official [spec test-suite][5]. To do this we need to have a test-runner (which is written in ruby) and a command-line tool ([`sassc`][6]) to run the tests. Therefore we need to additionally compile `sassc`. To do this, the build files of all three projects need to work together. This may not have the same quality for all build flavors. You definitely need to have ruby (2.1?) installed (version 1.9 seems to cause problems at least on windows). You also need some gems installed:
50
-
51
- ```bash
52
- ruby -v
53
- gem install minitest
54
- # should be optional
55
- gem install minitap
56
- ```
57
-
58
- Including the LibSass version
59
- --
60
-
61
- There is a function in `libsass` to query the current version. This has to be defined at compile time. We use a C macro for this, which can be defined by calling `g++ -DLIBSASS_VERSION="\"x.y.z.\""`. The two quotes are necessary, since it needs to end up as a valid C string. Normally you do not need to do anything if you use the makefiles or autotools. They will try to fetch the version via git directly. If you only have the sources without the git repo, you can pass the version as an environment variable to `make` or `configure`:
62
-
63
- ```
64
- export LIBSASS_VERSION="x.y.z."
65
- ```
66
-
67
- Continuous Integration
68
- --
69
-
70
- We use two CI services to automatically test all commits against the latest [spec test-suite][5].
71
-
72
- - [LibSass on Travis-CI (linux)][7]
73
- [![Build Status](https://travis-ci.org/sass/libsass.png?branch=master)](https://travis-ci.org/sass/libsass)
74
- - [LibSass on AppVeyor (windows)][8]
75
- [![Build status](https://ci.appveyor.com/api/projects/status/github/sass/libsass?svg=true)](https://ci.appveyor.com/project/mgreter/libsass-513/branch/master)
76
-
77
- Why not using CMake?
78
- --
79
-
80
- There were some efforts to get `libsass` to compile with CMake, which should make it easier to create build files for linux and windows. Unfortunately this was not completed. But we are certainly open for PRs!
81
-
82
- Miscellaneous
83
- --
84
-
85
- - [Ebuilds for Gentoo Linux](build-on-gentoo.md)
86
-
87
- [1]: build-with-makefiles.md
88
- [2]: build-with-autotools.md
89
- [3]: build-with-mingw.md
90
- [4]: build-shared-library.md
91
- [5]: https://github.com/sass/sass-spec
92
- [6]: https://github.com/sass/sassc
93
- [7]: https://github.com/sass/libsass/blob/master/.travis.yml
94
- [8]: https://github.com/sass/libsass/blob/master/appveyor.yml
95
- [9]: implementations.md
96
- [10]: build-on-darwin.md
97
- [11]: build-with-visual-studio.md
@@ -1,48 +0,0 @@
1
- This document is to serve as a living, changing plan for getting LibSass caught up with Ruby Sass.
2
-
3
- _Note: an "s" preceeding a version number is specifying a Ruby Sass version. Without an s, it's a version of LibSass._
4
-
5
- # Goal
6
- **Our goal is to reach full s3.4 compatibility as soon as possible. LibSass version 3.4 will behave just like Ruby Sass 3.4**
7
-
8
- I highlight the goal, because there are some things that are *not* currently priorities. To be clear, they WILL be priorities, but they are not at the moment:
9
-
10
- * Performance Improvements
11
- * Extensibility
12
-
13
- The overriding goal is correctness.
14
-
15
- ## Verifying Correctness
16
- LibSass uses the spec for its testing. The spec was originally based off s3.2 tests. Many things have changed in Ruby Sass since then and some of the tests need to be updated and changed in order to get them to match both LibSass and Ruby Sass.
17
-
18
- Until this project is complete, the spec will be primarily a place to test LibSass. By the time LibSass reaches 3.4, it is our goal that sass-spec will be fully usable as an official testing source for ALL implementations of Sass.
19
-
20
- ## Version Naming
21
- Until LibSass reaches parity with Ruby Sass, we will be aggressively bumping versions, and LibSass 3.4 will be the peer to Ruby Sass 3.4 in every way.
22
-
23
- # Release Plan
24
-
25
- ## 3.0
26
- The goal of 3.0 is to introduce some of the most demanded features for LibSass. That is, we are focusing on issues and features that have kept adoption down. This is a mongrel release wrt which version of Sass it's targeting. It's often a mixture of 3.2 / 3.3 / 3.4 behaviours. This is not ideal, but it's favourable to not existing. Targeting 3.4 strictly during this release would mean we never actually release.
27
-
28
- # 3.1
29
- The goal of 3.1 is to update all the passing specs to agree with 3.4. This will not be a complete representation of s3.4 (aka, there will me missing features), but the goal is to change existing features and implemented features to match 3.4 behaviour.
30
-
31
- By the end of this, the sass-spec must pass against 3.4.
32
-
33
- Major issues:
34
- * Variable Scoping
35
- * Color Handling
36
- * Precision
37
-
38
- # 3.2
39
- This version will focus on edge case fixes. There are a LOT of edge cases in the _todo_ tests and this is the release where we hunt those down like dogs (not that we want to hurt dogs, it's just a figure of speech in English).
40
-
41
- # 3.3
42
- Dress rehearsal. When we are 99% sure that we've fixed the main issues keeping us from saying we are compliant in s3.4 behaviour.
43
-
44
- # 3.4
45
- Compass Compatibility. We need to be able to work with Compass and all the other libraries out there. At this point, we are calling LibSass "mature"
46
-
47
- # Beyond 3.4
48
- Obviously, there is matching Sass 3.5 behaviour. But, beyond that, we'll want to focus on performance, stability, and error handling. These can always be improved upon and are the life's work of an open source project. We'll have to work closely with Sass in the future.
@@ -1,17 +0,0 @@
1
- First of all, welcome! Thanks for even reading this page. If you're here, you're probably wondering what you can do to help make the LibSass project even more awesome. And, even having that feeling means you are awesome!
2
-
3
- ## I'm a programmer
4
-
5
- Awesome! We need your help. The best thing to do is go find issues that are tagged with both "bug" and "test written". We do spec driven development here and these issues have a test that's written already in the sass-spec project. Go find the test by going to sass-spec/spec/LibSass-todo-issues/issue_XXX/ where XXX is the issue number. Write the code, and compile, and then issue a pull request referencing the issue. We'll quickly verify it and get it merged in!
6
-
7
- To get your dev environment setup, check out our article on [Setup-Dev-Environment](setup-environment.md).
8
-
9
- ## I'm not a backend programmer
10
-
11
- COOL! We also need your help. Doing [Issue-Triage](triage.md) is a big deal and something we need constant help with. That means helping to verify issues, write tests for them, and make sure they are getting fixed. It's being part of the smiling face of the project.
12
-
13
- Also, we need help with the Sass-Spec project itself. Just people to organize, refactor, and understand the tests in there.
14
-
15
- ## I don't know what a computer is?
16
-
17
- Hmm.... well, it's the thing you are looking at right now. Ummm... check out training courses! Then, come back and join us!
@@ -1,122 +0,0 @@
1
- # Developer Documentation
2
-
3
- Custom functions are internally represented by `struct Sass_C_Function_Descriptor`.
4
-
5
- ## Sass_C_Function_Descriptor
6
-
7
- ```C
8
- struct Sass_C_Function_Descriptor {
9
- const char* signature;
10
- Sass_C_Function function;
11
- void* cookie;
12
- };
13
- ```
14
-
15
- - `signature`: The function declaration, like `foo($bar, $baz:1)`
16
- - `function`: Reference to the C function callback
17
- - `cookie`: any pointer you want to attach
18
-
19
- ### signature
20
-
21
- The signature defines how the function can be invoked. It also declares which arguments are required and which are optional. Required arguments will be enforced by LibSass and a Sass error is thrown in the event a call as missing an argument. Optional arguments only need to be present when you want to overwrite the default value.
22
-
23
- foo($bar, $baz: 2)
24
-
25
- In this example, `$bar` is required and will error if not passed. `$baz` is optional and the default value of it is 2. A call like `foo(10)` is therefore equal to `foo(10, 2)`, while `foo()` will produce an error.
26
-
27
- ### function
28
-
29
- The callback function needs to be of the following form:
30
-
31
- ```C
32
- union Sass_Value* call_sass_function(
33
- const union Sass_Value* s_args,
34
- void* cookie
35
- ) {
36
- return sass_clone_value(s_args);
37
- }
38
- ```
39
-
40
- ### cookie
41
-
42
- The cookie can hold any pointer you want. In the `perl-libsass` implementation it holds the structure with the reference of the actual registered callback into the perl interpreter. Before that call `perl-libsass` will convert all `Sass_Values` to corresponding perl data types (so they can be used natively inside the perl interpretor). The callback can also return a `Sass_Value`. In `perl-libsass` the actual function returns a perl value, which has to be converted before `libsass` can work with it again!
43
-
44
- ## Sass_Values
45
-
46
- ```C
47
- // allocate memory (copies passed strings)
48
- union Sass_Value* sass_make_null (void);
49
- union Sass_Value* sass_make_boolean (bool val);
50
- union Sass_Value* sass_make_string (const char* val);
51
- union Sass_Value* sass_make_qstring (const char* val);
52
- union Sass_Value* sass_make_number (double val, const char* unit);
53
- union Sass_Value* sass_make_color (double r, double g, double b, double a);
54
- union Sass_Value* sass_make_list (size_t len, enum Sass_Separator sep, bool is_bracketed);
55
- union Sass_Value* sass_make_map (size_t len);
56
- union Sass_Value* sass_make_error (const char* msg);
57
- union Sass_Value* sass_make_warning (const char* msg);
58
-
59
- // Make a deep cloned copy of the given sass value
60
- union Sass_Value* sass_clone_value (const union Sass_Value* val);
61
-
62
- // deallocate memory (incl. all copied memory)
63
- void sass_delete_value (const union Sass_Value* val);
64
- ```
65
-
66
- ## Example main.c
67
-
68
- ```C
69
- #include <stdio.h>
70
- #include <stdint.h>
71
- #include "sass/context.h"
72
-
73
- union Sass_Value* call_fn_foo(const union Sass_Value* s_args, void* cookie)
74
- {
75
- // we actually abuse the void* to store an "int"
76
- return sass_make_number((size_t)cookie, "px");
77
- }
78
-
79
- int main( int argc, const char* argv[] )
80
- {
81
-
82
- // get the input file from first argument or use default
83
- const char* input = argc > 1 ? argv[1] : "styles.scss";
84
-
85
- // create the file context and get all related structs
86
- struct Sass_File_Context* file_ctx = sass_make_file_context(input);
87
- struct Sass_Context* ctx = sass_file_context_get_context(file_ctx);
88
- struct Sass_Options* ctx_opt = sass_context_get_options(ctx);
89
-
90
- // allocate a custom function caller
91
- Sass_C_Function_Callback fn_foo =
92
- sass_make_function("foo()", call_fn_foo, (void*)42);
93
-
94
- // create list of all custom functions
95
- Sass_C_Function_List fn_list = sass_make_function_list(1);
96
- sass_function_set_list_entry(fn_list, 0, fn_foo);
97
- sass_option_set_c_functions(ctx_opt, fn_list);
98
-
99
- // context is set up, call the compile step now
100
- int status = sass_compile_file_context(file_ctx);
101
-
102
- // print the result or the error to the stdout
103
- if (status == 0) puts(sass_context_get_output_string(ctx));
104
- else puts(sass_context_get_error_message(ctx));
105
-
106
- // release allocated memory
107
- sass_delete_file_context(file_ctx);
108
-
109
- // exit status
110
- return status;
111
-
112
- }
113
- ```
114
-
115
- ## Compile main.c
116
-
117
- ```bash
118
- gcc -c main.c -o main.o
119
- gcc -o sample main.o -lsass
120
- echo "foo { margin: foo(); }" > foo.scss
121
- ./sample foo.scss => "foo { margin: 42px }"
122
- ```
@@ -1,223 +0,0 @@
1
- # LibSass smart pointer implementation
2
-
3
- LibSass uses smart pointers very similar to `shared_ptr` known
4
- by Boost or C++11. Implementation is a bit less modular since
5
- it was not needed. Various compile time debug options are
6
- available if you need to debug memory life-cycles.
7
-
8
-
9
- ## Memory Classes
10
-
11
- ### SharedObj
12
-
13
- Base class for the actual node implementations. This ensures
14
- that every object has a reference counter and other values.
15
-
16
- ```c++
17
- class AST_Node : public SharedObj { ... };
18
- ```
19
-
20
- ### SharedPtr (base class for SharedImpl)
21
-
22
- Base class that holds on to the pointer. The reference counter
23
- is stored inside the pointer object directly (`SharedObj`).
24
-
25
- ### SharedImpl (inherits from SharedPtr)
26
-
27
- This is the main base class for objects you use in your code. It
28
- will make sure that the memory it points at will be deleted once
29
- all copies to the same object/memory go out of scope.
30
-
31
- ```c++
32
- Class* pointer = new Class(...);
33
- SharedImpl<Class> obj(pointer);
34
- ```
35
-
36
- To spare the developer of typing the templated class every time,
37
- we created typedefs for each available AST Node specialization.
38
-
39
- ```c++
40
- typedef SharedImpl<Number> Number_Obj;
41
- Number_Obj number = SASS_MEMORY_NEW(...);
42
- ```
43
-
44
-
45
- ## Memory life-cycles
46
-
47
- ### Pointer pickups
48
-
49
- I often use the terminology of "pickup". This means the moment when
50
- a raw pointer not under any control is assigned to a reference counted
51
- object (`XYZ_Obj = XYZ_Ptr`). From that point on memory will be
52
- automatically released once the object goes out of scope (but only
53
- if the reference counter reaches zero). Main point beeing, you don't
54
- have to worry about memory management yourself.
55
-
56
- ### Object detach
57
-
58
- Sometimes we can't return reference counted objects directly (see
59
- invalid covariant return types problems below). But we often still
60
- need to use reference objects inside a function to avoid leaks when
61
- something throws. For this you can use `detach`, which basically
62
- detaches the pointer memory from the reference counted object. So
63
- when the reference counted object goes out of scope, it will not
64
- free the attached memory. You are now again in charge of freeing
65
- the memory (just assign it to a reference counted object again).
66
-
67
-
68
- ## Circular references
69
-
70
- Reference counted memory implementations are prone to circular references.
71
- This can be addressed by using a multi generation garbage collector. But
72
- for our use-case that seems overkill. There is no way so far for users
73
- (sass code) to create circular references. Therefore we can code around
74
- this possible issue. But developers should be aware of this limitation.
75
-
76
- There are AFAIR two places where circular references could happen. One is
77
- the `sources` member on every `Selector`. The other one can happen in the
78
- extend code (Node handling). The easy way to avoid this is to only assign
79
- complete object clones to these members. If you know the objects lifetime
80
- is longer than the reference you create, you can also just store the raw
81
- pointer. Once needed this could be solved with weak pointers.
82
-
83
-
84
- ## Addressing the invalid covariant return types problems
85
-
86
- If you are not familiar with the mentioned problem, you may want
87
- to read up on covariant return types and virtual functions, i.e.
88
-
89
- - http://stackoverflow.com/questions/6924754/return-type-covariance-with-smart-pointers
90
- - http://stackoverflow.com/questions/196733/how-can-i-use-covariant-return-types-with-smart-pointers
91
- - http://stackoverflow.com/questions/2687790/how-to-accomplish-covariant-return-types-when-returning-a-shared-ptr
92
-
93
- We hit this issue at least with the CRTP visitor pattern (eval, expand,
94
- listize and so forth). This means we cannot return reference counted
95
- objects directly. We are forced to return raw pointers or we would need
96
- to have a lot of explicit and expensive upcasts by callers/consumers.
97
-
98
- ### Simple functions that allocate new AST Nodes
99
-
100
- In the parser step we often create new objects and can just return a
101
- unique pointer (meaning ownership clearly shifts back to the caller).
102
- The caller/consumer is responsible that the memory is freed.
103
-
104
- ```c++
105
- typedef Number* Number_Ptr;
106
- int parse_integer() {
107
- ... // do the parsing
108
- return 42;
109
- }
110
- Number_Ptr parse_number() {
111
- Number_Ptr p_nr = SASS_MEMORY_NEW(...);
112
- p_nr->value(parse_integer());
113
- return p_nr;
114
- }
115
- Number_Obj nr = parse_number();
116
- ```
117
-
118
- The above would be the encouraged pattern for such simple cases.
119
-
120
- ### Allocate new AST Nodes in functions that can throw
121
-
122
- There is a major caveat with the previous example, considering this
123
- more real-life implementation that throws an error. The throw may
124
- happen deep down in another function. Holding raw pointers that
125
- we need to free would leak in this case.
126
-
127
- ```c++
128
- int parse_integer() {
129
- ... // do the parsing
130
- if (error) throw(error);
131
- return 42;
132
- }
133
- ```
134
-
135
- With this `parse_integer` function the previous example would leak memory.
136
- I guess it is pretty obvious, as the allocated memory will not be freed,
137
- as it was never assigned to a SharedObj value. Therefore the above code
138
- would better be written as:
139
-
140
- ```c++
141
- typedef Number* Number_Ptr;
142
- int parse_integer() {
143
- ... // do the parsing
144
- if (error) throw(error);
145
- return 42;
146
- }
147
- // this leaks due to pointer return
148
- // should return Number_Obj instead
149
- // though not possible for virtuals!
150
- Number_Ptr parse_number() {
151
- Number_Obj nr = SASS_MEMORY_NEW(...);
152
- nr->value(parse_integer()); // throws
153
- return &nr; // Ptr from Obj
154
- }
155
- Number_Obj nr = parse_number();
156
- // will now be freed automatically
157
- ```
158
-
159
- The example above unfortunately will not work as is, since we return a
160
- `Number_Ptr` from that function. Therefore the object allocated inside
161
- the function is already gone when it is picked up again by the caller.
162
- The easy fix for the given simplified use case would be to change the
163
- return type of `parse_number` to `Number_Obj`. Indeed we do it exactly
164
- this way in the parser. But as stated above, this will not work for
165
- virtual functions due to invalid covariant return types!
166
-
167
- ### Return managed objects from virtual functions
168
-
169
- The easy fix would be to just create a new copy on the heap and return
170
- that. But this seems like a very inelegant solution to this problem. I
171
- mean why can't we just tell the object to treat it like a newly allocated
172
- object? And indeed we can. I've added a `detach` method that will tell
173
- the object to survive deallocation until the next pickup. This means
174
- that it will leak if it is not picked up by consumer.
175
-
176
- ```c++
177
- typedef Number* Number_Ptr;
178
- int parse_integer() {
179
- ... // do the parsing
180
- if (error) throw(error);
181
- return 42;
182
- }
183
- Number_Ptr parse_number() {
184
- Number_Obj nr = SASS_MEMORY_NEW(...);
185
- nr->value(parse_integer()); // throws
186
- return nr.detach();
187
- }
188
- Number_Obj nr = parse_number();
189
- // will now be freed automatically
190
- ```
191
-
192
-
193
- ## Compile time debug options
194
-
195
- To enable memory debugging you need to define `DEBUG_SHARED_PTR`.
196
- This can i.e. be done in `include/sass/base.h`
197
-
198
- ```c++
199
- define DEBUG_SHARED_PTR
200
- ```
201
-
202
- This will print lost memory on exit to stderr. You can also use
203
- `setDbg(true)` on sepecific variables to emit reference counter
204
- increase, decrease and other events.
205
-
206
-
207
- ## Why reinvent the wheel when there is `shared_ptr` from C++11
208
-
209
- First, implementing a smart pointer class is not really that hard. It
210
- was indeed also a learning experience for myself. But there are more
211
- profound advantages:
212
-
213
- - Better GCC 4.4 compatibility (which most code still has OOTB)
214
- - Not thread safe (give us some free performance on some compiler)
215
- - Beeing able to track memory allocations for debugging purposes
216
- - Adding additional features if needed (as seen in `detach`)
217
- - Optional: optimized weak pointer implementation possible
218
-
219
- ### Thread Safety
220
-
221
- As said above, this is not thread safe currently. But we don't need
222
- this ATM anyway. And I guess we probably never will share AST Nodes
223
- across different threads.