<commit_before>// Copyright 2013 The gl-rs developers. For a full listing of the authors,
// refer to the AUTHORS file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#[link(name = "glgen",
       author = "<NAME>",
       vers = "0.1")];
#[comment = "OpenGL function loader generator."];
#[license = "ASL2"];

//! Requires libxml2
//!
//! This will be used to generate the loader from the [registry xml files]
//! (https://cvs.khronos.org/svn/repos/ogl/trunk/doc/registry/public/api/):
//!
//! - `$ wget --no-check-certificate https://cvs.khronos.org/svn/repos/ogl/trunk/doc/registry/public/api/gl.xml`
//! - `$ wget --no-check-certificate https://cvs.khronos.org/svn/repos/ogl/trunk/doc/registry/public/api/glx.xml`
//! - `$ wget --no-check-certificate https://cvs.khronos.org/svn/repos/ogl/trunk/doc/registry/public/api/wgl.xml`

extern mod extra;

use extra::getopts::groups::*;

use std::hashmap::HashMap;
use std::io;
use std::os;

use registry::*;

pub mod registry;
pub mod ty;

pub struct GeneratorFilter {
    extensions: ~[~str],
    profile: ~str,
    version: ~str,
    api: ~str,
}

pub struct GeneratorOptions {
    filter: Option<GeneratorFilter>,
}

fn main() {
    let opts = &[
        optopt("", "namespace", "OpenGL namespace (gl by default)", "gl|glx|wgl"),
        optopt("", "api", "API to generate bindings for (gl by default)", "gl|gles1|gles2"),
        optopt("", "type", "Binding type to generate (ptr by default)", "ptr|struct"),
        optopt("", "profile", "Profile to generate (core by default)", "core|compatability"),
        optopt("", "version", "Version to generate bindings for (4.3 by default)", ""),
        optmulti("", "extension", "Extension to include", ""),
        optflag("", "full", "Generate API for all profiles and extensions"),
    ];

    let args = match getopts(os::args(), opts) {
        Ok(a) => a,
        Err(x) => fail!("Error: %s\n%s", x.to_err_msg(), usage("generator", opts)),
    };

    let (path, ns) = match args.opt_str("namespace").unwrap_or(~"gl") {
        ~"gl"  => (~"gl.xml", registry::Gl),
        ~"glx" => fail!("glx generation unimplemented"),
        ~"wgl" => fail!("wgl generation unimplemented"),
        ns     => fail2!("Unexpected opengl namespace '{}'", ns)
    };<commit_msg>Clarify help text for --full<commit_after>// Copyright 2013 The gl-rs developers. For a full listing of the authors,
// refer to the AUTHORS file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#[link(name = "glgen",
       author = "<NAME>",
       vers = "0.1")];
#[comment = "OpenGL function loader generator."];
#[license = "ASL2"];

//! Requires libxml2
//!
//! This will be used to generate the loader from the [registry xml files]
//! (https://cvs.khronos.org/svn/repos/ogl/trunk/doc/registry/public/api/):
//!
//! - `$ wget --no-check-certificate https://cvs.khronos.org/svn/repos/ogl/trunk/doc/registry/public/api/gl.xml`
//! - `$ wget --no-check-certificate https://cvs.khronos.org/svn/repos/ogl/trunk/doc/registry/public/api/glx.xml`
//! - `$ wget --no-check-certificate https://cvs.khronos.org/svn/repos/ogl/trunk/doc/registry/public/api/wgl.xml`

extern mod extra;

use extra::getopts::groups::*;

use std::hashmap::HashMap;
use std::io;
use std::os;

use registry::*;

pub mod registry;
pub mod ty;

pub struct GeneratorFilter {
    extensions: ~[~str],
    profile: ~str,
    version: ~str,
    api: ~str,
}

pub struct GeneratorOptions {
    filter: Option<GeneratorFilter>,
}

fn main() {
    let opts = &[
        optopt("", "namespace", "OpenGL namespace (gl by default)", "gl|glx|wgl"),
        optopt("", "api", "API to generate bindings for (gl by default)", "gl|gles1|gles2"),
        optopt("", "type", "Binding type to generate (ptr by default)", "ptr|struct"),
        optopt("", "profile", "Profile to generate (core by default)", "core|compatability"),
        optopt("", "version", "Version to generate bindings for (4.3 by default)", ""),
        optmulti("", "extension", "Extension to include", ""),
        optflag("", "full", "Generate API for all profiles, versions and extensions"),
    ];

    let args = match getopts(os::args(), opts) {
        Ok(a) => a,
        Err(x) => fail!("Error: %s\n%s", x.to_err_msg(), usage("generator", opts)),
    };

    let (path, ns) = match args.opt_str("namespace").unwrap_or(~"gl") {
        ~"gl"  => (~"gl.xml", registry::Gl),
        ~"glx" => fail!("glx generation unimplemented"),
        ~"wgl" => fail!("wgl generation unimplemented"),
        ns     => fail2!("Unexpected opengl namespace '{}'", ns)
    };
{'fraction_non_alphanumeric': 0.17074889867841408, 'fraction_numerical': 0.0059911894273127755, 'mean_word_length': 3.332824427480916, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 19, 'https://': 8, 'lorem ipsum': 0, 'www.': 2, 'xml': 12}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4515231', 'n_tokens_mistral': 1826, 'n_tokens_neox': 1793, 'n_words': 557}