Skip to content

Commit

Permalink
Merge pull request #3615 from andre2007/c_functions
Browse files Browse the repository at this point in the history
Add toolkit functions to c_wrapper
  • Loading branch information
lpugin authored Mar 4, 2024
2 parents 05b1072 + b2f9dc7 commit b7d4d7b
Show file tree
Hide file tree
Showing 2 changed files with 119 additions and 2 deletions.
101 changes: 100 additions & 1 deletion tools/c_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,19 @@ const char *vrvToolkit_getHumdrum(void *tkPtr)
return buffer;
}

bool vrvToolkit_getHumdrumFile(void *tkPtr, const char *filename)
{
Toolkit *tk = static_cast<Toolkit *>(tkPtr);
return tk->GetHumdrumFile(filename);
}

const char *vrvToolkit_getID(void *tkPtr)
{
Toolkit *tk = static_cast<Toolkit *>(tkPtr);
tk->SetCString(tk->GetID());
return tk->GetCString();
}

const char *vrvToolkit_convertHumdrumToHumdrum(void *tkPtr, const char *humdrumData)
{
Toolkit *tk = static_cast<Toolkit *>(tkPtr);
Expand Down Expand Up @@ -192,6 +205,19 @@ int vrvToolkit_getPageWithElement(void *tkPtr, const char *xmlId)
return tk->GetPageWithElement(xmlId);
}

const char *vrvToolkit_getResourcePath(void *tkPtr)
{
Toolkit *tk = static_cast<Toolkit *>(tkPtr);
tk->SetCString(tk->GetResourcePath());
return tk->GetCString();
}

int vrvToolkit_getScale(void *tkPtr)
{
Toolkit *tk = static_cast<Toolkit *>(tkPtr);
return tk->GetScale();
}

double vrvToolkit_getTimeForElement(void *tkPtr, const char *xmlId)
{
Toolkit *tk = static_cast<Toolkit *>(tkPtr);
Expand All @@ -218,6 +244,12 @@ bool vrvToolkit_loadData(void *tkPtr, const char *data)
return tk->LoadData(data);
}

bool vrvToolkit_loadFile(void *tkPtr, const char *filename)
{
Toolkit *tk = static_cast<Toolkit *>(tkPtr);
return tk->LoadFile(filename);
}

bool vrvToolkit_loadZipDataBase64(void *tkPtr, const char *data)
{
Toolkit *tk = static_cast<Toolkit *>(tkPtr);
Expand Down Expand Up @@ -256,34 +288,64 @@ const char *vrvToolkit_renderToExpansionMap(void *tkPtr)
return tk->GetCString();
}

const char *vrvToolkit_renderToMIDI(void *tkPtr, const char *c_options)
bool vrvToolkit_renderToExpansionMapFile(void *tkPtr, const char *filename)
{
Toolkit *tk = static_cast<Toolkit *>(tkPtr);
return tk->RenderToExpansionMapFile(filename);
}

const char *vrvToolkit_renderToMIDI(void *tkPtr)
{
Toolkit *tk = static_cast<Toolkit *>(tkPtr);
tk->SetCString(tk->RenderToMIDI());
return tk->GetCString();
}

bool vrvToolkit_renderToMIDIFile(void *tkPtr, const char *filename)
{
Toolkit *tk = static_cast<Toolkit *>(tkPtr);
return tk->RenderToMIDIFile(filename);
}

const char *vrvToolkit_renderToPAE(void *tkPtr)
{
Toolkit *tk = static_cast<Toolkit *>(tkPtr);
tk->SetCString(tk->RenderToPAE());
return tk->GetCString();
}

bool vrvToolkit_renderToPAEFile(void *tkPtr, const char *filename)
{
Toolkit *tk = static_cast<Toolkit *>(tkPtr);
return tk->RenderToPAEFile(filename);
}

