EventList and Spline do not seem to be defined (api)

Ouverte
#1 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Évaluation

Difficulté
3/5
Temps estimé
1-2 jours
Accessibilité débutants
45/100
Type d'issue
Bug
Clarté
Plutôt claire
Activité
À l'abandon
Stack technique
c, javascript
Domaine
api, build-system

Piste de recherche

Commencez par tools/gen_api.js et les entrées de la blocklist pour EventList et Spline, puis inspectez build/_deps/raylib-src/parser/output/raylib_api.json et le tools/api.json généré. Comparez les déclarations générées avec la version de raylib utilisée par le DLL FFI wrapper. C'est terminé lorsque les entrées d'API concernées correspondent aux symboles raylib disponibles et ne produisent plus d'erreurs de fonction indéfinie.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

api bug todo

Essentially, all the functions with EventList or Spline are not defined (but are output by raylib api-gen) and throw an error if DLL is ffi-wrapped.

I think this is related to versioning mismatch with raylib (which may be a sign I need to adjust build to use raylib better.)

https://github.com/konsumer/raylib-pointers/blob/f365325/tools/gen_api.js#L27


// this will generate API info about all the new wrapped stuff & utils
// it's basically the same as the stuff parser generates in raylib
// but I add my wrappers and and struct-utils

import { writeFile, readFile } from 'fs/promises'

// check if the function will be wrapped
const isWrapped = (f) => {
  const returnPointer = /^[A-Z]/.test(f.returnType)

  // do any params need to be converted to pointers?
  let paramPointer = false

  for (const p of f.params || []) {
    if (/[A-Z]/.test(p.type)) {
      paramPointer = true
      break
    }
  }
  return returnPointer || paramPointer
}

export const blocklist = [
  // this is blocked because I add wrapped_WindowShouldClose manually
  'WindowShouldClose',

  // TODO: I think these are not available in the current version, but for some reason are referenced
  'LoadAutomationEventList',
  'UnloadAutomationEventList',
  'ExportAutomationEventList',
  'SetAutomationEventList',
  'PlayAutomationEventList',
  'PlayAutomationEvent',
  'DrawLineBezier',
  'DrawCircleLinesV',
  'DrawSplineLinear',
  'DrawSplineBasis',
  'DrawSplineCatmullRom',
  'DrawSplineBezierQuadratic',
  'DrawSplineBezierCubic',
  'DrawSplineSegmentLinear',
  'DrawSplineSegmentBasis',
  'DrawSplineSegmentCatmullRom',
  'DrawSplineSegmentBezierQuadratic',
  'DrawSplineSegmentBezierCubic',
  'GetSplinePointLinear',
  'GetSplinePointBasis',
  'GetSplinePointCatmullRom',
  'GetSplinePointBezierQuad',
  'GetSplinePointBezierCubic'
]

const blocklistStructs = []

const { defines, structs, aliases, enums, callbacks, functions } = JSON.parse(await readFile('build/_deps/raylib-src/parser/output/raylib_api.json'))

const wrapped = []
const unwrapped = []
const struct_utils = []

for (const { name, description, fields } of structs) {
  if (blocklistStructs.includes(name)) {
    continue
  }

  struct_utils.push({
    name: `${name}_size`,
    description: `Get byte-size of ${name} struct`,
    returnType: 'unsigned int',
    params: []
  })
  for (const field of fields) {
    struct_utils.push({
      name: `${name}_get_${field.name}`,
      description: `Getter for ${name}->${field.name}`,
      returnType: field.type,
      params: [{ name: 'obj', type: `${field.name}*` }]
    })
    struct_utils.push({
      name: `${name}_set_${field.name}`,
      description: `Setter for ${name}->${field.name}`,
      returnType: 'void',
      params: [
        { name: 'obj', type: `${field.name}*` },
        { name: 'v', type: field.type }
      ]
    })
  }
}

for (const f of functions) {
  if (blocklist.includes(f.name)) {
    continue
  }
  if (isWrapped(f)) {
    wrapped.push({
      name: `wrapped_${f.name}`,
      description: f.description,
      original: f.name,
      returnType: /[A-Z]/.test(f.returnType) ? `${f.returnType}*` : f.returnType,
      params: (f.params || []).map((p) => {
        return {
          ...p,
          type: /[A-Z]/.test(p.type) ? `${p.type}*` : p.type
        }
      })
    })
  } else {
    f.params ||= []
    unwrapped.push(f)
  }
}

// these are my additions (per-frame alloc/free)

wrapped.push({
  name: 'wrapped_alloc',
  original: 'alloc',
  description: 'Allocate memory, cleared on every WindowShouldClose call (your frame update-loop)',
  returnType: 'void*',
  params: [
    {
      name: 'size',
      type: 'unsigned int',
      description: 'The size (in bytes) to allocate'
    }
  ]
})

wrapped.push({
  name: 'wrapped_free',
  original: 'free',
  description: 'Clear allocated memory. If it was not allocated (or has already been freed) this will error.',
  returnType: 'void',
  params: [
    {
      name: 'pointer',
      type: 'void*',
      description: 'The pointer to free'
    }
  ]
})

wrapped.push({
  name: 'wrapped_WindowShouldClose',
  original: 'WindowShouldClose',
  description: 'Check if application should close (KEY_ESCAPE pressed or windows close icon clicked.) This also clears memory that was allocated since last call.',
  returnType: 'bool',
  params: []
})

await writeFile('tools/api.json', JSON.stringify({ unwrapped, wrapped, struct_utils, defines, structs, aliases, enums, callbacks, functions }, null, 2))

Langage dominant
C
Étoiles
0
Forks
1
Métriques de merge des PR
Aucune PR mergée en 30 j

Préparer son environnement

Ce projet ne fournit ni conteneur de développement, ni Dockerfile, ni guide de contribution : l'installation est à votre charge. Commencez par son README, et consultez notre guide de la première contribution pour les étapes générales.

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de konsumer/raylib-pointers

Toutes les issues de konsumer/raylib-pointers

Issues similaires

Plus d'issues C

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.