Skip to content
Navigation Menu
Sign in
Appearance settings
Platform
AI CODE CREATION
GitHub Copilot
Write better code with AI
GitHub Copilot app
Direct agents from issue to merge
MCP Registry
Integrate external tools
DEVELOPER WORKFLOWS
Actions
Automate any workflow
Codespaces
Instant dev environments
Issues
Plan and track work
Code Review
Manage code changes
Code Quality
Enforce quality at merge
APPLICATION SECURITY
GitHub Advanced Security
Find and fix vulnerabilities
Code security
Secure your code as you build
Secret protection
Stop leaks before they start
EXPLORE
Why GitHub
Documentation
Blog
Changelog
Marketplace
View all features
Solutions
BY COMPANY SIZE
Enterprises
Small and medium teams
Startups
Nonprofits
BY USE CASE
App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
BY INDUSTRY
Healthcare
Financial services
Manufacturing
Government
View all industries
View all solutions
Resources
EXPLORE BY TOPIC
AI
Software Development
DevOps
Security
View all topics
EXPLORE BY TYPE
Customer stories
Events & webinars
Ebooks & reports
Business insights
GitHub Skills
SUPPORT & SERVICES
Documentation
Customer support
Community forum
Trust center
Partners
View all resources
Open Source
COMMUNITY
GitHub Sponsors
Fund open source developers
PROGRAMS
Security Lab
Maintainer Community
GitHub Stars
Archive Program
REPOSITORIES
Topics
Trending
Collections
Enterprise
ENTERPRISE SOLUTIONS
Enterprise platform
AI-powered developer platform
AVAILABLE ADD-ONS
GitHub Advanced Security
Enterprise-grade security features
Copilot for Business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
chetmurthy
ocaml-cppffigen
Repository navigation
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
More
items
Files
Expand file tree
master
Breadcrumbs
ocaml-cppffigen
/
cppffigen_main.ml
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
45 lines (38 loc) · 1.32 KB
master
Breadcrumbs
ocaml-cppffigen
/
cppffigen_main.ml
Copy path
Top
File metadata and controls
Code
Blame
45 lines (38 loc) · 1.32 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
44
45
(**pp -syntax camlp5o -package pa_ppx.located_sexp,pa_ppx_fmtformat*)
open Cppffigen
open Cmdliner
open Pa_ppx_located_sexp
Pa_ppx_runtime.Exceptions.Ploc.pp_loc_verbose := true ;;
Pa_ppx_runtime_fat.Exceptions.Ploc.pp_loc_verbose := true ;;
let expand_composite tmap t =
let expand1 = function
| ATTRIBUTE t -> expand_attribute t
| STRUCT t -> expand_struct tmap t
| t -> [t] in
{ stanzas = List.concat (List.map expand1 t.stanzas) }
let gen_f ic pps mode =
let t = t_of_located_sexp (Sexp.input_sexp ic) in
let tmap = TMAP.mk t.stanzas in
let t = expand_composite tmap t in
match mode with
| `CPP -> CPP.gen tmap pps t
| `ML -> ML.gen tmap pps t
| `MLI -> MLI.gen tmap pps t
| `SEXP -> Sexp.pp_hum pps (located_sexp_of_t t)
let opts_sect = "OPTIONS"
let gen_cmd =
let doc = "C++ FFI generator" in
let man = [] in
let ftype =
let doc = "output file type (cpp or ml)" in
let docs = opts_sect in
Arg.(value & opt (enum ["cpp",`CPP; "ml", `ML; "mli", `MLI; "sexp", `SEXP]) `CPP & info ["output"] ~docs ~docv:"OUTPUT-FILE-TYPE" ~doc) in
Term.(const (gen_f stdin Format.std_formatter) $ ftype),
Term.info "cppffigen" ~version ~sdocs:opts_sect ~doc ~man
let main () =
match Term.eval ~catch:true gen_cmd with
| `Error _ -> exit 1 | _ -> exit 0
;;
if not !Sys.interactive then
main()
;;
You can’t perform that action at this time.