forked from AcademySoftwareFoundation/OpenTimelineIO
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Proof of concept for C wrapper around C++ API.
- Loading branch information
Showing
5 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
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
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,21 @@ | ||
#include <stdio.h> | ||
#include "wrap.h" | ||
|
||
int main(int argc, char**argv){ | ||
printf("Hello\n"); | ||
|
||
RationalTime* t1 = OTIO_RationalTime_new(1,24); | ||
RationalTime* t2 = OTIO_RationalTime_new(10,24); | ||
RationalTime* t3 = OTIO_RationalTime_add(t1, t2); | ||
RationalTime* t4 = OTIO_RationalTime_rescaled_to(t3, 30); | ||
|
||
printf("t3 = %g @ %g\n", OTIO_RationalTime_get_value(t3), OTIO_RationalTime_get_rate(t3)); | ||
printf("t4 = %g @ %g\n", OTIO_RationalTime_get_value(t4), OTIO_RationalTime_get_rate(t4)); | ||
|
||
OTIO_RationalTime_delete(t1); | ||
OTIO_RationalTime_delete(t2); | ||
OTIO_RationalTime_delete(t3); | ||
OTIO_RationalTime_delete(t4); | ||
|
||
return 0; | ||
} |
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 @@ | ||
c++ -std=c++11 test_wrap.c wrap.cpp opentime.cpp && ./a.out |
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,33 @@ | ||
|
||
#include "wrap.h" | ||
|
||
#include "opentime.h" | ||
|
||
RationalTime* OTIO_RationalTime_new(double value, double rate) { | ||
return (RationalTime*)new opentime::RationalTime(value, rate); | ||
} | ||
|
||
void OTIO_RationalTime_delete(RationalTime* t) { | ||
delete (opentime::RationalTime*)t; | ||
} | ||
|
||
RationalTime* OTIO_RationalTime_add(RationalTime* a, RationalTime* b) { | ||
opentime::RationalTime* result = new opentime::RationalTime(*(opentime::RationalTime*)a); | ||
*result += *(opentime::RationalTime*)b; | ||
return (RationalTime*)result; | ||
} | ||
|
||
RationalTime* OTIO_RationalTime_rescaled_to(RationalTime* t, double rate) { | ||
opentime::RationalTime* result = new opentime::RationalTime( | ||
((opentime::RationalTime*)t)->rescaled_to(rate) | ||
); | ||
return (RationalTime*)result; | ||
} | ||
|
||
double OTIO_RationalTime_get_value(RationalTime* t) { | ||
return ((opentime::RationalTime*)t)->value; | ||
} | ||
|
||
double OTIO_RationalTime_get_rate(RationalTime* t) { | ||
return ((opentime::RationalTime*)t)->rate; | ||
} |
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,12 @@ | ||
|
||
extern "C" | ||
{ | ||
typedef void* RationalTime; | ||
|
||
RationalTime* OTIO_RationalTime_new(double value, double rate); | ||
void OTIO_RationalTime_delete(RationalTime* t); | ||
RationalTime* OTIO_RationalTime_add(RationalTime* a, RationalTime* b); | ||
RationalTime* OTIO_RationalTime_rescaled_to(RationalTime* t, double rate); | ||
double OTIO_RationalTime_get_value(RationalTime* t); | ||
double OTIO_RationalTime_get_rate(RationalTime* t); | ||
} |