const char *vrvToolkit_renderToSVG(void *tkPtr, int page_no, bool xmlDeclaration)
{
Toolkit *tk = static_cast<Toolkit *>(tkPtr);
tk->SetCString(tk->RenderToSVG(page_no, xmlDeclaration));
return tk->GetCString();
}

bool vrvToolkit_renderToSVGFile(void *tkPtr, const char *filename, int pageNo)
{
Toolkit *tk = static_cast<Toolkit *>(tkPtr);
return tk->RenderToSVGFile(filename, pageNo);
}

const char *vrvToolkit_renderToTimemap(void *tkPtr, const char *c_options)
{
Toolkit *tk = static_cast<Toolkit *>(tkPtr);
tk->SetCString(tk->RenderToTimemap(c_options));
return tk->GetCString();
}

bool vrvToolkit_renderToTimemapFile(void *tkPtr, const char *filename, const char *c_options)
{
Toolkit *tk = static_cast<Toolkit *>(tkPtr);
return tk->RenderToTimemapFile(filename, c_options);
}

void vrvToolkit_resetOptions(void *tkPtr)
{
Toolkit *tk = static_cast<Toolkit *>(tkPtr);
Expand All @@ -296,23 +358,60 @@ void vrvToolkit_resetXmlIdSeed(void *tkPtr, int seed)
tk->ResetXmlIdSeed(seed);
}

bool vrvToolkit_saveFile(void *tkPtr, const char *filename, const char *c_options)
{
Toolkit *tk = static_cast<Toolkit *>(tkPtr);
return tk->SaveFile(filename, c_options);
}

bool vrvToolkit_select(void *tkPtr, const char *selection)
{
Toolkit *tk = static_cast<Toolkit *>(tkPtr);
return tk->Select(selection);
}

bool vrvToolkit_setInputFrom(void *tkPtr, const char *inputFrom)
{
Toolkit *tk = static_cast<Toolkit *>(tkPtr);
return tk->SetInputFrom(inputFrom);
}

bool vrvToolkit_setOptions(void *tkPtr, const char *options)
{
Toolkit *tk = static_cast<Toolkit *>(tkPtr);
return tk->SetOptions(options);
}

bool vrvToolkit_setOutputTo(void *tkPtr, const char *outputTo)
{
Toolkit *tk = static_cast<Toolkit *>(tkPtr);
return tk->SetOutputTo(outputTo);
}

bool vrvToolkit_setResourcePath(void *tkPtr, const char *path)
{
Toolkit *tk = static_cast<Toolkit *>(tkPtr);
return tk->SetResourcePath(path);
}

bool vrvToolkit_setScale(void *tkPtr, int scale)
{
Toolkit *tk = static_cast<Toolkit *>(tkPtr);
return tk->SetScale(scale);
}

const char *vrvToolkit_validatePAE(void *tkPtr, const char *data)
{
Toolkit *tk = static_cast<Toolkit *>(tkPtr);
tk->SetCString(tk->ValidatePAE(data));
return tk->GetCString();
}

const char *vrvToolkit_validatePAEFile(void *tkPtr, const char *filename)
{
Toolkit *tk = static_cast<Toolkit *>(tkPtr);
tk->SetCString(tk->ValidatePAEFile(filename));
return tk->GetCString();
}

} // extern C
20 changes: 19 additions & 1 deletion tools/c_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,16 @@ void *vrvToolkit_constructorResourcePath(const char *resourcePath);

