Skip to content

Commit

Permalink
Add cpplint
Browse files Browse the repository at this point in the history
  • Loading branch information
raub committed Oct 10, 2023
1 parent 972fcdc commit 480b6ff
Show file tree
Hide file tree
Showing 5 changed files with 103 additions and 48 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/cpplint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Cpplint
defaults:
run:
shell: bash

on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
eslint:
name: Cpplint
runs-on: ubuntu-20.04

steps:

- name: Fetch Repository
uses: actions/checkout@v3
with:
persist-credentials: false

- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 18.16.0
cache: 'npm'

- name: Install Modules
run: npm ci

- name: Install Python
uses: actions/setup-python@v4
with:
python-version: '3.12'

- name: Install Cpplint
run: pip install cpplint

- name: Run Cpplint
run: |
node -e "require('addon-tools-raub').cpcpplint()"
cpplint --recursive ./src
62 changes: 40 additions & 22 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { EventEmitter } from 'events';

declare module "glfw-raub" {
type EventEmitter = import('node:events').EventEmitter;

type TWindowMode = 'windowed' | 'borderless' | 'fullscreen';

type TSize = Readonly<{ width: number; height: number }>;

type TPos = Readonly<{ x: number; y: number }>;

type TFnVoid = () => void;
type TCbVoid = () => void;

type TRect = TSize & TPos & {
left: number;
Expand All @@ -16,7 +16,7 @@ declare module "glfw-raub" {
bottom: number;
};

type TImage = TSize & Readonly<{
type TImageData = TSize & Readonly<{
data: Buffer;
noflip?: boolean;
}>;
Expand Down Expand Up @@ -111,7 +111,7 @@ declare module "glfw-raub" {

type TCbField<T extends TEvent> = TEventCb<T> | ReadonlyArray<TEventCb<T>>;

type TWindowOpts = Readonly<Partial<{
export type TWindowOpts = Readonly<Partial<{
/** Major OpenGL version to be used. Default is 2. */
major: number;
/** Minor OpenGL version to be used. Default is 1. */
Expand All @@ -135,7 +135,7 @@ declare module "glfw-raub" {
/** Multisample antialiasing level. Default is 2. */
msaa: number;
/** Winodw icon. Default is null. */
icon: TImage;
icon: TImageData;
/** If window has borders (use `false` for borderless fullscreen). Default is true. */
title: string;
/**
Expand All @@ -161,7 +161,7 @@ declare module "glfw-raub" {
* It helps managing window instances. It also extends
* EventEmitter to provide event-handling.
*/
class Window extends EventEmitter {
export class Window implements EventEmitter {
constructor(opts?: TWindowOpts);

/** The ratio between physical and logical pixels, e.g 2 for Retina. Default is 1.*/
Expand Down Expand Up @@ -295,7 +295,7 @@ declare module "glfw-raub" {
* @see https://github.com/node-3d/image-raub
* @see https://github.com/node-3d/glfw-raub/examples/icon.js
* */
icon: TImage;
icon: TImageData;

/** If the window is going to be closed. */
shouldClose: boolean;
Expand Down Expand Up @@ -400,10 +400,28 @@ declare module "glfw-raub" {

/** BOUND cancelAnimationFrame method. Cancels by id. */
cancelAnimationFrame(id: number): void;

// ------ implements EventEmitter

addListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
on(eventName: string | symbol, listener: (...args: any[]) => void): this;
once(eventName: string | symbol, listener: (...args: any[]) => void): this;
removeListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
off(eventName: string | symbol, listener: (...args: any[]) => void): this;
removeAllListeners(event?: string | symbol): this;
setMaxListeners(n: number): this;
getMaxListeners(): number;
listeners(eventName: string | symbol): Function[];
rawListeners(eventName: string | symbol): Function[];
emit(eventName: string | symbol, ...args: any[]): boolean;
listenerCount(eventName: string | symbol, listener?: Function): number;
prependListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
prependOnceListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
eventNames(): Array<string | symbol>;
}


type TDocumentOpts = TWindowOpts & Readonly<{
export type TDocumentOpts = TWindowOpts & Readonly<Partial<{
/** If the window should ignore the default quit signals, e.g. ESC key. */
ignoreQuit: boolean;

Expand All @@ -413,7 +431,7 @@ declare module "glfw-raub" {
* CTRL+SHIFT+F - back to windowed.
*/
autoFullscreen: boolean;
}>;
}>>;

/** Web-like Document
* Document extends Window to provide an additional web-style compatibility layer.
Expand All @@ -423,7 +441,7 @@ declare module "glfw-raub" {
* your choice and WebGL context (implementation).
* Two static methods are designated for this: setImage and setWebgl.
*/
class Document extends Window {
export class Document extends Window {
/** Set Image implementation
* For example, [this Image implementation](https://github.com/raub/node-image).
* Also sets global.HTMLImageElement.
Expand Down Expand Up @@ -479,23 +497,23 @@ declare module "glfw-raub" {
* a command, like `node script.js`, then this won't hide the window. **It's safe to call
* this function on all platforms, but it will be ignored, unless the platform is Windows**.
*/
const hideConsole: TFnVoid;
const hideConsole: TCbVoid;

/** Show the terminal window.
* **Windows ONLY** shows the console window
* if it was previously hidden with `glfw.hideConsole()`.
*/
const showConsole: TFnVoid;
const showConsole: TCbVoid;

/** Draws a test scene, used in examples here. */
const testScene: TFnVoid;
const testScene: TCbVoid;

/** Draws a test scene, that reacts to a joystick. */
const testJoystick: TFnVoid;
const testJoystick: TCbVoid;

const init: TFnVoid;
const init: TCbVoid;
const initHint: (hint: number, value: number) => void;
const terminate: TFnVoid;
const terminate: TCbVoid;
const getVersion: () => Readonly<{
major: number;
minor: number;
Expand All @@ -509,7 +527,7 @@ declare module "glfw-raub" {
const getPrimaryMonitor: () => TMonitor;
const windowHint: (hint: number, value: number) => void;
const windowHintString: (hint: number, value: string) => void;
const defaultWindowHints: TFnVoid;
const defaultWindowHints: TCbVoid;
const joystickPresent: () => boolean;
const getJoystickAxes: (id: number) => string;
const getJoystickButtons: (id: number) => string;
Expand All @@ -531,7 +549,7 @@ declare module "glfw-raub" {

const destroyWindow: TFnWindow;
const setWindowTitle: (window: TWindowPtr, title: string) => void;
const setWindowIcon: (window: TWindowPtr, icon: TImage) => void;
const setWindowIcon: (window: TWindowPtr, icon: TImageData) => void;
const getWindowSize: (window: TWindowPtr) => TSize;
const getWindowFrameSize: (window: TWindowPtr) => Readonly<{
left: number;
Expand Down Expand Up @@ -571,10 +589,10 @@ declare module "glfw-raub" {
const setWindowAttrib: (window: TWindowPtr, value: number) => void;
const setInputMode: (window: TWindowPtr, mode: number, value: number) => void;
const getInputMode: (window: TWindowPtr, mode: number) => number;
const pollEvents: TFnVoid;
const waitEvents: TFnVoid;
const pollEvents: TCbVoid;
const waitEvents: TCbVoid;
const waitEventsTimeout: (timeout: number) => void;
const postEmptyEvent: TFnVoid;
const postEmptyEvent: TCbVoid;
const getKey: (window: TWindowPtr, key: number) => number;
const getMouseButton: (window: TWindowPtr, button: number) => number;
const getCursorPos: (window: TWindowPtr, x: number, y: number) => void;
Expand Down
19 changes: 13 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"author": "Luis Blanco <[email protected]>",
"name": "glfw-raub",
"version": "5.2.1",
"version": "5.2.2",
"description": "GLFW for Node.js",
"license": "MIT",
"main": "index.js",
Expand Down Expand Up @@ -44,13 +44,14 @@
"url": "https://github.com/node-3d/glfw-raub.git"
},
"dependencies": {
"addon-tools-raub": "^7.3.0",
"addon-tools-raub": "^7.4.0",
"deps-opengl-raub": "^5.1.1",
"segfault-raub": "^2.1.2"
},
"devDependencies": {
"eslint-plugin-node": "^11.1.0",
"@types/node": "^20.8.3",
"eslint": "^8.51.0",
"eslint-plugin-node": "^11.1.0",
"node-addon-api": "^7.0.0",
"typescript": "^5.2.2"
}
Expand Down
17 changes: 0 additions & 17 deletions src/CPPLINT.cfg

This file was deleted.

0 comments on commit 480b6ff

Please sign in to comment.