My favorites | Sign in
Project Logo
          
Repository:
Checkout | Browse | Changes | Clones |
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# This file is part of Metasm, the Ruby assembly manipulation suite
# Copyright (C) 2006-2009 Yoann GUILLOT
#
# Licence is LGPL, see LICENCE in the top-level directory

#
# this exemple illustrates the use of the cparser/preprocessor #factorize functionnality:
# we write some code using standard headers, and the factorize call on CParser
# gives us back the macro/C definitions that we use in our code, so that we can
# get rid of the header
# Argument: C file to factorize, [path to visual studio installation]
# with a single argument, uses GCC standard headers
#

require 'metasm'
include Metasm

abort 'target needed' if not file = ARGV.shift

visualstudiopath = ARGV.shift
if visualstudiopath
stub = <<EOS
// add the path to the visual studio std headers
#ifdef __METASM__
#pragma include_dir #{(visualstudiopath+'/platformsdk/include').inspect}
#pragma include_dir #{(visualstudiopath+'/include').inspect}
#pragma prepare_visualstudio
#pragma no_warn_redefinition
#endif
EOS
else
stub = <<EOS
#ifdef __METASM__
#pragma prepare_gcc
#endif
EOS
end
stub << "#line 0\n"

# to trace only pp macros (using eg an asm source), use Preprocessor#factorize instead

puts Ia32.new.new_cparser.factorize(stub + File.read(file), file)

Show details Hide details

Change log

0e99db1fff by jj on Jul 10, 2009   Diff
copyright update
Go to: 
Sign in to write a code review

Older revisions

761e1e6257 by jj on Feb 26, 2009   Diff
minor C updates
be17fe829f by jj on Nov 25, 2008   Diff
whitespace cleanup
8ed46797ec by jj on Jul 25, 2008   Diff
preprocessor: added
define_weak/define_strong, fix
hooked_include; parse_c: handle gcc
headers; samples/fact_hdr: handle gcc
or VC file
All revisions of this file

File info

Size: 1246 bytes, 43 lines
Hosted by Google Code