void vrvToolkit_destructor(void *tkPtr);
bool vrvToolkit_edit(void *tkPtr, const char *editorAction);
const char *vrvToolkit_editInfo(void *tkPtr);
const char *vrvToolkit_getAvailableOptions(void *tkPtr);
const char *vrvToolkit_getDefaultOptions(void *tkPtr);
const char *vrvToolkit_getDescriptiveFeatures(void *tkPtr, const char *options);
const char *vrvToolkit_getElementAttr(void *tkPtr, const char *xmlId);
const char *vrvToolkit_getElementsAtTime(void *tkPtr, int millisec);
const char *vrvToolkit_getExpansionIdsForElement(void *tkPtr, const char *xmlId);
const char *vrvToolkit_getHumdrum(void *tkPtr);
bool vrvToolkit_getHumdrumFile(void *tkPtr, const char *filename);
const char *vrvToolkit_getID(void *tkPtr);
const char *vrvToolkit_convertHumdrumToHumdrum(void *tkPtr, const char *humdrumData);
const char *vrvToolkit_convertHumdrumToMIDI(void *tkPtr, const char *humdrumData);
const char *vrvToolkit_convertMEIToHumdrum(void *tkPtr, const char *meiData);
Expand All @@ -39,24 +42,39 @@ const char *vrvToolkit_getOptions(void *tkPtr);
const char *vrvToolkit_getOptionUsageString(void *tkPtr);
int vrvToolkit_getPageCount(void *tkPtr);
int vrvToolkit_getPageWithElement(void *tkPtr, const char *xmlId);
const char *vrvToolkit_getResourcePath(void *tkPtr);
int vrvToolkit_getScale(void *tkPtr);
double vrvToolkit_getTimeForElement(void *tkPtr, const char *xmlId);
const char *vrvToolkit_getTimesForElement(void *tkPtr, const char *xmlId);
const char *vrvToolkit_getVersion(void *tkPtr);
bool vrvToolkit_loadData(void *tkPtr, const char *data);
bool vrvToolkit_loadFile(void *tkPtr, const char *filename);
bool vrvToolkit_loadZipDataBase64(void *tkPtr, const char *data);
bool vrvToolkit_loadZipDataBuffer(void *tkPtr, const unsigned char *data, int length);
void vrvToolkit_redoLayout(void *tkPtr, const char *c_options);
void vrvToolkit_redoPagePitchPosLayout(void *tkPtr);
const char *vrvToolkit_renderData(void *tkPtr, const char *data, const char *options);
const char *vrvToolkit_renderToExpansionMap(void *tkPtr);
const char *vrvToolkit_renderToMIDI(void *tkPtr, const char *c_options);
bool vrvToolkit_renderToExpansionMapFile(void *tkPtr, const char *filename);
const char *vrvToolkit_renderToMIDI(void *tkPtr);
bool vrvToolkit_renderToMIDIFile(void *tkPtr, const char *filename);
const char *vrvToolkit_renderToPAE(void *tkPtr);
bool vrvToolkit_renderToPAEFile(void *tkPtr, const char *filename);
const char *vrvToolkit_renderToSVG(void *tkPtr, int page_no, bool xmlDeclaration);
bool vrvToolkit_renderToSVGFile(void *tkPtr, const char *filename, int pageNo);
const char *vrvToolkit_renderToTimemap(void *tkPtr, const char *c_options);
bool vrvToolkit_renderToTimemapFile(void *tkPtr, const char *filename, const char *c_options);
void vrvToolkit_resetOptions(void *tkPtr);
void vrvToolkit_resetXmlIdSeed(void *tkPtr, int seed);
bool vrvToolkit_saveFile(void *tkPtr, const char *filename, const char *c_options);
bool vrvToolkit_select(void *tkPtr, const char *selection);
bool vrvToolkit_setInputFrom(void *tkPtr, const char *inputFrom);
bool vrvToolkit_setOptions(void *tkPtr, const char *options);
bool vrvToolkit_setOutputTo(void *tkPtr, const char *outputTo);
bool vrvToolkit_setResourcePath(void *tkPtr, const char *path);
bool vrvToolkit_setScale(void *tkPtr, int scale);
const char *vrvToolkit_validatePAE(void *tkPtr, const char *data);
const char *vrvToolkit_validatePAEFile(void *tkPtr, const char *filename);

#ifdef __cplusplus
} // extern C
Expand Down

0 comments on commit b7d4d7b

Please sign in to comment.