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
I already have this separation: | |
*CmpActionSelect*: C++ native component that controls which action is active for the entity. | |
*ActionSelectWindow*: Javascript browser class that displays an action select HUD. | |
Whenever *CmpActionSelect* does something, it needs to tell *ActionSelectWindow* to update. I have these options: | |
1. Finish complete object replication feature that allows Javascript code to inspect native objects. *ActionSelectWindow* then periodically polls state of *CmpActionSelect* or reacts to specific object/property changes remotely. | |
2. Send RPC messages from *CmpActionSelect* to *ActionSelectWindow* whenever new actions are selected. | |
3. Create an intermediate native component that reacts to event changes in *CmpActionSelect* and sends RPC messages to *ActionSelectWindow*. |
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
// Assume a header file with a container of items | |
// Container.h | |
// ------------------------------------------------- | |
#include <vector> | |
// Forward-declared to avoid included header file | |
struct Item; | |
struct Container | |
{ |
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
# | |
# Correcting Art of Assembly's flawed acos implementation in Chapter 14 | |
# http://flint.cs.yale.edu/cs422/doc/art-of-asm/pdf/CH14.PDF | |
# | |
import math | |
# Alias commonly used math functions |
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
const char* cudaGetErrorEnum(cudaError_t error) | |
{ | |
const clcpp::Enum* enum_type = clcpp::GetType<cudaError_t>()->AsEnum(); | |
for (u32 i = 0; i < enum_type->constants.size; i++) | |
{ | |
const clcpp::EnumConstant* constant = enum_type->constants[i]; | |
if (constant->value == error) | |
return constant->name.text; | |
} |
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
#pragma once | |
#include <clcpp/clcpp.h> | |
#include <tinycrt/tinycrt.h> | |
// Forward declaration of SOCKET to prevent any windows inclusion | |
typedef u32 SOCKET; |
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
enum clcpp_attr(reflect) Enums | |
{ | |
A, B, C, D | |
}; | |
const clcpp::Type* enum_type = clcpp::GetType<Enums>()->AsEnum(); | |
for (size_t i = 0; i < enum_type->constants.size; i++) | |
{ | |
const clcpp::EnumConstant& enum_k = enum_type->constants[i]; |
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
namespace api | |
{ | |
namespace blah | |
{ | |
// Opaque handle to the type this namespace exposes functions for | |
struct Blah; | |
// Lifetime management (malloc/free with construct/destruct) | |
Blah* New(u32 param); |
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
// | |
// Pre-processor scans your C/header file for the '/*$gen:' signature | |
// It consumes everything inside the C-style comment and generates a unique hash | |
// This hash is used to determine if the contents of the comment have changed since it last looked | |
// The hash is stored after the '/*$gen:' signature | |
// | |
/*$gen:0x1AF673C3 | |
// This is your generic implementation with (T) the generic type |
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
// | |
// Uses pycgen: https://github.com/Celtoys/pycgen | |
// Generates code for C, HLSL, CUDA and OpenCL | |
// | |
void SH_Y2(float3 n, cmp_out float y[9]) | |
{ | |
/*$pycgen | |
from math import pi | |
from math import sqrt |
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
// Placement new from specific allocator: combines allocation+construction | |
void* operator new (size_t size, Allocator& allocator) | |
{ | |
return malloc(allocator); | |
} | |
// Required matching placement delete chained to by compiler-generated code | |
// whenever a constructor throws an exception during unwind | |
void operator delete(void* ptr, Allocator& allocator) | |
{ |
OlderNewer