Commit 6f1896f4 authored by Kunshan Wang's avatar Kunshan Wang

Added const qualifier to MuCString.

Now MuCString is a (const char*).  It has always been intended
that MuCString instances are not to be modified.  This change just makes
it explicit in the type.

muapiparser.py just ignores the const qualifier.
parent 607fe9c5
......@@ -48,13 +48,16 @@ The Mu Micro VM and Client Contexts
Mu IDs and names are represented as::
// C-style '\0'-terminated string
typedef char *MuCString;
typedef const char *MuCString;
// Identifiers and names of Mu
typedef uint32_t MuID;
typedef MuCString MuName;
``MuCString`` is the 0-terminated C string type.
``MuCString`` is the 0-terminated C string type. A ``MuCString`` points to a
constant string. Mu never modifies the string passed into Mu from the client.
If Mu returns a ``MuCString`` (including aliases such as ``MuName``) to the
client, the client must not write into the string content.
A Mu instance is represented as a pointer to the struct ``MuVM``::
......
......@@ -83,7 +83,7 @@ typedef MuGenRefValue MuIBRefValue; // irbuilderref
// Mu IR. If you want to build IR using this C API, use MuCtx->new_ir_builder.
// C-style '\0'-terminated string
typedef char *MuCString;
typedef const char *MuCString;
// Identifiers and names of Mu
typedef uint32_t MuID;
......
......@@ -15,7 +15,7 @@ r_param = re.compile(r'\s*(?P<type>\w+\s*\*?)\s*(?P<name>\w+)')
r_define = re.compile(r'^\s*#define\s+(?P<name>\w+)\s*\(\((?P<type>\w+)\)(?P<value>\w+)\)\s*' + rfrag_commpragma + r'\s*$', re.MULTILINE)
r_typedef = re.compile(r'^\s*typedef\s+(?P<expand_to>\w+\s*\*?)\s*(?P<name>\w+)\s*;', re.MULTILINE)
r_typedef = re.compile(r'^\s*typedef\s+(?P<const>const\s+)?(?P<expand_to>\w+\s*\*?)\s*(?P<name>\w+)\s*;', re.MULTILINE)
r_struct_start = re.compile(r'^struct\s+(\w+)\s*\{')
r_struct_end = re.compile(r'^\};')
......@@ -141,7 +141,7 @@ def extract_typedefs(text):
typedefs = {}
typedefs_order = []
for m in r_typedef.finditer(text):
expand_to, name = m.groups()
const_qualifier, expand_to, name = m.groups()
expand_to = expand_to.replace(" ","")
typedefs[name] = expand_to
typedefs_order.append((name, expand_to))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment