Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate some more code to reduce code duplication and table sync issues #64

Open
fingolfin opened this issue May 8, 2019 · 3 comments

Comments

@fingolfin
Copy link
Member

In Singular 4.1, they added some new types, including smatrix and cring. We probably will want to support those eventually. Right now, adding support for a new Singular type foobar is very cumbersome, as it involves at least changing the following (and more if we actually want to provide useful functions for those types):

  • src/singtypes.h: add SINGTYPE_FOOBAR and SINGTYPE_FOOBAR_IMM to enum SingType
  • src/singtypes.h: update GAPtoSingType, and HasRingTable (and ensure HasRingTable stays in sync with its counterpart in src/gen_highlevel_mappings.g); and also add ExportAsRecEntry(SINGTYPE_FOOBAR) in `InitSingTypesFromKernel()
  • lib/libsing.gd and lib/libsing.gi: add constructor SI_foobar`
  • lib/singtypes.gd: call DeclareCategory, create GAP types and put them into _SI_Types
  • lib/singtypes.gi: add a _SI_TypeName method
  • optionally (but recommended): lib/view.gi: add View methods
  • src/gen_highlevel_mappings.g: add foobar to IsRingDep and possibly singularConstructors
  • ... ?

A lot of that could be generated by a script from a single source file. That could then also do additional things; e.g. it would be nice if we also had a way to map Singular enum values like STRING_CMD to strings (e.g. "STRING_CMD") and back; then this can be used to add helpful comments in generated code and for other debugging purposes.

@hannes14
Copy link
Contributor

hannes14 commented May 8, 2019

libSingular provides Tok2Cmdname
(const char * Tok2Cmdname(int tok) in Singular/ipshell.h)
which converts STRING_CMD to "string", int('+') to "+", etc.
The other way is provided by IsCmd
(int IsCmd(const char *n, int & tok); in Singular/ipshell.h)
return for IsCmd("string",t) STRING_CMD (and sets t to ROOT_DECL_LIST)

@fingolfin
Copy link
Member Author

Beautiful, thank you, that makes some of these things a lot easier.

@fingolfin
Copy link
Member Author

OK, I just realized that I am actually aware of these, and we are using them -- what I meant is that I really want the string "STRING_CMD" as output for the input value STRING_CMD. But that, too, shouldn't be too hard to set up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants