-
-
Notifications
You must be signed in to change notification settings - Fork 3
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
d6bf2be
commit a0593fe
Showing
13 changed files
with
214 additions
and
61 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,98 @@ | ||
--- | ||
BasedOnStyle: LLVM | ||
IndentWidth: 4 | ||
--- | ||
Language: Cpp | ||
ColumnLimit: 190 | ||
AccessModifierOffset: 0 | ||
AlignAfterOpenBracket: true | ||
#AlignConsecutiveAssignments: true | ||
AlignConsecutiveBitFields: true | ||
#AlignConsecutiveDeclarations: true | ||
AlignConsecutiveMacros: true | ||
AlignEscapedNewlines: Left | ||
AlignOperands: true | ||
AlignTrailingComments: true | ||
AllowAllArgumentsOnNextLine: true | ||
AllowAllConstructorInitializersOnNextLine: true | ||
AllowAllParametersOfDeclarationOnNextLine: true | ||
AllowShortBlocksOnASingleLine: Never | ||
AllowShortCaseLabelsOnASingleLine: true | ||
AllowShortEnumsOnASingleLine: false | ||
AllowShortFunctionsOnASingleLine: Empty | ||
AllowShortIfStatementsOnASingleLine: Always | ||
AllowShortLambdasOnASingleLine: All | ||
AllowShortLoopsOnASingleLine: true | ||
AlwaysBreakBeforeMultilineStrings: false | ||
AlwaysBreakTemplateDeclarations: Yes | ||
BinPackArguments: false | ||
BinPackParameters: false | ||
#BitFieldColonSpacing: Both | ||
BraceWrapping: Custom | ||
BraceWrapping: | ||
AfterCaseLabel: true | ||
AfterClass: true | ||
AfterControlStatement: MultiLine | ||
AfterEnum: true | ||
AfterFunction: true | ||
AfterNamespace: false | ||
AfterStruct: true | ||
AfterUnion: true | ||
AfterExternBlock: true | ||
BeforeCatch: true | ||
BeforeElse: true | ||
BeforeLambdaBody: false | ||
BeforeWhile: false | ||
BreakBeforeBinaryOperators: None | ||
BreakBeforeBraces: Allman | ||
BreakBeforeTernaryOperators: true | ||
BreakConstructorInitializers: BeforeColon | ||
BreakInheritanceList: BeforeColon | ||
BreakStringLiterals: false | ||
CompactNamespaces: false | ||
ConstructorInitializerAllOnOneLineOrOnePerLine: true | ||
ContinuationIndentWidth: 2 | ||
Cpp11BracedListStyle: false | ||
#EmptyLineAfterAccessModifier: Never | ||
#EmptyLineBeforeAccessModifier: LogicalBlock | ||
FixNamespaceComments: true | ||
#IncludeBlocks: Regroup | ||
#IndentAccessModifiers: false | ||
AccessModifierOffset: -4 | ||
IndentCaseBlocks: false | ||
IndentCaseLabels: true | ||
IndentExternBlock: true | ||
IndentGotoLabels: false | ||
IndentPPDirectives: BeforeHash | ||
IndentWrappedFunctionNames: true | ||
InsertTrailingCommas: None | ||
KeepEmptyLinesAtTheStartOfBlocks: false | ||
MaxEmptyLinesToKeep: 1 | ||
NamespaceIndentation: All | ||
PointerAlignment: Left | ||
#ShortNamespaceLines: 0 | ||
SortIncludes: false | ||
SortUsingDeclarations: true | ||
SpaceAfterCStyleCast: false | ||
SpaceAfterLogicalNot: false | ||
SpaceAfterTemplateKeyword: false | ||
#SpaceAroundPointerQualifiers: Default | ||
SpaceBeforeAssignmentOperators: true | ||
#SpaceBeforeCaseColon: false | ||
SpaceBeforeCpp11BracedList: false | ||
SpaceBeforeCtorInitializerColon: true | ||
SpaceBeforeInheritanceColon: true | ||
SpaceBeforeParens: Never | ||
SpaceBeforeRangeBasedForLoopColon: true | ||
SpaceBeforeSquareBrackets: false | ||
SpaceInEmptyBlock: false | ||
SpaceInEmptyParentheses: false | ||
SpacesBeforeTrailingComments: 2 | ||
SpacesInAngles: false | ||
SpacesInCStyleCastParentheses: false | ||
SpacesInConditionalStatement: false | ||
SpacesInParentheses: false | ||
SpacesInSquareBrackets: false | ||
Standard: c++17 | ||
DeriveLineEnding: true | ||
UseTab: Never |
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
BUILD/ | ||
dist/ | ||
dist/ | ||
deps/v8/**/ |
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 |
---|---|---|
@@ -1,22 +1,22 @@ | ||
{ | ||
"configurations": [ | ||
{ | ||
"name": "Win32 Static", | ||
"includePath": [ | ||
"${workspaceFolder}/**" | ||
], | ||
"defines": [ | ||
"_DEBUG", | ||
"UNICODE", | ||
"_UNICODE", | ||
"ALT_SERVER_API" | ||
], | ||
"windowsSdkVersion": "10.0.19041.0", | ||
"cStandard": "c11", | ||
"cppStandard": "c++17", | ||
"intelliSenseMode": "msvc-x64" | ||
} | ||
{ | ||
"name": "Win32 Static", | ||
"includePath": [ | ||
"${workspaceFolder}/**" | ||
], | ||
"defines": [ | ||
"_DEBUG", | ||
"UNICODE", | ||
"_UNICODE", | ||
"ALT_SERVER_API" | ||
], | ||
"windowsSdkVersion": "10.0.19041.0", | ||
"cStandard": "c11", | ||
"cppStandard": "c++17", | ||
"intelliSenseMode": "msvc-x64", | ||
"configurationProvider": "ms-vscode.cmake-tools" | ||
} | ||
], | ||
"version": 4 | ||
} | ||
|
||
} |
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
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,52 @@ | ||
|
||
# Set this to false, when using a custom v8 build for testing | ||
set(__deps_check_enabled true) | ||
|
||
function(DownloadDeps basePath) | ||
set(__deps_release_lib "${basePath}/v8/lib/Release/v8_monolith.lib") | ||
set(__deps_debug_lib "${basePath}/v8/lib/Debug/v8_monolith.lib") | ||
set(__deps_headers "${basePath}/v8/include/headers.zip") | ||
set(__deps_update_file "${basePath}/v8/update.json") | ||
|
||
if(__deps_check_enabled) | ||
file(DOWNLOAD "https://cdn.altv.mp/deps/v8/dev/update.json" ${__deps_update_file}) | ||
file(READ ${__deps_update_file} __deps_update_json) | ||
string(JSON __deps_hashes GET ${__deps_update_json} hashList) | ||
file(REMOVE ${__deps_update_file}) | ||
|
||
if(EXISTS ${__deps_release_lib}) | ||
file(SHA1 ${__deps_release_lib} __deps_release_checksum) | ||
else() | ||
set(__deps_release_checksum 0) | ||
endif() | ||
string(JSON __deps_release_checksum_cdn GET ${__deps_hashes} v8_monolith.lib) | ||
if(NOT ${__deps_release_checksum} STREQUAL ${__deps_release_checksum_cdn}) | ||
message("Downloading release binary...") | ||
file(DOWNLOAD "https://cdn.altv.mp/deps/v8/dev/v8_monolith.lib" ${__deps_release_lib}) | ||
endif() | ||
|
||
if(EXISTS ${__deps_debug_lib}) | ||
file(SHA1 ${__deps_debug_lib} __deps_debug_checksum) | ||
else() | ||
set(__deps_debug_checksum 0) | ||
endif() | ||
string(JSON __deps_debug_checksum_cdn GET ${__deps_hashes} v8_monolithd.lib) | ||
if(NOT ${__deps_debug_checksum} STREQUAL ${__deps_debug_checksum_cdn}) | ||
message("Downloading debug binary...") | ||
file(DOWNLOAD "https://cdn.altv.mp/deps/v8/dev/v8_monolithd.lib" ${__deps_debug_lib}) | ||
endif() | ||
|
||
if(EXISTS ${__deps_headers}) | ||
file(SHA1 ${__deps_headers} __deps_headers_checksum) | ||
else() | ||
set(__deps_headers_checksum 0) | ||
endif() | ||
string(JSON __deps_headers_checksum_cdn GET ${__deps_hashes} headers.zip) | ||
if(NOT ${__deps_headers_checksum} STREQUAL ${__deps_headers_checksum_cdn}) | ||
message("Downloading headers...") | ||
file(DOWNLOAD "https://cdn.altv.mp/deps/v8/dev/headers.zip" ${__deps_headers}) | ||
message("Extracting headers...") | ||
file(ARCHIVE_EXTRACT INPUT ${__deps_headers} DESTINATION "${basePath}") | ||
endif() | ||
endif() | ||
endfunction() |
Submodule cpp-sdk
updated
21 files
+43 −0 | IAudioFilter.h | |
+21 −2 | ICore.h | |
+5 −0 | IResource.h | |
+3 −0 | SDK.h | |
+3 −1 | events/CEvent.h | |
+36 −0 | events/CPlayerBeforeConnectEvent.h | |
+7 −4 | events/CPlayerDamageEvent.h | |
+0 −16 | events/CRenderEvent.h | |
+30 −0 | events/CTaskChangeEvent.h | |
+54 −0 | events/CVehicleDamageEvent.h | |
+2 −1 | objects/IBaseObject.h | |
+3 −0 | objects/IEntity.h | |
+3 −0 | objects/ILocalPlayer.h | |
+31 −0 | objects/IPlayer.h | |
+36 −0 | objects/IVehicle.h | |
+9 −7 | script-objects/IBlip.h | |
+2 −0 | script-objects/IWebView.h | |
+35 −0 | types/ConnectionInfo.h | |
+37 −0 | types/HeadBlendData.h | |
+28 −0 | types/HeadOverlay.h | |
+26 −0 | types/Weapon.h |
Empty file.
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,23 @@ | ||
#pragma once | ||
#include "v8/include/v8.h" | ||
|
||
#include <string> | ||
|
||
namespace BytecodeCompiler | ||
{ | ||
constexpr uint32_t currentVersion = 1; | ||
|
||
struct Bytecode | ||
{ | ||
uint32_t version = 0; | ||
size_t size = 0; | ||
uint8_t* data = nullptr; | ||
|
||
bool IsValid() | ||
{ | ||
return version == currentVersion && size != 0 && data != nullptr; | ||
} | ||
|
||
Bytecode(uint32_t version, size_t size, uint8_t* data) : version(version), size(size), data(data) {} | ||
}; | ||
} // namespace BytecodeCompiler |
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 |
---|---|---|
@@ -1,28 +1,5 @@ | ||
#include "resource.h" | ||
#include "util/compiler.h" | ||
#include <sstream> | ||
#include <fstream> | ||
|
||
bool JSBytecodeResource::MakeClient(alt::IResource::CreationInfo *info, alt::Array<alt::String> files) | ||
{ | ||
if(info->type != "jsb" && info->type != "js") return true; | ||
|
||
v8::Locker locker(isolate); | ||
v8::Isolate::Scope isolateScope(isolate); | ||
v8::HandleScope handleScope(isolate); | ||
|
||
alt::String path = resource->GetPath() + "/" + info->main; | ||
std::ifstream iFile; | ||
iFile.open(path.CStr()); | ||
std::string source((std::istreambuf_iterator<char>(iFile)), std::istreambuf_iterator<char>()); | ||
|
||
auto bytecode = BytecodeCompiler::CompileSourceIntoBytecode(isolate, info->main.CStr(), source.c_str()); | ||
auto file = info->pkg->OpenFile(info->main); | ||
info->pkg->WriteFile(file, (void*)bytecode->data, bytecode->length); | ||
info->pkg->CloseFile(file); | ||
|
||
std::cout << __FUNCTION__ << " " << "size: " << bytecode->length << std::endl; | ||
std::cout << __FUNCTION__ << " " << "version: " << v8::ScriptCompiler::CachedDataVersionTag() << std::endl; | ||
|
||
return true; | ||
} | ||
bool JSBytecodeResource::WriteClientFile(alt::IPackage* package, const std::string& fileName, void* buffer, uint64_t size) {} |
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 |
---|---|---|
@@ -1,12 +1,12 @@ | ||
#include "runtime.h" | ||
|
||
JSBytecodeRuntime::JSBytecodeRuntime() | ||
JSBytecodeRuntime::JSBytecodeRuntime() | ||
{ | ||
platform = v8::platform::NewDefaultPlatform(); | ||
v8::V8::InitializePlatform(platform.get()); | ||
v8::V8::Initialize(); | ||
v8::V8::InitializePlatform(platform.get()); | ||
v8::V8::Initialize(); | ||
|
||
create_params.array_buffer_allocator = v8::ArrayBuffer::Allocator::NewDefaultAllocator(); | ||
create_params.array_buffer_allocator = v8::ArrayBuffer::Allocator::NewDefaultAllocator(); | ||
|
||
isolate = v8::Isolate::New(create_params); | ||
isolate = v8::Isolate::New(create_params); | ||
} |