<commit_before>/*
 * gauche-gl.c - Gauche GL binding
 *
 *  Copyright(C) 2001 by <NAME> (<EMAIL>)
 *
 *  Permission to use, copy, modify, distribute this software and
 *  accompanying documentation for any purpose is hereby granted,
 *  provided that existing copyright notices are retained in all
 *  copies and that this notice is included verbatim in all
 *  distributions.
 *  This software is provided as is, without express or implied
 *  warranty.  In no circumstances the author(s) shall be liable
 *  for any damages arising out of the use of this software.
 *
 *  $Id: gauche-gl.c,v 1.5 2001-10-02 09:07:54 shirok Exp $
 */

#include <gauche.h>
#include "gauche-gl.h"

/* Utility functions */

/* List of numbers -> array of doubles.  Returns # of elements. */
int Scm_GLGetDoubles(ScmObj val1, ScmObj list, double *result,
                     int maxresult, int minresult)
{
    int i = 0;
    ScmObj lp;

    if (!SCM_UNBOUNDP(val1)) {
        if (!SCM_NUMBERP(val1)) {
            Scm_Error("number required, but got %S", val1);
        }
        result[0] = Scm_GetDouble(val1);
        i++;
    }
    
    SCM_FOR_EACH(lp, list) {
        if (i >= maxresult) {
            Scm_Error("too many arguments: %S, at most %d allowed",
                      list, maxresult);
        }
        if (!SCM_NUMBERP(SCM_CAR(lp))) {
            Scm_Error("number required, but got %S", SCM_CAR(lp));
        }
        result[i] = Scm_GetDouble(SCM_CAR(lp));
        i++;
    }
    if (i < minresult) {
        Scm_Error("too few argument: %S, at least %d required",
                  list, minresult);
    }
    return i;
}

/* returns # of values returned by glGetTYPEv call for given state.
   -1 if the state can't be queried by glGetTYPEv. */
#if 0 /* not finished */
int Scm_GLStateInfoSize(GLenum state)
{
   switch(state) {
     case GL_CURRENT_COLOR:;
     case GL_CURRENT_TEXTURE_COORDS:;
     case GL_CURRENT_RASTER_POSITION:;
     case GL_CURRENT_RASTER_COLOR:;
     case GL_CURRENT_RASTER_TEXTURE_COORDS:;
     case GL_FOG_COLOR:;
     case GL_LIGHT_MODEL_AMBIENT:;
     case GL_COLOR_CLEAR_VALUE:;
     case GL_MAP2_GRID_DOMAIN: return 4;

     case GL_CURRENT_NORMAL: return 3;

     case GL_DEPTH_RANGE:;
     case GL_MAP1_GRID_DOMAIN:;
   case GL_MAP2_GRID_SEGMENTS: return 2;
   }
}
#endif
<commit_msg>added Scm_GLStateInfoSize<commit_after>/*
 * gauche-gl.c - Gauche GL binding
 *
 *  Copyright(C) 2001 by <NAME> (<EMAIL>)
 *
 *  Permission to use, copy, modify, distribute this software and
 *  accompanying documentation for any purpose is hereby granted,
 *  provided that existing copyright notices are retained in all
 *  copies and that this notice is included verbatim in all
 *  distributions.
 *  This software is provided as is, without express or implied
 *  warranty.  In no circumstances the author(s) shall be liable
 *  for any damages arising out of the use of this software.
 *
 *  $Id: gauche-gl.c,v 1.6 2001-10-02 11:08:28 shirok Exp $
 */

#include <gauche.h>
#include "gauche-gl.h"

/* Utility functions */

/* List of numbers -> array of doubles.  Returns # of elements. */
int Scm_GLGetDoubles(ScmObj val1, ScmObj list, double *result,
                     int maxresult, int minresult)
{
    int i = 0;
    ScmObj lp;

    if (!SCM_UNBOUNDP(val1)) {
        if (!SCM_NUMBERP(val1)) {
            Scm_Error("number required, but got %S", val1);
        }
        result[0] = Scm_GetDouble(val1);
        i++;
    }
    
    SCM_FOR_EACH(lp, list) {
        if (i >= maxresult) {
            Scm_Error("too many arguments: %S, at most %d allowed",
                      list, maxresult);
        }
        if (!SCM_NUMBERP(SCM_CAR(lp))) {
            Scm_Error("number required, but got %S", SCM_CAR(lp));
        }
        result[i] = Scm_GetDouble(SCM_CAR(lp));
        i++;
    }
    if (i < minresult) {
        Scm_Error("too few argument: %S, at least %d required",
                  list, minresult);
    }
    return i;
}

/* returns # of values returned by glGetTYPEv call for given state.
   -1 if the state can't be queried by glGetTYPEv. */
int Scm_GLStateInfoSize(GLenum state)
{
   switch(state) {
#include "gettype-sizes.c"
   }
   return -1;
}

{'fraction_non_alphanumeric': 0.10635260528194147, 'fraction_numerical': 0.015227218653342851, 'mean_word_length': 2.5327731092436974, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '1405581', 'n_tokens_mistral': 1486, 'n_tokens_neox': 1427, 'n_words': 426}