%PDF-1.5 %���� ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµùÕ5sLOšuY
Server IP : 188.40.95.74 / Your IP : 216.73.216.142 Web Server : Apache System : Linux cp01.striminghost.net 3.10.0-1160.119.1.el7.tuxcare.els13.x86_64 #1 SMP Fri Nov 22 06:29:45 UTC 2024 x86_64 User : vlasotin ( 1054) PHP Version : 5.6.40 Disable Function : NONE MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /opt/cpanel/ea-ruby27/src/passenger-release-6.0.23/build/support/vendor/cxxcodebuilder/ |
Upload File : |
# cxxcodebuilder: generate C/C++ code with a Builder-style DSL Cxxcodebuilder gives you a simple Ruby API for programmatically outputting C/C++ code with proper indenting and formatting. Code using this API is much more readable than code building raw strings. Cxxcodebuilder is similar to [Jbuilder](https://github.com/rails/jbuilder), which is for outputting JSON. ## Use cases This library is useful in build systems for automatically generating C/C++ code. It is much cleaner compared to using ERB or other generic text templating systems for the job. ## Example Suppose that you want to write the following piece of code: ~~~c++ #include <stdio.h> static int limit = 0; static int magicNumbers[] = [1, 2, 3]; static Foo foos[] = [ { "hello", 1 }, { "world", 2 } ]; /* * This is an awesome model * for a futuristic car. */ struct Car { unsigned int seats; }; static int modifyLimit(int diff) { int oldLimit = limit; limit += diff; printf("The new limit is: %s\n", limit); return oldLimit; } ~~~ Use Cxxcodebuilder as follows: ~~~ruby require 'cxxcodebuilder' builder = CxxCodeBuilder::Builder.new do include '<stdio.h>' separator field 'static int limit', 0 field 'static int magicNumbers[]' do array_initializer do element 1 element 2 element 3 end end field 'static Foo foo[]' do array_initializer do struct_element do string_element 'hello' element 1 end struct_element do string_element 'world' element 2 end end end separator comment %q{ This is an awesome model for a futuristic car. } struct 'Car' do field 'unsigned int seats' end separator function('static int modifyLimit(int diff)', %q{ int oldLimit = limit; limit += diff; printf("The new limit is: %s\n", limit); return oldLimit; }) end puts(builder) ~~~ ## API See the comments in lib/cxxcodebuilder/builder.rb for the full API.