-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
57a7c8a
commit b11a83f
Showing
42 changed files
with
6,458 additions
and
1,135 deletions.
There are no files selected for viewing
151 changes: 151 additions & 0 deletions
151
Examples/Primes/LibPrimes_component/Bindings/C/libprimes.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
/*++ | ||
Copyright (C) 2018 Automatic Component Toolkit Developers | ||
All rights reserved. | ||
This file has been generated by the Automatic Component Toolkit (ACT) version 1.2.4. | ||
Abstract: This is an autogenerated plain C Header file in order to allow an easy | ||
use of Prime Numbers Interface | ||
Interface version: 1.2.0 | ||
*/ | ||
|
||
#ifndef __LIBPRIMES_HEADER | ||
#define __LIBPRIMES_HEADER | ||
|
||
#ifdef __LIBPRIMES_DLL | ||
#ifdef WIN32 | ||
#define LIBPRIMES_DECLSPEC __declspec (dllexport) | ||
#else // WIN32 | ||
#define LIBPRIMES_DECLSPEC __attribute__((visibility("default"))) | ||
#endif // WIN32 | ||
#else // __LIBPRIMES_DLL | ||
#define LIBPRIMES_DECLSPEC | ||
#endif // __LIBPRIMES_DLL | ||
|
||
#include "libprimes_types.h" | ||
|
||
extern "C" { | ||
|
||
/************************************************************************************************************************* | ||
Class definition for Calculator | ||
**************************************************************************************************************************/ | ||
|
||
/** | ||
* Returns the current value of this Calculator | ||
* | ||
* @param[in] pCalculator - Calculator instance. | ||
* @param[out] pValue - The current value of this Calculator | ||
* @return error code or 0 (success) | ||
*/ | ||
LIBPRIMES_DECLSPEC LibPrimesResult libprimes_calculator_getvalue (LibPrimes_Calculator pCalculator, unsigned long long * pValue); | ||
|
||
/** | ||
* Sets the value to be factorized | ||
* | ||
* @param[in] pCalculator - Calculator instance. | ||
* @param[in] nValue - The value to be factorized | ||
* @return error code or 0 (success) | ||
*/ | ||
LIBPRIMES_DECLSPEC LibPrimesResult libprimes_calculator_setvalue (LibPrimes_Calculator pCalculator, unsigned long long nValue); | ||
|
||
/** | ||
* Sets the progress callback function | ||
* | ||
* @param[in] pCalculator - Calculator instance. | ||
* @param[in] pProgressCallback - The progress callback | ||
* @return error code or 0 (success) | ||
*/ | ||
LIBPRIMES_DECLSPEC LibPrimesResult libprimes_calculator_setprogresscallback (LibPrimes_Calculator pCalculator, LibPrimesProgressCallback pProgressCallback); | ||
|
||
/** | ||
* Performs the specific calculation of this Calculator | ||
* | ||
* @param[in] pCalculator - Calculator instance. | ||
* @return error code or 0 (success) | ||
*/ | ||
LIBPRIMES_DECLSPEC LibPrimesResult libprimes_calculator_calculate (LibPrimes_Calculator pCalculator); | ||
|
||
/************************************************************************************************************************* | ||
Class definition for FactorizationCalculator | ||
**************************************************************************************************************************/ | ||
|
||
/** | ||
* Returns the prime factors of this number (without multiplicity) | ||
* | ||
* @param[in] pFactorizationCalculator - FactorizationCalculator instance. | ||
* @param[in] nPrimeFactorsBufferSize - Number of elements in buffer | ||
* @param[out] pPrimeFactorsNeededCount - will be filled with the count of the written elements, or needed buffer size. | ||
* @param[out] pPrimeFactorsBuffer - PrimeFactor buffer of The prime factors of this number | ||
* @return error code or 0 (success) | ||
*/ | ||
LIBPRIMES_DECLSPEC LibPrimesResult libprimes_factorizationcalculator_getprimefactors (LibPrimes_FactorizationCalculator pFactorizationCalculator, const unsigned int nPrimeFactorsBufferSize, unsigned int * pPrimeFactorsNeededCount, sLibPrimesPrimeFactor * pPrimeFactorsBuffer); | ||
|
||
/************************************************************************************************************************* | ||
Class definition for SieveCalculator | ||
**************************************************************************************************************************/ | ||
|
||
/** | ||
* Returns all prime numbers lower or equal to the sieve's value | ||
* | ||
* @param[in] pSieveCalculator - SieveCalculator instance. | ||
* @param[in] nPrimesBufferSize - Number of elements in buffer | ||
* @param[out] pPrimesNeededCount - will be filled with the count of the written elements, or needed buffer size. | ||
* @param[out] pPrimesBuffer - uint64 buffer of The primes lower or equal to the sieve's value | ||
* @return error code or 0 (success) | ||
*/ | ||
LIBPRIMES_DECLSPEC LibPrimesResult libprimes_sievecalculator_getprimes (LibPrimes_SieveCalculator pSieveCalculator, const unsigned int nPrimesBufferSize, unsigned int * pPrimesNeededCount, unsigned long long * pPrimesBuffer); | ||
|
||
/************************************************************************************************************************* | ||
Global functions | ||
**************************************************************************************************************************/ | ||
|
||
/** | ||
* Creates a new FactorizationCalculator instance | ||
* | ||
* @param[out] pInstance - New FactorizationCalculator instance | ||
* @return error code or 0 (success) | ||
*/ | ||
LIBPRIMES_DECLSPEC LibPrimesResult libprimes_createfactorizationcalculator (LibPrimes_FactorizationCalculator * pInstance); | ||
|
||
/** | ||
* Creates a new SieveCalculator instance | ||
* | ||
* @param[out] pInstance - New SieveCalculator instance | ||
* @return error code or 0 (success) | ||
*/ | ||
LIBPRIMES_DECLSPEC LibPrimesResult libprimes_createsievecalculator (LibPrimes_SieveCalculator * pInstance); | ||
|
||
/** | ||
* Releases the memory of an Instance | ||
* | ||
* @param[in] pInstance - Instance Handle | ||
* @return error code or 0 (success) | ||
*/ | ||
LIBPRIMES_DECLSPEC LibPrimesResult libprimes_releaseinstance (LibPrimes_BaseClass pInstance); | ||
|
||
/** | ||
* retrieves the current version of the library. | ||
* | ||
* @param[out] pMajor - returns the major version of the library | ||
* @param[out] pMinor - returns the minor version of the library | ||
* @param[out] pMicro - returns the micro version of the library | ||
* @return error code or 0 (success) | ||
*/ | ||
LIBPRIMES_DECLSPEC LibPrimesResult libprimes_getlibraryversion (unsigned int * pMajor, unsigned int * pMinor, unsigned int * pMicro); | ||
|
||
/** | ||
* Handles Library Journaling | ||
* | ||
* @param[in] pFileName - Journal FileName | ||
* @return error code or 0 (success) | ||
*/ | ||
LIBPRIMES_DECLSPEC LibPrimesResult libprimes_setjournal (const char * pFileName); | ||
|
||
} | ||
|
||
#endif // __LIBPRIMES_HEADER | ||
|
83 changes: 83 additions & 0 deletions
83
Examples/Primes/LibPrimes_component/Bindings/C/libprimes_types.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/*++ | ||
Copyright (C) 2018 Automatic Component Toolkit Developers | ||
All rights reserved. | ||
This file has been generated by the Automatic Component Toolkit (ACT) version 1.2.4. | ||
Abstract: This is an autogenerated plain C Header file with basic types in | ||
order to allow an easy use of Prime Numbers Interface | ||
Interface version: 1.2.0 | ||
*/ | ||
|
||
#ifndef __LIBPRIMES_TYPES_HEADER | ||
#define __LIBPRIMES_TYPES_HEADER | ||
|
||
/************************************************************************************************************************* | ||
General type definitions | ||
**************************************************************************************************************************/ | ||
|
||
typedef int LibPrimesResult; | ||
typedef void * LibPrimesHandle; | ||
|
||
/************************************************************************************************************************* | ||
Version for LibPrimes | ||
**************************************************************************************************************************/ | ||
|
||
#define LIBPRIMES_VERSION_MAJOR 1 | ||
#define LIBPRIMES_VERSION_MINOR 2 | ||
#define LIBPRIMES_VERSION_MICRO 0 | ||
|
||
/************************************************************************************************************************* | ||
Error constants for LibPrimes | ||
**************************************************************************************************************************/ | ||
|
||
#define LIBPRIMES_SUCCESS 0 | ||
#define LIBPRIMES_ERROR_NOTIMPLEMENTED 1 | ||
#define LIBPRIMES_ERROR_INVALIDPARAM 2 | ||
#define LIBPRIMES_ERROR_INVALIDCAST 3 | ||
#define LIBPRIMES_ERROR_BUFFERTOOSMALL 4 | ||
#define LIBPRIMES_ERROR_GENERICEXCEPTION 5 | ||
#define LIBPRIMES_ERROR_COULDNOTLOADLIBRARY 6 | ||
#define LIBPRIMES_ERROR_COULDNOTFINDLIBRARYEXPORT 7 | ||
#define LIBPRIMES_ERROR_NORESULTAVAILABLE 8 | ||
#define LIBPRIMES_ERROR_CALCULATIONABORTED 9 | ||
|
||
/************************************************************************************************************************* | ||
Declaration of handle classes | ||
**************************************************************************************************************************/ | ||
|
||
typedef LibPrimesHandle LibPrimes_BaseClass; | ||
typedef LibPrimesHandle LibPrimes_Calculator; | ||
typedef LibPrimesHandle LibPrimes_FactorizationCalculator; | ||
typedef LibPrimesHandle LibPrimes_SieveCalculator; | ||
|
||
/************************************************************************************************************************* | ||
Declaration of structs | ||
**************************************************************************************************************************/ | ||
|
||
#pragma pack (1) | ||
|
||
typedef struct { | ||
unsigned long long m_Prime; | ||
unsigned int m_Multiplicity; | ||
} sLibPrimesPrimeFactor; | ||
|
||
#pragma pack () | ||
|
||
/************************************************************************************************************************* | ||
Declaration of function pointers | ||
**************************************************************************************************************************/ | ||
|
||
/** | ||
* LibPrimesProgressCallback - Callback to report calculation progress and query whether it should be aborted | ||
* | ||
* @param[in] fProgressPercentage - How far has the calculation progressed? | ||
* @param[out] pShouldAbort - Should the calculation be aborted? | ||
*/ | ||
typedef void(*LibPrimesProgressCallback)(float, bool*); | ||
|
||
#endif // __LIBPRIMES_TYPES_HEADER |
Oops, something went wrong.