Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Implementing parts of stdlib in Haxe

オープン
#1,354 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
25/100
issue の種類
機能追加
明瞭さ
説明が足りない
活発さ
静か
技術スタック
cpp

調査の方向性

まず、既存の Sys、File、FileSystem の実装、hxcpp ビルドツール、および例で使用されている marshalling extern types を確認します。プラットフォーム固有の shared objects をどのようにビルドしてキャッシュするか、また Haxe のバージョンと stdlib の実装間の互換性をどのように扱うかを判断します。この issue では完了の受け入れ基準は定義されていません。

索引モデルが issue の本文から書いたものです。

説明

I've been playing around with the Win32 API with the new marshalling extern types and have been quite pleased with how painless and "just works" it's been. This got me thinking that it would be quite nice if we could write the implementation of stuff like the Sys, File, and FileSystem class in Haxe.

E.g. Here's two functions for the file system class.

class FileSystem {
	public static function exists(path:String):Bool {
		final count  = Utf16.getByteCount(path);
		final buffer = Scratch.alloc(count.toInt() + 2);

		if (count != Utf16.encode(path, buffer.view)) {
			throw new Exception("Failed to encode string to UTF16");
		}
		
		return Shell.pathFileExists(buffer.view.reinterpret().ptr);
	}
	
	public static function isDirectory(path:String):Bool {
		final count  = Utf16.getByteCount(path);
		final buffer = Scratch.alloc(count.toInt() + 2);

		if (count != Utf16.encode(path, buffer.view)) {
			throw new Exception("Failed to encode string to UTF16");
		}

		final result = FileApi.getFileAttributes(buffer.view.reinterpret().ptr);
		if (result == FileApi.invalidFileAttributes) {
			throw new Exception("Failed to get file attributes");
		}

		return (result & FileApi.fileAttributeDirectory) != 0;
	}
}

and one for the sys class

class Sys {
	public static function getEnv(v:String):String {
		final nameCount  = Utf16.getByteCount(v);
		final nameBuffer = Scratch.alloc(nameCount.toInt() + 2);

		if (nameCount != Utf16.encode(v, nameBuffer.view)) {
			throw new Exception("Failed to encode string to UTF16");
		}

		final envCount  = Win32.getEnvironmentVariable(nameBuffer.view.reinterpret().ptr, null, 0);
		final envBuffer = Scratch.alloc(envCount * 2);

		if (envCount != Win32.getEnvironmentVariable(nameBuffer.view.reinterpret().ptr, envBuffer.view.reinterpret().ptr, envCount)) {
			throw new Exception("Return value was not the expected size");
		}

		return Utf16.decode(envBuffer.view);
	}
}

Obviously this raises lots of questions, such as

  • The hxcpp build tool would probably need to build and cache shared platform specific obs which are linked with user code (e.g. hxcpp-file-win32.obj, hxcpp-sys-unix.obj).
  • Managing compatibility between haxe versions and std lib implementations in hxcpp could be tricky.
  • Many other things.

I have given these no thoughts yet so don't have any answers, I'm not even sure if it's really worth it in the end. But in general I'm in favour of less C++ and I think the new marshalling types gives us a nice path to have that.

主要言語
C++
スター
330
フォーク
232
平均マージ
3日 5時間
マージ済み PR(30日)
3

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

HaxeFoundation/hxcpp のほかの issue

HaxeFoundation/hxcpp の issue をすべて見る

似ている issue

C++ の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。