-
Notifications
You must be signed in to change notification settings - Fork 0
naming_conventions
GML has no namespaces. The --prefix flag (default: gm) generates four derived tokens
that are prepended to every generated name to prevent collisions:
| Token | Example (gm) |
Used for |
|---|---|---|
{prefix}_ |
gm_ |
Public functions (endpoint wrappers, cookie API, auth API) |
_{prefix}_ |
_gm_ |
Private helpers (singleton getter, create_request, cookie_capture) |
{Prefix} |
Gm |
Struct constructor names |
{PREFIX}_ |
GM_ |
Macros and constants (reserved for future use) |
With --prefix petstore:
- Public:
petstore_get_pet() - Private:
_petstore_get_singleton() - Struct:
PetstoreUser
Names are derived from the operation's operationId field (required — the tool throws if absent).
The tag name (first entry in operation.tags) is prepended as a group prefix. Both
operationId and the tag are converted to snake_case.
operationId: "getUserById" tag: "Users"
→ users_get_user_by_id
operationId: "createOrder" tag: "Orders"
→ orders_create_order
operationId: "healthCheck" (no tag)
→ health_check
The full public name is {prefix}_{group}_{snake_operationId}.
The ToSnake() helper:
- Protects known acronyms/exceptions from being split (
OAuth2,OAuth,iOS,eBay,GitHub,iPhone) — these are lowercased as a single token. - Inserts
_at camelCase boundaries (userId→user_id). - Inserts
_at acronym boundaries (XMLParser→xml_parser). - Replaces non-alphanumeric characters with
_. - Collapses consecutive
_, trims leading/trailing_, lowercases.
If two operations map to the same generated name, numeric suffixes are appended:
get_item, get_item_2, get_item_3, …
If a generated name would clash with a GML reserved word (if, while, global,
true, false, undefined, etc.) the conflict is resolved at the parameter level by
prefixing with _. The full reserved list is in NameUtils.Reserved.
All parameters are prefixed with _ and converted to snake_case:
"userId" → _user_id
"max-count" → _max_count
"OAuth2Token" → _oauth2_token
Fields follow the same _snake_case conversion. Fields whose raw name is not a valid GML
identifier (contains special characters) use bracket syntax in the constructor:
self[$ "x-rate-limit"] = _x_rate_limit; // invalid ident → bracket
id = _id; // valid → direct assignmentschema name: "UserProfile" prefix: gm
→ struct constructor: GmUserProfile
→ validate function: GmUserProfile_validate
Internal variables inside endpoint functions use double-underscore-wrapped identifiers to minimise collision risk with user locals:
static __base_url__ // cached server URL
var __url__ // final request URL
static __content_type__ // cached content-type constant
var __security__ // auth scheme array for this requestThe generated helpers read two GameMaker Extension options from the extension named after the struct prefix:
extension_get_option_value("Gm", "server_rest_url") // base URL
extension_get_option_value("Gm", "debug_logging") // boolCreate an extension with the matching name and these option keys, or replace the helper functions with a custom implementation.
GameMaker