diff options
author | Tomas Johansson <[email protected]> | 2010-02-04 10:34:01 +0100 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2010-02-16 13:04:49 +0100 |
commit | 9d247b1f12dcec885e361d61a738463dae3237b0 (patch) | |
tree | 24f75738a6b385d2455ded26783c216a6d46db9a /lib/asn1/src/asn1ct_gen.erl | |
parent | 991d3def715c9edda47298878ab7bad0d614ab73 (diff) | |
download | otp-9d247b1f12dcec885e361d61a738463dae3237b0.tar.gz otp-9d247b1f12dcec885e361d61a738463dae3237b0.tar.bz2 otp-9d247b1f12dcec885e361d61a738463dae3237b0.zip |
Add support for prefixing macro names generated by the compiler
This is useful when multiple protocols that contains
macros with identical names are included in a single module.
Add the missing record_name_prefix compiler option to the documentation.
Diffstat (limited to 'lib/asn1/src/asn1ct_gen.erl')
-rw-r--r-- | lib/asn1/src/asn1ct_gen.erl | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/asn1/src/asn1ct_gen.erl b/lib/asn1/src/asn1ct_gen.erl index fefb92bb34..f0f253be70 100644 --- a/lib/asn1/src/asn1ct_gen.erl +++ b/lib/asn1/src/asn1ct_gen.erl @@ -1357,7 +1357,8 @@ pgen_hrltypes(Erules,Module,[H|T],NumRecords) -> %% Generates a macro for value Value defined in the ASN.1 module gen_macro(Value) when is_record(Value,valuedef) -> - emit({"-define('",Value#valuedef.name,"', ", + Prefix = get_macro_name_prefix(), + emit({"-define('",Prefix,Value#valuedef.name,"', ", {asis,Value#valuedef.value},").",nl}). %% Generate record functions ************** @@ -2064,3 +2065,11 @@ get_record_name_prefix() -> {value,{_,Prefix}} -> Prefix end. + +get_macro_name_prefix() -> + case lists:keysearch(macro_name_prefix,1,get(encoding_options)) of + false -> + ""; + {value,{_,Prefix}} -> + Prefix + end. |