forked from KristopherGBaker/libcmark_gfm
-
Notifications
You must be signed in to change notification settings - Fork 0
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
03ba8f3
commit 1be85db
Showing
78 changed files
with
39,651 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
language: objective-c | ||
osx_image: xcode9.2 | ||
env: | ||
global: | ||
- LC_CTYPE=en_US.UTF-8 | ||
- LANG=en_US.UTF-8 | ||
- PROJECT=libcmark_gfm.xcodeproj | ||
- IOS_FRAMEWORK_SCHEME="libcmark_gfm-iOS" | ||
- MACOS_FRAMEWORK_SCHEME="libcmark_gfm-macOS" | ||
- TVOS_FRAMEWORK_SCHEME="libcmark_gfm-tvOS" | ||
- WATCHOS_FRAMEWORK_SCHEME="libcmark_gfm-watchOS" | ||
- IOS_SDK=iphonesimulator11.2 | ||
- MACOS_SDK=macosx10.13 | ||
- TVOS_SDK=appletvsimulator11.2 | ||
- WATCHOS_SDK=watchsimulator4.2 | ||
matrix: | ||
- DESTINATION="OS=4.2,name=Apple Watch Series 3 - 42mm" SCHEME="$WATCHOS_FRAMEWORK_SCHEME" SDK="$WATCHOS_SDK" RUN_TESTS="NO" POD_LINT="NO" | ||
|
||
- DESTINATION="OS=11.2,name=Apple TV 4K" SCHEME="$TVOS_FRAMEWORK_SCHEME" SDK="$TVOS_SDK" RUN_TESTS="YES" POD_LINT="NO" | ||
|
||
- DESTINATION="arch=x86_64" SCHEME="$MACOS_FRAMEWORK_SCHEME" SDK="$MACOS_SDK" RUN_TESTS="YES" POD_LINT="NO" | ||
|
||
- DESTINATION="OS=11.2,name=iPhone X" SCHEME="$IOS_FRAMEWORK_SCHEME" SDK="$IOS_SDK" RUN_TESTS="YES" POD_LINT="YES" | ||
|
||
before_install: | ||
- gem install cocoapods --pre --no-rdoc --no-ri --no-document --quiet | ||
script: | ||
- pod install | ||
- set -o pipefail | ||
- xcodebuild -version | ||
- xcodebuild -showsdks | ||
|
||
# Build Framework in Debug and Run Tests if specified | ||
- if [ $RUN_TESTS == "YES" ]; then | ||
xcodebuild -project "$PROJECT" -scheme "$SCHEME" -sdk "$SDK" -destination "$DESTINATION" -configuration Debug ONLY_ACTIVE_ARCH=NO ENABLE_TESTABILITY=YES test | xcpretty; | ||
else | ||
xcodebuild -project "$PROJECT" -scheme "$SCHEME" -sdk "$SDK" -destination "$DESTINATION" -configuration Debug ONLY_ACTIVE_ARCH=NO build | xcpretty; | ||
fi | ||
|
||
# Build Framework in Release and Run Tests if specified | ||
- if [ $RUN_TESTS == "YES" ]; then | ||
xcodebuild -project "$PROJECT" -scheme "$SCHEME" -sdk "$SDK" -destination "$DESTINATION" -configuration Release ONLY_ACTIVE_ARCH=NO ENABLE_TESTABILITY=YES test | xcpretty; | ||
else | ||
xcodebuild -project "$PROJECT" -scheme "$SCHEME" -sdk "$SDK" -destination "$DESTINATION" -configuration Release ONLY_ACTIVE_ARCH=NO build | xcpretty; | ||
fi | ||
|
||
# Run `pod lib lint` if specified | ||
- if [ $POD_LINT == "YES" ]; then | ||
pod lib lint; | ||
fi |
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,17 @@ | ||
// swift-tools-version:4.0 | ||
|
||
import PackageDescription | ||
|
||
let package = Package( | ||
name: "libcmark_gfm", | ||
products: [ | ||
.library( | ||
name: "libcmark_gfm", | ||
targets: ["libcmark_gfm"]), | ||
], | ||
targets: [ | ||
.target( | ||
name: "libcmark_gfm", | ||
dependencies: []) | ||
] | ||
) |
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,5 @@ | ||
# libcmark_gfm | ||
|
||
Swift compatible framework for cmark-gfm. Works with CocoaPods, Carthage, and the Swift Package Manager. | ||
|
||
[](https://travis-ci.org/KristopherGBaker/libcmark_gfm) |
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,26 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>CFBundleDevelopmentRegion</key> | ||
<string>$(DEVELOPMENT_LANGUAGE)</string> | ||
<key>CFBundleExecutable</key> | ||
<string>$(EXECUTABLE_NAME)</string> | ||
<key>CFBundleIdentifier</key> | ||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> | ||
<key>CFBundleInfoDictionaryVersion</key> | ||
<string>6.0</string> | ||
<key>CFBundleName</key> | ||
<string>$(PRODUCT_NAME)</string> | ||
<key>CFBundlePackageType</key> | ||
<string>FMWK</string> | ||
<key>CFBundleShortVersionString</key> | ||
<string>1.0</string> | ||
<key>CFBundleVersion</key> | ||
<string>$(CURRENT_PROJECT_VERSION)</string> | ||
<key>NSHumanReadableCopyright</key> | ||
<string>Copyright © 2017 Kristopher Baker. All rights reserved.</string> | ||
<key>NSPrincipalClass</key> | ||
<string></string> | ||
</dict> | ||
</plist> |
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,103 @@ | ||
#include <stdlib.h> | ||
#include <string.h> | ||
#include <stdint.h> | ||
#include "cmark.h" | ||
#include "cmark_extension_api.h" | ||
|
||
static struct arena_chunk { | ||
size_t sz, used; | ||
uint8_t push_point; | ||
void *ptr; | ||
struct arena_chunk *prev; | ||
} *A = NULL; | ||
|
||
static struct arena_chunk *alloc_arena_chunk(size_t sz, struct arena_chunk *prev) { | ||
struct arena_chunk *c = (struct arena_chunk *)calloc(1, sizeof(*c)); | ||
if (!c) | ||
abort(); | ||
c->sz = sz; | ||
c->ptr = calloc(1, sz); | ||
if (!c->ptr) | ||
abort(); | ||
c->prev = prev; | ||
return c; | ||
} | ||
|
||
void cmark_arena_push(void) { | ||
if (!A) | ||
return; | ||
A->push_point = 1; | ||
A = alloc_arena_chunk(10240, A); | ||
} | ||
|
||
int cmark_arena_pop(void) { | ||
if (!A) | ||
return 0; | ||
while (A && !A->push_point) { | ||
free(A->ptr); | ||
struct arena_chunk *n = A->prev; | ||
free(A); | ||
A = n; | ||
} | ||
if (A) | ||
A->push_point = 0; | ||
return 1; | ||
} | ||
|
||
static void init_arena(void) { | ||
A = alloc_arena_chunk(4 * 1048576, NULL); | ||
} | ||
|
||
void cmark_arena_reset(void) { | ||
while (A) { | ||
free(A->ptr); | ||
struct arena_chunk *n = A->prev; | ||
free(A); | ||
A = n; | ||
} | ||
} | ||
|
||
static void *arena_calloc(size_t nmem, size_t size) { | ||
if (!A) | ||
init_arena(); | ||
|
||
size_t sz = nmem * size + sizeof(size_t); | ||
|
||
// Round allocation sizes to largest integer size to | ||
// ensure returned memory is correctly aligned | ||
const size_t align = sizeof(size_t) - 1; | ||
sz = (sz + align) & ~align; | ||
|
||
if (sz > A->sz) { | ||
A->prev = alloc_arena_chunk(sz, A->prev); | ||
return (uint8_t *) A->prev->ptr + sizeof(size_t); | ||
} | ||
if (sz > A->sz - A->used) { | ||
A = alloc_arena_chunk(A->sz + A->sz / 2, A); | ||
} | ||
void *ptr = (uint8_t *) A->ptr + A->used; | ||
A->used += sz; | ||
*((size_t *) ptr) = sz - sizeof(size_t); | ||
return (uint8_t *) ptr + sizeof(size_t); | ||
} | ||
|
||
static void *arena_realloc(void *ptr, size_t size) { | ||
if (!A) | ||
init_arena(); | ||
|
||
void *new_ptr = arena_calloc(1, size); | ||
if (ptr) | ||
memcpy(new_ptr, ptr, ((size_t *) ptr)[-1]); | ||
return new_ptr; | ||
} | ||
|
||
static void arena_free(void *ptr) { | ||
(void) ptr; | ||
/* no-op */ | ||
} | ||
|
||
cmark_mem CMARK_ARENA_MEM_ALLOCATOR = {arena_calloc, arena_realloc, arena_free}; | ||
|
||
cmark_mem *cmark_get_arena_mem_allocator() { | ||
return &CMARK_ARENA_MEM_ALLOCATOR; | ||
} |
Oops, something went wrong.