demake 0.2.3 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/demake +199 -6
- data/lib/apps/example/Makefile +0 -0
- data/lib/apps/example/demake/auto_bits.rb +59 -0
- data/lib/apps/example/demake/auto_list.rb +60 -0
- data/lib/apps/example/src/Makefile +6 -0
- data/lib/apps/example/src/goodbye.c +0 -0
- data/lib/apps/example/src/hello.c +0 -0
- data/lib/apps/example/src/string/string.c +0 -0
- data/lib/apps/example/src/string/string.h +0 -0
- data/lib/apps/oreo/Makefile +0 -0
- data/lib/apps/oreo/src/Makefile +6 -0
- data/lib/apps/oreo/src/defines.h +0 -0
- data/lib/apps/oreo/src/fast_read_file.h +0 -0
- data/lib/apps/oreo/src/oreo.c +0 -0
- data/lib/apps/oreo/src/typedefs.h +0 -0
- data/lib/data/libsrc/auto_bits.c +41 -0
- data/lib/data/libsrc/auto_bits.h +212 -4
- data/lib/data/libsrc/auto_bits.rb +9 -0
- data/lib/data/libsrc/auto_list.rb +9 -0
- data/lib/data/libsrc/auto_string.c +300 -0
- data/lib/data/libsrc/auto_string.h +1023 -0
- data/lib/data/libsrc/auto_string_clamp_test.c +52 -0
- data/lib/data/libsrc/base.h +0 -0
- data/lib/data/libsrc/cpu_mark_check.h +0 -0
- data/lib/data/libsrc/defines.h +29 -3
- data/lib/data/libsrc/fast_read_file.h +0 -0
- data/lib/data/libsrc/fast_sha2.h +0 -0
- data/lib/data/libsrc/memory_arena.c +32 -0
- data/lib/data/libsrc/memory_arena.h +345 -0
- data/lib/data/libsrc/memory_arena_test.c +173 -0
- data/lib/data/libsrc/parse_arguments.h +0 -0
- data/lib/data/libsrc/rb_library.c +0 -0
- data/lib/data/libsrc/simple_linked_list.c +42 -22
- data/lib/data/libsrc/simple_linked_list.h +140 -56
- data/lib/data/libsrc/typedefs.h +5 -3
- data/lib/to_plural.rb +126 -0
- metadata +24 -13
- data/lib/data/libsrc/simple_linked_list +0 -0
- data/lib/data/libsrc/smart_alloc.h +0 -45
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2ffe6f303e6b1353350fca9dfbfe5b4cff29a4150797efb62677fef654c0ad96
|
|
4
|
+
data.tar.gz: e104191198f2de99aa479e9c577dd623829b8b19e4b437e7f1dc140c11d9ca99
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a5e213d7abbdc81750dcff7afc5caf988265e105cf386dfc40d366f7a2a03f531859c49e453b160c24baa3044f86a7ee360f2ac04447e86c21f28af0e6005071
|
|
7
|
+
data.tar.gz: 602615ed7ccf3bc3a7af337d0f453b6f4160c8539180f89b82ea575b9c54090f272ed1b0d6a3ca350f915b443758182c86b23e587ff23ab285d3b9de80f85ce4
|
data/bin/demake
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
2
|
#
|
|
3
|
-
# demake
|
|
4
|
-
#
|
|
3
|
+
# demake
|
|
4
|
+
#
|
|
5
|
+
# Develop, Decorate and manage Dependencies for C (GNU) Makefiles easily with Ruby
|
|
5
6
|
#
|
|
6
7
|
require 'rbconfig' # Needed by older versions of Ruby
|
|
7
8
|
require 'pipetext'
|
|
9
|
+
@lib_dir = File.join(File.expand_path("../..", __FILE__), "lib")
|
|
10
|
+
@lib_data = File.join(File.expand_path("../..", __FILE__), "lib", "data")
|
|
11
|
+
@lib_apps = File.join(File.expand_path("../..", __FILE__), "lib", "apps")
|
|
12
|
+
load @lib_dir + '/to_plural.rb'
|
|
8
13
|
|
|
9
|
-
demake_version = "0.2.
|
|
14
|
+
demake_version = "0.2.4"
|
|
10
15
|
|
|
11
16
|
@silent = false
|
|
12
17
|
@compiler = "gcc"
|
|
@@ -119,9 +124,6 @@ def notify(string)
|
|
|
119
124
|
STDERR.puts(@pipe.pipetext(string))
|
|
120
125
|
end
|
|
121
126
|
|
|
122
|
-
@lib_data = File.join(File.expand_path("../..", __FILE__), "lib", "data")
|
|
123
|
-
@lib_apps = File.join(File.expand_path("../..", __FILE__), "lib", "apps")
|
|
124
|
-
@lib_dir = File.join(File.expand_path("../..", __FILE__), "lib")
|
|
125
127
|
@available_apps = Array.new
|
|
126
128
|
Dir.entries(@lib_apps).each do |e|
|
|
127
129
|
if(e != '.' && e != '..')
|
|
@@ -203,6 +205,10 @@ def create_new_application(new_name)
|
|
|
203
205
|
notify("#{@emoji_success} Created file: |y#{new_name}/demake/settings.rb|n |[page facing up]\n")
|
|
204
206
|
file_open_write_close(new_name + "/demake/license", file_open_read_close(@lib_apps + "/example/demake/license"))
|
|
205
207
|
notify("#{@emoji_success} Created file: |y#{new_name}/demake/license|n |[page facing up]\n")
|
|
208
|
+
file_open_write_close(new_name + "/demake/auto_bits.rb", file_open_read_close(@lib_apps + "/example/demake/auto_bits.rb"))
|
|
209
|
+
notify("#{@emoji_success} Created file: |y#{new_name}/demake/auto_bits.rb|n |[page facing up]\n")
|
|
210
|
+
file_open_write_close(new_name + "/demake/auto_list.rb", file_open_read_close(@lib_apps + "/example/demake/auto_list.rb"))
|
|
211
|
+
notify("#{@emoji_success} Created file: |y#{new_name}/demake/auto_list.rb|n |[page facing up]\n")
|
|
206
212
|
begin
|
|
207
213
|
File.open("#{new_name}/demake/test-target.rb", 'w') do |f|
|
|
208
214
|
f.write("test_targets = <<-END_OF_STRING\n")
|
|
@@ -218,9 +224,14 @@ def create_new_application(new_name)
|
|
|
218
224
|
Dir.mkdir(new_name + "/src")
|
|
219
225
|
notify("#{@emoji_success} Created directory: |g#{new_name}/src|n |[open file folder]\n")
|
|
220
226
|
end
|
|
227
|
+
file_open_write_close(new_name + "/src/Makefile", file_open_read_close(@lib_apps + "/example/src/Makefile"))
|
|
228
|
+
notify("#{@emoji_success} Created file: |y#{new_name}/src/Makefile|n |[page facing up]\n")
|
|
221
229
|
file_open_write_close(new_name + "/src/typedefs.h", file_open_read_close(@lib_data + "/libsrc/typedefs.h"))
|
|
230
|
+
notify("#{@emoji_success} Created file: |y#{new_name}/src/typedefs.h|n |[page facing up]\n")
|
|
222
231
|
file_open_write_close(new_name + "/src/defines.h", file_open_read_close(@lib_data + "/libsrc/defines.h"))
|
|
232
|
+
notify("#{@emoji_success} Created file: |y#{new_name}/src/defines.h|n |[page facing up]\n")
|
|
223
233
|
file_open_write_close(new_name + "/src/base.h", file_open_read_close(@lib_data + "/libsrc/base.h"))
|
|
234
|
+
notify("#{@emoji_success} Created file: |y#{new_name}/src/base.h|n |[page facing up]\n")
|
|
224
235
|
begin
|
|
225
236
|
File.open("#{new_name}/src/#{new_name}.c", 'w') do |f|
|
|
226
237
|
f.write("/*\n\n #{new_name}.c - #{new_name} main application entry point\n\n*/\n\n" +
|
|
@@ -239,6 +250,16 @@ def create_new_application(new_name)
|
|
|
239
250
|
end
|
|
240
251
|
end
|
|
241
252
|
|
|
253
|
+
@auto_bits = Hash.new
|
|
254
|
+
def auto_bits_add(prefix, list, file=nil)
|
|
255
|
+
@auto_bits[prefix] = { 'prefix' => prefix, 'list' => list, 'file' => file }
|
|
256
|
+
end
|
|
257
|
+
|
|
258
|
+
@auto_list = Hash.new
|
|
259
|
+
def auto_list_add(prefix, list, file=nil)
|
|
260
|
+
@auto_list[prefix] = { 'prefix' => prefix, 'list' => list, 'file' => file }
|
|
261
|
+
end
|
|
262
|
+
|
|
242
263
|
@found_application = nil
|
|
243
264
|
@suggestion = String.new
|
|
244
265
|
|
|
@@ -251,6 +272,176 @@ if(ARGV[0] =~ /^new/)
|
|
|
251
272
|
create_new_application(ARGV[1])
|
|
252
273
|
Dir.chdir(ARGV[1])
|
|
253
274
|
@working_directory = Dir.pwd
|
|
275
|
+
elsif(ARGV[0] =~ /^auto_bits/ || ARGV[0] =~ /^auto-bits/ || ARGV[0] =~ /^auto_list/ || ARGV[0] =~ /^auto-list/)
|
|
276
|
+
if(ARGV[0] =~ /^auto_bits/ || ARGV[0] =~ /^auto-bits/)
|
|
277
|
+
auto_bits = true
|
|
278
|
+
elsif(ARGV[0] =~ /^auto_list/ || ARGV[0] =~ /^auto-list/)
|
|
279
|
+
auto_list = true
|
|
280
|
+
end
|
|
281
|
+
begin
|
|
282
|
+
if(ARGV[1] != nil)
|
|
283
|
+
code = file_open_read_close(ARGV[1])
|
|
284
|
+
else
|
|
285
|
+
if(auto_bits)
|
|
286
|
+
code = file_open_read_close('demake/auto_bits.rb')
|
|
287
|
+
elsif(auto_list)
|
|
288
|
+
code = file_open_read_close('demake/auto_list.rb')
|
|
289
|
+
end
|
|
290
|
+
end
|
|
291
|
+
if(@emojis == false)
|
|
292
|
+
strip_emojis!(code)
|
|
293
|
+
end
|
|
294
|
+
eval code
|
|
295
|
+
rescue Errno::ENOENT
|
|
296
|
+
if(auto_bits)
|
|
297
|
+
notify("\n#{@emoji_fail}|RError|n: |Ydemake/auto_bits.rb|n or |Yadditional argument|n |Rrequired|n.\n\n")
|
|
298
|
+
elsif(auto_list)
|
|
299
|
+
notify("\n#{@emoji_fail}|RError|n: |Ydemake/auto_list.rb|n or |Yadditional argument|n |Rrequired|n.\n\n")
|
|
300
|
+
end
|
|
301
|
+
exit!
|
|
302
|
+
rescue
|
|
303
|
+
notify("\n#{@emoji_fail}|RError|n: #{$!}\n\n")
|
|
304
|
+
exit!
|
|
305
|
+
end
|
|
306
|
+
if(@auto_bits == {} && auto_bits)
|
|
307
|
+
notify("\n#{@emoji_fail}|RError|n: No auto_bits.rb configurations found.\n\n")
|
|
308
|
+
exit!
|
|
309
|
+
end
|
|
310
|
+
if(@auto_list == {} && auto_list)
|
|
311
|
+
notify("\n#{@emoji_fail}|RError|n: No auto_list.rb configurations found.\n\n")
|
|
312
|
+
exit!
|
|
313
|
+
end
|
|
314
|
+
if(!defined?(@prespace))
|
|
315
|
+
@prespace = 0
|
|
316
|
+
end
|
|
317
|
+
if(!defined?(@target_tab_column))
|
|
318
|
+
@target_tab_column = 5
|
|
319
|
+
end
|
|
320
|
+
@text = String.new
|
|
321
|
+
@spaces = " " * @prespace
|
|
322
|
+
@auto_bits.each do |bits|
|
|
323
|
+
bits[1]['list'].each_with_index do |entry, index|
|
|
324
|
+
text = @spaces + "#define #{bits[1]['prefix'].upcase.gsub(' ', '_')}_"
|
|
325
|
+
text << entry.upcase.gsub(' ', '_')
|
|
326
|
+
text << "\t" * [1, @target_tab_column - (text.length / 8).floor].max
|
|
327
|
+
text << "(1 << #{index})\n"
|
|
328
|
+
@text << text
|
|
329
|
+
end
|
|
330
|
+
text = @spaces + "#define NUM_#{to_plural(bits[1]['prefix']).upcase.gsub(' ', '_')}"
|
|
331
|
+
text << "\t" * [1, @target_tab_column - (text.length / 8).floor].max
|
|
332
|
+
text << bits[1]['list'].count.to_s + "\n"
|
|
333
|
+
@text << "\n" + text
|
|
334
|
+
@text << "\n" + @spaces + "cc8 #{to_plural(bits[1]['prefix']).gsub(' ', '_')}_list[] = {\n"
|
|
335
|
+
bits[1]['list'].each do |entry|
|
|
336
|
+
text = @spaces + " \"#{entry}\",\n"
|
|
337
|
+
@text << text
|
|
338
|
+
end
|
|
339
|
+
@text << @spaces + " NULL\n"
|
|
340
|
+
@text << @spaces + "};\n\n"
|
|
341
|
+
if(bits[1]['file'] == nil)
|
|
342
|
+
file_name = "auto_bits_generated.h"
|
|
343
|
+
else
|
|
344
|
+
file_name = bits[1]['file']
|
|
345
|
+
end
|
|
346
|
+
same_file = false
|
|
347
|
+
@auto_bits.each do |bits2|
|
|
348
|
+
if(bits == bits2)
|
|
349
|
+
break
|
|
350
|
+
elsif(bits[1]['file'] == bits2[1]['file'])
|
|
351
|
+
same_file = true
|
|
352
|
+
break
|
|
353
|
+
elsif(bits[1]['file'] == nil && bits2[1]['file'] == file_name)
|
|
354
|
+
same_file = true
|
|
355
|
+
break
|
|
356
|
+
end
|
|
357
|
+
end
|
|
358
|
+
if(same_file == true) # Append
|
|
359
|
+
File.open(file_name, "a") do |file|
|
|
360
|
+
file.puts(@text)
|
|
361
|
+
end
|
|
362
|
+
else # New File
|
|
363
|
+
output = <<-END_OF_STRING
|
|
364
|
+
/*
|
|
365
|
+
|
|
366
|
+
This file automatically generated by Ruby Gem - demake #{demake_version}
|
|
367
|
+
|
|
368
|
+
*/
|
|
369
|
+
|
|
370
|
+
#ifndef NULL
|
|
371
|
+
#define NULL ((void *) 0)
|
|
372
|
+
#endif
|
|
373
|
+
|
|
374
|
+
END_OF_STRING
|
|
375
|
+
File.open(file_name, "w") do |file|
|
|
376
|
+
file.puts(output)
|
|
377
|
+
file.puts(@text)
|
|
378
|
+
end
|
|
379
|
+
notify("#{@emoji_success} Created file: |y#{file_name}|n |[page facing up]\n\n")
|
|
380
|
+
end
|
|
381
|
+
@text = String.new
|
|
382
|
+
end
|
|
383
|
+
@auto_list.each do |list|
|
|
384
|
+
list[1]['list'].each_with_index do |entry, index|
|
|
385
|
+
text = @spaces + "#define #{list[1]['prefix'].upcase.gsub(' ', '_')}_"
|
|
386
|
+
text << entry.upcase.gsub(' ', '_')
|
|
387
|
+
text << "\t" * [1, @target_tab_column - (text.length / 8).floor].max
|
|
388
|
+
text << "#{index}\n"
|
|
389
|
+
@text << text
|
|
390
|
+
end
|
|
391
|
+
text = @spaces + "#define NUM_#{to_plural(list[1]['prefix']).upcase.gsub(' ', '_')}"
|
|
392
|
+
text << "\t" * [1, @target_tab_column - (text.length / 8).floor].max
|
|
393
|
+
text << list[1]['list'].count.to_s + "\n"
|
|
394
|
+
@text << "\n" + text
|
|
395
|
+
@text << "\n" + @spaces + "cc8 #{to_plural(list[1]['prefix']).gsub(' ', '_')}_list[] = {\n"
|
|
396
|
+
list[1]['list'].each do |entry|
|
|
397
|
+
text = @spaces + " \"#{entry}\",\n"
|
|
398
|
+
@text << text
|
|
399
|
+
end
|
|
400
|
+
@text << @spaces + " NULL\n"
|
|
401
|
+
@text << @spaces + "};\n\n"
|
|
402
|
+
if(list[1]['file'] == nil)
|
|
403
|
+
file_name = "auto_list_generated.h"
|
|
404
|
+
else
|
|
405
|
+
file_name = list[1]['file']
|
|
406
|
+
end
|
|
407
|
+
same_file = false
|
|
408
|
+
@auto_list.each do |list2|
|
|
409
|
+
if(list == list2)
|
|
410
|
+
break
|
|
411
|
+
elsif(list[1]['file'] == list2[1]['file'])
|
|
412
|
+
same_file = true
|
|
413
|
+
break
|
|
414
|
+
elsif(list[1]['file'] == nil && list2[1]['file'] == file_name)
|
|
415
|
+
same_file = true
|
|
416
|
+
break
|
|
417
|
+
end
|
|
418
|
+
end
|
|
419
|
+
if(same_file == true) # Append
|
|
420
|
+
File.open(file_name, "a") do |file|
|
|
421
|
+
file.puts(@text)
|
|
422
|
+
end
|
|
423
|
+
else # New File
|
|
424
|
+
output = <<-END_OF_STRING
|
|
425
|
+
/*
|
|
426
|
+
|
|
427
|
+
This file automatically generated by Ruby Gem - demake #{demake_version}
|
|
428
|
+
|
|
429
|
+
*/
|
|
430
|
+
|
|
431
|
+
#ifndef NULL
|
|
432
|
+
#define NULL ((void *) 0)
|
|
433
|
+
#endif
|
|
434
|
+
|
|
435
|
+
END_OF_STRING
|
|
436
|
+
File.open(file_name, "w") do |file|
|
|
437
|
+
file.puts(output)
|
|
438
|
+
file.puts(@text)
|
|
439
|
+
end
|
|
440
|
+
notify("#{@emoji_success} Created file: |y#{file_name}|n |[page facing up]\n\n")
|
|
441
|
+
end
|
|
442
|
+
@text = String.new
|
|
443
|
+
end
|
|
444
|
+
exit!
|
|
254
445
|
else
|
|
255
446
|
@available_apps.sort.each do |app|
|
|
256
447
|
if(ARGV[0] =~ /^#{app}$/)
|
|
@@ -288,6 +479,8 @@ if(need_help == true)
|
|
|
288
479
|
syntax = "|]#{COLUMN_WIDTH}Command syntax:\n\n" + "|y#{program}|n|; - Create or update Makefile\n"
|
|
289
480
|
syntax << "|y#{program} ?|n|; - View this help information\n"
|
|
290
481
|
syntax << "|y#{program} new <name>|n|; - Create new application\n"
|
|
482
|
+
syntax << "|y#{program} auto_bits|n|; - Generate auto_bits code\n"
|
|
483
|
+
syntax << "|y#{program} auto_list|n|; - Generate auto_list code\n"
|
|
291
484
|
@available_apps.sort.each do |app|
|
|
292
485
|
data = String.new
|
|
293
486
|
begin
|
data/lib/apps/example/Makefile
CHANGED
|
File without changes
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
#file = "auto_bits_generated.h"
|
|
2
|
+
prefix = "bit"
|
|
3
|
+
list = [ "0", "1", "2", "3" ]
|
|
4
|
+
auto_bits_add(prefix, list)
|
|
5
|
+
#auto_bits_add(prefix, list, file)
|
|
6
|
+
|
|
7
|
+
prefix = "flag"
|
|
8
|
+
list = [ "A", "B", "C", "D" ]
|
|
9
|
+
auto_bits_add(prefix, list)
|
|
10
|
+
|
|
11
|
+
@prespace = 0
|
|
12
|
+
@target_tab_column = 5
|
|
13
|
+
notify("|g|[check mark]|n demake/auto_bits.rb is present - generating code")
|
|
14
|
+
|
|
15
|
+
=begin
|
|
16
|
+
|
|
17
|
+
The default configuration above generates the following C code
|
|
18
|
+
in the file auto_bits_generated.h:
|
|
19
|
+
|
|
20
|
+
/*
|
|
21
|
+
|
|
22
|
+
This file automatically generated by Ruby Gem - demake 0.2.4
|
|
23
|
+
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
#ifndef NULL
|
|
27
|
+
#define NULL ((void *) 0)
|
|
28
|
+
#endif
|
|
29
|
+
|
|
30
|
+
#define BIT_0 (1 << 0)
|
|
31
|
+
#define BIT_1 (1 << 1)
|
|
32
|
+
#define BIT_2 (1 << 2)
|
|
33
|
+
#define BIT_3 (1 << 3)
|
|
34
|
+
|
|
35
|
+
#define NUM_BITS 4
|
|
36
|
+
|
|
37
|
+
cc8 bits_list[] = {
|
|
38
|
+
"0",
|
|
39
|
+
"1",
|
|
40
|
+
"2",
|
|
41
|
+
"3",
|
|
42
|
+
NULL
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
#define FLAG_A (1 << 0)
|
|
46
|
+
#define FLAG_B (1 << 1)
|
|
47
|
+
#define FLAG_C (1 << 2)
|
|
48
|
+
#define FLAG_D (1 << 3)
|
|
49
|
+
|
|
50
|
+
#define NUM_FLAGS 4
|
|
51
|
+
|
|
52
|
+
cc8 flags_list[] = {
|
|
53
|
+
"A",
|
|
54
|
+
"B",
|
|
55
|
+
"C",
|
|
56
|
+
"D",
|
|
57
|
+
NULL
|
|
58
|
+
};
|
|
59
|
+
=end
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
#file = "auto_list_generated.h"
|
|
2
|
+
prefix = "color"
|
|
3
|
+
list = [ "blue", "green", "red", "purple" ]
|
|
4
|
+
auto_list_add(prefix, list)
|
|
5
|
+
#auto_bits_add(prefix, list, file)
|
|
6
|
+
|
|
7
|
+
prefix = "shape"
|
|
8
|
+
list = [ "circle", "triangle", "square", "hexagon" ]
|
|
9
|
+
auto_list_add(prefix, list)
|
|
10
|
+
|
|
11
|
+
@prespace = 0
|
|
12
|
+
@target_tab_column = 5
|
|
13
|
+
notify("|g|[check mark]|n demake/auto_list.rb is present - generating code")
|
|
14
|
+
|
|
15
|
+
=begin
|
|
16
|
+
|
|
17
|
+
The default configuration above generates the following C code
|
|
18
|
+
in the file auto_list_generated.h:
|
|
19
|
+
|
|
20
|
+
/*
|
|
21
|
+
|
|
22
|
+
This file automatically generated by Ruby Gem - demake 0.2.4
|
|
23
|
+
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
#ifndef NULL
|
|
27
|
+
#define NULL ((void *) 0)
|
|
28
|
+
#endif
|
|
29
|
+
|
|
30
|
+
#define COLOR_BLUE 0
|
|
31
|
+
#define COLOR_GREEN 1
|
|
32
|
+
#define COLOR_RED 2
|
|
33
|
+
#define COLOR_PURPLE 3
|
|
34
|
+
|
|
35
|
+
#define NUM_COLORS 4
|
|
36
|
+
|
|
37
|
+
cc8 colors_list[] = {
|
|
38
|
+
"blue",
|
|
39
|
+
"green",
|
|
40
|
+
"red",
|
|
41
|
+
"purple",
|
|
42
|
+
NULL
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
#define SHAPE_CIRCLE 0
|
|
46
|
+
#define SHAPE_TRIANGLE 1
|
|
47
|
+
#define SHAPE_SQUARE 2
|
|
48
|
+
#define SHAPE_HEXAGON 3
|
|
49
|
+
|
|
50
|
+
#define NUM_SHAPES 4
|
|
51
|
+
|
|
52
|
+
cc8 shapes_list[] = {
|
|
53
|
+
"circle",
|
|
54
|
+
"triangle",
|
|
55
|
+
"square",
|
|
56
|
+
"hexagon",
|
|
57
|
+
NULL
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
=end
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
data/lib/apps/oreo/Makefile
CHANGED
|
File without changes
|
data/lib/apps/oreo/src/defines.h
CHANGED
|
File without changes
|
|
File without changes
|
data/lib/apps/oreo/src/oreo.c
CHANGED
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
#define AUTO_BITS_IMPLEMENTATION
|
|
2
|
+
#include "auto_bits.h"
|
|
3
|
+
|
|
4
|
+
#define BIT_0 (1 << 0)
|
|
5
|
+
#define BIT_1 (1 << 1)
|
|
6
|
+
#define BIT_2 (1 << 2)
|
|
7
|
+
#define BIT_3 (1 << 3)
|
|
8
|
+
|
|
9
|
+
cc8 *bit_list[] = {
|
|
10
|
+
"0",
|
|
11
|
+
"1",
|
|
12
|
+
"2",
|
|
13
|
+
"3",
|
|
14
|
+
NULL
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
i32 main(i32 argc, c8 *argv[])
|
|
18
|
+
{
|
|
19
|
+
b8 bits = 0;
|
|
20
|
+
|
|
21
|
+
printf("-- Set both bits 1 & 2:\n");
|
|
22
|
+
SET_BIT(bits, BIT_1|BIT_2);
|
|
23
|
+
auto_bits_print(bit_list, bits);
|
|
24
|
+
if(IS_SET(bits, BIT_2))
|
|
25
|
+
printf("Bit #2 is set.\n");
|
|
26
|
+
printf("Manual list set bits: ");
|
|
27
|
+
auto_bits_show(bit_list, bits, "|");
|
|
28
|
+
printf("\n\n-- Remove both bits 1 & 2:\n");
|
|
29
|
+
REMOVE_BIT(bits, BIT_1|BIT_2);
|
|
30
|
+
auto_bits_print(bit_list, bits);
|
|
31
|
+
printf("\n-- Set all 4 bits:\n");
|
|
32
|
+
SET_BIT(bits, BIT_0|BIT_1|BIT_2|BIT_3);
|
|
33
|
+
auto_bits_print(bit_list, bits);
|
|
34
|
+
printf("Manual list set bits: ");
|
|
35
|
+
auto_bits_show(bit_list, bits, " + ");
|
|
36
|
+
printf("\n\n-- Toggle both bits 1 & 2:\n");
|
|
37
|
+
TOGGLE_BIT(bits, BIT_1|BIT_2);
|
|
38
|
+
auto_bits_print(bit_list, bits);
|
|
39
|
+
|
|
40
|
+
return 0;
|
|
41
|
+
}
|