// Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
//
// This program and the accompanying materials are made available under the
// terms of the Eclipse Public License v. 2.0 which is available at
// http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
// v. 1.0 which is available at
// http://www.eclipse.org/org/documents/edl-v10.php.
//
// SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause

import "allocs.st"
import "banner.st"
import "file.st"
import "module.st"
import "struct.st"
import "union.st"
import "dlldef.st"
import "enum.st"
import "seqdef.st"
import "seqdef_base.st"
import "const.st"

idlToCTypeMap ::= [
  "octet":"uint8_t",
  "boolean":"bool",
  "char":"char",
  "short":"int16_t",
  "unsigned short":"uint16_t",
  "long":"int32_t",
  "unsigned long":"uint32_t",
  "long long":"int64_t",
  "unsigned long long":"uint64_t",
  "float":"float",
  "double":"double",
  "string":"char *",
  "bstring":"char",
  default:key
]

ctype (scope, type) ::= <<
<if(scope)><scopedname(scope,type)><else><idlToCTypeMap.(type)><endif>
>>

member (name, arraydim, scope, type, str_size) ::= <<
<ctype(...)> <name><str_size><arraydim>;
>>

scalar_typedef (namescope, name, scope, type, arraydim, str_size) ::= <<
typedef <ctype(scope, type)> <scopedname(namescope, name)> <str_size><arraydim>;

<allocs(namescope, name)>
>>

scopedname (scope, name) ::= <<
<if(scope)><scope;separator="_">_<endif><name>
>>

keyfield (name, offset) ::= <<
>>
