<commit_before> package mirror;

import haxe.macro.Context;
import haxe.macro.Expr;
import haxe.macro.Type;

using haxe.macro.ComplexTypeTools;
using haxe.macro.TypeTools;
using haxe.macro.Tools;
using tools.ExprTool;
using tools.FieldTool;
using tools.MetadataTools;

 class JniFieldTool
 {
 	public static inline var TagJni = 'JNI';
 	public static inline var TagDefaultClassName = 'JNI_DEFAULT_CLASS_NAME';
 	public static inline var TagDefaultLibrary = 'JNI_DEFAULT_PACKAGE';

 	public static function isJni(field:Field):Bool
 	{
 		return field.meta.has(TagJni);
 	}

 	public static function getPackageName(field:Field):String
 	{
 		var result:String;
 		var metas = Context.getLocalClass().get().meta.get();
 		var entry:MetadataEntry = field.meta.get(TagJni);
 		var hasFileName:Bool;
 		if (metas.has(TagDefaultLibrary))
 		{
 			if (metas.get(TagDefaultLibrary).params.length == 0)
 			{
 				#if (haxe_ver >= 3.1)
				Context.fatalError("Default package is defined " 
					+ "(JNI_DEFAULT_PACKAGE) without argument", field.pos);
				#end
 			}

 			result = entry.params.length > 0 ? entry.params[0].getString() 
 				: metas.get(TagDefaultLibrary).params[0].getString();
 		}
 		else
 		{
			var params = entry.params;
			if (params.length > 1)
			{
				result = params[0].getString();
			}
			else
			{
				if (metas.has(TagDefaultClassName) 
					&& metas.get(TagDefaultClassName).params.length > 0)
				{
					hasFileName = false;
				}
				else
				{
					result = Context.getLocalModule();
					hasFileName = true;
				}
			}
 		}

 		var splitted = result.split('.');
 		if (!hasFileName)
 		{
 			if (metas.has(TagDefaultClassName))
 			{
 				if (metas.get(TagDefaultClassName).params.length == 0)
	 			{
	 				#if (haxe_ver >= 3.1)
					Context.fatalError("Default package is defined " 
						+ '($TagDefaultClassName) without argument', field.pos);
					#end
	 			}	
	 			else
	 			{
	 				splitted.push(metas.get(TagDefaultClassName).params[0].getString());
	 			}
 			}
 			else
 			{
 				splitted.push(Context.getLocalClass().get().name);
 			}
 		}

 		result = splitted.join("/");
 		
 		return result;
 	}

 	public static function getPrimitiveName(field:Field):String
 	{
 		var entry:MetadataEntry = field.meta.get(TagJni);
 		var params = entry.params;
 		var length = params.length;
<commit_msg>Fix Package name (?)<commit_after> package mirror;

import haxe.macro.Context;
import haxe.macro.Expr;
import haxe.macro.Type;

using haxe.macro.ComplexTypeTools;
using haxe.macro.TypeTools;
using haxe.macro.Tools;
using tools.ExprTool;
using tools.FieldTool;
using tools.MetadataTools;

 class JniFieldTool
 {
 	public static inline var TagJni = 'JNI';
 	public static inline var TagDefaultClassName = 'JNI_DEFAULT_CLASS_NAME';
 	public static inline var TagDefaultLibrary = 'JNI_DEFAULT_PACKAGE';

 	public static function isJni(field:Field):Bool
 	{
 		return field.meta.has(TagJni);
 	}

 	public static function getPackageName(field:Field):String
 	{
 		var result:String;
 		var metas = Context.getLocalClass().get().meta.get();
 		var entry:MetadataEntry = field.meta.get(TagJni);
 		var hasFileName:Bool;
 		if (metas.has(TagDefaultLibrary))
 		{
 			if (metas.get(TagDefaultLibrary).params.length == 0)
 			{
 				#if (haxe_ver >= 3.1)
				Context.fatalError("Default package is defined " 
					+ "(JNI_DEFAULT_PACKAGE) without argument", field.pos);
				#end
 			}

 			result = entry.params.length > 0 ? entry.params[0].getString() 
 				: metas.get(TagDefaultLibrary).params[0].getString();
 		}
 		else
 		{
			var params = entry.params;
			if (params.length > 1)
			{
				result = params[0].getString();
			}
			else
			{
				if (metas.has(TagDefaultClassName) 
					&& metas.get(TagDefaultClassName).params.length > 0)
				{
					hasFileName = false;
				}
				else
				{
					result = Context.getLocalModule();
					hasFileName = true;
				}
			}
 		}

 		var splitted = result.split('.');
 		/*if (!hasFileName)
 		{
 			if (metas.has(TagDefaultClassName))
 			{
 				if (metas.get(TagDefaultClassName).params.length == 0)
	 			{
	 				#if (haxe_ver >= 3.1)
					Context.fatalError("Default package is defined " 
						+ '($TagDefaultClassName) without argument', field.pos);
					#end
	 			}	
	 			else
	 			{
	 				splitted.push(metas.get(TagDefaultClassName).params[0].getString());
	 			}
 			}
 			else
 			{
 				splitted.push(Context.getLocalClass().get().name);
 			}
 		}*/

 		result = splitted.join("/");
 		
 		return result;
 	}

 	public static function getPrimitiveName(field:Field):String
 	{
 		var entry:MetadataEntry = field.meta.get(TagJni);
 		var params = entry.params;
 		var length = params.length;

{'fraction_non_alphanumeric': 0.12743628185907047, 'fraction_numerical': 0.00556864424930392, 'mean_word_length': 3.0608695652173914, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3365868', 'n_tokens_mistral': 1987, 'n_tokens_neox': 1608, 'n_words': 297}